aboutsummaryrefslogtreecommitdiff
path: root/source/Commands/CommandObjectType.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Commands/CommandObjectType.cpp')
-rw-r--r--source/Commands/CommandObjectType.cpp793
1 files changed, 382 insertions, 411 deletions
diff --git a/source/Commands/CommandObjectType.cpp b/source/Commands/CommandObjectType.cpp
index 2b803e7eb0d3..6f1199de69de 100644
--- a/source/Commands/CommandObjectType.cpp
+++ b/source/Commands/CommandObjectType.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectType.cpp ----------------------------------*- C++ -*-===//
+//===-- CommandObjectType.cpp -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,14 +10,15 @@
#include "CommandObjectType.h"
// C Includes
-
-#include <ctype.h>
-
// C++ Includes
+#include <algorithm>
+#include <cctype>
#include <functional>
+// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
+// Project includes
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/IOHandler.h"
@@ -33,6 +34,7 @@
#include "lldb/Interpreter/OptionValueBoolean.h"
#include "lldb/Interpreter/OptionValueLanguage.h"
#include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
@@ -43,20 +45,13 @@
using namespace lldb;
using namespace lldb_private;
-
class ScriptAddOptions
{
-
public:
-
TypeSummaryImpl::Flags m_flags;
-
StringList m_target_types;
-
bool m_regex;
-
ConstString m_name;
-
std::string m_category;
ScriptAddOptions(const TypeSummaryImpl::Flags& flags,
@@ -71,20 +66,16 @@ public:
}
typedef std::shared_ptr<ScriptAddOptions> SharedPointer;
-
};
class SynthAddOptions
{
-
public:
-
bool m_skip_pointers;
bool m_skip_references;
bool m_cascade;
bool m_regex;
StringList m_target_types;
-
std::string m_category;
SynthAddOptions(bool sptr,
@@ -102,7 +93,6 @@ public:
}
typedef std::shared_ptr<SynthAddOptions> SharedPointer;
-
};
static bool
@@ -136,20 +126,17 @@ class CommandObjectTypeSummaryAdd :
public CommandObjectParsed,
public IOHandlerDelegateMultiline
{
-
private:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter)
{
}
-
- ~CommandOptions () override {}
-
+
+ ~CommandOptions() override = default;
+
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override;
@@ -193,7 +180,6 @@ private:
Execute_StringSummary (Args& command, CommandReturnObject &result);
public:
-
enum SummaryFormatType
{
eRegularSummary,
@@ -202,11 +188,9 @@ public:
};
CommandObjectTypeSummaryAdd (CommandInterpreter &interpreter);
-
- ~CommandObjectTypeSummaryAdd () override
- {
- }
-
+
+ ~CommandObjectTypeSummaryAdd() override = default;
+
void
IOHandlerActivated (IOHandler &io_handler) override
{
@@ -222,8 +206,7 @@ public:
output_sp->Flush();
}
}
-
-
+
void
IOHandlerInputComplete (IOHandler &io_handler, std::string &data) override
{
@@ -344,7 +327,7 @@ public:
error_sp->Printf ("error: script interpreter missing, didn't add python command.\n");
error_sp->Flush();
}
-#endif // #ifndef LLDB_DISABLE_PYTHON
+#endif // LLDB_DISABLE_PYTHON
io_handler.SetIsDone(true);
}
@@ -353,11 +336,11 @@ public:
lldb::TypeSummaryImplSP entry,
SummaryFormatType type,
std::string category,
- Error* error = NULL);
+ Error* error = nullptr);
+
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override;
-
};
static const char *g_synth_addreader_instructions = "Enter your Python command(s). Type 'DONE' to end.\n"
@@ -374,20 +357,17 @@ class CommandObjectTypeSynthAdd :
public CommandObjectParsed,
public IOHandlerDelegateMultiline
{
-
private:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter)
{
}
-
- ~CommandOptions () override {}
-
+
+ ~CommandOptions() override = default;
+
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -460,13 +440,9 @@ private:
std::string m_class_name;
bool m_input_python;
std::string m_category;
-
bool is_class_based;
-
bool handwrite_python;
-
bool m_regex;
-
};
CommandOptions m_options;
@@ -511,8 +487,7 @@ protected:
output_sp->Flush();
}
}
-
-
+
void
IOHandlerInputComplete (IOHandler &io_handler, std::string &data) override
{
@@ -614,12 +589,11 @@ protected:
error_sp->Flush();
}
-#endif // #ifndef LLDB_DISABLE_PYTHON
+#endif // LLDB_DISABLE_PYTHON
io_handler.SetIsDone(true);
}
public:
-
enum SynthFormatType
{
eRegularSynth,
@@ -627,11 +601,9 @@ public:
};
CommandObjectTypeSynthAdd (CommandInterpreter &interpreter);
-
- ~CommandObjectTypeSynthAdd () override
- {
- }
-
+
+ ~CommandObjectTypeSynthAdd() override = default;
+
static bool
AddSynth(ConstString type_name,
lldb::SyntheticChildrenSP entry,
@@ -646,22 +618,17 @@ public:
class CommandObjectTypeFormatAdd : public CommandObjectParsed
{
-
private:
-
class CommandOptions : public OptionGroup
{
public:
-
CommandOptions () :
OptionGroup()
{
}
-
- ~CommandOptions () override
- {
- }
-
+
+ ~CommandOptions() override = default;
+
uint32_t
GetNumDefinitions () override;
@@ -681,6 +648,7 @@ private:
m_category.assign("default");
m_custom_type_name.clear();
}
+
Error
SetOptionValue (CommandInterpreter &interpreter,
uint32_t option_idx,
@@ -746,10 +714,10 @@ private:
public:
CommandObjectTypeFormatAdd (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type format add",
- "Add a new formatting style for a type.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "type format add",
+ "Add a new formatting style for a type.",
+ nullptr),
m_option_group (interpreter),
m_format_options (eFormatInvalid),
m_command_options ()
@@ -804,13 +772,10 @@ pointers to floats. Nor will it change the default display for Afloat and Bfloa
m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT, LLDB_OPT_SET_1);
m_option_group.Append (&m_command_options);
m_option_group.Finalize();
-
}
-
- ~CommandObjectTypeFormatAdd () override
- {
- }
-
+
+ ~CommandObjectTypeFormatAdd() override = default;
+
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -891,16 +856,15 @@ protected:
OptionDefinition
CommandObjectTypeFormatAdd::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Add this to the given category instead of the default one."},
- { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "If true, cascade through typedef chains."},
- { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."},
- { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Don't use this format for references-to-type objects."},
- { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Type names are actually regular expressions."},
- { LLDB_OPT_SET_2, false, "type", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Format variables as if they were of this type."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "Add this to the given category instead of the default one."},
+ { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "If true, cascade through typedef chains."},
+ { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."},
+ { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Don't use this format for references-to-type objects."},
+ { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Type names are actually regular expressions."},
+ { LLDB_OPT_SET_2, false, "type", 't', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "Format variables as if they were of this type."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
uint32_t
CommandObjectTypeFormatAdd::CommandOptions::GetNumDefinitions ()
{
@@ -913,14 +877,13 @@ protected:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter)
{
}
-
- ~CommandOptions () override {}
-
+
+ ~CommandOptions() override = default;
+
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -985,12 +948,12 @@ public:
uint32_t formatter_kind_mask,
const char* name,
const char* help) :
- CommandObjectParsed (interpreter,
- name,
- help,
- NULL),
- m_options(interpreter),
- m_formatter_kind_mask(formatter_kind_mask)
+ CommandObjectParsed(interpreter,
+ name,
+ help,
+ nullptr),
+ m_options(interpreter),
+ m_formatter_kind_mask(formatter_kind_mask)
{
CommandArgumentEntry type_arg;
CommandArgumentData type_style_arg;
@@ -1001,11 +964,10 @@ public:
type_arg.push_back (type_style_arg);
m_arguments.push_back (type_arg);
-
}
-
- ~CommandObjectTypeFormatterDelete () override = default;
-
+
+ ~CommandObjectTypeFormatterDelete() override = default;
+
protected:
virtual bool
FormatterSpecificDeletion (ConstString typeCS)
@@ -1076,35 +1038,31 @@ protected:
result.SetStatus(eReturnStatusFailed);
return false;
}
-
}
-
};
OptionDefinition
CommandObjectTypeFormatterDelete::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "all", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Delete from every category."},
- { LLDB_OPT_SET_2, false, "category", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Delete from given category."},
- { LLDB_OPT_SET_3, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Delete from given language's category."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_1, false, "all", 'a', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Delete from every category."},
+ { LLDB_OPT_SET_2, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "Delete from given category."},
+ { LLDB_OPT_SET_3, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage, "Delete from given language's category."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
class CommandObjectTypeFormatterClear : public CommandObjectParsed
{
private:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter)
{
}
-
- ~CommandOptions () override {}
-
+
+ ~CommandOptions() override = default;
+
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -1158,19 +1116,17 @@ public:
uint32_t formatter_kind_mask,
const char* name,
const char* help) :
- CommandObjectParsed (interpreter,
- name,
- help,
- NULL),
- m_options(interpreter),
- m_formatter_kind_mask(formatter_kind_mask)
+ CommandObjectParsed(interpreter,
+ name,
+ help,
+ nullptr),
+ m_options(interpreter),
+ m_formatter_kind_mask(formatter_kind_mask)
{
}
-
- ~CommandObjectTypeFormatterClear () override
- {
- }
-
+
+ ~CommandObjectTypeFormatterClear() override = default;
+
protected:
virtual void
FormatterSpecificDeletion ()
@@ -1198,7 +1154,7 @@ protected:
}
else
{
- DataVisualization::Categories::GetCategory(ConstString(NULL), category);
+ DataVisualization::Categories::GetCategory(ConstString(nullptr), category);
}
category->Clear(m_formatter_kind_mask);
}
@@ -1208,14 +1164,13 @@ protected:
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
-
};
OptionDefinition
CommandObjectTypeFormatterClear::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "all", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Clear every category."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "all", 'a', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Clear every category."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -1232,10 +1187,8 @@ public:
"Delete an existing formatting style for a type.")
{
}
-
- ~CommandObjectTypeFormatDelete () override
- {
- }
+
+ ~CommandObjectTypeFormatDelete() override = default;
};
//-------------------------------------------------------------------------
@@ -1262,16 +1215,15 @@ class CommandObjectTypeFormatterList : public CommandObjectParsed
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_category_regex("",""),
m_category_language(lldb::eLanguageTypeUnknown, lldb::eLanguageTypeUnknown)
{
}
-
- ~CommandOptions () override {}
-
+
+ ~CommandOptions() override = default;
+
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -1282,9 +1234,12 @@ class CommandObjectTypeFormatterList : public CommandObjectParsed
{
case 'w':
m_category_regex.SetCurrentValue(option_arg);
+ m_category_regex.SetOptionWasSet();
break;
case 'l':
error = m_category_language.SetValueFromString(option_arg);
+ if (error.Success())
+ m_category_language.SetOptionWasSet();
break;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
@@ -1306,9 +1261,9 @@ class CommandObjectTypeFormatterList : public CommandObjectParsed
{
static OptionDefinition g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Only show categories matching this filter."},
- { LLDB_OPT_SET_2, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Only show the category for a specific language."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_1, false, "category-regex", 'w', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "Only show categories matching this filter."},
+ { LLDB_OPT_SET_2, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage, "Only show the category for a specific language."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
return g_option_table;
@@ -1336,11 +1291,11 @@ public:
CommandObjectTypeFormatterList (CommandInterpreter &interpreter,
const char* name,
const char* help) :
- CommandObjectParsed (interpreter,
- name,
- help,
- NULL),
- m_options(interpreter)
+ CommandObjectParsed(interpreter,
+ name,
+ help,
+ nullptr),
+ m_options(interpreter)
{
CommandArgumentEntry type_arg;
CommandArgumentData type_style_arg;
@@ -1352,15 +1307,14 @@ public:
m_arguments.push_back (type_arg);
}
-
- ~CommandObjectTypeFormatterList () override
- {
- }
-
+
+ ~CommandObjectTypeFormatterList() override = default;
+
protected:
- virtual void
+ virtual bool
FormatterSpecificList (CommandReturnObject &result)
{
+ return false;
}
bool
@@ -1384,7 +1338,7 @@ protected:
if (argc == 1)
{
- const char* arg = command.GetArgumentAtIndex(1);
+ const char* arg = command.GetArgumentAtIndex(0);
formatter_regex.reset(new RegularExpression());
if (!formatter_regex->Compile(arg))
{
@@ -1394,10 +1348,15 @@ protected:
}
}
- auto category_closure = [&result, &formatter_regex] (const lldb::TypeCategoryImplSP& category) -> void {
- result.GetOutputStream().Printf("-----------------------\nCategory: %s\n-----------------------\n", category->GetName());
+ bool any_printed = false;
+
+ auto category_closure = [&result, &formatter_regex, &any_printed] (const lldb::TypeCategoryImplSP& category) -> void {
+ result.GetOutputStream().Printf("-----------------------\nCategory: %s%s\n-----------------------\n",
+ category->GetName(),
+ category->IsEnabled() ? "" : " (disabled)");
+
TypeCategoryImpl::ForEachCallbacks<FormatterType> foreach;
- foreach.SetExact([&result, &formatter_regex] (ConstString name, const FormatterSharedPointer& format_sp) -> bool {
+ foreach.SetExact([&result, &formatter_regex, &any_printed] (ConstString name, const FormatterSharedPointer& format_sp) -> bool {
if (formatter_regex)
{
bool escape = true;
@@ -1413,13 +1372,13 @@ protected:
if (escape)
return true;
}
-
+
+ any_printed = true;
result.GetOutputStream().Printf ("%s: %s\n", name.AsCString(), format_sp->GetDescription().c_str());
-
return true;
});
- foreach.SetWithRegex( [&result, &formatter_regex] (RegularExpressionSP regex_sp, const FormatterSharedPointer& format_sp) -> bool {
+ foreach.SetWithRegex([&result, &formatter_regex, &any_printed] (RegularExpressionSP regex_sp, const FormatterSharedPointer& format_sp) -> bool {
if (formatter_regex)
{
bool escape = true;
@@ -1436,8 +1395,8 @@ protected:
return true;
}
+ any_printed = true;
result.GetOutputStream().Printf ("%s: %s\n", regex_sp->GetText(), format_sp->GetDescription().c_str());
-
return true;
});
@@ -1475,10 +1434,16 @@ protected:
return true;
});
- FormatterSpecificList(result);
+ any_printed = FormatterSpecificList(result) | any_printed;
}
- result.SetStatus(eReturnStatusSuccessFinishResult);
+ if (any_printed)
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ else
+ {
+ result.GetOutputStream().PutCString("no matching results found.\n");
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ }
return result.Succeeded();
}
};
@@ -1505,7 +1470,7 @@ public:
// CommandObjectTypeSummaryAdd
//-------------------------------------------------------------------------
-#endif // #ifndef LLDB_DISABLE_PYTHON
+#endif // LLDB_DISABLE_PYTHON
Error
CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
@@ -1588,8 +1553,6 @@ CommandObjectTypeSummaryAdd::CommandOptions::OptionParsingStarting ()
m_category = "default";
}
-
-
#ifndef LLDB_DISABLE_PYTHON
bool
@@ -1624,7 +1587,7 @@ CommandObjectTypeSummaryAdd::Execute_ScriptSummary (Args& command, CommandReturn
ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
- if (interpreter && interpreter->CheckObjectExists(funct_name) == false)
+ if (interpreter && !interpreter->CheckObjectExists(funct_name))
result.AppendWarningWithFormat("The provided function \"%s\" does not exist - "
"please define it before attempting to use this summary.\n",
funct_name);
@@ -1727,8 +1690,7 @@ CommandObjectTypeSummaryAdd::Execute_ScriptSummary (Args& command, CommandReturn
return result.Succeeded();
}
-#endif
-
+#endif // LLDB_DISABLE_PYTHON
bool
CommandObjectTypeSummaryAdd::Execute_StringSummary (Args& command, CommandReturnObject &result)
@@ -1759,20 +1721,23 @@ CommandObjectTypeSummaryAdd::Execute_StringSummary (Args& command, CommandReturn
return false;
}
- Error error;
-
- lldb::TypeSummaryImplSP entry(new StringSummaryFormat(m_options.m_flags,
- format_cstr));
-
- if (error.Fail())
+ std::unique_ptr<StringSummaryFormat> string_format(new StringSummaryFormat(m_options.m_flags, format_cstr));
+ if (!string_format)
{
- result.AppendError(error.AsCString());
+ result.AppendError("summary creation failed");
result.SetStatus(eReturnStatusFailed);
return false;
}
+ if (string_format->m_error.Fail())
+ {
+ result.AppendErrorWithFormat("syntax error: %s", string_format->m_error.AsCString("<unknown>"));
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ lldb::TypeSummaryImplSP entry(string_format.release());
// now I have a valid format, let's add it to every type
-
+ Error error;
for (size_t i = 0; i < argc; i++)
{
const char* typeA = command.GetArgumentAtIndex(i);
@@ -1815,10 +1780,10 @@ CommandObjectTypeSummaryAdd::Execute_StringSummary (Args& command, CommandReturn
}
CommandObjectTypeSummaryAdd::CommandObjectTypeSummaryAdd (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type summary add",
- "Add a new summary style for a type.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "type summary add",
+ "Add a new summary style for a type.",
+ nullptr),
IOHandlerDelegateMultiline ("DONE"),
m_options (interpreter)
{
@@ -1928,7 +1893,7 @@ CommandObjectTypeSummaryAdd::DoExecute (Args& command, CommandReturnObject &resu
result.AppendError ("python is disabled");
result.SetStatus(eReturnStatusFailed);
return false;
-#endif
+#endif // LLDB_DISABLE_PYTHON
}
return Execute_StringSummary(command, result);
@@ -2000,25 +1965,24 @@ CommandObjectTypeSummaryAdd::AddSummary(ConstString type_name,
OptionDefinition
CommandObjectTypeSummaryAdd::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Add this to the given category instead of the default one."},
- { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "If true, cascade through typedef chains."},
- { LLDB_OPT_SET_ALL, false, "no-value", 'v', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Don't show the value, just show the summary, for this type."},
- { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."},
- { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Don't use this format for references-to-type objects."},
- { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Type names are actually regular expressions."},
- { LLDB_OPT_SET_1 , true, "inline-children", 'c', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "If true, inline all child values into summary string."},
- { LLDB_OPT_SET_1 , false, "omit-names", 'O', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "If true, omit value names in the summary display."},
- { LLDB_OPT_SET_2 , true, "summary-string", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeSummaryString, "Summary string used to display text and object contents."},
- { LLDB_OPT_SET_3, false, "python-script", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonScript, "Give a one-liner Python script as part of the command."},
- { LLDB_OPT_SET_3, false, "python-function", 'F', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonFunction, "Give the name of a Python function to use for this type."},
- { LLDB_OPT_SET_3, false, "input-python", 'P', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Input Python code to use for this type manually."},
- { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "expand", 'e', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Expand aggregate data types to show children on separate lines."},
- { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "hide-empty", 'h', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Do not expand aggregate data types with no children."},
- { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "A name for this summary string."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "Add this to the given category instead of the default one."},
+ { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "If true, cascade through typedef chains."},
+ { LLDB_OPT_SET_ALL, false, "no-value", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Don't show the value, just show the summary, for this type."},
+ { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."},
+ { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Don't use this format for references-to-type objects."},
+ { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Type names are actually regular expressions."},
+ { LLDB_OPT_SET_1 , true, "inline-children", 'c', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "If true, inline all child values into summary string."},
+ { LLDB_OPT_SET_1 , false, "omit-names", 'O', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "If true, omit value names in the summary display."},
+ { LLDB_OPT_SET_2 , true, "summary-string", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeSummaryString, "Summary string used to display text and object contents."},
+ { LLDB_OPT_SET_3, false, "python-script", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePythonScript, "Give a one-liner Python script as part of the command."},
+ { LLDB_OPT_SET_3, false, "python-function", 'F', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePythonFunction, "Give the name of a Python function to use for this type."},
+ { LLDB_OPT_SET_3, false, "input-python", 'P', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Input Python code to use for this type manually."},
+ { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "expand", 'e', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Expand aggregate data types to show children on separate lines."},
+ { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "hide-empty", 'h', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Do not expand aggregate data types with no children."},
+ { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "A name for this summary string."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
//-------------------------------------------------------------------------
// CommandObjectTypeSummaryDelete
//-------------------------------------------------------------------------
@@ -2033,11 +1997,9 @@ public:
"Delete an existing summary for a type.")
{
}
-
- ~CommandObjectTypeSummaryDelete () override
- {
- }
-
+
+ ~CommandObjectTypeSummaryDelete() override = default;
+
protected:
bool
FormatterSpecificDeletion (ConstString typeCS) override
@@ -2074,7 +2036,6 @@ protected:
class CommandObjectTypeSummaryList : public CommandObjectTypeFormatterList<TypeSummaryImpl>
{
public:
-
CommandObjectTypeSummaryList (CommandInterpreter &interpreter) :
CommandObjectTypeFormatterList(interpreter,
"type summary list",
@@ -2083,7 +2044,7 @@ public:
}
protected:
- void
+ bool
FormatterSpecificList (CommandReturnObject &result) override
{
if (DataVisualization::NamedSummaryFormats::GetCount() > 0)
@@ -2093,7 +2054,9 @@ protected:
result.GetOutputStream().Printf ("%s: %s\n", name.AsCString(), summary_sp->GetDescription().c_str());
return true;
});
+ return true;
}
+ return false;
}
};
@@ -2103,20 +2066,18 @@ protected:
class CommandObjectTypeCategoryDefine : public CommandObjectParsed
{
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_define_enabled(false,false),
m_cate_language(eLanguageTypeUnknown,eLanguageTypeUnknown)
{
}
-
- ~CommandOptions () override {}
-
+
+ ~CommandOptions() override = default;
+
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -2160,8 +2121,6 @@ class CommandObjectTypeCategoryDefine : public CommandObjectParsed
OptionValueBoolean m_define_enabled;
OptionValueLanguage m_cate_language;
-
-
};
CommandOptions m_options;
@@ -2174,11 +2133,11 @@ class CommandObjectTypeCategoryDefine : public CommandObjectParsed
public:
CommandObjectTypeCategoryDefine (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type category define",
- "Define a new category as a source of formatters.",
- NULL),
- m_options(interpreter)
+ CommandObjectParsed(interpreter,
+ "type category define",
+ "Define a new category as a source of formatters.",
+ nullptr),
+ m_options(interpreter)
{
CommandArgumentEntry type_arg;
CommandArgumentData type_style_arg;
@@ -2189,13 +2148,10 @@ public:
type_arg.push_back (type_style_arg);
m_arguments.push_back (type_arg);
-
- }
-
- ~CommandObjectTypeCategoryDefine () override
- {
}
-
+
+ ~CommandObjectTypeCategoryDefine() override = default;
+
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -2224,15 +2180,14 @@ protected:
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
-
};
OptionDefinition
CommandObjectTypeCategoryDefine::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "enabled", 'e', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "If specified, this category will be created enabled."},
- { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Specify the language that this category is supported for."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "enabled", 'e', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "If specified, this category will be created enabled."},
+ { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage, "Specify the language that this category is supported for."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -2244,14 +2199,13 @@ class CommandObjectTypeCategoryEnable : public CommandObjectParsed
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter)
{
}
-
- ~CommandOptions () override {}
-
+
+ ~CommandOptions() override = default;
+
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -2308,10 +2262,10 @@ class CommandObjectTypeCategoryEnable : public CommandObjectParsed
public:
CommandObjectTypeCategoryEnable (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type category enable",
- "Enable a category as a source of formatters.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "type category enable",
+ "Enable a category as a source of formatters.",
+ nullptr),
m_options(interpreter)
{
CommandArgumentEntry type_arg;
@@ -2325,11 +2279,9 @@ public:
m_arguments.push_back (type_arg);
}
-
- ~CommandObjectTypeCategoryEnable () override
- {
- }
-
+
+ ~CommandObjectTypeCategoryEnable() override = default;
+
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -2363,7 +2315,7 @@ protected:
}
DataVisualization::Categories::Enable(typeCS);
lldb::TypeCategoryImplSP cate;
- if (DataVisualization::Categories::GetCategory(typeCS, cate) && cate.get())
+ if (DataVisualization::Categories::GetCategory(typeCS, cate) && cate)
{
if (cate->GetCount() == 0)
{
@@ -2379,14 +2331,13 @@ protected:
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
-
};
OptionDefinition
CommandObjectTypeCategoryEnable::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Enable the category for this language."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage, "Enable the category for this language."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -2397,10 +2348,10 @@ class CommandObjectTypeCategoryDelete : public CommandObjectParsed
{
public:
CommandObjectTypeCategoryDelete (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type category delete",
- "Delete a category and all associated formatters.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "type category delete",
+ "Delete a category and all associated formatters.",
+ nullptr)
{
CommandArgumentEntry type_arg;
CommandArgumentData type_style_arg;
@@ -2411,13 +2362,10 @@ public:
type_arg.push_back (type_style_arg);
m_arguments.push_back (type_arg);
-
- }
-
- ~CommandObjectTypeCategoryDelete () override
- {
}
-
+
+ ~CommandObjectTypeCategoryDelete() override = default;
+
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -2471,14 +2419,13 @@ class CommandObjectTypeCategoryDisable : public CommandObjectParsed
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter)
{
}
-
- ~CommandOptions () override {}
-
+
+ ~CommandOptions() override = default;
+
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -2522,7 +2469,6 @@ class CommandObjectTypeCategoryDisable : public CommandObjectParsed
// Instance variables to hold the values for command options.
lldb::LanguageType m_language;
-
};
CommandOptions m_options;
@@ -2535,10 +2481,10 @@ class CommandObjectTypeCategoryDisable : public CommandObjectParsed
public:
CommandObjectTypeCategoryDisable (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type category disable",
- "Disable a category as a source of formatters.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "type category disable",
+ "Disable a category as a source of formatters.",
+ nullptr),
m_options(interpreter)
{
CommandArgumentEntry type_arg;
@@ -2550,13 +2496,10 @@ public:
type_arg.push_back (type_style_arg);
m_arguments.push_back (type_arg);
-
}
-
- ~CommandObjectTypeCategoryDisable () override
- {
- }
-
+
+ ~CommandObjectTypeCategoryDisable() override = default;
+
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -2599,14 +2542,13 @@ protected:
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
-
};
OptionDefinition
CommandObjectTypeCategoryDisable::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Enable the category for this language."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage, "Enable the category for this language."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -2617,10 +2559,10 @@ class CommandObjectTypeCategoryList : public CommandObjectParsed
{
public:
CommandObjectTypeCategoryList (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type category list",
- "Provide a list of all existing categories.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "type category list",
+ "Provide a list of all existing categories.",
+ nullptr)
{
CommandArgumentEntry type_arg;
CommandArgumentData type_style_arg;
@@ -2632,11 +2574,9 @@ public:
m_arguments.push_back (type_arg);
}
-
- ~CommandObjectTypeCategoryList () override
- {
- }
-
+
+ ~CommandObjectTypeCategoryList() override = default;
+
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -2688,7 +2628,6 @@ protected:
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
-
};
//-------------------------------------------------------------------------
@@ -2698,7 +2637,6 @@ protected:
class CommandObjectTypeFilterList : public CommandObjectTypeFormatterList<TypeFilterImpl>
{
public:
-
CommandObjectTypeFilterList (CommandInterpreter &interpreter) :
CommandObjectTypeFormatterList(interpreter,
"type filter list",
@@ -2716,7 +2654,6 @@ public:
class CommandObjectTypeSynthList : public CommandObjectTypeFormatterList<SyntheticChildren>
{
public:
-
CommandObjectTypeSynthList (CommandInterpreter &interpreter) :
CommandObjectTypeFormatterList(interpreter,
"type synthetic list",
@@ -2725,7 +2662,8 @@ public:
}
};
-#endif // #ifndef LLDB_DISABLE_PYTHON
+#endif // LLDB_DISABLE_PYTHON
+
//-------------------------------------------------------------------------
// CommandObjectTypeFilterDelete
//-------------------------------------------------------------------------
@@ -2740,10 +2678,8 @@ public:
"Delete an existing filter for a type.")
{
}
-
- ~CommandObjectTypeFilterDelete () override
- {
- }
+
+ ~CommandObjectTypeFilterDelete() override = default;
};
#ifndef LLDB_DISABLE_PYTHON
@@ -2762,13 +2698,11 @@ public:
"Delete an existing synthetic provider for a type.")
{
}
-
- ~CommandObjectTypeSynthDelete () override
- {
- }
+
+ ~CommandObjectTypeSynthDelete() override = default;
};
-#endif // #ifndef LLDB_DISABLE_PYTHON
+#endif // LLDB_DISABLE_PYTHON
//-------------------------------------------------------------------------
// CommandObjectTypeFilterClear
@@ -2866,7 +2800,7 @@ CommandObjectTypeSynthAdd::Execute_PythonClass (Args& command, CommandReturnObje
ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
- if (interpreter && interpreter->CheckObjectExists(impl->GetPythonClassName()) == false)
+ if (interpreter && !interpreter->CheckObjectExists(impl->GetPythonClassName()))
result.AppendWarning("The provided class does not exist - please define it before attempting to use this synthetic provider");
// now I have a valid provider, let's add it to every type
@@ -2906,10 +2840,10 @@ CommandObjectTypeSynthAdd::Execute_PythonClass (Args& command, CommandReturnObje
}
CommandObjectTypeSynthAdd::CommandObjectTypeSynthAdd (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type synthetic add",
- "Add a new synthetic provider for a type.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "type synthetic add",
+ "Add a new synthetic provider for a type.",
+ nullptr),
IOHandlerDelegateMultiline ("DONE"),
m_options (interpreter)
{
@@ -2922,7 +2856,6 @@ CommandObjectTypeSynthAdd::CommandObjectTypeSynthAdd (CommandInterpreter &interp
type_arg.push_back (type_style_arg);
m_arguments.push_back (type_arg);
-
}
bool
@@ -2975,35 +2908,33 @@ CommandObjectTypeSynthAdd::AddSynth(ConstString type_name,
OptionDefinition
CommandObjectTypeSynthAdd::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "If true, cascade through typedef chains."},
- { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."},
- { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Don't use this format for references-to-type objects."},
- { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Add this to the given category instead of the default one."},
- { LLDB_OPT_SET_2, false, "python-class", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonClass, "Use this Python class to produce synthetic children."},
- { LLDB_OPT_SET_3, false, "input-python", 'P', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Type Python code to generate a class that provides synthetic children."},
- { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Type names are actually regular expressions."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "If true, cascade through typedef chains."},
+ { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."},
+ { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Don't use this format for references-to-type objects."},
+ { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "Add this to the given category instead of the default one."},
+ { LLDB_OPT_SET_2, false, "python-class", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePythonClass, "Use this Python class to produce synthetic children."},
+ { LLDB_OPT_SET_3, false, "input-python", 'P', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Type Python code to generate a class that provides synthetic children."},
+ { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Type names are actually regular expressions."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-#endif // #ifndef LLDB_DISABLE_PYTHON
+#endif // LLDB_DISABLE_PYTHON
class CommandObjectTypeFilterAdd : public CommandObjectParsed
{
-
private:
-
class CommandOptions : public Options
{
typedef std::vector<std::string> option_vector;
+
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter)
{
}
-
- ~CommandOptions () override {}
-
+
+ ~CommandOptions() override = default;
+
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -3072,9 +3003,7 @@ private:
bool m_input_python;
option_vector m_expr_paths;
std::string m_category;
-
bool has_child_list;
-
bool m_regex;
typedef option_vector::iterator ExpressionPathsIterator;
@@ -3141,14 +3070,12 @@ private:
}
}
-
public:
-
CommandObjectTypeFilterAdd (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "type filter add",
- "Add a new filter for a type.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "type filter add",
+ "Add a new filter for a type.",
+ nullptr),
m_options (interpreter)
{
CommandArgumentEntry type_arg;
@@ -3194,11 +3121,9 @@ all children of my_foo as if no filter was defined:" R"(
(lldb) frame variable my_foo --raw)"
);
}
-
- ~CommandObjectTypeFilterAdd () override
- {
- }
-
+
+ ~CommandObjectTypeFilterAdd() override = default;
+
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -3212,7 +3137,7 @@ protected:
return false;
}
- if (m_options.m_expr_paths.size() == 0)
+ if (m_options.m_expr_paths.empty())
{
result.AppendErrorWithFormat ("%s needs one or more children.\n", m_cmd_name.c_str());
result.SetStatus(eReturnStatusFailed);
@@ -3267,19 +3192,18 @@ protected:
result.SetStatus(eReturnStatusSuccessFinishNoResult);
return result.Succeeded();
}
-
};
OptionDefinition
CommandObjectTypeFilterAdd::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "If true, cascade through typedef chains."},
- { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."},
- { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Don't use this format for references-to-type objects."},
- { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Add this to the given category instead of the default one."},
- { LLDB_OPT_SET_ALL, false, "child", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeExpressionPath, "Include this expression path in the synthetic view."},
- { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Type names are actually regular expressions."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "If true, cascade through typedef chains."},
+ { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."},
+ { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Don't use this format for references-to-type objects."},
+ { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "Add this to the given category instead of the default one."},
+ { LLDB_OPT_SET_ALL, false, "child", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeExpressionPath, "Include this expression path in the synthetic view."},
+ { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Type names are actually regular expressions."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//----------------------------------------------------------------------
@@ -3288,19 +3212,38 @@ CommandObjectTypeFilterAdd::CommandOptions::g_option_table[] =
class CommandObjectTypeLookup : public CommandObjectRaw
{
protected:
+ // this function is allowed to do a more aggressive job at guessing languages than the expression parser
+ // is comfortable with - so leave the original call alone and add one that is specific to type lookup
+ lldb::LanguageType
+ GuessLanguage (StackFrame *frame)
+ {
+ lldb::LanguageType lang_type = lldb::eLanguageTypeUnknown;
+
+ if (!frame)
+ return lang_type;
+
+ lang_type = frame->GuessLanguage();
+ if (lang_type != lldb::eLanguageTypeUnknown)
+ return lang_type;
+
+ Symbol *s = frame->GetSymbolContext(eSymbolContextSymbol).symbol;
+ if (s)
+ lang_type = s->GetMangled().GuessLanguage();
+
+ return lang_type;
+ }
class CommandOptions : public OptionGroup
{
public:
-
CommandOptions () :
OptionGroup(),
m_show_help(false),
m_language(eLanguageTypeUnknown)
{}
-
- ~CommandOptions () override {}
-
+
+ ~CommandOptions() override = default;
+
uint32_t
GetNumDefinitions () override
{
@@ -3358,12 +3301,11 @@ protected:
CommandOptions m_command_options;
public:
-
CommandObjectTypeLookup (CommandInterpreter &interpreter) :
CommandObjectRaw (interpreter,
"type lookup",
- "Lookup a type by name in the select target.",
- "type lookup <typename>",
+ "Lookup types and declarations in the current target, following language-specific naming conventions.",
+ "type lookup <type-specifier>",
eCommandRequiresTarget),
m_option_group(interpreter),
m_command_options()
@@ -3371,17 +3313,41 @@ public:
m_option_group.Append(&m_command_options);
m_option_group.Finalize();
}
-
- ~CommandObjectTypeLookup () override
- {
- }
-
+
+ ~CommandObjectTypeLookup() override = default;
+
Options *
GetOptions () override
{
return &m_option_group;
}
+ const char*
+ GetHelpLong () override
+ {
+ if (m_cmd_help_long.empty())
+ {
+ StreamString stream;
+ // FIXME: hardcoding languages is not good
+ lldb::LanguageType languages[] = {eLanguageTypeObjC,eLanguageTypeC_plus_plus};
+
+ for(const auto lang_type : languages)
+ {
+ if (auto language = Language::FindPlugin(lang_type))
+ {
+ if (const char* help = language->GetLanguageSpecificTypeLookupHelp())
+ {
+ stream.Printf("%s\n", help);
+ }
+ }
+ }
+
+ if (stream.GetData())
+ m_cmd_help_long.assign(stream.GetString());
+ }
+ return this->CommandObject::GetHelpLong();
+ }
+
bool
DoExecute (const char *raw_command_line, CommandReturnObject &result) override
{
@@ -3393,12 +3359,12 @@ public:
m_option_group.NotifyOptionParsingStarting();
- const char * name_of_type = NULL;
+ const char * name_of_type = nullptr;
if (raw_command_line[0] == '-')
{
// We have some options and these options MUST end with --.
- const char *end_options = NULL;
+ const char *end_options = nullptr;
const char *s = raw_command_line;
while (s && s[0])
{
@@ -3444,7 +3410,9 @@ public:
std::vector<Language*> languages;
- if (m_command_options.m_language == eLanguageTypeUnknown)
+ bool is_global_search = false;
+
+ if ( (is_global_search = (m_command_options.m_language == eLanguageTypeUnknown)) )
{
// FIXME: hardcoding languages is not good
languages.push_back(Language::FindPlugin(eLanguageTypeObjC));
@@ -3455,6 +3423,27 @@ public:
languages.push_back(Language::FindPlugin(m_command_options.m_language));
}
+ // This is not the most efficient way to do this, but we support very few languages
+ // so the cost of the sort is going to be dwarfed by the actual lookup anyway
+ if (StackFrame* frame = m_exe_ctx.GetFramePtr())
+ {
+ LanguageType lang = GuessLanguage(frame);
+ if (lang != eLanguageTypeUnknown)
+ {
+ std::sort(languages.begin(),
+ languages.end(),
+ [lang] (Language* lang1,
+ Language* lang2) -> bool {
+ if (!lang1 || !lang2) return false;
+ LanguageType lt1 = lang1->GetLanguageType();
+ LanguageType lt2 = lang2->GetLanguageType();
+ if (lt1 == lang) return true; // make the selected frame's language come first
+ if (lt2 == lang) return false; // make the selected frame's language come first
+ return (lt1 < lt2); // normal comparison otherwise
+ });
+ }
+ }
+
for (Language* language : languages)
{
if (!language)
@@ -3474,21 +3463,26 @@ public:
}
}
}
+ // this is "type lookup SomeName" and we did find a match, so get out
+ if (any_found && is_global_search)
+ break;
}
}
+ if (!any_found)
+ result.AppendMessageWithFormat("no type was found matching '%s'\n", name_of_type);
+
result.SetStatus (any_found ? lldb::eReturnStatusSuccessFinishResult : lldb::eReturnStatusSuccessFinishNoResult);
return true;
}
-
};
OptionDefinition
CommandObjectTypeLookup::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "show-help", 'h', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display available help for types"},
- { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Which language's types should the search scope be"},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "show-help", 'h', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display available help for types"},
+ { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage, "Which language's types should the search scope be"},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
template <typename FormatterType>
@@ -3517,17 +3511,23 @@ public:
syntax.Printf("type %s info <expr>", formatter_name);
SetSyntax(syntax.GetData());
}
-
- ~CommandObjectFormatterInfo () override
- {
- }
-
+
+ ~CommandObjectFormatterInfo() override = default;
+
protected:
bool
DoExecute (const char *command, CommandReturnObject &result) override
{
- auto target_sp = m_interpreter.GetDebugger().GetSelectedTarget();
- auto frame_sp = target_sp->GetProcessSP()->GetThreadList().GetSelectedThread()->GetSelectedFrame();
+ TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget();
+ Thread *thread = GetDefaultThread();
+ if (!thread)
+ {
+ result.AppendError("no default thread");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+
+ StackFrameSP frame_sp = thread->GetSelectedFrame();
ValueObjectSP result_valobj_sp;
EvaluateExpressionOptions options;
lldb::ExpressionResults expr_result = target_sp->EvaluateExpression(command, frame_sp.get(), result_valobj_sp, options);
@@ -3571,11 +3571,9 @@ private:
class CommandObjectTypeFormat : public CommandObjectMultiword
{
public:
- CommandObjectTypeFormat (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "type format",
- "A set of commands for editing variable value display options",
- "type format [<sub-command-options>] ")
+ CommandObjectTypeFormat(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "type format", "Commands for customizing value display formats.",
+ "type format [<sub-command-options>] ")
{
LoadSubCommand ("add", CommandObjectSP (new CommandObjectTypeFormatAdd (interpreter)));
LoadSubCommand ("clear", CommandObjectSP (new CommandObjectTypeFormatClear (interpreter)));
@@ -3588,10 +3586,7 @@ public:
})));
}
-
- ~CommandObjectTypeFormat () override
- {
- }
+ ~CommandObjectTypeFormat() override = default;
};
#ifndef LLDB_DISABLE_PYTHON
@@ -3599,11 +3594,10 @@ public:
class CommandObjectTypeSynth : public CommandObjectMultiword
{
public:
- CommandObjectTypeSynth (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "type synthetic",
- "A set of commands for operating on synthetic type representations",
- "type synthetic [<sub-command-options>] ")
+ CommandObjectTypeSynth(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "type synthetic",
+ "Commands for operating on synthetic type representations.",
+ "type synthetic [<sub-command-options>] ")
{
LoadSubCommand ("add", CommandObjectSP (new CommandObjectTypeSynthAdd (interpreter)));
LoadSubCommand ("clear", CommandObjectSP (new CommandObjectTypeSynthClear (interpreter)));
@@ -3615,44 +3609,34 @@ public:
return valobj.GetSyntheticChildren();
})));
}
-
-
- ~CommandObjectTypeSynth () override
- {
- }
+
+ ~CommandObjectTypeSynth() override = default;
};
-#endif // #ifndef LLDB_DISABLE_PYTHON
+#endif // LLDB_DISABLE_PYTHON
class CommandObjectTypeFilter : public CommandObjectMultiword
{
public:
- CommandObjectTypeFilter (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "type filter",
- "A set of commands for operating on type filters",
- "type synthetic [<sub-command-options>] ")
+ CommandObjectTypeFilter(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "type filter", "Commands for operating on type filters.",
+ "type synthetic [<sub-command-options>] ")
{
LoadSubCommand ("add", CommandObjectSP (new CommandObjectTypeFilterAdd (interpreter)));
LoadSubCommand ("clear", CommandObjectSP (new CommandObjectTypeFilterClear (interpreter)));
LoadSubCommand ("delete", CommandObjectSP (new CommandObjectTypeFilterDelete (interpreter)));
LoadSubCommand ("list", CommandObjectSP (new CommandObjectTypeFilterList (interpreter)));
}
-
-
- ~CommandObjectTypeFilter () override
- {
- }
+
+ ~CommandObjectTypeFilter() override = default;
};
class CommandObjectTypeCategory : public CommandObjectMultiword
{
public:
- CommandObjectTypeCategory (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "type category",
- "A set of commands for operating on categories",
- "type category [<sub-command-options>] ")
+ CommandObjectTypeCategory(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "type category", "Commands for operating on type categories.",
+ "type category [<sub-command-options>] ")
{
LoadSubCommand ("define", CommandObjectSP (new CommandObjectTypeCategoryDefine (interpreter)));
LoadSubCommand ("enable", CommandObjectSP (new CommandObjectTypeCategoryEnable (interpreter)));
@@ -3660,21 +3644,16 @@ public:
LoadSubCommand ("delete", CommandObjectSP (new CommandObjectTypeCategoryDelete (interpreter)));
LoadSubCommand ("list", CommandObjectSP (new CommandObjectTypeCategoryList (interpreter)));
}
-
-
- ~CommandObjectTypeCategory () override
- {
- }
+
+ ~CommandObjectTypeCategory() override = default;
};
class CommandObjectTypeSummary : public CommandObjectMultiword
{
public:
- CommandObjectTypeSummary (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "type summary",
- "A set of commands for editing variable summary display options",
- "type summary [<sub-command-options>] ")
+ CommandObjectTypeSummary(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "type summary", "Commands for editing variable summary display options.",
+ "type summary [<sub-command-options>] ")
{
LoadSubCommand ("add", CommandObjectSP (new CommandObjectTypeSummaryAdd (interpreter)));
LoadSubCommand ("clear", CommandObjectSP (new CommandObjectTypeSummaryClear (interpreter)));
@@ -3686,22 +3665,17 @@ public:
return valobj.GetSummaryFormat();
})));
}
-
-
- ~CommandObjectTypeSummary () override
- {
- }
+
+ ~CommandObjectTypeSummary() override = default;
};
//-------------------------------------------------------------------------
// CommandObjectType
//-------------------------------------------------------------------------
-CommandObjectType::CommandObjectType (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "type",
- "A set of commands for operating on the type system",
- "type [<sub-command-options>]")
+CommandObjectType::CommandObjectType(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "type", "Commands for operating on the type system.",
+ "type [<sub-command-options>]")
{
LoadSubCommand ("category", CommandObjectSP (new CommandObjectTypeCategory (interpreter)));
LoadSubCommand ("filter", CommandObjectSP (new CommandObjectTypeFilter (interpreter)));
@@ -3709,11 +3683,8 @@ CommandObjectType::CommandObjectType (CommandInterpreter &interpreter) :
LoadSubCommand ("summary", CommandObjectSP (new CommandObjectTypeSummary (interpreter)));
#ifndef LLDB_DISABLE_PYTHON
LoadSubCommand ("synthetic", CommandObjectSP (new CommandObjectTypeSynth (interpreter)));
-#endif
+#endif // LLDB_DISABLE_PYTHON
LoadSubCommand ("lookup", CommandObjectSP (new CommandObjectTypeLookup (interpreter)));
}
-
-CommandObjectType::~CommandObjectType ()
-{
-}
+CommandObjectType::~CommandObjectType() = default;