aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectType.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-07-26 19:03:47 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-07-26 19:04:23 +0000
commit7fa27ce4a07f19b07799a767fc29416f3b625afb (patch)
tree27825c83636c4de341eb09a74f49f5d38a15d165 /lldb/source/Commands/CommandObjectType.cpp
parente3b557809604d036af6e00c60f012c2025b59a5e (diff)
Diffstat (limited to 'lldb/source/Commands/CommandObjectType.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectType.cpp114
1 files changed, 73 insertions, 41 deletions
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index 1120caa1da4c..e6dd63a6cb21 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -39,9 +39,6 @@
#include <functional>
#include <memory>
-#define CHECK_FORMATTER_KIND_MASK(VAL) \
- ((m_formatter_kind_mask & (VAL)) == (VAL))
-
using namespace lldb;
using namespace lldb_private;
@@ -100,6 +97,22 @@ static bool WarnOnPotentialUnquotedUnsignedType(Args &command,
return false;
}
+const char *FormatCategoryToString(FormatCategoryItem item, bool long_name) {
+ switch (item) {
+ case eFormatCategoryItemSummary:
+ return "summary";
+ case eFormatCategoryItemFilter:
+ return "filter";
+ case eFormatCategoryItemSynth:
+ if (long_name)
+ return "synthetic child provider";
+ return "synthetic";
+ case eFormatCategoryItemFormat:
+ return "format";
+ }
+ llvm_unreachable("Fully covered switch above!");
+}
+
#define LLDB_OPTIONS_type_summary_add
#include "CommandOptions.inc"
@@ -754,16 +767,25 @@ protected:
};
CommandOptions m_options;
- uint32_t m_formatter_kind_mask;
+ FormatCategoryItem m_formatter_kind;
Options *GetOptions() override { return &m_options; }
+ static constexpr const char *g_short_help_template =
+ "Delete an existing %s for a type.";
+
+ static constexpr const char *g_long_help_template =
+ "Delete an existing %s for a type. Unless you specify a "
+ "specific category or all categories, only the "
+ "'default' category is searched. The names must be exactly as "
+ "shown in the 'type %s list' output";
+
public:
CommandObjectTypeFormatterDelete(CommandInterpreter &interpreter,
- uint32_t formatter_kind_mask,
- const char *name, const char *help)
- : CommandObjectParsed(interpreter, name, help, nullptr),
- m_formatter_kind_mask(formatter_kind_mask) {
+ FormatCategoryItem formatter_kind)
+ : CommandObjectParsed(interpreter,
+ FormatCategoryToString(formatter_kind, false)),
+ m_formatter_kind(formatter_kind) {
CommandArgumentEntry type_arg;
CommandArgumentData type_style_arg;
@@ -773,6 +795,19 @@ public:
type_arg.push_back(type_style_arg);
m_arguments.push_back(type_arg);
+
+ const char *kind = FormatCategoryToString(formatter_kind, true);
+ const char *short_kind = FormatCategoryToString(formatter_kind, false);
+
+ StreamString s;
+ s.Printf(g_short_help_template, kind);
+ SetHelp(s.GetData());
+ s.Clear();
+ s.Printf(g_long_help_template, kind, short_kind);
+ SetHelpLong(s.GetData());
+ s.Clear();
+ s.Printf("type %s delete", short_kind);
+ SetCommandName(s.GetData());
}
~CommandObjectTypeFormatterDelete() override = default;
@@ -785,7 +820,7 @@ public:
DataVisualization::Categories::ForEach(
[this, &request](const lldb::TypeCategoryImplSP &category_sp) {
- category_sp->AutoComplete(request, m_formatter_kind_mask);
+ category_sp->AutoComplete(request, m_formatter_kind);
return true;
});
}
@@ -812,7 +847,7 @@ protected:
if (m_options.m_delete_all) {
DataVisualization::Categories::ForEach(
[this, typeCS](const lldb::TypeCategoryImplSP &category_sp) -> bool {
- category_sp->Delete(typeCS, m_formatter_kind_mask);
+ category_sp->Delete(typeCS, m_formatter_kind);
return true;
});
result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -827,14 +862,14 @@ protected:
DataVisualization::Categories::GetCategory(m_options.m_language,
category);
if (category)
- delete_category = category->Delete(typeCS, m_formatter_kind_mask);
+ delete_category = category->Delete(typeCS, m_formatter_kind);
extra_deletion = FormatterSpecificDeletion(typeCS);
} else {
lldb::TypeCategoryImplSP category;
DataVisualization::Categories::GetCategory(
ConstString(m_options.m_category.c_str()), category);
if (category)
- delete_category = category->Delete(typeCS, m_formatter_kind_mask);
+ delete_category = category->Delete(typeCS, m_formatter_kind);
extra_deletion = FormatterSpecificDeletion(typeCS);
}
@@ -888,16 +923,16 @@ private:
};
CommandOptions m_options;
- uint32_t m_formatter_kind_mask;
+ FormatCategoryItem m_formatter_kind;
Options *GetOptions() override { return &m_options; }
public:
CommandObjectTypeFormatterClear(CommandInterpreter &interpreter,
- uint32_t formatter_kind_mask,
+ FormatCategoryItem formatter_kind,
const char *name, const char *help)
: CommandObjectParsed(interpreter, name, help, nullptr),
- m_formatter_kind_mask(formatter_kind_mask) {
+ m_formatter_kind(formatter_kind) {
CommandArgumentData category_arg{eArgTypeName, eArgRepeatOptional};
m_arguments.push_back({category_arg});
}
@@ -911,7 +946,7 @@ protected:
if (m_options.m_delete_all) {
DataVisualization::Categories::ForEach(
[this](const TypeCategoryImplSP &category_sp) -> bool {
- category_sp->Clear(m_formatter_kind_mask);
+ category_sp->Clear(m_formatter_kind);
return true;
});
} else {
@@ -924,7 +959,7 @@ protected:
DataVisualization::Categories::GetCategory(ConstString(nullptr),
category);
}
- category->Clear(m_formatter_kind_mask);
+ category->Clear(m_formatter_kind);
}
FormatterSpecificDeletion();
@@ -940,8 +975,7 @@ class CommandObjectTypeFormatDelete : public CommandObjectTypeFormatterDelete {
public:
CommandObjectTypeFormatDelete(CommandInterpreter &interpreter)
: CommandObjectTypeFormatterDelete(
- interpreter, eFormatCategoryItemFormat, "type format delete",
- "Delete an existing formatting style for a type.") {}
+ interpreter, eFormatCategoryItemFormat) {}
~CommandObjectTypeFormatDelete() override = default;
};
@@ -1609,8 +1643,7 @@ class CommandObjectTypeSummaryDelete : public CommandObjectTypeFormatterDelete {
public:
CommandObjectTypeSummaryDelete(CommandInterpreter &interpreter)
: CommandObjectTypeFormatterDelete(
- interpreter, eFormatCategoryItemSummary, "type summary delete",
- "Delete an existing summary for a type.") {}
+ interpreter, eFormatCategoryItemSummary) {}
~CommandObjectTypeSummaryDelete() override = default;
@@ -1734,9 +1767,9 @@ public:
void
HandleArgumentCompletion(CompletionRequest &request,
OptionElementVector &opt_element_vector) override {
- CommandCompletions::InvokeCommonCompletionCallbacks(
- GetCommandInterpreter(),
- CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
+ lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), lldb::eTypeCategoryNameCompletion, request,
+ nullptr);
}
protected:
@@ -1836,9 +1869,9 @@ public:
void
HandleArgumentCompletion(CompletionRequest &request,
OptionElementVector &opt_element_vector) override {
- CommandCompletions::InvokeCommonCompletionCallbacks(
- GetCommandInterpreter(),
- CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
+ lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), lldb::eTypeCategoryNameCompletion, request,
+ nullptr);
}
protected:
@@ -1904,9 +1937,9 @@ public:
void
HandleArgumentCompletion(CompletionRequest &request,
OptionElementVector &opt_element_vector) override {
- CommandCompletions::InvokeCommonCompletionCallbacks(
- GetCommandInterpreter(),
- CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
+ lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), lldb::eTypeCategoryNameCompletion, request,
+ nullptr);
}
protected:
@@ -2013,9 +2046,9 @@ public:
void
HandleArgumentCompletion(CompletionRequest &request,
OptionElementVector &opt_element_vector) override {
- CommandCompletions::InvokeCommonCompletionCallbacks(
- GetCommandInterpreter(),
- CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
+ lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), lldb::eTypeCategoryNameCompletion, request,
+ nullptr);
}
protected:
@@ -2078,9 +2111,9 @@ public:
OptionElementVector &opt_element_vector) override {
if (request.GetCursorIndex())
return;
- CommandCompletions::InvokeCommonCompletionCallbacks(
- GetCommandInterpreter(),
- CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
+ lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), lldb::eTypeCategoryNameCompletion, request,
+ nullptr);
}
protected:
@@ -2159,8 +2192,7 @@ class CommandObjectTypeFilterDelete : public CommandObjectTypeFormatterDelete {
public:
CommandObjectTypeFilterDelete(CommandInterpreter &interpreter)
: CommandObjectTypeFormatterDelete(
- interpreter, eFormatCategoryItemFilter, "type filter delete",
- "Delete an existing filter for a type.") {}
+ interpreter, eFormatCategoryItemFilter) {}
~CommandObjectTypeFilterDelete() override = default;
};
@@ -2173,8 +2205,7 @@ class CommandObjectTypeSynthDelete : public CommandObjectTypeFormatterDelete {
public:
CommandObjectTypeSynthDelete(CommandInterpreter &interpreter)
: CommandObjectTypeFormatterDelete(
- interpreter, eFormatCategoryItemSynth, "type synthetic delete",
- "Delete an existing synthetic provider for a type.") {}
+ interpreter, eFormatCategoryItemSynth) {}
~CommandObjectTypeSynthDelete() override = default;
};
@@ -2845,7 +2876,8 @@ protected:
return false;
}
- StackFrameSP frame_sp = thread->GetSelectedFrame();
+ StackFrameSP frame_sp =
+ thread->GetSelectedFrame(DoNoSelectMostRelevantFrame);
ValueObjectSP result_valobj_sp;
EvaluateExpressionOptions options;
lldb::ExpressionResults expr_result = target_sp->EvaluateExpression(