summaryrefslogtreecommitdiff
path: root/source/Commands
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
commitf3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch)
tree48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /source/Commands
parent2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff)
Notes
Diffstat (limited to 'source/Commands')
-rw-r--r--source/Commands/CommandCompletions.cpp263
-rw-r--r--source/Commands/CommandObjectApropos.cpp51
-rw-r--r--source/Commands/CommandObjectArgs.cpp20
-rw-r--r--source/Commands/CommandObjectBreakpoint.cpp485
-rw-r--r--source/Commands/CommandObjectBreakpointCommand.cpp124
-rw-r--r--source/Commands/CommandObjectBugreport.cpp8
-rw-r--r--source/Commands/CommandObjectCommands.cpp755
-rw-r--r--source/Commands/CommandObjectDisassemble.cpp97
-rw-r--r--source/Commands/CommandObjectDisassemble.h7
-rw-r--r--source/Commands/CommandObjectExpression.cpp234
-rw-r--r--source/Commands/CommandObjectExpression.h17
-rw-r--r--source/Commands/CommandObjectFrame.cpp169
-rw-r--r--source/Commands/CommandObjectHelp.cpp108
-rw-r--r--source/Commands/CommandObjectHelp.h8
-rw-r--r--source/Commands/CommandObjectLanguage.cpp14
-rw-r--r--source/Commands/CommandObjectLanguage.h3
-rw-r--r--source/Commands/CommandObjectLog.cpp99
-rw-r--r--source/Commands/CommandObjectMemory.cpp336
-rw-r--r--source/Commands/CommandObjectMultiword.cpp108
-rw-r--r--source/Commands/CommandObjectPlatform.cpp562
-rw-r--r--source/Commands/CommandObjectPlugin.cpp53
-rw-r--r--source/Commands/CommandObjectProcess.cpp344
-rw-r--r--source/Commands/CommandObjectQuit.cpp4
-rw-r--r--source/Commands/CommandObjectRegister.cpp92
-rw-r--r--source/Commands/CommandObjectSettings.cpp306
-rw-r--r--source/Commands/CommandObjectSource.cpp132
-rw-r--r--source/Commands/CommandObjectSyntax.cpp27
-rw-r--r--source/Commands/CommandObjectTarget.cpp925
-rw-r--r--source/Commands/CommandObjectThread.cpp802
-rw-r--r--source/Commands/CommandObjectType.cpp793
-rw-r--r--source/Commands/CommandObjectVersion.cpp4
-rw-r--r--source/Commands/CommandObjectWatchpoint.cpp261
-rw-r--r--source/Commands/CommandObjectWatchpointCommand.cpp121
-rw-r--r--source/Commands/Makefile16
34 files changed, 3507 insertions, 3841 deletions
diff --git a/source/Commands/CommandCompletions.cpp b/source/Commands/CommandCompletions.cpp
index 37696e3bbfdb5..dd0ecb4b82e98 100644
--- a/source/Commands/CommandCompletions.cpp
+++ b/source/Commands/CommandCompletions.cpp
@@ -15,11 +15,14 @@
// C++ Includes
// Other libraries and framework includes
+#include "llvm/ADT/SmallString.h"
+
// Project includes
-#include "lldb/Host/FileSpec.h"
#include "lldb/Core/FileSpecList.h"
-#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Host/FileSpec.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -36,7 +39,7 @@ using namespace lldb_private;
CommandCompletions::CommonCompletionElement
CommandCompletions::g_common_completions[] =
{
- {eCustomCompletion, NULL},
+ {eCustomCompletion, nullptr},
{eSourceFileCompletion, CommandCompletions::SourceFiles},
{eDiskFileCompletion, CommandCompletions::DiskFiles},
{eDiskDirectoryCompletion, CommandCompletions::DiskDirectories},
@@ -46,21 +49,18 @@ CommandCompletions::g_common_completions[] =
{ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames},
{eArchitectureCompletion, CommandCompletions::ArchitectureNames},
{eVariablePathCompletion, CommandCompletions::VariablePath},
- {eNoCompletion, NULL} // This one has to be last in the list.
+ {eNoCompletion, nullptr} // This one has to be last in the list.
};
bool
-CommandCompletions::InvokeCommonCompletionCallbacks
-(
- CommandInterpreter &interpreter,
- uint32_t completion_mask,
- const char *completion_str,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- StringList &matches
-)
+CommandCompletions::InvokeCommonCompletionCallbacks(CommandInterpreter &interpreter,
+ uint32_t completion_mask,
+ const char *completion_str,
+ int match_start_point,
+ int max_return_elements,
+ SearchFilter *searcher,
+ bool &word_complete,
+ StringList &matches)
{
bool handled = false;
@@ -72,7 +72,7 @@ CommandCompletions::InvokeCommonCompletionCallbacks
if (g_common_completions[i].type == eNoCompletion)
break;
else if ((g_common_completions[i].type & completion_mask) == g_common_completions[i].type
- && g_common_completions[i].callback != NULL)
+ && g_common_completions[i].callback != nullptr)
{
handled = true;
g_common_completions[i].callback (interpreter,
@@ -88,16 +88,13 @@ CommandCompletions::InvokeCommonCompletionCallbacks
}
int
-CommandCompletions::SourceFiles
-(
- CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- StringList &matches
-)
+CommandCompletions::SourceFiles(CommandInterpreter &interpreter,
+ const char *partial_file_name,
+ int match_start_point,
+ int max_return_elements,
+ SearchFilter *searcher,
+ bool &word_complete,
+ StringList &matches)
{
word_complete = true;
// Find some way to switch "include support files..."
@@ -108,7 +105,7 @@ CommandCompletions::SourceFiles
max_return_elements,
matches);
- if (searcher == NULL)
+ if (searcher == nullptr)
{
lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget();
SearchFilterForUnconstrainedSearches null_searcher (target_sp);
@@ -166,8 +163,7 @@ FileSpec::EnumerateDirectoryResult DiskFilesOrDirectoriesCallback(void *baton, F
isa_directory = true;
else if (file_type == FileSpec::eFileTypeSymbolicLink)
{
- struct stat stat_buf;
- if ((stat(partial_name_copy, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode))
+ if (FileSpec(partial_name_copy, false).IsDirectory())
isa_directory = true;
}
@@ -187,13 +183,10 @@ FileSpec::EnumerateDirectoryResult DiskFilesOrDirectoriesCallback(void *baton, F
}
static int
-DiskFilesOrDirectories
-(
- const char *partial_file_name,
- bool only_directories,
- bool &saw_directory,
- StringList &matches
-)
+DiskFilesOrDirectories(const char *partial_file_name,
+ bool only_directories,
+ bool &saw_directory,
+ StringList &matches)
{
// I'm going to use the "glob" function with GLOB_TILDE for user directory expansion.
// If it is not defined on your host system, you'll need to implement it yourself...
@@ -224,7 +217,7 @@ DiskFilesOrDirectories
// This will store the resolved form of the containing directory
llvm::SmallString<64> containing_part;
- if (end_ptr == NULL)
+ if (end_ptr == nullptr)
{
// There's no directory. If the thing begins with a "~" then this is a bare
// user name.
@@ -312,18 +305,14 @@ DiskFilesOrDirectories
}
int
-CommandCompletions::DiskFiles
-(
- CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- StringList &matches
-)
+CommandCompletions::DiskFiles(CommandInterpreter &interpreter,
+ const char *partial_file_name,
+ int match_start_point,
+ int max_return_elements,
+ SearchFilter *searcher,
+ bool &word_complete,
+ StringList &matches)
{
-
int ret_val = DiskFilesOrDirectories (partial_file_name,
false,
word_complete,
@@ -333,16 +322,13 @@ CommandCompletions::DiskFiles
}
int
-CommandCompletions::DiskDirectories
-(
- CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- StringList &matches
-)
+CommandCompletions::DiskDirectories(CommandInterpreter &interpreter,
+ const char *partial_file_name,
+ int match_start_point,
+ int max_return_elements,
+ SearchFilter *searcher,
+ bool &word_complete,
+ StringList &matches)
{
int ret_val = DiskFilesOrDirectories (partial_file_name,
true,
@@ -353,16 +339,13 @@ CommandCompletions::DiskDirectories
}
int
-CommandCompletions::Modules
-(
- CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- StringList &matches
-)
+CommandCompletions::Modules(CommandInterpreter &interpreter,
+ const char *partial_file_name,
+ int match_start_point,
+ int max_return_elements,
+ SearchFilter *searcher,
+ bool &word_complete,
+ StringList &matches)
{
word_complete = true;
ModuleCompleter completer (interpreter,
@@ -371,7 +354,7 @@ CommandCompletions::Modules
max_return_elements,
matches);
- if (searcher == NULL)
+ if (searcher == nullptr)
{
lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget();
SearchFilterForUnconstrainedSearches null_searcher (target_sp);
@@ -385,15 +368,13 @@ CommandCompletions::Modules
}
int
-CommandCompletions::Symbols
-(
- CommandInterpreter &interpreter,
- const char *partial_file_name,
- int match_start_point,
- int max_return_elements,
- SearchFilter *searcher,
- bool &word_complete,
- StringList &matches)
+CommandCompletions::Symbols(CommandInterpreter &interpreter,
+ const char *partial_file_name,
+ int match_start_point,
+ int max_return_elements,
+ SearchFilter *searcher,
+ bool &word_complete,
+ StringList &matches)
{
word_complete = true;
SymbolCompleter completer (interpreter,
@@ -402,7 +383,7 @@ CommandCompletions::Symbols
max_return_elements,
matches);
- if (searcher == NULL)
+ if (searcher == nullptr)
{
lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget();
SearchFilterForUnconstrainedSearches null_searcher (target_sp);
@@ -433,7 +414,7 @@ CommandCompletions::SettingsNames (CommandInterpreter &interpreter,
if (properties_sp)
{
StreamString strm;
- properties_sp->DumpValue(NULL, strm, OptionValue::eDumpOptionName);
+ properties_sp->DumpValue(nullptr, strm, OptionValue::eDumpOptionName);
const std::string &str = strm.GetString();
g_property_names.SplitIntoLines(str.c_str(), str.size());
}
@@ -445,7 +426,6 @@ CommandCompletions::SettingsNames (CommandInterpreter &interpreter,
return num_matches;
}
-
int
CommandCompletions::PlatformPluginNames (CommandInterpreter &interpreter,
const char *partial_name,
@@ -474,7 +454,6 @@ CommandCompletions::ArchitectureNames (CommandInterpreter &interpreter,
return num_matches;
}
-
int
CommandCompletions::VariablePath (CommandInterpreter &interpreter,
const char *partial_name,
@@ -487,15 +466,11 @@ CommandCompletions::VariablePath (CommandInterpreter &interpreter,
return Variable::AutoComplete (interpreter.GetExecutionContext(), partial_name, matches, word_complete);
}
-
-CommandCompletions::Completer::Completer
-(
- CommandInterpreter &interpreter,
- const char *completion_str,
- int match_start_point,
- int max_return_elements,
- StringList &matches
-) :
+CommandCompletions::Completer::Completer(CommandInterpreter &interpreter,
+ const char *completion_str,
+ int match_start_point,
+ int max_return_elements,
+ StringList &matches) :
m_interpreter (interpreter),
m_completion_str (completion_str),
m_match_start_point (match_start_point),
@@ -504,24 +479,18 @@ CommandCompletions::Completer::Completer
{
}
-CommandCompletions::Completer::~Completer ()
-{
-
-}
+CommandCompletions::Completer::~Completer() = default;
//----------------------------------------------------------------------
// SourceFileCompleter
//----------------------------------------------------------------------
-CommandCompletions::SourceFileCompleter::SourceFileCompleter
-(
- CommandInterpreter &interpreter,
- bool include_support_files,
- const char *completion_str,
- int match_start_point,
- int max_return_elements,
- StringList &matches
-) :
+CommandCompletions::SourceFileCompleter::SourceFileCompleter(CommandInterpreter &interpreter,
+ bool include_support_files,
+ const char *completion_str,
+ int match_start_point,
+ int max_return_elements,
+ StringList &matches) :
CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches),
m_include_support_files (include_support_files),
m_matching_files()
@@ -538,14 +507,12 @@ CommandCompletions::SourceFileCompleter::GetDepth()
}
Searcher::CallbackReturn
-CommandCompletions::SourceFileCompleter::SearchCallback (
- SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool complete
-)
+CommandCompletions::SourceFileCompleter::SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool complete)
{
- if (context.comp_unit != NULL)
+ if (context.comp_unit != nullptr)
{
if (m_include_support_files)
{
@@ -568,7 +535,6 @@ CommandCompletions::SourceFileCompleter::SearchCallback (
m_matching_files.AppendIfUnique(sfile_spec);
}
}
-
}
else
{
@@ -603,7 +569,6 @@ CommandCompletions::SourceFileCompleter::DoCompletion (SearchFilter *filter)
m_matches.AppendString (m_matching_files.GetFileSpecAtIndex(i).GetFilename().GetCString());
}
return m_matches.GetSize();
-
}
//----------------------------------------------------------------------
@@ -613,29 +578,24 @@ CommandCompletions::SourceFileCompleter::DoCompletion (SearchFilter *filter)
static bool
regex_chars (const char comp)
{
- if (comp == '[' || comp == ']' ||
- comp == '(' || comp == ')' ||
- comp == '{' || comp == '}' ||
- comp == '+' ||
- comp == '.' ||
- comp == '*' ||
- comp == '|' ||
- comp == '^' ||
- comp == '$' ||
- comp == '\\' ||
- comp == '?')
- return true;
- else
- return false;
+ return (comp == '[' || comp == ']' ||
+ comp == '(' || comp == ')' ||
+ comp == '{' || comp == '}' ||
+ comp == '+' ||
+ comp == '.' ||
+ comp == '*' ||
+ comp == '|' ||
+ comp == '^' ||
+ comp == '$' ||
+ comp == '\\' ||
+ comp == '?');
}
-CommandCompletions::SymbolCompleter::SymbolCompleter
-(
- CommandInterpreter &interpreter,
- const char *completion_str,
- int match_start_point,
- int max_return_elements,
- StringList &matches
-) :
+
+CommandCompletions::SymbolCompleter::SymbolCompleter(CommandInterpreter &interpreter,
+ const char *completion_str,
+ int match_start_point,
+ int max_return_elements,
+ StringList &matches) :
CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches)
{
std::string regex_str;
@@ -665,12 +625,10 @@ CommandCompletions::SymbolCompleter::GetDepth()
}
Searcher::CallbackReturn
-CommandCompletions::SymbolCompleter::SearchCallback (
- SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool complete
-)
+CommandCompletions::SymbolCompleter::SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool complete)
{
if (context.module_sp)
{
@@ -709,14 +667,11 @@ CommandCompletions::SymbolCompleter::DoCompletion (SearchFilter *filter)
//----------------------------------------------------------------------
// ModuleCompleter
//----------------------------------------------------------------------
-CommandCompletions::ModuleCompleter::ModuleCompleter
-(
- CommandInterpreter &interpreter,
- const char *completion_str,
- int match_start_point,
- int max_return_elements,
- StringList &matches
-) :
+CommandCompletions::ModuleCompleter::ModuleCompleter(CommandInterpreter &interpreter,
+ const char *completion_str,
+ int match_start_point,
+ int max_return_elements,
+ StringList &matches) :
CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches)
{
FileSpec partial_spec (m_completion_str.c_str(), false);
@@ -731,12 +686,10 @@ CommandCompletions::ModuleCompleter::GetDepth()
}
Searcher::CallbackReturn
-CommandCompletions::ModuleCompleter::SearchCallback (
- SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool complete
-)
+CommandCompletions::ModuleCompleter::SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool complete)
{
if (context.module_sp)
{
diff --git a/source/Commands/CommandObjectApropos.cpp b/source/Commands/CommandObjectApropos.cpp
index 47890b1e83b74..29e1f14e3b28a 100644
--- a/source/Commands/CommandObjectApropos.cpp
+++ b/source/Commands/CommandObjectApropos.cpp
@@ -7,16 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectApropos.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "CommandObjectApropos.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/Property.h"
-
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -27,11 +25,8 @@ using namespace lldb_private;
// CommandObjectApropos
//-------------------------------------------------------------------------
-CommandObjectApropos::CommandObjectApropos (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "apropos",
- "Find a list of debugger commands related to a particular word/subject.",
- NULL)
+CommandObjectApropos::CommandObjectApropos(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "apropos", "List debugger commands related to a word or subject.", nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData search_word_arg;
@@ -47,10 +42,7 @@ CommandObjectApropos::CommandObjectApropos (CommandInterpreter &interpreter) :
m_arguments.push_back (arg);
}
-CommandObjectApropos::~CommandObjectApropos()
-{
-}
-
+CommandObjectApropos::~CommandObjectApropos() = default;
bool
CommandObjectApropos::DoExecute (Args& args, CommandReturnObject &result)
@@ -60,20 +52,17 @@ CommandObjectApropos::DoExecute (Args& args, CommandReturnObject &result)
if (argc == 1)
{
const char *search_word = args.GetArgumentAtIndex(0);
- if ((search_word != NULL)
+ if ((search_word != nullptr)
&& (strlen (search_word) > 0))
{
// The bulk of the work must be done inside the Command Interpreter, since the command dictionary
// is private.
StringList commands_found;
StringList commands_help;
- StringList user_commands_found;
- StringList user_commands_help;
- m_interpreter.FindCommandsForApropos (search_word, commands_found, commands_help, true, false);
- m_interpreter.FindCommandsForApropos (search_word, user_commands_found, user_commands_help, false, true);
+ m_interpreter.FindCommandsForApropos (search_word, commands_found, commands_help, true, true, true);
- if (commands_found.GetSize() == 0 && user_commands_found.GetSize() == 0)
+ if (commands_found.GetSize() == 0)
{
result.AppendMessageWithFormat ("No commands found pertaining to '%s'. Try 'help' to see a complete list of debugger commands.\n", search_word);
}
@@ -81,7 +70,7 @@ CommandObjectApropos::DoExecute (Args& args, CommandReturnObject &result)
{
if (commands_found.GetSize() > 0)
{
- result.AppendMessageWithFormat ("The following built-in commands may relate to '%s':\n", search_word);
+ result.AppendMessageWithFormat ("The following commands may relate to '%s':\n", search_word);
size_t max_len = 0;
for (size_t i = 0; i < commands_found.GetSize(); ++i)
@@ -97,33 +86,9 @@ CommandObjectApropos::DoExecute (Args& args, CommandReturnObject &result)
"--",
commands_help.GetStringAtIndex(i),
max_len);
- if (user_commands_found.GetSize() > 0)
- result.AppendMessage("");
- }
-
- if (user_commands_found.GetSize() > 0)
- {
- result.AppendMessageWithFormat ("The following user commands may relate to '%s':\n", search_word);
- size_t max_len = 0;
-
- for (size_t i = 0; i < user_commands_found.GetSize(); ++i)
- {
- size_t len = strlen (user_commands_found.GetStringAtIndex (i));
- if (len > max_len)
- max_len = len;
- }
-
- for (size_t i = 0; i < user_commands_found.GetSize(); ++i)
- m_interpreter.OutputFormattedHelpText (result.GetOutputStream(),
- user_commands_found.GetStringAtIndex(i),
- "--",
- user_commands_help.GetStringAtIndex(i),
- max_len);
}
-
}
-
std::vector<const Property *> properties;
const size_t num_properties = m_interpreter.GetDebugger().Apropos(search_word, properties);
if (num_properties)
diff --git a/source/Commands/CommandObjectArgs.cpp b/source/Commands/CommandObjectArgs.cpp
index 9f22bba78c551..206a26f45e4d1 100644
--- a/source/Commands/CommandObjectArgs.cpp
+++ b/source/Commands/CommandObjectArgs.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectArgs.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "CommandObjectArgs.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
@@ -44,10 +43,7 @@ CommandObjectArgs::CommandOptions::CommandOptions (CommandInterpreter &interpret
OptionParsingStarting();
}
-
-CommandObjectArgs::CommandOptions::~CommandOptions ()
-{
-}
+CommandObjectArgs::CommandOptions::~CommandOptions() = default;
Error
CommandObjectArgs::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
@@ -80,9 +76,7 @@ CommandObjectArgs::CommandObjectArgs (CommandInterpreter &interpreter) :
{
}
-CommandObjectArgs::~CommandObjectArgs ()
-{
-}
+CommandObjectArgs::~CommandObjectArgs() = default;
Options *
CommandObjectArgs::GetOptions ()
@@ -94,8 +88,7 @@ bool
CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result)
{
ConstString target_triple;
-
-
+
Process *process = m_exe_ctx.GetProcessPtr();
if (!process)
{
@@ -263,7 +256,6 @@ CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result)
OptionDefinition
CommandObjectArgs::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable verbose debug logging of the expression parsing and evaluation."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable verbose debug logging of the expression parsing and evaluation."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
diff --git a/source/Commands/CommandObjectBreakpoint.cpp b/source/Commands/CommandObjectBreakpoint.cpp
index bb59e1f82e8dc..6a71389a3f693 100644
--- a/source/Commands/CommandObjectBreakpoint.cpp
+++ b/source/Commands/CommandObjectBreakpoint.cpp
@@ -7,13 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectBreakpoint.h"
-#include "CommandObjectBreakpointCommand.h"
-
// C Includes
// C++ Includes
+#include <vector>
+
// Other libraries and framework includes
// Project includes
+#include "CommandObjectBreakpoint.h"
+#include "CommandObjectBreakpointCommand.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointIDList.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
@@ -33,8 +34,6 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
-#include <vector>
-
using namespace lldb;
using namespace lldb_private;
@@ -51,11 +50,9 @@ AddBreakpointDescription (Stream *s, Breakpoint *bp, lldb::DescriptionLevel leve
// CommandObjectBreakpointSet
//-------------------------------------------------------------------------
-
class CommandObjectBreakpointSet : public CommandObjectParsed
{
public:
-
typedef enum BreakpointSetType
{
eSetTypeInvalid,
@@ -76,8 +73,7 @@ public:
{
}
-
- ~CommandObjectBreakpointSet () override {}
+ ~CommandObjectBreakpointSet() override = default;
Options *
GetOptions () override
@@ -88,7 +84,6 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_condition (),
@@ -118,8 +113,7 @@ public:
{
}
-
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -153,6 +147,7 @@ public:
error.SetErrorStringWithFormat("invalid column number: %s", option_arg);
break;
}
+
case 'c':
m_condition.assign(option_arg);
break;
@@ -217,12 +212,10 @@ public:
break;
case 'i':
- {
m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_ignore_count == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
break;
- }
case 'K':
{
@@ -284,6 +277,16 @@ public:
m_breakpoint_names.push_back (option_arg);
break;
+ case 'R':
+ {
+ ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+ lldb::addr_t tmp_offset_addr;
+ tmp_offset_addr = Args::StringToAddress(&exe_ctx, option_arg, 0, &error);
+ if (error.Success())
+ m_offset_addr = tmp_offset_addr;
+ }
+ break;
+
case 'o':
m_one_shot = true;
break;
@@ -306,10 +309,8 @@ public:
break;
case 's':
- {
m_modules.AppendIfUnique (FileSpec (option_arg, false));
break;
- }
case 'S':
m_func_names.push_back (option_arg);
@@ -317,12 +318,10 @@ public:
break;
case 't' :
- {
m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
if (m_thread_id == LLDB_INVALID_THREAD_ID)
error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
- }
- break;
+ break;
case 'T':
m_thread_name.assign (option_arg);
@@ -338,14 +337,15 @@ public:
break;
case 'x':
- {
m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_thread_id == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
-
- }
- break;
+ break;
+ case 'X':
+ m_source_regex_func_names.insert(option_arg);
+ break;
+
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
break;
@@ -353,6 +353,7 @@ public:
return error;
}
+
void
OptionParsingStarting () override
{
@@ -366,6 +367,7 @@ public:
m_source_text_regexp.clear();
m_modules.Clear();
m_load_addr = LLDB_INVALID_ADDRESS;
+ m_offset_addr = 0;
m_ignore_count = 0;
m_thread_id = LLDB_INVALID_THREAD_ID;
m_thread_index = UINT32_MAX;
@@ -383,6 +385,7 @@ public:
m_all_files = false;
m_exception_extra_args.Clear();
m_move_to_nearest_code = eLazyBoolCalculate;
+ m_source_regex_func_names.clear();
}
const OptionDefinition*
@@ -408,6 +411,7 @@ public:
std::string m_source_text_regexp;
FileSpecList m_modules;
lldb::addr_t m_load_addr;
+ lldb::addr_t m_offset_addr;
uint32_t m_ignore_count;
lldb::tid_t m_thread_id;
uint32_t m_thread_index;
@@ -424,7 +428,7 @@ public:
bool m_all_files;
Args m_exception_extra_args;
LazyBool m_move_to_nearest_code;
-
+ std::unordered_set<std::string> m_source_regex_func_names;
};
protected:
@@ -464,9 +468,13 @@ protected:
else if (m_options.m_exception_language != eLanguageTypeUnknown)
break_type = eSetTypeException;
- Breakpoint *bp = NULL;
+ Breakpoint *bp = nullptr;
FileSpec module_spec;
const bool internal = false;
+
+ // If the user didn't specify skip-prologue, having an offset should turn that off.
+ if (m_options.m_offset_addr != 0 && m_options.m_skip_prologue == eLazyBoolCalculate)
+ m_options.m_skip_prologue = eLazyBoolNo;
switch (break_type)
{
@@ -498,6 +506,7 @@ protected:
bp = target->CreateBreakpoint (&(m_options.m_modules),
file,
m_options.m_line_num,
+ m_options.m_offset_addr,
check_inlines,
m_options.m_skip_prologue,
internal,
@@ -545,6 +554,7 @@ protected:
m_options.m_func_names,
name_type_mask,
m_options.m_language,
+ m_options.m_offset_addr,
m_options.m_skip_prologue,
internal,
m_options.m_hardware).get();
@@ -604,6 +614,7 @@ protected:
}
bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules),
&(m_options.m_filenames),
+ m_options.m_source_regex_func_names,
regexp,
internal,
m_options.m_hardware,
@@ -701,7 +712,7 @@ private:
if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line))
{
StackFrame *cur_frame = m_exe_ctx.GetFramePtr();
- if (cur_frame == NULL)
+ if (cur_frame == nullptr)
{
result.AppendError ("No selected frame to use to find the default file.");
result.SetStatus (eReturnStatusFailed);
@@ -733,60 +744,62 @@ private:
CommandOptions m_options;
};
+
// If an additional option set beyond LLDB_OPTION_SET_10 is added, make sure to
// update the numbers passed to LLDB_OPT_SET_FROM_TO(...) appropriately.
#define LLDB_OPT_FILE ( LLDB_OPT_SET_FROM_TO(1, 9) & ~LLDB_OPT_SET_2 )
#define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 )
#define LLDB_OPT_SKIP_PROLOGUE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3,8) )
+#define LLDB_OPT_OFFSET_APPLIES (LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3,8) )
#define LLDB_OPT_MOVE_TO_NEAREST_CODE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_9 )
#define LLDB_OPT_EXPR_LANGUAGE ( LLDB_OPT_SET_FROM_TO(3, 8) )
OptionDefinition
CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_NOT_10, false, "shlib", 's', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName,
+ { LLDB_OPT_NOT_10, false, "shlib", 's', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eModuleCompletion, eArgTypeShlibName,
"Set the breakpoint only in this shared library. "
"Can repeat this option multiple times to specify multiple shared libraries."},
- { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount,
+ { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount,
"Set the number of times this breakpoint is skipped before stopping." },
- { LLDB_OPT_SET_ALL, false, "one-shot", 'o', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_ALL, false, "one-shot", 'o', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"The breakpoint is deleted the first time it causes a stop." },
- { LLDB_OPT_SET_ALL, false, "condition", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeExpression,
+ { LLDB_OPT_SET_ALL, false, "condition", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeExpression,
"The breakpoint stops only if this condition expression evaluates to true."},
- { LLDB_OPT_SET_ALL, false, "thread-index", 'x', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadIndex,
+ { LLDB_OPT_SET_ALL, false, "thread-index", 'x', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadIndex,
"The breakpoint stops only for the thread whose indeX matches this argument."},
- { LLDB_OPT_SET_ALL, false, "thread-id", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadID,
+ { LLDB_OPT_SET_ALL, false, "thread-id", 't', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadID,
"The breakpoint stops only for the thread whose TID matches this argument."},
- { LLDB_OPT_SET_ALL, false, "thread-name", 'T', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadName,
+ { LLDB_OPT_SET_ALL, false, "thread-name", 'T', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadName,
"The breakpoint stops only for the thread whose thread name matches this argument."},
- { LLDB_OPT_SET_ALL, false, "hardware", 'H', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_ALL, false, "hardware", 'H', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Require the breakpoint to use hardware breakpoints."},
- { LLDB_OPT_SET_ALL, false, "queue-name", 'q', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeQueueName,
+ { LLDB_OPT_SET_ALL, false, "queue-name", 'q', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeQueueName,
"The breakpoint stops only for threads in the queue whose name is given by this argument."},
- { LLDB_OPT_FILE, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
+ { LLDB_OPT_FILE, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
"Specifies the source file in which to set this breakpoint. "
"Note, by default lldb only looks for files that are #included if they use the standard include file extensions. "
"To set breakpoints on .c/.cpp/.m/.mm files that are #included, set target.inline-breakpoint-strategy"
" to \"always\"."},
- { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum,
+ { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum,
"Specifies the line number on which to set this breakpoint."},
// Comment out this option for the moment, as we don't actually use it, but will in the future.
// This way users won't see it, but the infrastructure is left in place.
- // { 0, false, "column", 'C', OptionParser::eRequiredArgument, NULL, "<column>",
+ // { 0, false, "column", 'C', OptionParser::eRequiredArgument, nullptr, "<column>",
// "Set the breakpoint by source location at this particular column."},
- { LLDB_OPT_SET_2, true, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression,
+ { LLDB_OPT_SET_2, true, "address", 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddressOrExpression,
"Set the breakpoint at the specified address. "
"If the address maps uniquely to a particular "
"binary, then the address will be converted to a \"file\" address, so that the breakpoint will track that binary+offset no matter where "
@@ -796,64 +809,72 @@ CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
"subsequent reloads. The module need not have been loaded at the time you specify this breakpoint, and will "
"get resolved when the module is loaded."},
- { LLDB_OPT_SET_3, true, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
+ { LLDB_OPT_SET_3, true, "name", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
"Set the breakpoint by function name. Can be repeated multiple times to make one breakpoint for multiple names" },
- { LLDB_OPT_SET_4, true, "fullname", 'F', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName,
+ { LLDB_OPT_SET_9, false, "source-regexp-function", 'X', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
+ "When used with '-p' limits the source regex to source contained in the named functions. Can be repeated multiple times." },
+
+ { LLDB_OPT_SET_4, true, "fullname", 'F', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSymbolCompletion, eArgTypeFullName,
"Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguments, and "
"for Objective C this means a full function prototype with class and selector. "
"Can be repeated multiple times to make one breakpoint for multiple names." },
- { LLDB_OPT_SET_5, true, "selector", 'S', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeSelector,
+ { LLDB_OPT_SET_5, true, "selector", 'S', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeSelector,
"Set the breakpoint by ObjC selector name. Can be repeated multiple times to make one breakpoint for multiple Selectors." },
- { LLDB_OPT_SET_6, true, "method", 'M', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeMethod,
+ { LLDB_OPT_SET_6, true, "method", 'M', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeMethod,
"Set the breakpoint by C++ method names. Can be repeated multiple times to make one breakpoint for multiple methods." },
- { LLDB_OPT_SET_7, true, "func-regex", 'r', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeRegularExpression,
+ { LLDB_OPT_SET_7, true, "func-regex", 'r', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeRegularExpression,
"Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." },
- { LLDB_OPT_SET_8, true, "basename", 'b', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
+ { LLDB_OPT_SET_8, true, "basename", 'b', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
"Set the breakpoint by function basename (C++ namespaces and arguments will be ignored). "
"Can be repeated multiple times to make one breakpoint for multiple symbols." },
- { LLDB_OPT_SET_9, true, "source-pattern-regexp", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeRegularExpression,
+ { LLDB_OPT_SET_9, true, "source-pattern-regexp", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeRegularExpression,
"Set the breakpoint by specifying a regular expression which is matched against the source text in a source file or files "
"specified with the -f option. The -f option can be specified more than once. "
- "If no source files are specified, uses the current \"default source file\"" },
+ "If no source files are specified, uses the current \"default source file\". "
+ "If you want to match against all source files, pass the \"--all-files\" option." },
- { LLDB_OPT_SET_9, false, "all-files", 'A', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_9, false, "all-files", 'A', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"All files are searched for source pattern matches." },
- { LLDB_OPT_SET_10, true, "language-exception", 'E', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage,
+ { LLDB_OPT_SET_10, true, "language-exception", 'E', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage,
"Set the breakpoint on exceptions thrown by the specified language (without options, on throw but not catch.)" },
- { LLDB_OPT_SET_10, false, "on-throw", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean,
+ { LLDB_OPT_SET_10, false, "on-throw", 'w', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
"Set the breakpoint on exception throW." },
- { LLDB_OPT_SET_10, false, "on-catch", 'h', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean,
+ { LLDB_OPT_SET_10, false, "on-catch", 'h', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
"Set the breakpoint on exception catcH." },
// Don't add this option till it actually does something useful...
-// { LLDB_OPT_SET_10, false, "exception-typename", 'O', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeTypeName,
+// { LLDB_OPT_SET_10, false, "exception-typename", 'O', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeTypeName,
// "The breakpoint will only stop if an exception Object of this type is thrown. Can be repeated multiple times to stop for multiple object types" },
- { LLDB_OPT_EXPR_LANGUAGE, false, "language", 'L', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage,
+ { LLDB_OPT_EXPR_LANGUAGE, false, "language", 'L', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage,
"Specifies the Language to use when interpreting the breakpoint's expression (note: currently only implemented for setting breakpoints on identifiers). If not set the target.language setting is used." },
- { LLDB_OPT_SKIP_PROLOGUE, false, "skip-prologue", 'K', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean,
+ { LLDB_OPT_SKIP_PROLOGUE, false, "skip-prologue", 'K', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
"sKip the prologue if the breakpoint is at the beginning of a function. If not set the target.skip-prologue setting is used." },
- { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Sets Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."},
- { LLDB_OPT_SET_ALL, false, "breakpoint-name", 'N', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBreakpointName,
- "Adds this to the list of names for this breakopint."},
+ { LLDB_OPT_SET_ALL, false, "breakpoint-name", 'N', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBreakpointName,
+ "Adds this to the list of names for this breakpoint."},
+
+ { LLDB_OPT_OFFSET_APPLIES, false, "address-slide", 'R', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddress,
+ "Add the specified offset to whatever address(es) the breakpoint resolves to. "
+ "At present this applies the offset directly as given, and doesn't try to align it to instruction boundaries."},
- { LLDB_OPT_MOVE_TO_NEAREST_CODE, false, "move-to-nearest-code", 'm', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean,
+ { LLDB_OPT_MOVE_TO_NEAREST_CODE, false, "move-to-nearest-code", 'm', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
"Move breakpoints to nearest code. If not set the target.move-to-nearest-code setting is used." },
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -864,14 +885,13 @@ CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
class CommandObjectBreakpointModify : public CommandObjectParsed
{
public:
-
CommandObjectBreakpointModify (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "breakpoint modify",
- "Modify the options on a breakpoint or set of breakpoints in the executable. "
- "If no breakpoint is specified, acts on the last created breakpoint. "
- "With the exception of -e, -d and -i, passing an empty argument clears the modification.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "breakpoint modify",
+ "Modify the options on a breakpoint or set of breakpoints in the executable. "
+ "If no breakpoint is specified, acts on the last created breakpoint. "
+ "With the exception of -e, -d and -i, passing an empty argument clears the modification.",
+ nullptr),
m_options (interpreter)
{
CommandArgumentEntry arg;
@@ -880,8 +900,7 @@ public:
m_arguments.push_back (arg);
}
-
- ~CommandObjectBreakpointModify () override {}
+ ~CommandObjectBreakpointModify() override = default;
Options *
GetOptions () override
@@ -892,7 +911,6 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_ignore_count (0),
@@ -914,7 +932,7 @@ public:
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -925,7 +943,7 @@ public:
switch (short_option)
{
case 'c':
- if (option_arg != NULL)
+ if (option_arg != nullptr)
m_condition.assign (option_arg);
else
m_condition.clear();
@@ -943,12 +961,10 @@ public:
m_enable_value = true;
break;
case 'i':
- {
m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_ignore_count == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
- }
- break;
+ break;
case 'o':
{
bool value, success;
@@ -963,7 +979,6 @@ public:
}
break;
case 't' :
- {
if (option_arg[0] == '\0')
{
m_thread_id = LLDB_INVALID_THREAD_ID;
@@ -977,24 +992,22 @@ public:
else
m_thread_id_passed = true;
}
- }
- break;
+ break;
case 'T':
- if (option_arg != NULL)
+ if (option_arg != nullptr)
m_thread_name.assign (option_arg);
else
m_thread_name.clear();
m_name_passed = true;
break;
case 'q':
- if (option_arg != NULL)
+ if (option_arg != nullptr)
m_queue_name.assign (option_arg);
else
m_queue_name.clear();
m_queue_passed = true;
break;
case 'x':
- {
if (option_arg[0] == '\n')
{
m_thread_index = UINT32_MAX;
@@ -1008,8 +1021,7 @@ public:
else
m_thread_index_passed = true;
}
- }
- break;
+ break;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
break;
@@ -1017,6 +1029,7 @@ public:
return error;
}
+
void
OptionParsingStarting () override
{
@@ -1043,7 +1056,6 @@ public:
return g_option_table;
}
-
// Options table: Required for subclasses of Options.
static OptionDefinition g_option_table[];
@@ -1066,7 +1078,6 @@ public:
bool m_condition_passed;
bool m_one_shot_passed;
bool m_use_dummy;
-
};
protected:
@@ -1074,16 +1085,16 @@ protected:
DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("Invalid target. No existing target or breakpoints.");
result.SetStatus (eReturnStatusFailed);
return false;
}
- Mutex::Locker locker;
- target->GetBreakpointList().GetListMutex(locker);
-
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetBreakpointList().GetListMutex(lock);
+
BreakpointIDList valid_bp_ids;
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (command, target, result, &valid_bp_ids);
@@ -1163,18 +1174,18 @@ private:
OptionDefinition
CommandObjectBreakpointModify::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." },
-{ LLDB_OPT_SET_ALL, false, "one-shot", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "The breakpoint is deleted the first time it stop causes a stop." },
-{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose index matches this argument."},
-{ LLDB_OPT_SET_ALL, false, "thread-id", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument."},
-{ LLDB_OPT_SET_ALL, false, "thread-name", 'T', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument."},
-{ LLDB_OPT_SET_ALL, false, "queue-name", 'q', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."},
-{ LLDB_OPT_SET_ALL, false, "condition", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."},
-{ LLDB_OPT_SET_1, false, "enable", 'e', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable the breakpoint."},
-{ LLDB_OPT_SET_2, false, "disable", 'd', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Disable the breakpoint."},
-{ LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Sets Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."},
-
-{ 0, false, NULL, 0 , 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." },
+{ LLDB_OPT_SET_ALL, false, "one-shot", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "The breakpoint is deleted the first time it stop causes a stop." },
+{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose index matches this argument."},
+{ LLDB_OPT_SET_ALL, false, "thread-id", 't', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument."},
+{ LLDB_OPT_SET_ALL, false, "thread-name", 'T', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument."},
+{ LLDB_OPT_SET_ALL, false, "queue-name", 'q', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."},
+{ LLDB_OPT_SET_ALL, false, "condition", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."},
+{ LLDB_OPT_SET_1, false, "enable", 'e', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable the breakpoint."},
+{ LLDB_OPT_SET_2, false, "disable", 'd', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Disable the breakpoint."},
+{ LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Sets Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."},
+
+{ 0, false, nullptr, 0 , 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -1186,10 +1197,10 @@ class CommandObjectBreakpointEnable : public CommandObjectParsed
{
public:
CommandObjectBreakpointEnable (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "enable",
- "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "enable",
+ "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.",
+ nullptr)
{
CommandArgumentEntry arg;
CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
@@ -1197,23 +1208,22 @@ public:
m_arguments.push_back (arg);
}
-
- ~CommandObjectBreakpointEnable () override {}
+ ~CommandObjectBreakpointEnable() override = default;
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("Invalid target. No existing target or breakpoints.");
result.SetStatus (eReturnStatusFailed);
return false;
}
- Mutex::Locker locker;
- target->GetBreakpointList().GetListMutex(locker);
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetBreakpointList().GetListMutex(lock);
const BreakpointList &breakpoints = target->GetBreakpointList();
@@ -1284,18 +1294,20 @@ protected:
class CommandObjectBreakpointDisable : public CommandObjectParsed
{
public:
- CommandObjectBreakpointDisable (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "breakpoint disable",
- "Disable the specified breakpoint(s) without removing them. If none are specified, disable all breakpoints.",
- NULL)
+ CommandObjectBreakpointDisable(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "breakpoint disable", "Disable the specified breakpoint(s) without deleting "
+ "them. If none are specified, disable all "
+ "breakpoints.",
+ nullptr)
{
- SetHelpLong(
-"Disable the specified breakpoint(s) without removing them. \
-If none are specified, disable all breakpoints." R"(
+ SetHelpLong("Disable the specified breakpoint(s) without deleting them. \
+If none are specified, disable all breakpoints."
+ R"(
-)" "Note: disabling a breakpoint will cause none of its locations to be hit \
-regardless of whether they are enabled or disabled. After the sequence:" R"(
+)"
+ "Note: disabling a breakpoint will cause none of its locations to be hit \
+regardless of whether individual locations are enabled or disabled. After the sequence:"
+ R"(
(lldb) break disable 1
(lldb) break enable 1.1
@@ -1305,34 +1317,32 @@ execution will NOT stop at location 1.1. To achieve that, type:
(lldb) break disable 1.*
(lldb) break enable 1.1
-)" "The first command disables all the locations of breakpoint 1, \
-the second re-enables the first location."
- );
-
+)"
+ "The first command disables all locations for breakpoint 1, \
+the second re-enables the first location.");
+
CommandArgumentEntry arg;
CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
// Add the entry for the first argument for this command to the object's arguments vector.
m_arguments.push_back (arg);
-
}
-
- ~CommandObjectBreakpointDisable () override {}
+ ~CommandObjectBreakpointDisable() override = default;
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("Invalid target. No existing target or breakpoints.");
result.SetStatus (eReturnStatusFailed);
return false;
}
- Mutex::Locker locker;
- target->GetBreakpointList().GetListMutex(locker);
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetBreakpointList().GetListMutex(lock);
const BreakpointList &breakpoints = target->GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@@ -1393,7 +1403,6 @@ protected:
return result.Succeeded();
}
-
};
//-------------------------------------------------------------------------
@@ -1405,10 +1414,10 @@ class CommandObjectBreakpointList : public CommandObjectParsed
{
public:
CommandObjectBreakpointList (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "breakpoint list",
- "List some or all breakpoints at configurable levels of detail.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "breakpoint list",
+ "List some or all breakpoints at configurable levels of detail.",
+ nullptr),
m_options (interpreter)
{
CommandArgumentEntry arg;
@@ -1425,8 +1434,7 @@ public:
m_arguments.push_back (arg);
}
-
- ~CommandObjectBreakpointList () override {}
+ ~CommandObjectBreakpointList() override = default;
Options *
GetOptions () override
@@ -1437,7 +1445,6 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_level (lldb::eDescriptionLevelBrief),
@@ -1445,7 +1452,7 @@ public:
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -1510,7 +1517,7 @@ protected:
{
Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("Invalid target. No current target or breakpoints.");
result.SetStatus (eReturnStatusSuccessFinishNoResult);
@@ -1518,8 +1525,8 @@ protected:
}
const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal);
- Mutex::Locker locker;
- target->GetBreakpointList(m_options.m_internal).GetListMutex(locker);
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetBreakpointList(m_options.m_internal).GetListMutex(lock);
size_t num_breakpoints = breakpoints.GetSize();
@@ -1561,7 +1568,7 @@ protected:
}
else
{
- result.AppendError ("Invalid breakpoint id.");
+ result.AppendError("Invalid breakpoint ID.");
result.SetStatus (eReturnStatusFailed);
}
}
@@ -1577,24 +1584,24 @@ private:
OptionDefinition
CommandObjectBreakpointList::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "internal", 'i', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_ALL, false, "internal", 'i', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Show debugger internal breakpoints" },
- { LLDB_OPT_SET_1, false, "brief", 'b', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_1, false, "brief", 'b', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Give a brief description of the breakpoint (no location info)."},
// FIXME: We need to add an "internal" command, and then add this sort of thing to it.
// But I need to see it for now, and don't want to wait.
- { LLDB_OPT_SET_2, false, "full", 'f', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_2, false, "full", 'f', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Give a full description of the breakpoint and its locations."},
- { LLDB_OPT_SET_3, false, "verbose", 'v', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_3, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Explain everything we know about the breakpoint (for debugging debugger bugs)." },
- { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"List Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -1605,23 +1612,21 @@ CommandObjectBreakpointList::CommandOptions::g_option_table[] =
class CommandObjectBreakpointClear : public CommandObjectParsed
{
public:
-
typedef enum BreakpointClearType
{
eClearTypeInvalid,
eClearTypeFileAndLine
} BreakpointClearType;
- CommandObjectBreakpointClear (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "breakpoint clear",
- "Clears a breakpoint or set of breakpoints in the executable.",
- "breakpoint clear <cmd-options>"),
- m_options (interpreter)
+ CommandObjectBreakpointClear(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "breakpoint clear",
+ "Delete or disable breakpoints matching the specified source file and line.",
+ "breakpoint clear <cmd-options>"),
+ m_options(interpreter)
{
}
- ~CommandObjectBreakpointClear () override {}
+ ~CommandObjectBreakpointClear() override = default;
Options *
GetOptions () override
@@ -1632,7 +1637,6 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_filename (),
@@ -1640,7 +1644,7 @@ public:
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -1695,7 +1699,7 @@ protected:
DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("Invalid target. No existing target or breakpoints.");
result.SetStatus (eReturnStatusFailed);
@@ -1710,8 +1714,8 @@ protected:
if (m_options.m_line_num != 0)
break_type = eClearTypeFileAndLine;
- Mutex::Locker locker;
- target->GetBreakpointList().GetListMutex(locker);
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetBreakpointList().GetListMutex(lock);
BreakpointList &breakpoints = target->GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@@ -1729,7 +1733,7 @@ protected:
// First create a copy of all the IDs.
std::vector<break_id_t> BreakIDs;
for (size_t i = 0; i < num_breakpoints; ++i)
- BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i).get()->GetID());
+ BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i)->GetID());
int num_cleared = 0;
StreamString ss;
@@ -1789,13 +1793,13 @@ private:
OptionDefinition
CommandObjectBreakpointClear::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
+ { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
"Specify the breakpoint by source location in this particular file."},
- { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum,
+ { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum,
"Specify the breakpoint by source location at this particular line."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -1807,10 +1811,10 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed
{
public:
CommandObjectBreakpointDelete (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "breakpoint delete",
- "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "breakpoint delete",
+ "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.",
+ nullptr),
m_options (interpreter)
{
CommandArgumentEntry arg;
@@ -1819,7 +1823,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectBreakpointDelete () override {}
+ ~CommandObjectBreakpointDelete() override = default;
Options *
GetOptions () override
@@ -1830,7 +1834,6 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_use_dummy (false),
@@ -1838,7 +1841,7 @@ public:
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -1892,16 +1895,16 @@ protected:
{
Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("Invalid target. No existing target or breakpoints.");
result.SetStatus (eReturnStatusFailed);
return false;
}
- Mutex::Locker locker;
- target->GetBreakpointList().GetListMutex(locker);
-
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetBreakpointList().GetListMutex(lock);
+
const BreakpointList &breakpoints = target->GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@@ -1968,6 +1971,7 @@ protected:
}
return result.Succeeded();
}
+
private:
CommandOptions m_options;
};
@@ -1975,26 +1979,26 @@ private:
OptionDefinition
CommandObjectBreakpointDelete::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "force", 'f', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_1, false, "force", 'f', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Delete all breakpoints without querying for confirmation."},
- { LLDB_OPT_SET_1, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_1, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Delete Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
// CommandObjectBreakpointName
//-------------------------------------------------------------------------
-static OptionDefinition
-g_breakpoint_name_options[] =
-{
- { LLDB_OPT_SET_1, false, "name", 'N', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBreakpointName, "Specifies a breakpoint name to use."},
- { LLDB_OPT_SET_2, false, "breakpoint-id", 'B', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBreakpointID, "Specify a breakpoint id to use."},
- { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
- "Operate on Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."},
+static OptionDefinition g_breakpoint_name_options[] = {
+ {LLDB_OPT_SET_1, false, "name", 'N', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBreakpointName,
+ "Specifies a breakpoint name to use."},
+ {LLDB_OPT_SET_2, false, "breakpoint-id", 'B', OptionParser::eRequiredArgument, nullptr, nullptr, 0,
+ eArgTypeBreakpointID, "Specify a breakpoint ID to use."},
+ {LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
+ "Operate on Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."},
};
class BreakpointNameOptionGroup : public OptionGroup
{
@@ -2004,13 +2008,10 @@ public:
m_breakpoint(LLDB_INVALID_BREAK_ID),
m_use_dummy (false)
{
-
}
- ~BreakpointNameOptionGroup () override
- {
- }
-
+ ~BreakpointNameOptionGroup() override = default;
+
uint32_t
GetNumDefinitions () override
{
@@ -2068,7 +2069,6 @@ public:
OptionValueBoolean m_use_dummy;
};
-
class CommandObjectBreakpointNameAdd : public CommandObjectParsed
{
public:
@@ -2092,14 +2092,14 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectBreakpointNameAdd () override {}
+ ~CommandObjectBreakpointNameAdd() override = default;
+
+ Options *
+ GetOptions() override
+ {
+ return &m_option_group;
+ }
- Options *
- GetOptions () override
- {
- return &m_option_group;
- }
-
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -2112,16 +2112,16 @@ protected:
Target *target = GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue());
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("Invalid target. No existing target or breakpoints.");
result.SetStatus (eReturnStatusFailed);
return false;
}
- Mutex::Locker locker;
- target->GetBreakpointList().GetListMutex(locker);
-
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetBreakpointList().GetListMutex(lock);
+
const BreakpointList &breakpoints = target->GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@@ -2162,8 +2162,6 @@ private:
OptionGroupOptions m_option_group;
};
-
-
class CommandObjectBreakpointNameDelete : public CommandObjectParsed
{
public:
@@ -2187,14 +2185,14 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectBreakpointNameDelete () override {}
+ ~CommandObjectBreakpointNameDelete() override = default;
+
+ Options *
+ GetOptions() override
+ {
+ return &m_option_group;
+ }
- Options *
- GetOptions () override
- {
- return &m_option_group;
- }
-
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -2207,16 +2205,16 @@ protected:
Target *target = GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue());
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("Invalid target. No existing target or breakpoints.");
result.SetStatus (eReturnStatusFailed);
return false;
}
- Mutex::Locker locker;
- target->GetBreakpointList().GetListMutex(locker);
-
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetBreakpointList().GetListMutex(lock);
+
const BreakpointList &breakpoints = target->GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@@ -2271,21 +2269,21 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectBreakpointNameList () override {}
+ ~CommandObjectBreakpointNameList() override = default;
+
+ Options *
+ GetOptions() override
+ {
+ return &m_option_group;
+ }
- Options *
- GetOptions () override
- {
- return &m_option_group;
- }
-
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue());
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("Invalid target. No existing target or breakpoints.");
result.SetStatus (eReturnStatusFailed);
@@ -2295,9 +2293,9 @@ protected:
if (m_name_options.m_name.OptionWasSet())
{
const char *name = m_name_options.m_name.GetCurrentValue();
- Mutex::Locker locker;
- target->GetBreakpointList().GetListMutex(locker);
-
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetBreakpointList().GetListMutex(lock);
+
BreakpointList &breakpoints = target->GetBreakpointList();
for (BreakpointSP bp_sp : breakpoints.Breakpoints())
{
@@ -2350,11 +2348,9 @@ private:
class CommandObjectBreakpointName : public CommandObjectMultiword
{
public:
- CommandObjectBreakpointName (CommandInterpreter &interpreter) :
- CommandObjectMultiword(interpreter,
- "name",
- "A set of commands to manage name tags for breakpoints",
- "breakpoint name <command> [<command-options>]")
+ CommandObjectBreakpointName(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "name", "Commands to manage name tags for breakpoints",
+ "breakpoint name <subcommand> [<command-options>]")
{
CommandObjectSP add_command_object (new CommandObjectBreakpointNameAdd (interpreter));
CommandObjectSP delete_command_object (new CommandObjectBreakpointNameDelete (interpreter));
@@ -2363,26 +2359,20 @@ public:
LoadSubCommand ("add", add_command_object);
LoadSubCommand ("delete", delete_command_object);
LoadSubCommand ("list", list_command_object);
-
- }
-
- ~CommandObjectBreakpointName () override
- {
}
+ ~CommandObjectBreakpointName() override = default;
};
-
//-------------------------------------------------------------------------
// CommandObjectMultiwordBreakpoint
//-------------------------------------------------------------------------
#pragma mark MultiwordBreakpoint
-CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "breakpoint",
- "A set of commands for operating on breakpoints. Also see _regexp-break.",
- "breakpoint <command> [<command-options>]")
+CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "breakpoint",
+ "Commands for operating on breakpoints (see 'help b' for shorthand.)",
+ "breakpoint <subcommand> [<command-options>]")
{
CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter));
CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter));
@@ -2415,9 +2405,7 @@ CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInter
LoadSubCommand ("name", name_command_object);
}
-CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint ()
-{
-}
+CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint() = default;
void
CommandObjectMultiwordBreakpoint::VerifyIDs (Args &args,
@@ -2473,7 +2461,7 @@ CommandObjectMultiwordBreakpoint::VerifyIDs (Args &args,
{
BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i);
Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
- if (breakpoint != NULL)
+ if (breakpoint != nullptr)
{
const size_t num_locations = breakpoint->GetNumLocations();
if (static_cast<size_t>(cur_bp_id.GetLocationID()) > num_locations)
@@ -2491,7 +2479,8 @@ CommandObjectMultiwordBreakpoint::VerifyIDs (Args &args,
else
{
i = valid_ids->GetSize() + 1;
- result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID());
+ result.AppendErrorWithFormat("'%d' is not a currently valid breakpoint ID.\n",
+ cur_bp_id.GetBreakpointID());
result.SetStatus (eReturnStatusFailed);
}
}
diff --git a/source/Commands/CommandObjectBreakpointCommand.cpp b/source/Commands/CommandObjectBreakpointCommand.cpp
index 7b58bf9185bca..57572c8ef144c 100644
--- a/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -9,11 +9,10 @@
// C Includes
// C++ Includes
-
-
+// Other libraries and framework includes
+// Project includes
#include "CommandObjectBreakpointCommand.h"
#include "CommandObjectBreakpoint.h"
-
#include "lldb/Core/IOHandler.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -32,21 +31,18 @@ using namespace lldb_private;
// CommandObjectBreakpointCommandAdd
//-------------------------------------------------------------------------
-
class CommandObjectBreakpointCommandAdd :
public CommandObjectParsed,
public IOHandlerDelegateMultiline
{
public:
-
- CommandObjectBreakpointCommandAdd (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "add",
- "Add a set of commands to a breakpoint, to be executed whenever the breakpoint is hit."
- " If no breakpoint is specified, adds the commands to the last created breakpoint.",
- NULL),
- IOHandlerDelegateMultiline ("DONE", IOHandlerDelegate::Completion::LLDBCommand),
- m_options (interpreter)
+ CommandObjectBreakpointCommandAdd(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "add",
+ "Add LLDB commands to a breakpoint, to be executed whenever the breakpoint is hit."
+ " If no breakpoint is specified, adds the commands to the last created breakpoint.",
+ nullptr),
+ IOHandlerDelegateMultiline("DONE", IOHandlerDelegate::Completion::LLDBCommand),
+ m_options(interpreter)
{
SetHelpLong (
R"(
@@ -178,7 +174,7 @@ are no syntax errors may indicate that a function was declared but never called.
m_arguments.push_back (arg);
}
- ~CommandObjectBreakpointCommandAdd () override {}
+ ~CommandObjectBreakpointCommandAdd() override = default;
Options *
GetOptions () override
@@ -196,8 +192,7 @@ are no syntax errors may indicate that a function was declared but never called.
output_sp->Flush();
}
}
-
-
+
void
IOHandlerInputComplete (IOHandler &io_handler, std::string &line) override
{
@@ -210,7 +205,7 @@ are no syntax errors may indicate that a function was declared but never called.
continue;
std::unique_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData());
- if (data_ap.get())
+ if (data_ap)
{
data_ap->user_source.SplitIntoLines (line.c_str(), line.size());
BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release()));
@@ -248,7 +243,6 @@ are no syntax errors may indicate that a function was declared but never called.
BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release()));
bp_options->SetCallback (BreakpointOptionsCallbackFunction, baton_sp);
}
- return;
}
static bool
@@ -258,10 +252,9 @@ are no syntax errors may indicate that a function was declared but never called.
lldb::user_id_t break_loc_id)
{
bool ret_value = true;
- if (baton == NULL)
+ if (baton == nullptr)
return true;
-
-
+
BreakpointOptions::CommandData *data = (BreakpointOptions::CommandData *) baton;
StringList &commands = data->user_source;
@@ -302,7 +295,6 @@ are no syntax errors may indicate that a function was declared but never called.
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_use_commands (false),
@@ -314,7 +306,7 @@ are no syntax errors may indicate that a function was declared but never called.
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -355,11 +347,9 @@ are no syntax errors may indicate that a function was declared but never called.
break;
case 'F':
- {
- m_use_one_liner = false;
- m_use_script_language = true;
- m_function_name.assign(option_arg);
- }
+ m_use_one_liner = false;
+ m_use_script_language = true;
+ m_function_name.assign(option_arg);
break;
case 'D':
@@ -371,6 +361,7 @@ are no syntax errors may indicate that a function was declared but never called.
}
return error;
}
+
void
OptionParsingStarting () override
{
@@ -415,7 +406,7 @@ protected:
{
Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("There is not a current executable; there are no breakpoints to which to add commands");
result.SetStatus (eReturnStatusFailed);
@@ -432,7 +423,7 @@ protected:
return false;
}
- if (m_options.m_use_script_language == false && m_options.m_function_name.size())
+ if (!m_options.m_use_script_language && !m_options.m_function_name.empty())
{
result.AppendError ("need to enable scripting to have a function run as a breakpoint command");
result.SetStatus (eReturnStatusFailed);
@@ -454,7 +445,7 @@ protected:
if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
{
Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
- BreakpointOptions *bp_options = NULL;
+ BreakpointOptions *bp_options = nullptr;
if (cur_bp_id.GetLocationID() == LLDB_INVALID_BREAK_ID)
{
// This breakpoint does not have an associated location.
@@ -485,7 +476,7 @@ protected:
script_interp->SetBreakpointCommandCallback (m_bp_options_vec,
m_options.m_one_liner.c_str());
}
- else if (m_options.m_function_name.size())
+ else if (!m_options.m_function_name.empty())
{
script_interp->SetBreakpointCommandCallbackFunction (m_bp_options_vec,
m_options.m_function_name.c_str());
@@ -506,7 +497,6 @@ protected:
CollectDataForBreakpointCommandCallback (m_bp_options_vec,
result);
}
-
}
return result.Succeeded();
@@ -526,7 +516,6 @@ private:
// so it isn't worthwhile to come up with a more complex mechanism
// to address this particular weakness right now.
static const char *g_reader_instructions;
-
};
const char *
@@ -541,28 +530,28 @@ g_script_option_enumeration[4] =
{ eScriptLanguageNone, "command", "Commands are in the lldb command interpreter language"},
{ eScriptLanguagePython, "python", "Commands are in the Python language."},
{ eSortOrderByName, "default-script", "Commands are in the default scripting language."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
OptionDefinition
CommandObjectBreakpointCommandAdd::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOneLiner,
+ { LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOneLiner,
"Specify a one-line breakpoint command inline. Be sure to surround it with quotes." },
- { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean,
+ { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
"Specify whether breakpoint command execution should terminate on error." },
- { LLDB_OPT_SET_ALL, false, "script-type", 's', OptionParser::eRequiredArgument, NULL, g_script_option_enumeration, 0, eArgTypeNone,
+ { LLDB_OPT_SET_ALL, false, "script-type", 's', OptionParser::eRequiredArgument, nullptr, g_script_option_enumeration, 0, eArgTypeNone,
"Specify the language for the commands - if none is specified, the lldb command interpreter will be used."},
- { LLDB_OPT_SET_2, false, "python-function", 'F', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonFunction,
+ { LLDB_OPT_SET_2, false, "python-function", 'F', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePythonFunction,
"Give the name of a Python function to run as command for this breakpoint. Be sure to give a module name if appropriate."},
- { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Sets Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -573,10 +562,10 @@ class CommandObjectBreakpointCommandDelete : public CommandObjectParsed
{
public:
CommandObjectBreakpointCommandDelete (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "delete",
- "Delete the set of commands from a breakpoint.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "delete",
+ "Delete the set of commands from a breakpoint.",
+ nullptr),
m_options (interpreter)
{
CommandArgumentEntry arg;
@@ -593,8 +582,7 @@ public:
m_arguments.push_back (arg);
}
-
- ~CommandObjectBreakpointCommandDelete () override {}
+ ~CommandObjectBreakpointCommandDelete() override = default;
Options *
GetOptions () override
@@ -605,14 +593,13 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_use_dummy (false)
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -660,7 +647,7 @@ protected:
{
Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("There is not a current executable; there are no breakpoints from which to delete commands");
result.SetStatus (eReturnStatusFailed);
@@ -719,6 +706,7 @@ protected:
}
return result.Succeeded();
}
+
private:
CommandOptions m_options;
};
@@ -726,13 +714,12 @@ private:
OptionDefinition
CommandObjectBreakpointCommandDelete::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_1, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Delete commands from Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
//-------------------------------------------------------------------------
// CommandObjectBreakpointCommandList
//-------------------------------------------------------------------------
@@ -741,10 +728,10 @@ class CommandObjectBreakpointCommandList : public CommandObjectParsed
{
public:
CommandObjectBreakpointCommandList (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "list",
- "List the script or set of commands to be executed when the breakpoint is hit.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "list",
+ "List the script or set of commands to be executed when the breakpoint is hit.",
+ nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData bp_id_arg;
@@ -760,7 +747,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectBreakpointCommandList () override {}
+ ~CommandObjectBreakpointCommandList() override = default;
protected:
bool
@@ -769,7 +756,7 @@ protected:
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("There is not a current executable; there are no breakpoints for which to list commands");
result.SetStatus (eReturnStatusFailed);
@@ -808,7 +795,7 @@ protected:
if (bp)
{
- const BreakpointOptions *bp_options = NULL;
+ const BreakpointOptions *bp_options = nullptr;
if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
{
BreakpointLocationSP bp_loc_sp(bp->FindLocationByID (cur_bp_id.GetLocationID()));
@@ -855,7 +842,6 @@ protected:
result.AppendErrorWithFormat("Invalid breakpoint ID: %u.\n", cur_bp_id.GetBreakpointID());
result.SetStatus (eReturnStatusFailed);
}
-
}
}
}
@@ -868,11 +854,11 @@ protected:
// CommandObjectBreakpointCommand
//-------------------------------------------------------------------------
-CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "command",
- "A set of commands for adding, removing and examining bits of code to be executed when the breakpoint is hit (breakpoint 'commands').",
- "command <sub-command> [<sub-command-options>] <breakpoint-id>")
+CommandObjectBreakpointCommand::CommandObjectBreakpointCommand(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(
+ interpreter, "command",
+ "Commands for adding, removing and listing LLDB commands executed when a breakpoint is hit.",
+ "command <sub-command> [<sub-command-options>] <breakpoint-id>")
{
CommandObjectSP add_command_object (new CommandObjectBreakpointCommandAdd (interpreter));
CommandObjectSP delete_command_object (new CommandObjectBreakpointCommandDelete (interpreter));
@@ -887,8 +873,4 @@ CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpret
LoadSubCommand ("list", list_command_object);
}
-CommandObjectBreakpointCommand::~CommandObjectBreakpointCommand ()
-{
-}
-
-
+CommandObjectBreakpointCommand::~CommandObjectBreakpointCommand() = default;
diff --git a/source/Commands/CommandObjectBugreport.cpp b/source/Commands/CommandObjectBugreport.cpp
index 3d00cb817e3d8..db8c06c0e9e36 100644
--- a/source/Commands/CommandObjectBugreport.cpp
+++ b/source/Commands/CommandObjectBugreport.cpp
@@ -130,11 +130,9 @@ private:
// CommandObjectMultiwordBugreport
//-------------------------------------------------------------------------
-CommandObjectMultiwordBugreport::CommandObjectMultiwordBugreport(CommandInterpreter &interpreter) :
- CommandObjectMultiword(interpreter,
- "bugreport",
- "Set of commands for creating domain specific bugreports.",
- "bugreport <subcommand> [<subcommand-options>]")
+CommandObjectMultiwordBugreport::CommandObjectMultiwordBugreport(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "bugreport", "Commands for creating domain-specific bug reports.",
+ "bugreport <subcommand> [<subcommand-options>]")
{
LoadSubCommand("unwind", CommandObjectSP(new CommandObjectBugreportUnwind(interpreter)));
diff --git a/source/Commands/CommandObjectCommands.cpp b/source/Commands/CommandObjectCommands.cpp
index e859b5d64b11c..dd2fd9a0efc89 100644
--- a/source/Commands/CommandObjectCommands.cpp
+++ b/source/Commands/CommandObjectCommands.cpp
@@ -7,14 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectCommands.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
// Project includes
+#include "CommandObjectCommands.h"
+#include "CommandObjectHelp.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/IOHandler.h"
#include "lldb/Core/StringList.h"
@@ -24,6 +24,7 @@
#include "lldb/Interpreter/CommandObjectRegexCommand.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionValueBoolean.h"
+#include "lldb/Interpreter/OptionValueString.h"
#include "lldb/Interpreter/OptionValueUInt64.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
@@ -39,15 +40,15 @@ class CommandObjectCommandsHistory : public CommandObjectParsed
{
public:
CommandObjectCommandsHistory(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "command history",
- "Dump the history of commands in this session.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "command history",
+ "Dump the history of commands in this session.",
+ nullptr),
m_options (interpreter)
{
}
- ~CommandObjectCommandsHistory () override {}
+ ~CommandObjectCommandsHistory() override = default;
Options *
GetOptions () override
@@ -56,11 +57,9 @@ public:
}
protected:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_start_idx(0),
@@ -70,7 +69,7 @@ protected:
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -222,14 +221,13 @@ protected:
OptionDefinition
CommandObjectCommandsHistory::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeUnsignedInteger, "How many history commands to print."},
-{ LLDB_OPT_SET_1, false, "start-index", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeUnsignedInteger, "Index at which to start printing history commands (or end to mean tail mode)."},
-{ LLDB_OPT_SET_1, false, "end-index", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeUnsignedInteger, "Index at which to stop printing history commands."},
-{ LLDB_OPT_SET_2, false, "clear", 'C', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeBoolean, "Clears the current command history."},
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeUnsignedInteger, "How many history commands to print."},
+{ LLDB_OPT_SET_1, false, "start-index", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeUnsignedInteger, "Index at which to start printing history commands (or end to mean tail mode)."},
+{ LLDB_OPT_SET_1, false, "end-index", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeUnsignedInteger, "Index at which to stop printing history commands."},
+{ LLDB_OPT_SET_2, false, "clear", 'C', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Clears the current command history."},
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
//-------------------------------------------------------------------------
// CommandObjectCommandsSource
//-------------------------------------------------------------------------
@@ -237,12 +235,10 @@ CommandObjectCommandsHistory::CommandOptions::g_option_table[] =
class CommandObjectCommandsSource : public CommandObjectParsed
{
public:
- CommandObjectCommandsSource(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "command source",
- "Read in debugger commands from the file <filename> and execute them.",
- NULL),
- m_options (interpreter)
+ CommandObjectCommandsSource(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "command source", "Read and execute LLDB commands from the file <filename>.",
+ nullptr),
+ m_options(interpreter)
{
CommandArgumentEntry arg;
CommandArgumentData file_arg;
@@ -258,7 +254,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectCommandsSource () override {}
+ ~CommandObjectCommandsSource() override = default;
const char*
GetRepeatCommand (Args &current_command_args, uint32_t index) override
@@ -279,14 +275,14 @@ public:
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eDiskFileCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eDiskFileCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -297,11 +293,9 @@ public:
}
protected:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_stop_on_error (true),
@@ -310,7 +304,7 @@ protected:
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -374,7 +368,7 @@ protected:
const char *filename = command.GetArgumentAtIndex(0);
FileSpec cmd_file (filename, true);
- ExecutionContext *exe_ctx = NULL; // Just use the default context.
+ ExecutionContext *exe_ctx = nullptr; // Just use the default context.
// If any options were set, then use them
if (m_options.m_stop_on_error.OptionWasSet() ||
@@ -392,7 +386,6 @@ protected:
exe_ctx,
options,
result);
-
}
else
{
@@ -403,7 +396,6 @@ protected:
exe_ctx,
options,
result);
-
}
}
else
@@ -412,18 +404,18 @@ protected:
result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
-
}
+
CommandOptions m_options;
};
OptionDefinition
CommandObjectCommandsSource::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "If true, stop executing commands on error."},
-{ LLDB_OPT_SET_ALL, false, "stop-on-continue", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "If true, stop executing commands on continue."},
-{ LLDB_OPT_SET_ALL, false, "silent-run", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "If true don't echo commands while executing."},
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "If true, stop executing commands on error."},
+{ LLDB_OPT_SET_ALL, false, "stop-on-continue", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "If true, stop executing commands on continue."},
+{ LLDB_OPT_SET_ALL, false, "silent-run", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "If true don't echo commands while executing."},
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
#pragma mark CommandObjectCommandsAlias
@@ -435,18 +427,94 @@ static const char *g_python_command_instructions = "Enter your Python command(
"You must define a Python function with this signature:\n"
"def my_command_impl(debugger, args, result, internal_dict):\n";
-
class CommandObjectCommandsAlias : public CommandObjectRaw
{
-
+protected:
+ class CommandOptions : public OptionGroup
+ {
+ public:
+ CommandOptions () :
+ OptionGroup(),
+ m_help(),
+ m_long_help()
+ {}
+
+ ~CommandOptions() override = default;
+
+ uint32_t
+ GetNumDefinitions () override
+ {
+ return 3;
+ }
+
+ const OptionDefinition*
+ GetDefinitions () override
+ {
+ return g_option_table;
+ }
+
+ Error
+ SetOptionValue (CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value) override
+ {
+ Error error;
+
+ const int short_option = g_option_table[option_idx].short_option;
+
+ switch (short_option)
+ {
+ case 'h':
+ m_help.SetCurrentValue(option_value);
+ m_help.SetOptionWasSet();
+ break;
+
+ case 'H':
+ m_long_help.SetCurrentValue(option_value);
+ m_long_help.SetOptionWasSet();
+ break;
+
+ default:
+ error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
+ break;
+ }
+
+ return error;
+ }
+
+ void
+ OptionParsingStarting (CommandInterpreter &interpreter) override
+ {
+ m_help.Clear();
+ m_long_help.Clear();
+ }
+
+ // Options table: Required for subclasses of Options.
+
+ static OptionDefinition g_option_table[];
+ OptionValueString m_help;
+ OptionValueString m_long_help;
+ };
+
+ OptionGroupOptions m_option_group;
+ CommandOptions m_command_options;
public:
- CommandObjectCommandsAlias (CommandInterpreter &interpreter) :
- CommandObjectRaw (interpreter,
- "command alias",
- "Allow users to define their own debugger command abbreviations.",
- NULL)
+ Options *
+ GetOptions () override
+ {
+ return &m_option_group;
+ }
+
+ CommandObjectCommandsAlias(CommandInterpreter &interpreter)
+ : CommandObjectRaw(interpreter, "command alias", "Define a custom command in terms of an existing command.",
+ nullptr),
+ m_option_group(interpreter),
+ m_command_options()
{
+ m_option_group.Append(&m_command_options);
+ m_option_group.Finalize();
+
SetHelpLong(
"'alias' allows the user to create a short-cut or abbreviation for long \
commands, multi-word commands, and commands that take particular options. \
@@ -551,22 +619,70 @@ rather than using a positional placeholder:" R"(
m_arguments.push_back (arg3);
}
- ~CommandObjectCommandsAlias () override
- {
- }
+ ~CommandObjectCommandsAlias() override = default;
protected:
bool
DoExecute (const char *raw_command_line, CommandReturnObject &result) override
{
- Args args (raw_command_line);
- std::string raw_command_string (raw_command_line);
+ if (!raw_command_line || !raw_command_line[0])
+ {
+ result.AppendError ("'command alias' requires at least two arguments");
+ return false;
+ }
+
+ m_option_group.NotifyOptionParsingStarting();
+
+ const char * remainder = nullptr;
+
+ if (raw_command_line[0] == '-')
+ {
+ // We have some options and these options MUST end with --.
+ const char *end_options = nullptr;
+ const char *s = raw_command_line;
+ while (s && s[0])
+ {
+ end_options = ::strstr (s, "--");
+ if (end_options)
+ {
+ end_options += 2; // Get past the "--"
+ if (::isspace (end_options[0]))
+ {
+ remainder = end_options;
+ while (::isspace (*remainder))
+ ++remainder;
+ break;
+ }
+ }
+ s = end_options;
+ }
+
+ if (end_options)
+ {
+ Args args (llvm::StringRef(raw_command_line, end_options - raw_command_line));
+ if (!ParseOptions (args, result))
+ return false;
+
+ Error error (m_option_group.NotifyOptionParsingFinished());
+ if (error.Fail())
+ {
+ result.AppendError (error.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
+ }
+ if (nullptr == remainder)
+ remainder = raw_command_line;
+
+ std::string raw_command_string (remainder);
+ Args args (raw_command_string.c_str());
size_t argc = args.GetArgumentCount();
if (argc < 2)
{
- result.AppendError ("'alias' requires at least two arguments");
+ result.AppendError ("'command alias' requires at least two arguments");
result.SetStatus (eReturnStatusFailed);
return false;
}
@@ -574,6 +690,17 @@ protected:
// Get the alias command.
const std::string alias_command = args.GetArgumentAtIndex (0);
+ if (alias_command.size() > 1 &&
+ alias_command[0] == '-')
+ {
+ result.AppendError("aliases starting with a dash are not supported");
+ if (alias_command == "--help" || alias_command == "--long-help")
+ {
+ result.AppendWarning("if trying to pass options to 'command alias' add a -- at the end of the options");
+ }
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
// Strip the new alias name off 'raw_command_string' (leave it on args, which gets passed to 'Execute', which
// does the stripping itself.
@@ -604,12 +731,13 @@ protected:
// Get CommandObject that is being aliased. The command name is read from the front of raw_command_string.
// raw_command_string is returned with the name of the command object stripped off the front.
+ std::string original_raw_command_string(raw_command_string);
CommandObject *cmd_obj = m_interpreter.GetCommandObjectForCommand (raw_command_string);
if (!cmd_obj)
{
- result.AppendErrorWithFormat ("invalid command given to 'alias'. '%s' does not begin with a valid command."
- " No alias created.", raw_command_string.c_str());
+ result.AppendErrorWithFormat ("invalid command given to 'command alias'. '%s' does not begin with a valid command."
+ " No alias created.", original_raw_command_string.c_str());
result.SetStatus (eReturnStatusFailed);
return false;
}
@@ -632,43 +760,36 @@ protected:
// Verify & handle any options/arguments passed to the alias command
OptionArgVectorSP option_arg_vector_sp = OptionArgVectorSP (new OptionArgVector);
- OptionArgVector *option_arg_vector = option_arg_vector_sp.get();
-
- CommandObjectSP cmd_obj_sp = m_interpreter.GetCommandSPExact (cmd_obj.GetCommandName(), false);
-
- if (!m_interpreter.ProcessAliasOptionsArgs (cmd_obj_sp, raw_command_string.c_str(), option_arg_vector_sp))
- {
- result.AppendError ("Unable to create requested alias.\n");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
-
- // Create the alias
- if (m_interpreter.AliasExists (alias_command.c_str())
- || m_interpreter.UserCommandExists (alias_command.c_str()))
+
+ if (CommandObjectSP cmd_obj_sp = m_interpreter.GetCommandSPExact (cmd_obj.GetCommandName(), false))
{
- OptionArgVectorSP temp_option_arg_sp (m_interpreter.GetAliasOptions (alias_command.c_str()));
- if (temp_option_arg_sp.get())
+ if (m_interpreter.AliasExists (alias_command.c_str())
+ || m_interpreter.UserCommandExists (alias_command.c_str()))
{
- if (option_arg_vector->size() == 0)
- m_interpreter.RemoveAliasOptions (alias_command.c_str());
+ result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n",
+ alias_command.c_str());
}
- result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n",
- alias_command.c_str());
- }
-
- if (cmd_obj_sp)
- {
- m_interpreter.AddAlias (alias_command.c_str(), cmd_obj_sp);
- if (option_arg_vector->size() > 0)
- m_interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp);
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ if (CommandAlias *alias = m_interpreter.AddAlias (alias_command.c_str(), cmd_obj_sp, raw_command_string.c_str()))
+ {
+ if (m_command_options.m_help.OptionWasSet())
+ alias->SetHelp(m_command_options.m_help.GetCurrentValue());
+ if (m_command_options.m_long_help.OptionWasSet())
+ alias->SetHelpLong(m_command_options.m_long_help.GetCurrentValue());
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ }
+ else
+ {
+ result.AppendError ("Unable to create requested alias.\n");
+ result.SetStatus (eReturnStatusFailed);
+ }
+
}
else
{
result.AppendError ("Unable to create requested alias.\n");
result.SetStatus (eReturnStatusFailed);
}
+
return result.Succeeded ();
}
@@ -679,7 +800,7 @@ protected:
if (argc < 2)
{
- result.AppendError ("'alias' requires at least two arguments");
+ result.AppendError ("'command alias' requires at least two arguments");
result.SetStatus (eReturnStatusFailed);
return false;
}
@@ -703,12 +824,11 @@ protected:
CommandObjectSP command_obj_sp(m_interpreter.GetCommandSPExact (actual_command.c_str(), true));
CommandObjectSP subcommand_obj_sp;
bool use_subcommand = false;
- if (command_obj_sp.get())
+ if (command_obj_sp)
{
CommandObject *cmd_obj = command_obj_sp.get();
- CommandObject *sub_cmd_obj = NULL;
+ CommandObject *sub_cmd_obj = nullptr;
OptionArgVectorSP option_arg_vector_sp = OptionArgVectorSP (new OptionArgVector);
- OptionArgVector *option_arg_vector = option_arg_vector_sp.get();
while (cmd_obj->IsMultiwordObject() && args.GetArgumentCount() > 0)
{
@@ -717,7 +837,7 @@ protected:
const std::string sub_command = args.GetArgumentAtIndex(0);
assert (sub_command.length() != 0);
subcommand_obj_sp = cmd_obj->GetSubcommandSP (sub_command.c_str());
- if (subcommand_obj_sp.get())
+ if (subcommand_obj_sp)
{
sub_cmd_obj = subcommand_obj_sp.get();
use_subcommand = true;
@@ -737,45 +857,40 @@ protected:
// Verify & handle any options/arguments passed to the alias command
+ std::string args_string;
+
if (args.GetArgumentCount () > 0)
{
CommandObjectSP tmp_sp = m_interpreter.GetCommandSPExact (cmd_obj->GetCommandName(), false);
if (use_subcommand)
tmp_sp = m_interpreter.GetCommandSPExact (sub_cmd_obj->GetCommandName(), false);
- std::string args_string;
args.GetCommandString (args_string);
-
- if (!m_interpreter.ProcessAliasOptionsArgs (tmp_sp, args_string.c_str(), option_arg_vector_sp))
- {
- result.AppendError ("Unable to create requested alias.\n");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
}
-
- // Create the alias.
-
+
if (m_interpreter.AliasExists (alias_command.c_str())
|| m_interpreter.UserCommandExists (alias_command.c_str()))
{
- OptionArgVectorSP tmp_option_arg_sp (m_interpreter.GetAliasOptions (alias_command.c_str()));
- if (tmp_option_arg_sp.get())
- {
- if (option_arg_vector->size() == 0)
- m_interpreter.RemoveAliasOptions (alias_command.c_str());
- }
- result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n",
+ result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n",
alias_command.c_str());
}
-
- if (use_subcommand)
- m_interpreter.AddAlias (alias_command.c_str(), subcommand_obj_sp);
+
+ if (CommandAlias *alias = m_interpreter.AddAlias(alias_command.c_str(),
+ use_subcommand ? subcommand_obj_sp : command_obj_sp,
+ args_string.c_str()))
+ {
+ if (m_command_options.m_help.OptionWasSet())
+ alias->SetHelp(m_command_options.m_help.GetCurrentValue());
+ if (m_command_options.m_long_help.OptionWasSet())
+ alias->SetHelpLong(m_command_options.m_long_help.GetCurrentValue());
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ }
else
- m_interpreter.AddAlias (alias_command.c_str(), command_obj_sp);
- if (option_arg_vector->size() > 0)
- m_interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp);
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ {
+ result.AppendError ("Unable to create requested alias.\n");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
}
else
{
@@ -787,7 +902,14 @@ protected:
return result.Succeeded();
}
-
+};
+
+OptionDefinition
+CommandObjectCommandsAlias::CommandOptions::g_option_table[] =
+{
+ { LLDB_OPT_SET_ALL, false, "help", 'h', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeHelpText, "Help text for this command"},
+ { LLDB_OPT_SET_ALL, false, "long-help", 'H', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeHelpText, "Long help text for this command"},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
#pragma mark CommandObjectCommandsUnalias
@@ -798,11 +920,9 @@ protected:
class CommandObjectCommandsUnalias : public CommandObjectParsed
{
public:
- CommandObjectCommandsUnalias (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "command unalias",
- "Allow the user to remove/delete a user-defined command abbreviation.",
- NULL)
+ CommandObjectCommandsUnalias(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "command unalias",
+ "Delete one or more custom commands defined by 'command alias'.", nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData alias_arg;
@@ -818,9 +938,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectCommandsUnalias() override
- {
- }
+ ~CommandObjectCommandsUnalias() override = default;
protected:
bool
@@ -851,8 +969,7 @@ protected:
}
else
{
-
- if (m_interpreter.RemoveAlias (command_name) == false)
+ if (!m_interpreter.RemoveAlias(command_name))
{
if (m_interpreter.AliasExists (command_name))
result.AppendErrorWithFormat ("Error occurred while attempting to unalias '%s'.\n",
@@ -891,11 +1008,9 @@ protected:
class CommandObjectCommandsDelete : public CommandObjectParsed
{
public:
- CommandObjectCommandsDelete (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "command delete",
- "Allow the user to delete user-defined regular expression, python or multi-word commands.",
- NULL)
+ CommandObjectCommandsDelete(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "command delete",
+ "Delete one or more custom commands defined by 'command regex'.", nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData alias_arg;
@@ -911,9 +1026,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectCommandsDelete() override
- {
- }
+ ~CommandObjectCommandsDelete() override = default;
protected:
bool
@@ -939,14 +1052,24 @@ protected:
}
else
{
- result.AppendErrorWithFormat ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n",
- command_name);
+ StreamString error_msg_stream;
+ const bool generate_apropos = true;
+ const bool generate_type_lookup = false;
+ CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage(&error_msg_stream,
+ command_name,
+ nullptr,
+ nullptr,
+ generate_apropos,
+ generate_type_lookup);
+ result.AppendErrorWithFormat ("%s", error_msg_stream.GetData());
result.SetStatus (eReturnStatusFailed);
}
}
else
{
- result.AppendErrorWithFormat ("must call '%s' with one or more valid user defined regular expression, python or multi-word command names", GetCommandName ());
+ result.AppendErrorWithFormat(
+ "must call '%s' with one or more valid user defined regular expression command names",
+ GetCommandName());
result.SetStatus (eReturnStatusFailed);
}
@@ -964,13 +1087,12 @@ class CommandObjectCommandsAddRegex :
public IOHandlerDelegateMultiline
{
public:
- CommandObjectCommandsAddRegex (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "command regex",
- "Allow the user to create a regular expression command.",
- "command regex <cmd-name> [s/<regex>/<subst>/ ...]"),
- IOHandlerDelegateMultiline ("", IOHandlerDelegate::Completion::LLDBCommand),
- m_options (interpreter)
+ CommandObjectCommandsAddRegex(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "command regex",
+ "Define a custom command in terms of existing commands by matching regular expressions.",
+ "command regex <cmd-name> [s/<regex>/<subst>/ ...]"),
+ IOHandlerDelegateMultiline("", IOHandlerDelegate::Completion::LLDBCommand),
+ m_options(interpreter)
{
SetHelpLong(R"(
)" "This command allows the user to create powerful regular expression commands \
@@ -997,14 +1119,10 @@ a number follows 'f':" R"(
(lldb) command regex f s/^$/finish/ 's/([0-9]+)/frame select %1/')"
);
}
-
- ~CommandObjectCommandsAddRegex() override
- {
- }
-
-
+
+ ~CommandObjectCommandsAddRegex() override = default;
+
protected:
-
void
IOHandlerActivated (IOHandler &io_handler) override
{
@@ -1020,7 +1138,7 @@ protected:
IOHandlerInputComplete (IOHandler &io_handler, std::string &data) override
{
io_handler.SetIsDone(true);
- if (m_regex_cmd_ap.get())
+ if (m_regex_cmd_ap)
{
StringList lines;
if (lines.SplitIntoLines (data))
@@ -1075,15 +1193,15 @@ protected:
Debugger &debugger = m_interpreter.GetDebugger();
bool color_prompt = debugger.GetUseColor();
const bool multiple_lines = true; // Get multiple lines
- IOHandlerSP io_handler_sp (new IOHandlerEditline (debugger,
- IOHandler::Type::Other,
- "lldb-regex", // Name of input reader for history
- "> ", // Prompt
- NULL, // Continuation prompt
- multiple_lines,
- color_prompt,
- 0, // Don't show line numbers
- *this));
+ IOHandlerSP io_handler_sp(new IOHandlerEditline(debugger,
+ IOHandler::Type::Other,
+ "lldb-regex", // Name of input reader for history
+ "> ", // Prompt
+ nullptr, // Continuation prompt
+ multiple_lines,
+ color_prompt,
+ 0, // Don't show line numbers
+ *this));
if (io_handler_sp)
{
@@ -1122,7 +1240,7 @@ protected:
{
Error error;
- if (m_regex_cmd_ap.get() == NULL)
+ if (!m_regex_cmd_ap)
{
error.SetErrorStringWithFormat("invalid regular expression command object for: '%.*s'",
(int)regex_sed.size(),
@@ -1190,7 +1308,6 @@ protected:
regex_sed.data() + (third_separator_char_pos + 1));
return error;
}
-
}
else if (first_separator_char_pos + 1 == second_separator_char_pos)
{
@@ -1213,7 +1330,7 @@ protected:
return error;
}
- if (check_only == false)
+ if (!check_only)
{
std::string regex(regex_sed.substr(first_separator_char_pos + 1, second_separator_char_pos - first_separator_char_pos - 1));
std::string subst(regex_sed.substr(second_separator_char_pos + 1, third_separator_char_pos - second_separator_char_pos - 1));
@@ -1226,7 +1343,7 @@ protected:
void
AddRegexCommandToInterpreter()
{
- if (m_regex_cmd_ap.get())
+ if (m_regex_cmd_ap)
{
if (m_regex_cmd_ap->HasRegexEntries())
{
@@ -1242,14 +1359,13 @@ 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
{
@@ -1264,7 +1380,6 @@ private:
case 's':
m_syntax.assign (option_arg);
break;
-
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
break;
@@ -1291,21 +1406,20 @@ private:
static OptionDefinition g_option_table[];
const char *
- GetHelp ()
+ GetHelp()
{
- if (m_help.empty())
- return NULL;
- return m_help.c_str();
+ return (m_help.empty() ? nullptr : m_help.c_str());
}
+
const char *
GetSyntax ()
{
- if (m_syntax.empty())
- return NULL;
- return m_syntax.c_str();
+ return (m_syntax.empty() ? nullptr : m_syntax.c_str());
}
- // Instance variables to hold the values for command options.
+
protected:
+ // Instance variables to hold the values for command options.
+
std::string m_help;
std::string m_syntax;
};
@@ -1322,30 +1436,23 @@ private:
OptionDefinition
CommandObjectCommandsAddRegex::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, false, "help" , 'h', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeNone, "The help text to display for this command."},
-{ LLDB_OPT_SET_1, false, "syntax", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeNone, "A syntax string showing the typical usage syntax."},
-{ 0 , false, NULL , 0 , 0 , NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_1, false, "help" , 'h', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeNone, "The help text to display for this command."},
+{ LLDB_OPT_SET_1, false, "syntax", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeNone, "A syntax string showing the typical usage syntax."},
+{ 0 , false, nullptr , 0 , 0 , nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
class CommandObjectPythonFunction : public CommandObjectRaw
{
-private:
- std::string m_function_name;
- ScriptedCommandSynchronicity m_synchro;
- bool m_fetched_help_long;
-
public:
-
CommandObjectPythonFunction (CommandInterpreter &interpreter,
std::string name,
std::string funct,
std::string help,
ScriptedCommandSynchronicity synch) :
- CommandObjectRaw (interpreter,
- name.c_str(),
- NULL,
- NULL),
+ CommandObjectRaw(interpreter,
+ name.c_str(),
+ nullptr,
+ nullptr),
m_function_name(funct),
m_synchro(synch),
m_fetched_help_long(false)
@@ -1359,11 +1466,9 @@ public:
SetHelp(stream.GetData());
}
}
-
- ~CommandObjectPythonFunction () override
- {
- }
-
+
+ ~CommandObjectPythonFunction() override = default;
+
bool
IsRemovable () const override
{
@@ -1393,7 +1498,7 @@ public:
std::string docstring;
m_fetched_help_long = scripter->GetDocumentationForItem(m_function_name.c_str(),docstring);
if (!docstring.empty())
- SetHelpLong(docstring);
+ SetHelpLong(docstring.c_str());
}
}
return CommandObjectRaw::GetHelpLong();
@@ -1409,12 +1514,12 @@ protected:
result.SetStatus(eReturnStatusInvalid);
- if (!scripter || scripter->RunScriptBasedCommand(m_function_name.c_str(),
- raw_command_line,
- m_synchro,
- result,
- error,
- m_exe_ctx) == false)
+ if (!scripter || !scripter->RunScriptBasedCommand(m_function_name.c_str(),
+ raw_command_line,
+ m_synchro,
+ result,
+ error,
+ m_exe_ctx))
{
result.AppendError(error.AsCString());
result.SetStatus(eReturnStatusFailed);
@@ -1424,7 +1529,7 @@ protected:
// Don't change the status if the command already set it...
if (result.GetStatus() == eReturnStatusInvalid)
{
- if (result.GetOutputData() == NULL || result.GetOutputData()[0] == '\0')
+ if (result.GetOutputData() == nullptr || result.GetOutputData()[0] == '\0')
result.SetStatus(eReturnStatusSuccessFinishNoResult);
else
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -1433,31 +1538,28 @@ protected:
return result.Succeeded();
}
-
+
+private:
+ std::string m_function_name;
+ ScriptedCommandSynchronicity m_synchro;
+ bool m_fetched_help_long;
};
class CommandObjectScriptingObject : public CommandObjectRaw
{
-private:
- StructuredData::GenericSP m_cmd_obj_sp;
- ScriptedCommandSynchronicity m_synchro;
- bool m_fetched_help_short:1;
- bool m_fetched_help_long:1;
-
public:
-
CommandObjectScriptingObject (CommandInterpreter &interpreter,
std::string name,
StructuredData::GenericSP cmd_obj_sp,
ScriptedCommandSynchronicity synch) :
- CommandObjectRaw (interpreter,
- name.c_str(),
- NULL,
- NULL),
- m_cmd_obj_sp(cmd_obj_sp),
- m_synchro(synch),
- m_fetched_help_short(false),
- m_fetched_help_long(false)
+ CommandObjectRaw(interpreter,
+ name.c_str(),
+ nullptr,
+ nullptr),
+ m_cmd_obj_sp(cmd_obj_sp),
+ m_synchro(synch),
+ m_fetched_help_short(false),
+ m_fetched_help_long(false)
{
StreamString stream;
stream.Printf("For more information run 'help %s'",name.c_str());
@@ -1465,11 +1567,9 @@ public:
if (ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter())
GetFlags().Set(scripter->GetFlagsForCommandObject(cmd_obj_sp));
}
-
- ~CommandObjectScriptingObject () override
- {
- }
-
+
+ ~CommandObjectScriptingObject() override = default;
+
bool
IsRemovable () const override
{
@@ -1499,7 +1599,7 @@ public:
std::string docstring;
m_fetched_help_short = scripter->GetShortHelpForCommandObject(m_cmd_obj_sp,docstring);
if (!docstring.empty())
- SetHelp(docstring);
+ SetHelp(docstring.c_str());
}
}
return CommandObjectRaw::GetHelp();
@@ -1516,7 +1616,7 @@ public:
std::string docstring;
m_fetched_help_long = scripter->GetLongHelpForCommandObject(m_cmd_obj_sp,docstring);
if (!docstring.empty())
- SetHelpLong(docstring);
+ SetHelpLong(docstring.c_str());
}
}
return CommandObjectRaw::GetHelpLong();
@@ -1532,12 +1632,12 @@ protected:
result.SetStatus(eReturnStatusInvalid);
- if (!scripter || scripter->RunScriptBasedCommand(m_cmd_obj_sp,
- raw_command_line,
- m_synchro,
- result,
- error,
- m_exe_ctx) == false)
+ if (!scripter || !scripter->RunScriptBasedCommand(m_cmd_obj_sp,
+ raw_command_line,
+ m_synchro,
+ result,
+ error,
+ m_exe_ctx))
{
result.AppendError(error.AsCString());
result.SetStatus(eReturnStatusFailed);
@@ -1547,7 +1647,7 @@ protected:
// Don't change the status if the command already set it...
if (result.GetStatus() == eReturnStatusInvalid)
{
- if (result.GetOutputData() == NULL || result.GetOutputData()[0] == '\0')
+ if (result.GetOutputData() == nullptr || result.GetOutputData()[0] == '\0')
result.SetStatus(eReturnStatusSuccessFinishNoResult);
else
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -1556,7 +1656,12 @@ protected:
return result.Succeeded();
}
-
+
+private:
+ StructuredData::GenericSP m_cmd_obj_sp;
+ ScriptedCommandSynchronicity m_synchro;
+ bool m_fetched_help_short: 1;
+ bool m_fetched_help_long: 1;
};
//-------------------------------------------------------------------------
@@ -1567,10 +1672,10 @@ class CommandObjectCommandsScriptImport : public CommandObjectParsed
{
public:
CommandObjectCommandsScriptImport (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "command script import",
- "Import a scripting module in LLDB.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "command script import",
+ "Import a scripting module in LLDB.",
+ nullptr),
m_options(interpreter)
{
CommandArgumentEntry arg1;
@@ -1586,11 +1691,9 @@ public:
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back (arg1);
}
-
- ~CommandObjectCommandsScriptImport () override
- {
- }
-
+
+ ~CommandObjectCommandsScriptImport() override = default;
+
int
HandleArgumentCompletion (Args &input,
int &cursor_index,
@@ -1604,14 +1707,14 @@ public:
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eDiskFileCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eDiskFileCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -1622,18 +1725,16 @@ public:
}
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
{
@@ -1730,11 +1831,10 @@ protected:
OptionDefinition
CommandObjectCommandsScriptImport::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "allow-reload", 'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Allow the script to be loaded even if it was already loaded before. This argument exists for backwards compatibility, but reloading is always allowed, whether you specify it or not."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_1, false, "allow-reload", 'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Allow the script to be loaded even if it was already loaded before. This argument exists for backwards compatibility, but reloading is always allowed, whether you specify it or not."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
//-------------------------------------------------------------------------
// CommandObjectCommandsScriptAdd
//-------------------------------------------------------------------------
@@ -1745,10 +1845,10 @@ class CommandObjectCommandsScriptAdd :
{
public:
CommandObjectCommandsScriptAdd(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "command script add",
- "Add a scripted function as an LLDB command.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "command script add",
+ "Add a scripted function as an LLDB command.",
+ nullptr),
IOHandlerDelegateMultiline ("DONE"),
m_options (interpreter)
{
@@ -1765,11 +1865,9 @@ public:
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back (arg1);
}
-
- ~CommandObjectCommandsScriptAdd () override
- {
- }
-
+
+ ~CommandObjectCommandsScriptAdd() override = default;
+
Options *
GetOptions () override
{
@@ -1777,11 +1875,9 @@ public:
}
protected:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_class_name(),
@@ -1790,9 +1886,9 @@ protected:
m_synchronicity(eScriptedCommandSynchronicitySynchronous)
{
}
-
- ~CommandOptions () override {}
-
+
+ ~CommandOptions() override = default;
+
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -1922,15 +2018,12 @@ protected:
}
io_handler.SetIsDone(true);
-
-
}
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
{
-
if (m_interpreter.GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython)
{
result.AppendError ("only scripting language supported for scripted commands is currently Python");
@@ -1956,10 +2049,10 @@ protected:
{
if (m_options.m_funct_name.empty())
{
- m_interpreter.GetPythonCommandsFromIOHandler (" ", // Prompt
- *this, // IOHandlerDelegate
- true, // Run IOHandler in async mode
- NULL); // Baton for the "io_handler" that will be passed back into our IOHandlerDelegate functions
+ m_interpreter.GetPythonCommandsFromIOHandler(" ", // Prompt
+ *this, // IOHandlerDelegate
+ true, // Run IOHandler in async mode
+ nullptr); // Baton for the "io_handler" that will be passed back into our IOHandlerDelegate functions
}
else
{
@@ -2013,7 +2106,6 @@ protected:
}
return result.Succeeded();
-
}
CommandOptions m_options;
@@ -2027,17 +2119,17 @@ static OptionEnumValueElement g_script_synchro_type[] =
{ eScriptedCommandSynchronicitySynchronous, "synchronous", "Run synchronous"},
{ eScriptedCommandSynchronicityAsynchronous, "asynchronous", "Run asynchronous"},
{ eScriptedCommandSynchronicityCurrentValue, "current", "Do not alter current setting"},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
OptionDefinition
CommandObjectCommandsScriptAdd::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "function", 'f', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonFunction, "Name of the Python function to bind to this command name."},
- { LLDB_OPT_SET_2, false, "class", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonClass, "Name of the Python class to bind to this command name."},
- { LLDB_OPT_SET_1, false, "help" , 'h', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeHelpText, "The help text to display for this command."},
- { LLDB_OPT_SET_ALL, false, "synchronicity", 's', OptionParser::eRequiredArgument, NULL, g_script_synchro_type, 0, eArgTypeScriptedCommandSynchronicity, "Set the synchronicity of this command's executions with regard to LLDB event system."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_1, false, "function", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePythonFunction, "Name of the Python function to bind to this command name."},
+ { LLDB_OPT_SET_2, false, "class", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePythonClass, "Name of the Python class to bind to this command name."},
+ { LLDB_OPT_SET_1, false, "help" , 'h', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeHelpText, "The help text to display for this command."},
+ { LLDB_OPT_SET_ALL, false, "synchronicity", 's', OptionParser::eRequiredArgument, nullptr, g_script_synchro_type, 0, eArgTypeScriptedCommandSynchronicity, "Set the synchronicity of this command's executions with regard to LLDB event system."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -2046,33 +2138,26 @@ CommandObjectCommandsScriptAdd::CommandOptions::g_option_table[] =
class CommandObjectCommandsScriptList : public CommandObjectParsed
{
-private:
-
public:
CommandObjectCommandsScriptList(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "command script list",
- "List defined scripted commands.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "command script list",
+ "List defined scripted commands.",
+ nullptr)
{
}
-
- ~CommandObjectCommandsScriptList () override
- {
- }
-
+
+ ~CommandObjectCommandsScriptList() override = default;
+
bool
DoExecute (Args& command, CommandReturnObject &result) override
{
-
m_interpreter.GetHelp(result,
CommandInterpreter::eCommandTypesUserDef);
result.SetStatus (eReturnStatusSuccessFinishResult);
return true;
-
-
}
};
@@ -2082,26 +2167,21 @@ public:
class CommandObjectCommandsScriptClear : public CommandObjectParsed
{
-private:
-
public:
CommandObjectCommandsScriptClear(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "command script clear",
- "Delete all scripted commands.",
- NULL)
- {
- }
-
- ~CommandObjectCommandsScriptClear () override
+ CommandObjectParsed(interpreter,
+ "command script clear",
+ "Delete all scripted commands.",
+ nullptr)
{
}
-
+
+ ~CommandObjectCommandsScriptClear() override = default;
+
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
{
-
m_interpreter.RemoveAllUser();
result.SetStatus (eReturnStatusSuccessFinishResult);
@@ -2118,10 +2198,10 @@ class CommandObjectCommandsScriptDelete : public CommandObjectParsed
{
public:
CommandObjectCommandsScriptDelete(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "command script delete",
- "Delete a scripted command.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "command script delete",
+ "Delete a scripted command.",
+ nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentData cmd_arg;
@@ -2136,11 +2216,9 @@ public:
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back (arg1);
}
-
- ~CommandObjectCommandsScriptDelete () override
- {
- }
-
+
+ ~CommandObjectCommandsScriptDelete() override = default;
+
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -2169,7 +2247,6 @@ protected:
}
return result.Succeeded();
-
}
};
@@ -2182,11 +2259,10 @@ protected:
class CommandObjectMultiwordCommandsScript : public CommandObjectMultiword
{
public:
- CommandObjectMultiwordCommandsScript (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "command script",
- "A set of commands for managing or customizing script commands.",
- "command script <subcommand> [<subcommand-options>]")
+ CommandObjectMultiwordCommandsScript(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "command script",
+ "Commands for managing custom commands implemented by interpreter scripts.",
+ "command script <subcommand> [<subcommand-options>]")
{
LoadSubCommand ("add", CommandObjectSP (new CommandObjectCommandsScriptAdd (interpreter)));
LoadSubCommand ("delete", CommandObjectSP (new CommandObjectCommandsScriptDelete (interpreter)));
@@ -2195,24 +2271,18 @@ public:
LoadSubCommand ("import", CommandObjectSP (new CommandObjectCommandsScriptImport (interpreter)));
}
- ~CommandObjectMultiwordCommandsScript () override
- {
- }
-
+ ~CommandObjectMultiwordCommandsScript() override = default;
};
-
#pragma mark CommandObjectMultiwordCommands
//-------------------------------------------------------------------------
// CommandObjectMultiwordCommands
//-------------------------------------------------------------------------
-CommandObjectMultiwordCommands::CommandObjectMultiwordCommands (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "command",
- "A set of commands for managing or customizing the debugger commands.",
- "command <subcommand> [<subcommand-options>]")
+CommandObjectMultiwordCommands::CommandObjectMultiwordCommands(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "command", "Commands for managing custom LLDB commands.",
+ "command <subcommand> [<subcommand-options>]")
{
LoadSubCommand ("source", CommandObjectSP (new CommandObjectCommandsSource (interpreter)));
LoadSubCommand ("alias", CommandObjectSP (new CommandObjectCommandsAlias (interpreter)));
@@ -2223,7 +2293,4 @@ CommandObjectMultiwordCommands::CommandObjectMultiwordCommands (CommandInterpret
LoadSubCommand ("script", CommandObjectSP (new CommandObjectMultiwordCommandsScript (interpreter)));
}
-CommandObjectMultiwordCommands::~CommandObjectMultiwordCommands ()
-{
-}
-
+CommandObjectMultiwordCommands::~CommandObjectMultiwordCommands() = default;
diff --git a/source/Commands/CommandObjectDisassemble.cpp b/source/Commands/CommandObjectDisassemble.cpp
index 100d8692039f4..07a847aaebae6 100644
--- a/source/Commands/CommandObjectDisassemble.cpp
+++ b/source/Commands/CommandObjectDisassemble.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectDisassemble.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "CommandObjectDisassemble.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
@@ -54,9 +53,7 @@ CommandObjectDisassemble::CommandOptions::CommandOptions (CommandInterpreter &in
OptionParsingStarting();
}
-CommandObjectDisassemble::CommandOptions::~CommandOptions ()
-{
-}
+CommandObjectDisassemble::CommandOptions::~CommandOptions() = default;
Error
CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
@@ -105,6 +102,7 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, c
some_location_specified = true;
}
break;
+
case 'n':
func_name.assign (option_arg);
some_location_specified = true;
@@ -139,6 +137,7 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, c
error.SetErrorStringWithFormat("Disassembler flavors are currently only supported for x86 and x86_64 targets.");
break;
}
+
case 'r':
raw = true;
break;
@@ -218,7 +217,6 @@ CommandObjectDisassemble::CommandOptions::OptionParsingFinished ()
if (!some_location_specified)
current_function = true;
return Error();
-
}
const OptionDefinition*
@@ -230,55 +228,51 @@ CommandObjectDisassemble::CommandOptions::GetDefinitions ()
OptionDefinition
CommandObjectDisassemble::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_ALL, false, "bytes" , 'b', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Show opcode bytes when disassembling."},
-{ LLDB_OPT_SET_ALL, false, "context" , 'C', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeNumLines, "Number of context lines of source to show."},
-{ LLDB_OPT_SET_ALL, false, "mixed" , 'm', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Enable mixed source and assembly display."},
-{ LLDB_OPT_SET_ALL, false, "raw" , 'r', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Print raw disassembly with no symbol information."},
-{ LLDB_OPT_SET_ALL, false, "plugin" , 'P', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypePlugin, "Name of the disassembler plugin you want to use."},
-{ LLDB_OPT_SET_ALL, false, "flavor" , 'F', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeDisassemblyFlavor, "Name of the disassembly flavor you want to use. "
+{ LLDB_OPT_SET_ALL, false, "bytes" , 'b', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Show opcode bytes when disassembling."},
+{ LLDB_OPT_SET_ALL, false, "context" , 'C', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeNumLines, "Number of context lines of source to show."},
+{ LLDB_OPT_SET_ALL, false, "mixed" , 'm', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Enable mixed source and assembly display."},
+{ LLDB_OPT_SET_ALL, false, "raw" , 'r', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Print raw disassembly with no symbol information."},
+{ LLDB_OPT_SET_ALL, false, "plugin" , 'P', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypePlugin, "Name of the disassembler plugin you want to use."},
+{ LLDB_OPT_SET_ALL, false, "flavor" , 'F', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeDisassemblyFlavor, "Name of the disassembly flavor you want to use. "
"Currently the only valid options are default, and for Intel"
" architectures, att and intel."},
-{ LLDB_OPT_SET_ALL, false, "arch" , 'A', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeArchitecture,"Specify the architecture to use from cross disassembly."},
+{ LLDB_OPT_SET_ALL, false, "arch" , 'A', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeArchitecture,"Specify the architecture to use from cross disassembly."},
{ LLDB_OPT_SET_1 |
- LLDB_OPT_SET_2 , true , "start-address", 's', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeAddressOrExpression,"Address at which to start disassembling."},
-{ LLDB_OPT_SET_1 , false, "end-address" , 'e', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeAddressOrExpression, "Address at which to end disassembling."},
+ LLDB_OPT_SET_2 , true , "start-address", 's', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeAddressOrExpression,"Address at which to start disassembling."},
+{ LLDB_OPT_SET_1 , false, "end-address" , 'e', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Address at which to end disassembling."},
{ LLDB_OPT_SET_2 |
LLDB_OPT_SET_3 |
LLDB_OPT_SET_4 |
- LLDB_OPT_SET_5 , false, "count" , 'c', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeNumLines, "Number of instructions to display."},
-{ LLDB_OPT_SET_3 , false, "name" , 'n', OptionParser::eRequiredArgument , NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
+ LLDB_OPT_SET_5 , false, "count" , 'c', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeNumLines, "Number of instructions to display."},
+{ LLDB_OPT_SET_3 , false, "name" , 'n', OptionParser::eRequiredArgument , nullptr, nullptr, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
"Disassemble entire contents of the given function name."},
-{ LLDB_OPT_SET_4 , false, "frame" , 'f', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Disassemble from the start of the current frame's function."},
-{ LLDB_OPT_SET_5 , false, "pc" , 'p', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Disassemble around the current pc."},
-{ LLDB_OPT_SET_6 , false, "line" , 'l', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Disassemble the current frame's current source line instructions if there is debug line table information, else disassemble around the pc."},
-{ LLDB_OPT_SET_7 , false, "address" , 'a', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeAddressOrExpression, "Disassemble function containing this address."},
-{ 0 , false, NULL , 0, 0 , NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_4 , false, "frame" , 'f', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Disassemble from the start of the current frame's function."},
+{ LLDB_OPT_SET_5 , false, "pc" , 'p', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Disassemble around the current pc."},
+{ LLDB_OPT_SET_6 , false, "line" , 'l', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Disassemble the current frame's current source line instructions if there is debug line table information, else disassemble around the pc."},
+{ LLDB_OPT_SET_7 , false, "address" , 'a', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Disassemble function containing this address."},
+{ 0 , false, nullptr , 0, 0 , nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
-
//-------------------------------------------------------------------------
// CommandObjectDisassemble
//-------------------------------------------------------------------------
-CommandObjectDisassemble::CommandObjectDisassemble (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "disassemble",
- "Disassemble bytes in the current function, or elsewhere in the executable program as specified by the user.",
- "disassemble [<cmd-options>]"),
- m_options (interpreter)
+CommandObjectDisassemble::CommandObjectDisassemble(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "disassemble", "Disassemble specified instructions in the current target. "
+ "Defaults to the current function for the current thread and "
+ "stack frame.",
+ "disassemble [<cmd-options>]"),
+ m_options(interpreter)
{
}
-CommandObjectDisassemble::~CommandObjectDisassemble()
-{
-}
+CommandObjectDisassemble::~CommandObjectDisassemble() = default;
bool
CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result)
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("invalid target, create a debug target using the 'target create' command");
result.SetStatus (eReturnStatusFailed);
@@ -313,7 +307,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result)
result.SetStatus (eReturnStatusFailed);
return false;
}
- else if (flavor_string != NULL && !disassembler->FlavorValidForArchSpec(m_options.arch, flavor_string))
+ else if (flavor_string != nullptr && !disassembler->FlavorValidForArchSpec(m_options.arch, flavor_string))
result.AppendWarningWithFormat("invalid disassembler flavor \"%s\", using default.\n", flavor_string);
result.SetStatus (eReturnStatusSuccessFinishResult);
@@ -346,17 +340,17 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result)
{
ConstString name(m_options.func_name.c_str());
- if (Disassembler::Disassemble (m_interpreter.GetDebugger(),
- m_options.arch,
- plugin_name,
- flavor_string,
- m_exe_ctx,
- name,
- NULL, // Module *
- m_options.num_instructions,
- m_options.show_mixed ? m_options.num_lines_context : 0,
- options,
- result.GetOutputStream()))
+ if (Disassembler::Disassemble(m_interpreter.GetDebugger(),
+ m_options.arch,
+ plugin_name,
+ flavor_string,
+ m_exe_ctx,
+ name,
+ nullptr, // Module *
+ m_options.num_instructions,
+ m_options.show_mixed ? m_options.num_lines_context : 0,
+ options,
+ result.GetOutputStream()))
{
result.SetStatus (eReturnStatusSuccessFinishResult);
}
@@ -373,7 +367,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result)
StackFrame *frame = m_exe_ctx.GetFramePtr();
if (m_options.frame_line)
{
- if (frame == NULL)
+ if (frame == nullptr)
{
result.AppendError ("Cannot disassemble around the current line without a selected frame.\n");
result.SetStatus (eReturnStatusFailed);
@@ -392,7 +386,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result)
}
else if (m_options.current_function)
{
- if (frame == NULL)
+ if (frame == nullptr)
{
result.AppendError ("Cannot disassemble around the current function without a selected frame.\n");
result.SetStatus (eReturnStatusFailed);
@@ -412,7 +406,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result)
{
if (m_options.at_pc)
{
- if (frame == NULL)
+ if (frame == nullptr)
{
result.AppendError ("Cannot disassemble around the current PC without a selected frame.\n");
result.SetStatus (eReturnStatusFailed);
@@ -498,7 +492,6 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result)
}
}
}
-
}
}
}
@@ -509,7 +502,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result)
if (m_options.num_instructions != 0)
{
- if (ranges.size() == 0)
+ if (ranges.empty())
{
// The default action is to disassemble the current frame function.
if (frame)
@@ -561,7 +554,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result)
}
else
{
- if (ranges.size() == 0)
+ if (ranges.empty())
{
// The default action is to disassemble the current frame function.
if (frame)
diff --git a/source/Commands/CommandObjectDisassemble.h b/source/Commands/CommandObjectDisassemble.h
index d892824d017de..ef19b3cf316a1 100644
--- a/source/Commands/CommandObjectDisassemble.h
+++ b/source/Commands/CommandObjectDisassemble.h
@@ -30,7 +30,6 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter);
~CommandOptions() override;
@@ -47,16 +46,14 @@ public:
const char *
GetPluginName ()
{
- if (plugin_name.empty())
- return NULL;
- return plugin_name.c_str();
+ return (plugin_name.empty() ? nullptr : plugin_name.c_str());
}
const char *
GetFlavorString ()
{
if (flavor_string.empty() || flavor_string == "default")
- return NULL;
+ return nullptr;
return flavor_string.c_str();
}
diff --git a/source/Commands/CommandObjectExpression.cpp b/source/Commands/CommandObjectExpression.cpp
index 7f0b03b37c20a..f2bd3ed367caf 100644
--- a/source/Commands/CommandObjectExpression.cpp
+++ b/source/Commands/CommandObjectExpression.cpp
@@ -7,12 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectExpression.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+
// Project includes
+#include "CommandObjectExpression.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
@@ -32,8 +34,6 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringRef.h"
using namespace lldb;
using namespace lldb_private;
@@ -43,31 +43,30 @@ CommandObjectExpression::CommandOptions::CommandOptions () :
{
}
-
-CommandObjectExpression::CommandOptions::~CommandOptions ()
-{
-}
+CommandObjectExpression::CommandOptions::~CommandOptions() = default;
static OptionEnumValueElement g_description_verbosity_type[] =
{
{ eLanguageRuntimeDescriptionDisplayVerbosityCompact, "compact", "Only show the description string"},
{ eLanguageRuntimeDescriptionDisplayVerbosityFull, "full", "Show the full output, including persistent variable's name and type"},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
OptionDefinition
CommandObjectExpression::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "all-threads", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Should we run all threads if the execution doesn't complete on one thread."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "ignore-breakpoints", 'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Ignore breakpoint hits while running expressions"},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "timeout", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeUnsignedInteger, "Timeout value (in microseconds) for running the expression."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error", 'u', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, or raises a signal. Note, unlike gdb hitting a breakpoint is controlled by another option (-i)."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "debug", 'g', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "When specified, debug the JIT code by setting a breakpoint on the first instruction and forcing breakpoints to not be ignored (-i0) and no unwinding to happen on error (-u0)."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Specifies the Language to use when parsing the expression. If not set the target.language setting is used." },
- { LLDB_OPT_SET_1, false, "description-verbosity", 'v', OptionParser::eOptionalArgument, NULL, g_description_verbosity_type, 0, eArgTypeDescriptionVerbosity, "How verbose should the output of this expression be, if the object description is asked for."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "all-threads", 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Should we run all threads if the execution doesn't complete on one thread."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "ignore-breakpoints", 'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Ignore breakpoint hits while running expressions"},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "timeout", 't', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeUnsignedInteger, "Timeout value (in microseconds) for running the expression."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error", 'u', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, or raises a signal. Note, unlike gdb hitting a breakpoint is controlled by another option (-i)."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "debug", 'g', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "When specified, debug the JIT code by setting a breakpoint on the first instruction and forcing breakpoints to not be ignored (-i0) and no unwinding to happen on error (-u0)."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage, "Specifies the Language to use when parsing the expression. If not set the target.language setting is used." },
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "apply-fixits", 'X', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage, "If true, simple fix-it hints will be automatically applied to the expression." },
+ { LLDB_OPT_SET_1, false, "description-verbosity", 'v', OptionParser::eOptionalArgument, nullptr, g_description_verbosity_type, 0, eArgTypeDescriptionVerbosity, "How verbose should the output of this expression be, if the object description is asked for."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "top-level", 'p', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Interpret the expression as top-level definitions rather than code to be immediately executed."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "allow-jit", 'j', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Controls whether the expression can fall back to being JITted if it's not supported by the interpreter (defaults to true)."}
};
-
uint32_t
CommandObjectExpression::CommandOptions::GetNumDefinitions ()
{
@@ -113,6 +112,18 @@ CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &int
error.SetErrorStringWithFormat("could not convert \"%s\" to a boolean value.", option_arg);
break;
}
+
+ case 'j':
+ {
+ bool success;
+ bool tmp_value = Args::StringToBoolean(option_arg, true, &success);
+ if (success)
+ allow_jit = tmp_value;
+ else
+ error.SetErrorStringWithFormat("could not convert \"%s\" to a boolean value.", option_arg);
+ break;
+ }
+
case 't':
{
bool success;
@@ -152,7 +163,22 @@ CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &int
unwind_on_error = false;
ignore_breakpoints = false;
break;
+
+ case 'p':
+ top_level = true;
+ break;
+ case 'X':
+ {
+ bool success;
+ bool tmp_value = Args::StringToBoolean(option_arg, true, &success);
+ if (success)
+ auto_apply_fixits = tmp_value ? eLazyBoolYes : eLazyBoolNo;
+ else
+ error.SetErrorStringWithFormat("could not convert \"%s\" to a boolean value.", option_arg);
+ break;
+ }
+
default:
error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
break;
@@ -165,7 +191,7 @@ void
CommandObjectExpression::CommandOptions::OptionParsingStarting (CommandInterpreter &interpreter)
{
Process *process = interpreter.GetExecutionContext().GetProcessPtr();
- if (process != NULL)
+ if (process != nullptr)
{
ignore_breakpoints = process->GetIgnoreBreakpointsInExpressions();
unwind_on_error = process->GetUnwindOnErrorInExpressions();
@@ -182,6 +208,9 @@ CommandObjectExpression::CommandOptions::OptionParsingStarting (CommandInterpret
debug = false;
language = eLanguageTypeUnknown;
m_verbosity = eLanguageRuntimeDescriptionDisplayVerbosityCompact;
+ auto_apply_fixits = eLazyBoolCalculate;
+ top_level = false;
+ allow_jit = true;
}
const OptionDefinition*
@@ -190,19 +219,18 @@ CommandObjectExpression::CommandOptions::GetDefinitions ()
return g_option_table;
}
-CommandObjectExpression::CommandObjectExpression (CommandInterpreter &interpreter) :
- CommandObjectRaw (interpreter,
- "expression",
- "Evaluate an expression in the current program context, using user defined variables and variables currently in scope.",
- NULL,
- eCommandProcessMustBePaused | eCommandTryTargetAPILock),
- IOHandlerDelegate (IOHandlerDelegate::Completion::Expression),
- m_option_group (interpreter),
- m_format_options (eFormatDefault),
- m_repl_option (LLDB_OPT_SET_1, false, "repl", 'r', "Drop into REPL", false, true),
- m_command_options (),
- m_expr_line_count (0),
- m_expr_lines ()
+CommandObjectExpression::CommandObjectExpression(CommandInterpreter &interpreter)
+ : CommandObjectRaw(
+ interpreter, "expression",
+ "Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.",
+ nullptr, eCommandProcessMustBePaused | eCommandTryTargetAPILock),
+ IOHandlerDelegate(IOHandlerDelegate::Completion::Expression),
+ m_option_group(interpreter),
+ m_format_options(eFormatDefault),
+ m_repl_option(LLDB_OPT_SET_1, false, "repl", 'r', "Drop into REPL", false, true),
+ m_command_options(),
+ m_expr_line_count(0),
+ m_expr_lines()
{
SetHelpLong(
R"(
@@ -259,9 +287,7 @@ Examples:
m_option_group.Finalize();
}
-CommandObjectExpression::~CommandObjectExpression ()
-{
-}
+CommandObjectExpression::~CommandObjectExpression() = default;
Options *
CommandObjectExpression::GetOptions ()
@@ -269,14 +295,23 @@ CommandObjectExpression::GetOptions ()
return &m_option_group;
}
+static lldb_private::Error
+CanBeUsedForElementCountPrinting (ValueObject& valobj)
+{
+ CompilerType type(valobj.GetCompilerType());
+ CompilerType pointee;
+ if (!type.IsPointerType(&pointee))
+ return Error("as it does not refer to a pointer");
+ if (pointee.IsVoidType())
+ return Error("as it refers to a pointer to void");
+ return Error();
+}
+
bool
-CommandObjectExpression::EvaluateExpression
-(
- const char *expr,
- Stream *output_stream,
- Stream *error_stream,
- CommandReturnObject *result
-)
+CommandObjectExpression::EvaluateExpression(const char *expr,
+ Stream *output_stream,
+ Stream *error_stream,
+ CommandReturnObject *result)
{
// Don't use m_exe_ctx as this might be called asynchronously
// after the command object DoExecute has finished when doing
@@ -303,6 +338,20 @@ CommandObjectExpression::EvaluateExpression
options.SetTryAllThreads(m_command_options.try_all_threads);
options.SetDebug(m_command_options.debug);
options.SetLanguage(m_command_options.language);
+ options.SetExecutionPolicy(m_command_options.allow_jit ?
+ EvaluateExpressionOptions::default_execution_policy :
+ lldb_private::eExecutionPolicyNever);
+
+ bool auto_apply_fixits;
+ if (m_command_options.auto_apply_fixits == eLazyBoolCalculate)
+ auto_apply_fixits = target->GetEnableAutoApplyFixIts();
+ else
+ auto_apply_fixits = m_command_options.auto_apply_fixits == eLazyBoolYes ? true : false;
+
+ options.SetAutoApplyFixIts(auto_apply_fixits);
+
+ if (m_command_options.top_level)
+ options.SetExecutionPolicy(eExecutionPolicyTopLevel);
// If there is any chance we are going to stop and want to see
// what went wrong with our expression, we should generate debug info
@@ -315,7 +364,14 @@ CommandObjectExpression::EvaluateExpression
else
options.SetTimeoutUsec(0);
- target->EvaluateExpression(expr, frame, result_valobj_sp, options);
+ ExpressionResults success = target->EvaluateExpression(expr, frame, result_valobj_sp, options, &m_fixed_expression);
+
+ // We only tell you about the FixIt if we applied it. The compiler errors will suggest the FixIt if it parsed.
+ if (error_stream && !m_fixed_expression.empty() && target->GetEnableNotifyAboutFixIts())
+ {
+ if (success == eExpressionCompleted)
+ error_stream->Printf (" Fix-it applied, fixed expression was: \n %s\n", m_fixed_expression.c_str());
+ }
if (result_valobj_sp)
{
@@ -328,6 +384,17 @@ CommandObjectExpression::EvaluateExpression
if (format != eFormatDefault)
result_valobj_sp->SetFormat (format);
+ if (m_varobj_options.elem_count > 0)
+ {
+ Error error(CanBeUsedForElementCountPrinting(*result_valobj_sp));
+ if (error.Fail())
+ {
+ result->AppendErrorWithFormat("expression cannot be used with --element-count %s\n", error.AsCString(""));
+ result->SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ }
+
DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(m_command_options.m_verbosity,format));
options.SetVariableFormatDisplayLanguage(result_valobj_sp->GetPreferredDisplayLanguage());
@@ -400,28 +467,21 @@ CommandObjectExpression::IOHandlerInputComplete (IOHandler &io_handler, std::str
error_sp->Flush();
}
-LineStatus
-CommandObjectExpression::IOHandlerLinesUpdated (IOHandler &io_handler,
- StringList &lines,
- uint32_t line_idx,
- Error &error)
+bool
+CommandObjectExpression::IOHandlerIsInputComplete (IOHandler &io_handler,
+ StringList &lines)
{
- if (line_idx == UINT32_MAX)
+ // An empty lines is used to indicate the end of input
+ const size_t num_lines = lines.GetSize();
+ if (num_lines > 0 && lines[num_lines - 1].empty())
{
- // Remove the last line from "lines" so it doesn't appear
- // in our final expression
+ // Remove the last empty line from "lines" so it doesn't appear
+ // in our resulting input and return true to indicate we are done
+ // getting lines
lines.PopBack();
- error.Clear();
- return LineStatus::Done;
- }
- else if (line_idx + 1 == lines.GetSize())
- {
- // The last line was edited, if this line is empty, then we are done
- // getting our multiple lines.
- if (lines[line_idx].empty())
- return LineStatus::Done;
+ return true;
}
- return LineStatus::Success;
+ return false;
}
void
@@ -433,15 +493,15 @@ CommandObjectExpression::GetMultilineExpression ()
Debugger &debugger = GetCommandInterpreter().GetDebugger();
bool color_prompt = debugger.GetUseColor();
const bool multiple_lines = true; // Get multiple lines
- IOHandlerSP io_handler_sp (new IOHandlerEditline (debugger,
- IOHandler::Type::Expression,
- "lldb-expr", // Name of input reader for history
- NULL, // No prompt
- NULL, // Continuation prompt
- multiple_lines,
- color_prompt,
- 1, // Show line numbers starting at 1
- *this));
+ IOHandlerSP io_handler_sp(new IOHandlerEditline(debugger,
+ IOHandler::Type::Expression,
+ "lldb-expr", // Name of input reader for history
+ nullptr, // No prompt
+ nullptr, // Continuation prompt
+ multiple_lines,
+ color_prompt,
+ 1, // Show line numbers starting at 1
+ *this));
StreamFileSP output_sp(io_handler_sp->GetOutputStreamFile());
if (output_sp)
@@ -453,15 +513,13 @@ CommandObjectExpression::GetMultilineExpression ()
}
bool
-CommandObjectExpression::DoExecute
-(
- const char *command,
- CommandReturnObject &result
-)
+CommandObjectExpression::DoExecute(const char *command,
+ CommandReturnObject &result)
{
+ m_fixed_expression.clear();
m_option_group.NotifyOptionParsingStarting();
- const char * expr = NULL;
+ const char * expr = nullptr;
if (command[0] == '\0')
{
@@ -472,7 +530,7 @@ CommandObjectExpression::DoExecute
if (command[0] == '-')
{
// We have some options and these options MUST end with --.
- const char *end_options = NULL;
+ const char *end_options = nullptr;
const char *s = command;
while (s && s[0])
{
@@ -568,7 +626,7 @@ CommandObjectExpression::DoExecute
}
}
// No expression following options
- else if (expr == NULL || expr[0] == '\0')
+ else if (expr == nullptr || expr[0] == '\0')
{
GetMultilineExpression ();
return result.Succeeded();
@@ -576,13 +634,31 @@ CommandObjectExpression::DoExecute
}
}
- if (expr == NULL)
+ if (expr == nullptr)
expr = command;
if (EvaluateExpression (expr, &(result.GetOutputStream()), &(result.GetErrorStream()), &result))
+ {
+ Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
+ if (!m_fixed_expression.empty() && target->GetEnableNotifyAboutFixIts())
+ {
+ CommandHistory &history = m_interpreter.GetCommandHistory();
+ // FIXME: Can we figure out what the user actually typed (e.g. some alias for expr???)
+ // If we can it would be nice to show that.
+ std::string fixed_command("expression ");
+ if (expr == command)
+ fixed_command.append(m_fixed_expression);
+ else
+ {
+ // Add in any options that might have been in the original command:
+ fixed_command.append(command, expr - command);
+ fixed_command.append(m_fixed_expression);
+ }
+ history.AppendString(fixed_command);
+ }
return true;
+ }
result.SetStatus (eReturnStatusFailed);
return false;
}
-
diff --git a/source/Commands/CommandObjectExpression.h b/source/Commands/CommandObjectExpression.h
index 7103675f39924..3445aef276654 100644
--- a/source/Commands/CommandObjectExpression.h
+++ b/source/Commands/CommandObjectExpression.h
@@ -14,13 +14,13 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/lldb-private-enumerations.h"
#include "lldb/Core/IOHandler.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/OptionGroupBoolean.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
#include "lldb/Target/ExecutionContext.h"
-
namespace lldb_private {
class CommandObjectExpression :
@@ -54,8 +54,10 @@ public:
// Options table: Required for subclasses of Options.
static OptionDefinition g_option_table[];
+ bool top_level;
bool unwind_on_error;
bool ignore_breakpoints;
+ bool allow_jit;
bool show_types;
bool show_summary;
bool debug;
@@ -63,6 +65,7 @@ public:
bool try_all_threads;
lldb::LanguageType language;
LanguageRuntimeDescriptionDisplayVerbosity m_verbosity;
+ LazyBool auto_apply_fixits;
};
CommandObjectExpression (CommandInterpreter &interpreter);
@@ -80,12 +83,11 @@ protected:
void
IOHandlerInputComplete(IOHandler &io_handler,
std::string &line) override;
-
- virtual LineStatus
- IOHandlerLinesUpdated (IOHandler &io_handler,
- StringList &lines,
- uint32_t line_idx,
- Error &error);
+
+ bool
+ IOHandlerIsInputComplete (IOHandler &io_handler,
+ StringList &lines) override;
+
bool
DoExecute(const char *command,
CommandReturnObject &result) override;
@@ -106,6 +108,7 @@ protected:
CommandOptions m_command_options;
uint32_t m_expr_line_count;
std::string m_expr_lines; // Multi-line expression support
+ std::string m_fixed_expression; // Holds the current expression's fixed text.
};
} // namespace lldb_private
diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp
index 9477b50a58df2..cd436dfdb97a1 100644
--- a/source/Commands/CommandObjectFrame.cpp
+++ b/source/Commands/CommandObjectFrame.cpp
@@ -7,13 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectFrame.h"
-
// C Includes
// C++ Includes
#include <string>
+
// Other libraries and framework includes
// Project includes
+#include "CommandObjectFrame.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
@@ -58,22 +58,15 @@ using namespace lldb_private;
class CommandObjectFrameInfo : public CommandObjectParsed
{
public:
-
- CommandObjectFrameInfo (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "frame info",
- "List information about the currently selected frame in the current thread.",
- "frame info",
- eCommandRequiresFrame |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused )
+ CommandObjectFrameInfo(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "frame info",
+ "List information about the current stack frame in the current thread.", "frame info",
+ eCommandRequiresFrame | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched |
+ eCommandProcessMustBePaused)
{
}
- ~CommandObjectFrameInfo () override
- {
- }
+ ~CommandObjectFrameInfo() override = default;
protected:
bool
@@ -94,20 +87,16 @@ protected:
class CommandObjectFrameSelect : public CommandObjectParsed
{
public:
-
- class CommandOptions : public Options
+ class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options(interpreter)
{
OptionParsingStarting ();
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -148,17 +137,14 @@ public:
static OptionDefinition g_option_table[];
int32_t relative_frame_offset;
};
-
- CommandObjectFrameSelect (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "frame select",
- "Select a frame by index from within the current thread and make it the current frame.",
- NULL,
- eCommandRequiresThread |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused ),
- m_options (interpreter)
+
+ CommandObjectFrameSelect(CommandInterpreter &interpreter)
+ : CommandObjectParsed(
+ interpreter, "frame select",
+ "Select the current stack frame by index from within the current thread (see 'thread backtrace'.)",
+ nullptr, eCommandRequiresThread | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched |
+ eCommandProcessMustBePaused),
+ m_options(interpreter)
{
CommandArgumentEntry arg;
CommandArgumentData index_arg;
@@ -174,9 +160,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectFrameSelect () override
- {
- }
+ ~CommandObjectFrameSelect() override = default;
Options *
GetOptions () override
@@ -184,7 +168,6 @@ public:
return &m_options;
}
-
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -209,7 +192,7 @@ protected:
if (frame_idx == 0)
{
//If you are already at the bottom of the stack, then just warn and don't reset the frame.
- result.AppendError("Already at the bottom of the stack");
+ result.AppendError("Already at the bottom of the stack.");
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -229,7 +212,7 @@ protected:
if (frame_idx == num_frames - 1)
{
//If we are already at the top of the stack, just warn and don't reset the frame.
- result.AppendError("Already at the top of the stack");
+ result.AppendError("Already at the top of the stack.");
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -247,7 +230,7 @@ protected:
frame_idx = StringConvert::ToUInt32 (frame_idx_cstr, UINT32_MAX, 0, &success);
if (!success)
{
- result.AppendErrorWithFormat ("invalid frame index argument '%s'", frame_idx_cstr);
+ result.AppendErrorWithFormat("invalid frame index argument '%s'.", frame_idx_cstr);
result.SetStatus (eReturnStatusFailed);
return false;
}
@@ -283,16 +266,16 @@ protected:
return result.Succeeded();
}
-protected:
+protected:
CommandOptions m_options;
};
OptionDefinition
CommandObjectFrameSelect::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, false, "relative", 'r', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOffset, "A relative frame index offset from the current frame index."},
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_1, false, "relative", 'r', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOffset, "A relative frame index offset from the current frame index."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
#pragma mark CommandObjectFrameVariable
@@ -302,26 +285,19 @@ CommandObjectFrameSelect::CommandOptions::g_option_table[] =
class CommandObjectFrameVariable : public CommandObjectParsed
{
public:
-
- CommandObjectFrameVariable (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "frame variable",
- "Show frame variables. All argument and local variables "
- "that are in scope will be shown when no arguments are given. "
- "If any arguments are specified, they can be names of "
- "argument, local, file static and file global variables. "
- "Children of aggregate variables can be specified such as "
- "'var->child.x'.",
- NULL,
- eCommandRequiresFrame |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused |
- eCommandRequiresProcess),
- m_option_group (interpreter),
- m_option_variable(true), // Include the frame specific options by passing "true"
- m_option_format (eFormatDefault),
- m_varobj_options()
+ CommandObjectFrameVariable(CommandInterpreter &interpreter)
+ : CommandObjectParsed(
+ interpreter, "frame variable", "Show variables for the current stack frame. Defaults to all "
+ "arguments and local variables in scope. Names of argument, "
+ "local, file static and file global variables can be specified. "
+ "Children of aggregate variables can be specified such as "
+ "'var->child.x'.",
+ nullptr, eCommandRequiresFrame | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched |
+ eCommandProcessMustBePaused | eCommandRequiresProcess),
+ m_option_group(interpreter),
+ m_option_variable(true), // Include the frame specific options by passing "true"
+ m_option_format(eFormatDefault),
+ m_varobj_options()
{
CommandArgumentEntry arg;
CommandArgumentData var_name_arg;
@@ -342,9 +318,7 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectFrameVariable () override
- {
- }
+ ~CommandObjectFrameVariable() override = default;
Options *
GetOptions () override
@@ -352,7 +326,6 @@ public:
return &m_option_group;
}
-
int
HandleArgumentCompletion (Args &input,
int &cursor_index,
@@ -367,14 +340,14 @@ public:
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eVariablePathCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eVariablePathCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -387,17 +360,15 @@ protected:
Stream &s = result.GetOutputStream();
- bool get_file_globals = true;
-
// Be careful about the stack frame, if any summary formatter runs code, it might clear the StackFrameList
// for the thread. So hold onto a shared pointer to the frame so it stays alive.
- VariableList *variable_list = frame->GetVariableList (get_file_globals);
+ VariableList *variable_list = frame->GetVariableList (m_option_variable.show_globals);
VariableSP var_sp;
ValueObjectSP valobj_sp;
- const char *name_cstr = NULL;
+ const char *name_cstr = nullptr;
size_t idx;
TypeSummaryImplSP summary_format_sp;
@@ -423,7 +394,7 @@ protected:
// If we have any args to the variable command, we will make
// variable objects from them...
- for (idx = 0; (name_cstr = command.GetArgumentAtIndex(idx)) != NULL; ++idx)
+ for (idx = 0; (name_cstr = command.GetArgumentAtIndex(idx)) != nullptr; ++idx)
{
if (m_option_variable.use_regex)
{
@@ -502,16 +473,18 @@ protected:
options.SetVariableFormatDisplayLanguage(valobj_sp->GetPreferredDisplayLanguage());
Stream &output_stream = result.GetOutputStream();
- options.SetRootValueObjectName(valobj_sp->GetParent() ? name_cstr : NULL);
+ options.SetRootValueObjectName(valobj_sp->GetParent() ? name_cstr : nullptr);
valobj_sp->Dump(output_stream,options);
}
else
{
- const char *error_cstr = error.AsCString(NULL);
+ const char *error_cstr = error.AsCString(nullptr);
if (error_cstr)
result.GetErrorStream().Printf("error: %s\n", error_cstr);
else
- result.GetErrorStream().Printf ("error: unable to find any variable expression path that matches '%s'\n", name_cstr);
+ result.GetErrorStream().Printf(
+ "error: unable to find any variable expression path that matches '%s'.\n",
+ name_cstr);
}
}
}
@@ -529,13 +502,16 @@ protected:
switch (var_sp->GetScope())
{
case eValueTypeVariableGlobal:
- dump_variable = m_option_variable.show_globals;
+ // Always dump globals since we only fetched them if
+ // m_option_variable.show_scope was true
if (dump_variable && m_option_variable.show_scope)
scope_string = "GLOBAL: ";
break;
case eValueTypeVariableStatic:
- dump_variable = m_option_variable.show_globals;
+ // Always dump globals since we only fetched them if
+ // m_option_variable.show_scope was true, or this is
+ // a static variable from a block in the current scope
if (dump_variable && m_option_variable.show_scope)
scope_string = "STATIC: ";
break;
@@ -552,6 +528,10 @@ protected:
scope_string = " LOCAL: ";
break;
+ case eValueTypeVariableThreadLocal:
+ if (dump_variable && m_option_variable.show_scope)
+ scope_string = "THREAD: ";
+ break;
default:
break;
}
@@ -572,8 +552,8 @@ protected:
// that are not in scope to avoid extra unneeded output
if (valobj_sp->IsInScope ())
{
- if (false == valobj_sp->GetTargetSP()->GetDisplayRuntimeSupportValues() &&
- true == valobj_sp->IsRuntimeSupportValue())
+ if (!valobj_sp->GetTargetSP()->GetDisplayRuntimeSupportValues() &&
+ valobj_sp->IsRuntimeSupportValue())
continue;
if (!scope_string.empty())
@@ -607,33 +587,28 @@ protected:
return result.Succeeded();
}
-protected:
+protected:
OptionGroupOptions m_option_group;
OptionGroupVariable m_option_variable;
OptionGroupFormat m_option_format;
OptionGroupValueObjectDisplay m_varobj_options;
};
-
#pragma mark CommandObjectMultiwordFrame
//-------------------------------------------------------------------------
// CommandObjectMultiwordFrame
//-------------------------------------------------------------------------
-CommandObjectMultiwordFrame::CommandObjectMultiwordFrame (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "frame",
- "A set of commands for operating on the current thread's frames.",
- "frame <subcommand> [<subcommand-options>]")
+CommandObjectMultiwordFrame::CommandObjectMultiwordFrame(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "frame",
+ "Commands for selecting and examing the current thread's stack frames.",
+ "frame <subcommand> [<subcommand-options>]")
{
LoadSubCommand ("info", CommandObjectSP (new CommandObjectFrameInfo (interpreter)));
LoadSubCommand ("select", CommandObjectSP (new CommandObjectFrameSelect (interpreter)));
LoadSubCommand ("variable", CommandObjectSP (new CommandObjectFrameVariable (interpreter)));
}
-CommandObjectMultiwordFrame::~CommandObjectMultiwordFrame ()
-{
-}
-
+CommandObjectMultiwordFrame::~CommandObjectMultiwordFrame() = default;
diff --git a/source/Commands/CommandObjectHelp.cpp b/source/Commands/CommandObjectHelp.cpp
index 18dc44a32b5af..4cf74885e9980 100644
--- a/source/Commands/CommandObjectHelp.cpp
+++ b/source/Commands/CommandObjectHelp.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectHelp.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "CommandObjectHelp.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/Options.h"
@@ -25,11 +24,36 @@ using namespace lldb_private;
// CommandObjectHelp
//-------------------------------------------------------------------------
-CommandObjectHelp::CommandObjectHelp (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "help",
- "Show a list of all debugger commands, or give details about specific commands.",
- "help [<cmd-name>]"), m_options (interpreter)
+void
+CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage (Stream *s,
+ const char* command,
+ const char* prefix,
+ const char* subcommand,
+ bool include_apropos,
+ bool include_type_lookup)
+{
+ if (s && command && *command)
+ {
+ s->Printf("'%s' is not a known command.\n", command);
+ s->Printf("Try '%shelp' to see a current list of commands.\n", prefix ? prefix : "");
+ if (include_apropos)
+ {
+ s->Printf("Try '%sapropos %s' for a list of related commands.\n",
+ prefix ? prefix : "", subcommand ? subcommand : command);
+ }
+ if (include_type_lookup)
+ {
+ s->Printf("Try '%stype lookup %s' for information on types, methods, functions, modules, etc.",
+ prefix ? prefix : "", subcommand ? subcommand : command);
+ }
+ }
+}
+
+CommandObjectHelp::CommandObjectHelp(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "help",
+ "Show a list of all debugger commands, or give details about a specific command.",
+ "help [<cmd-name>]"),
+ m_options(interpreter)
{
CommandArgumentEntry arg;
CommandArgumentData command_arg;
@@ -45,17 +69,15 @@ CommandObjectHelp::CommandObjectHelp (CommandInterpreter &interpreter) :
m_arguments.push_back (arg);
}
-CommandObjectHelp::~CommandObjectHelp()
-{
-}
+CommandObjectHelp::~CommandObjectHelp() = default;
OptionDefinition
CommandObjectHelp::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Hide aliases in the command list."},
- { LLDB_OPT_SET_ALL, false, "hide-user-commands", 'u', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Hide user-defined commands from the list."},
- { LLDB_OPT_SET_ALL, false, "show-hidden-commands", 'h', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Include commands prefixed with an underscore."},
- { 0, false, NULL, 0, 0, 0, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Hide aliases in the command list."},
+ { LLDB_OPT_SET_ALL, false, "hide-user-commands", 'u', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Hide user-defined commands from the list."},
+ { LLDB_OPT_SET_ALL, false, "show-hidden-commands", 'h', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Include commands prefixed with an underscore."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
bool
@@ -88,17 +110,20 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
bool is_alias_command = m_interpreter.AliasExists (command.GetArgumentAtIndex (0));
std::string alias_name = command.GetArgumentAtIndex(0);
- if (cmd_obj != NULL)
+ if (cmd_obj != nullptr)
{
StringList matches;
bool all_okay = true;
CommandObject *sub_cmd_obj = cmd_obj;
// Loop down through sub_command dictionaries until we find the command object that corresponds
// to the help command entered.
+ std::string sub_command;
for (size_t i = 1; i < argc && all_okay; ++i)
{
- std::string sub_command = command.GetArgumentAtIndex(i);
+ sub_command = command.GetArgumentAtIndex(i);
matches.Clear();
+ if (sub_cmd_obj->IsAlias())
+ sub_cmd_obj = ((CommandAlias*)sub_cmd_obj)->GetUnderlyingCommand().get();
if (! sub_cmd_obj->IsMultiwordObject ())
{
all_okay = false;
@@ -107,7 +132,7 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
{
CommandObject *found_cmd;
found_cmd = sub_cmd_obj->GetSubcommandObject(sub_command.c_str(), &matches);
- if (found_cmd == NULL)
+ if (found_cmd == nullptr)
all_okay = false;
else if (matches.GetSize() > 1)
all_okay = false;
@@ -116,7 +141,7 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
}
}
- if (!all_okay || (sub_cmd_obj == NULL))
+ if (!all_okay || (sub_cmd_obj == nullptr))
{
std::string cmd_string;
command.GetCommandString (cmd_string);
@@ -136,21 +161,22 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
}
else if (!sub_cmd_obj)
{
- result.AppendErrorWithFormat("'%s' is not a known command.\n"
- "Try '%shelp' to see a current list of commands.\n",
- cmd_string.c_str(),
- m_interpreter.GetCommandPrefix());
+ StreamString error_msg_stream;
+ GenerateAdditionalHelpAvenuesMessage(&error_msg_stream,
+ cmd_string.c_str(),
+ m_interpreter.GetCommandPrefix(),
+ sub_command.c_str());
+ result.AppendErrorWithFormat("%s",error_msg_stream.GetData());
result.SetStatus (eReturnStatusFailed);
return false;
}
else
{
- result.GetOutputStream().Printf("'%s' is not a known command.\n"
- "Try '%shelp' to see a current list of commands.\n"
- "The closest match is '%s'. Help on it follows.\n\n",
- cmd_string.c_str(),
- m_interpreter.GetCommandPrefix(),
- sub_cmd_obj->GetCommandName());
+ GenerateAdditionalHelpAvenuesMessage(&result.GetOutputStream(),
+ cmd_string.c_str(),
+ m_interpreter.GetCommandPrefix(),
+ sub_command.c_str());
+ result.GetOutputStream().Printf("\nThe closest match is '%s'. Help on it follows.\n\n", sub_cmd_obj->GetCommandName());
}
}
@@ -159,7 +185,7 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
if (is_alias_command)
{
StreamString sstr;
- m_interpreter.GetAliasHelp (alias_name.c_str(), cmd_obj->GetCommandName(), sstr);
+ m_interpreter.GetAlias(alias_name.c_str())->GetAliasExpansion(sstr);
result.GetOutputStream().Printf ("\n'%s' is an abbreviation for %s\n", alias_name.c_str(), sstr.GetData());
}
}
@@ -185,10 +211,9 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
}
else
{
- result.AppendErrorWithFormat
- ("'%s' is not a known command.\nTry '%shelp' to see a current list of commands.\n",
- command.GetArgumentAtIndex(0),
- m_interpreter.GetCommandPrefix());
+ StreamString error_msg_stream;
+ GenerateAdditionalHelpAvenuesMessage(&error_msg_stream, command.GetArgumentAtIndex(0), m_interpreter.GetCommandPrefix());
+ result.AppendErrorWithFormat("%s",error_msg_stream.GetData());
result.SetStatus (eReturnStatusFailed);
}
}
@@ -198,16 +223,13 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
}
int
-CommandObjectHelp::HandleCompletion
-(
- Args &input,
- int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches
-)
+CommandObjectHelp::HandleCompletion(Args &input,
+ int &cursor_index,
+ int &cursor_char_position,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches)
{
// Return the completions of the commands in the help system:
if (cursor_index == 0)
diff --git a/source/Commands/CommandObjectHelp.h b/source/Commands/CommandObjectHelp.h
index 1dd7b9b8d6a8f..a374a10e3e7d7 100644
--- a/source/Commands/CommandObjectHelp.h
+++ b/source/Commands/CommandObjectHelp.h
@@ -40,6 +40,14 @@ public:
bool &word_complete,
StringList &matches) override;
+ static void
+ GenerateAdditionalHelpAvenuesMessage (Stream *s,
+ const char* command,
+ const char* prefix = nullptr,
+ const char* subcommand = nullptr,
+ bool include_apropos = true,
+ bool include_type_lookup = true);
+
class CommandOptions : public Options
{
public:
diff --git a/source/Commands/CommandObjectLanguage.cpp b/source/Commands/CommandObjectLanguage.cpp
index 5a8f166cb3a6b..ebe33765acc6a 100644
--- a/source/Commands/CommandObjectLanguage.cpp
+++ b/source/Commands/CommandObjectLanguage.cpp
@@ -20,22 +20,14 @@
using namespace lldb;
using namespace lldb_private;
-CommandObjectLanguage::CommandObjectLanguage (CommandInterpreter &interpreter) :
-CommandObjectMultiword (interpreter,
- "language",
- "A set of commands for managing language-specific functionality.'.",
- "language <language-name> <subcommand> [<subcommand-options>]"
- )
+CommandObjectLanguage::CommandObjectLanguage(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "language", "Commands specific to a source language.",
+ "language <language-name> <subcommand> [<subcommand-options>]")
{
//Let the LanguageRuntime populates this command with subcommands
LanguageRuntime::InitializeCommands(this);
}
-void
-CommandObjectLanguage::GenerateHelpText (Stream &output_stream) {
- CommandObjectMultiword::GenerateHelpText(output_stream);
-}
-
CommandObjectLanguage::~CommandObjectLanguage ()
{
}
diff --git a/source/Commands/CommandObjectLanguage.h b/source/Commands/CommandObjectLanguage.h
index 15902bb8ad4b1..6003a590d77da 100644
--- a/source/Commands/CommandObjectLanguage.h
+++ b/source/Commands/CommandObjectLanguage.h
@@ -27,9 +27,6 @@ namespace lldb_private {
~CommandObjectLanguage() override;
- void
- GenerateHelpText(Stream &output_stream) override;
-
protected:
bool
DoExecute (Args& command, CommandReturnObject &result);
diff --git a/source/Commands/CommandObjectLog.cpp b/source/Commands/CommandObjectLog.cpp
index 8e29cd5223b02..ca6b39c0ebfa7 100644
--- a/source/Commands/CommandObjectLog.cpp
+++ b/source/Commands/CommandObjectLog.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectLog.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "CommandObjectLog.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Host/FileSpec.h"
@@ -23,24 +22,20 @@
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Timer.h"
-
#include "lldb/Core/Debugger.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
-
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
-
class CommandObjectLogEnable : public CommandObjectParsed
{
public:
@@ -48,13 +43,12 @@ public:
// Constructors and Destructors
//------------------------------------------------------------------
CommandObjectLogEnable(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "log enable",
- "Enable logging for a single log channel.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "log enable",
+ "Enable logging for a single log channel.",
+ nullptr),
m_options (interpreter)
{
-
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
CommandArgumentData channel_arg;
@@ -77,9 +71,7 @@ public:
m_arguments.push_back (arg2);
}
- ~CommandObjectLogEnable() override
- {
- }
+ ~CommandObjectLogEnable() override = default;
Options *
GetOptions () override
@@ -112,7 +104,6 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
log_file (),
@@ -120,10 +111,7 @@ public:
{
}
-
- ~CommandOptions () override
- {
- }
+ ~CommandOptions () override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -211,17 +199,17 @@ protected:
OptionDefinition
CommandObjectLogEnable::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFilename, "Set the destination file to log to."},
-{ LLDB_OPT_SET_1, false, "threadsafe", 't', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable thread safe logging to avoid interweaved log lines." },
-{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable verbose logging." },
-{ LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable debug logging." },
-{ LLDB_OPT_SET_1, false, "sequence", 's', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with an increasing integer sequence id." },
-{ LLDB_OPT_SET_1, false, "timestamp", 'T', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with a timestamp." },
-{ LLDB_OPT_SET_1, false, "pid-tid", 'p', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." },
-{ LLDB_OPT_SET_1, false, "thread-name",'n', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with the thread name for the thread that generates the log line." },
-{ LLDB_OPT_SET_1, false, "stack", 'S', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Append a stack backtrace to each log line." },
-{ LLDB_OPT_SET_1, false, "append", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Append to the log file instead of overwriting." },
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename, "Set the destination file to log to."},
+{ LLDB_OPT_SET_1, false, "threadsafe", 't', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable thread safe logging to avoid interweaved log lines." },
+{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable verbose logging." },
+{ LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable debug logging." },
+{ LLDB_OPT_SET_1, false, "sequence", 's', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with an increasing integer sequence id." },
+{ LLDB_OPT_SET_1, false, "timestamp", 'T', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with a timestamp." },
+{ LLDB_OPT_SET_1, false, "pid-tid", 'p', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." },
+{ LLDB_OPT_SET_1, false, "thread-name",'n', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with the thread name for the thread that generates the log line." },
+{ LLDB_OPT_SET_1, false, "stack", 'S', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Append a stack backtrace to each log line." },
+{ LLDB_OPT_SET_1, false, "append", 'a', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Append to the log file instead of overwriting." },
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
class CommandObjectLogDisable : public CommandObjectParsed
@@ -231,10 +219,10 @@ public:
// Constructors and Destructors
//------------------------------------------------------------------
CommandObjectLogDisable(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "log disable",
- "Disable one or more log channel categories.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "log disable",
+ "Disable one or more log channel categories.",
+ nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -258,9 +246,7 @@ public:
m_arguments.push_back (arg2);
}
- ~CommandObjectLogDisable() override
- {
- }
+ ~CommandObjectLogDisable() override = default;
protected:
bool
@@ -310,10 +296,10 @@ public:
// Constructors and Destructors
//------------------------------------------------------------------
CommandObjectLogList(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "log list",
- "List the log categories for one or more log channels. If none specified, lists them all.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "log list",
+ "List the log categories for one or more log channels. If none specified, lists them all.",
+ nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData channel_arg;
@@ -329,9 +315,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectLogList() override
- {
- }
+ ~CommandObjectLogList() override = default;
protected:
bool
@@ -392,9 +376,7 @@ public:
{
}
- ~CommandObjectLogTimer() override
- {
- }
+ ~CommandObjectLogTimer() override = default;
protected:
bool
@@ -429,7 +411,6 @@ protected:
Timer::ResetCategoryTimes ();
result.SetStatus(eReturnStatusSuccessFinishResult);
}
-
}
else if (argc == 2)
{
@@ -470,14 +451,9 @@ protected:
}
};
-//----------------------------------------------------------------------
-// CommandObjectLog constructor
-//----------------------------------------------------------------------
-CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "log",
- "A set of commands for operating on logs.",
- "log <command> [<command-options>]")
+CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "log", "Commands controlling LLDB internal logging.",
+ "log <subcommand> [<command-options>]")
{
LoadSubCommand ("enable", CommandObjectSP (new CommandObjectLogEnable (interpreter)));
LoadSubCommand ("disable", CommandObjectSP (new CommandObjectLogDisable (interpreter)));
@@ -485,13 +461,4 @@ CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter) :
LoadSubCommand ("timers", CommandObjectSP (new CommandObjectLogTimer (interpreter)));
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-CommandObjectLog::~CommandObjectLog()
-{
-}
-
-
-
-
+CommandObjectLog::~CommandObjectLog() = default;
diff --git a/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp
index f8fe456d4d467..7065e65ac96b4 100644
--- a/source/Commands/CommandObjectMemory.cpp
+++ b/source/Commands/CommandObjectMemory.cpp
@@ -7,60 +7,62 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectMemory.h"
-
// C Includes
#include <inttypes.h>
// C++ Includes
// Other libraries and framework includes
#include "clang/AST/Decl.h"
+
// Project includes
+#include "CommandObjectMemory.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/Section.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
-#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Interpreter/Options.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
#include "lldb/Interpreter/OptionGroupOutputFile.h"
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
#include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Interpreter/Options.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Target/MemoryHistory.h"
+#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Thread.h"
+#include "lldb/lldb-private.h"
+
using namespace lldb;
using namespace lldb_private;
static OptionDefinition
g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "num-per-line" ,'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."},
- { LLDB_OPT_SET_2, false, "binary" ,'b', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."},
- { LLDB_OPT_SET_3, true , "type" ,'t', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."},
- { LLDB_OPT_SET_3, false , "offset" ,'E', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount ,"How many elements of the specified type to skip before starting to display data."},
+ { LLDB_OPT_SET_1, false, "num-per-line" ,'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeNumberPerLine ,"The number of items per line to display."},
+ { LLDB_OPT_SET_2, false, "binary" ,'b', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."},
+ { LLDB_OPT_SET_3, true , "type" ,'t', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeNone ,"The name of a type to view memory as."},
+ { LLDB_OPT_SET_3, false , "offset" ,'E', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount ,"How many elements of the specified type to skip before starting to display data."},
{ LLDB_OPT_SET_1|
LLDB_OPT_SET_2|
- LLDB_OPT_SET_3, false, "force" ,'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone ,"Necessary if reading over target.max-memory-read-size bytes."},
+ LLDB_OPT_SET_3, false, "force" ,'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone ,"Necessary if reading over target.max-memory-read-size bytes."},
};
-
-
class OptionGroupReadMemory : public OptionGroup
{
public:
-
OptionGroupReadMemory () :
m_num_per_line (1,1),
m_output_as_binary (false),
@@ -69,11 +71,8 @@ public:
{
}
- ~OptionGroupReadMemory () override
- {
- }
-
-
+ ~OptionGroupReadMemory() override = default;
+
uint32_t
GetNumDefinitions () override
{
@@ -206,9 +205,11 @@ public:
if (byte_size_option_set)
{
if (byte_size_value > 1)
- error.SetErrorStringWithFormat ("display format (bytes/bytes with ascii) conflicts with the specified byte size %" PRIu64 "\n"
- "\tconsider using a different display format or don't specify the byte size",
- byte_size_value.GetCurrentValue());
+ error.SetErrorStringWithFormat(
+ "display format (bytes/bytes with ASCII) conflicts with the specified byte size %" PRIu64
+ "\n"
+ "\tconsider using a different display format or don't specify the byte size.",
+ byte_size_value.GetCurrentValue());
}
else
byte_size_value = 1;
@@ -217,6 +218,7 @@ public:
if (!count_option_set)
format_options.GetCountValue() = 32;
break;
+
case eFormatCharArray:
case eFormatChar:
case eFormatCharPrintable:
@@ -227,6 +229,7 @@ public:
if (!count_option_set)
format_options.GetCountValue() = 64;
break;
+
case eFormatComplex:
if (!byte_size_option_set)
byte_size_value = 8;
@@ -235,6 +238,7 @@ public:
if (!count_option_set)
format_options.GetCountValue() = 8;
break;
+
case eFormatComplexInteger:
if (!byte_size_option_set)
byte_size_value = 8;
@@ -243,6 +247,7 @@ public:
if (!count_option_set)
format_options.GetCountValue() = 8;
break;
+
case eFormatHex:
if (!byte_size_option_set)
byte_size_value = 4;
@@ -309,32 +314,26 @@ public:
OptionValueUInt64 m_offset;
};
-
-
//----------------------------------------------------------------------
// Read memory from the inferior process
//----------------------------------------------------------------------
class CommandObjectMemoryRead : public CommandObjectParsed
{
public:
-
- CommandObjectMemoryRead (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "memory read",
- "Read from the memory of the process being debugged.",
- NULL,
- eCommandRequiresTarget | eCommandProcessMustBePaused),
- m_option_group (interpreter),
- m_format_options (eFormatBytesWithASCII, 1, 8),
- m_memory_options (),
- m_outfile_options (),
- m_varobj_options(),
- m_next_addr(LLDB_INVALID_ADDRESS),
- m_prev_byte_size(0),
- m_prev_format_options (eFormatBytesWithASCII, 1, 8),
- m_prev_memory_options (),
- m_prev_outfile_options (),
- m_prev_varobj_options()
+ CommandObjectMemoryRead(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "memory read", "Read from the memory of the current target process.",
+ nullptr, eCommandRequiresTarget | eCommandProcessMustBePaused),
+ m_option_group(interpreter),
+ m_format_options(eFormatBytesWithASCII, 1, 8),
+ m_memory_options(),
+ m_outfile_options(),
+ m_varobj_options(),
+ m_next_addr(LLDB_INVALID_ADDRESS),
+ m_prev_byte_size(0),
+ m_prev_format_options(eFormatBytesWithASCII, 1, 8),
+ m_prev_memory_options(),
+ m_prev_outfile_options(),
+ m_prev_varobj_options()
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -376,9 +375,7 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectMemoryRead () override
- {
- }
+ ~CommandObjectMemoryRead() override = default;
Options *
GetOptions () override
@@ -487,7 +484,7 @@ protected:
{
case '*':
++pointer_count;
- // fall through...
+ LLVM_FALLTHROUGH;
case ' ':
case '\t':
type_str.erase(type_str.size()-1);
@@ -514,6 +511,7 @@ protected:
}
}
+ llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
ConstString lookup_type_name(type_str.c_str());
StackFrame *frame = m_exe_ctx.GetFramePtr();
if (frame)
@@ -524,7 +522,8 @@ protected:
sc.module_sp->FindTypes (sc,
lookup_type_name,
exact_match,
- 1,
+ 1,
+ searched_symbol_files,
type_list);
}
}
@@ -533,7 +532,8 @@ protected:
target->GetImages().FindTypes (sc,
lookup_type_name,
exact_match,
- 1,
+ 1,
+ searched_symbol_files,
type_list);
}
@@ -541,7 +541,7 @@ protected:
{
if (ClangPersistentVariables *persistent_vars = llvm::dyn_cast_or_null<ClangPersistentVariables>(target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC)))
{
- clang::TypeDecl *tdecl = persistent_vars->GetPersistentType(ConstString(lookup_type_name));
+ clang::TypeDecl *tdecl = llvm::dyn_cast_or_null<clang::TypeDecl>(persistent_vars->GetPersistentDecl(ConstString(lookup_type_name)));
if (tdecl)
{
@@ -551,7 +551,7 @@ protected:
}
}
- if (clang_ast_type.IsValid() == false)
+ if (!clang_ast_type.IsValid())
{
if (type_list.GetSize() == 0)
{
@@ -662,7 +662,8 @@ protected:
if (argc == 2)
{
- lldb::addr_t end_addr = Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(1), LLDB_INVALID_ADDRESS, 0);
+ lldb::addr_t end_addr = Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(1),
+ LLDB_INVALID_ADDRESS, nullptr);
if (end_addr == LLDB_INVALID_ADDRESS)
{
result.AppendError("invalid end address expression.");
@@ -702,7 +703,7 @@ protected:
if (clang_ast_type.GetOpaqueQualType())
{
// Make sure we don't display our type as ASCII bytes like the default memory read
- if (m_format_options.GetFormatValue().OptionWasSet() == false)
+ if (!m_format_options.GetFormatValue().OptionWasSet())
m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault);
bytes_read = clang_ast_type.GetByteSize(nullptr) * m_format_options.GetCountValue().GetCurrentValue();
@@ -713,14 +714,14 @@ protected:
else if (m_format_options.GetFormatValue().GetCurrentValue() != eFormatCString)
{
data_sp.reset (new DataBufferHeap (total_byte_size, '\0'));
- if (data_sp->GetBytes() == NULL)
+ if (data_sp->GetBytes() == nullptr)
{
result.AppendErrorWithFormat ("can't allocate 0x%" PRIx32 " bytes for the memory read buffer, specify a smaller size to read", (uint32_t)total_byte_size);
result.SetStatus(eReturnStatusFailed);
return false;
}
- Address address(addr, NULL);
+ Address address(addr, nullptr);
bytes_read = target->ReadMemory(address, false, data_sp->GetBytes (), data_sp->GetByteSize(), error);
if (bytes_read == 0)
{
@@ -750,7 +751,7 @@ protected:
if (!m_format_options.GetCountValue().OptionWasSet())
item_count = 1;
data_sp.reset (new DataBufferHeap ((item_byte_size+1) * item_count, '\0')); // account for NULLs as necessary
- if (data_sp->GetBytes() == NULL)
+ if (data_sp->GetBytes() == nullptr)
{
result.AppendErrorWithFormat ("can't allocate 0x%" PRIx64 " bytes for the memory read buffer, specify a smaller size to read", (uint64_t)((item_byte_size+1) * item_count));
result.SetStatus(eReturnStatusFailed);
@@ -804,7 +805,7 @@ protected:
m_prev_clang_ast_type = clang_ast_type;
StreamFile outfile_stream;
- Stream *output_stream = NULL;
+ Stream *output_stream = nullptr;
const FileSpec &outfile_spec = m_outfile_options.GetFile().GetCurrentValue();
if (outfile_spec)
{
@@ -855,7 +856,6 @@ protected:
output_stream = &result.GetOutputStream();
}
-
ExecutionContextScope *exe_scope = m_exe_ctx.GetBestExecutionContextScope();
if (clang_ast_type.GetOpaqueQualType())
{
@@ -902,7 +902,7 @@ protected:
&& (item_byte_size != 1))
{
// if a count was not passed, or it is 1
- if (m_format_options.GetCountValue().OptionWasSet() == false || item_count == 1)
+ if (!m_format_options.GetCountValue().OptionWasSet() || item_count == 1)
{
// this turns requests such as
// memory read -fc -s10 -c1 *charPtrPtr
@@ -956,10 +956,10 @@ protected:
OptionDefinition
g_memory_find_option_table[] =
{
- { LLDB_OPT_SET_1, false, "expression", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeExpression, "Evaluate an expression to obtain a byte pattern."},
- { LLDB_OPT_SET_2, false, "string", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Use text to find a byte pattern."},
- { LLDB_OPT_SET_1|LLDB_OPT_SET_2, false, "count", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount, "How many times to perform the search."},
- { LLDB_OPT_SET_1|LLDB_OPT_SET_2, false, "dump-offset", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOffset, "When dumping memory for a match, an offset from the match location to start dumping from."},
+ { LLDB_OPT_SET_1, true, "expression", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeExpression, "Evaluate an expression to obtain a byte pattern."},
+ { LLDB_OPT_SET_2, true, "string", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "Use text to find a byte pattern."},
+ { LLDB_OPT_SET_ALL, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount, "How many times to perform the search."},
+ { LLDB_OPT_SET_ALL, false, "dump-offset", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOffset, "When dumping memory for a match, an offset from the match location to start dumping from."},
};
//----------------------------------------------------------------------
@@ -968,7 +968,6 @@ g_memory_find_option_table[] =
class CommandObjectMemoryFind : public CommandObjectParsed
{
public:
-
class OptionGroupFindMemory : public OptionGroup
{
public:
@@ -978,11 +977,9 @@ public:
m_offset(0)
{
}
-
- ~OptionGroupFindMemory () override
- {
- }
-
+
+ ~OptionGroupFindMemory() override = default;
+
uint32_t
GetNumDefinitions () override
{
@@ -1043,15 +1040,12 @@ public:
OptionValueUInt64 m_count;
OptionValueUInt64 m_offset;
};
-
- CommandObjectMemoryFind (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "memory find",
- "Find a value in the memory of the process being debugged.",
- NULL,
- eCommandRequiresProcess | eCommandProcessMustBeLaunched),
- m_option_group (interpreter),
- m_memory_options ()
+
+ CommandObjectMemoryFind(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "memory find", "Find a value in the memory of the current target process.",
+ nullptr, eCommandRequiresProcess | eCommandProcessMustBeLaunched),
+ m_option_group(interpreter),
+ m_memory_options()
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -1076,14 +1070,12 @@ public:
m_arguments.push_back (arg1);
m_arguments.push_back (arg2);
- m_option_group.Append (&m_memory_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_2);
+ m_option_group.Append (&m_memory_options);
m_option_group.Finalize();
}
-
- ~CommandObjectMemoryFind () override
- {
- }
-
+
+ ~CommandObjectMemoryFind() override = default;
+
Options *
GetOptions () override
{
@@ -1136,7 +1128,7 @@ protected:
StackFrame* frame = m_exe_ctx.GetFramePtr();
ValueObjectSP result_sp;
if ((eExpressionCompleted == process->GetTarget().EvaluateExpression(m_memory_options.m_expr.GetStringValue(), frame, result_sp)) &&
- result_sp.get())
+ result_sp)
{
uint64_t value = result_sp->GetValueAsUnsigned(0);
switch (result_sp->GetCompilerType().GetByteSize(nullptr))
@@ -1246,12 +1238,11 @@ protected:
OptionGroupFindMemory m_memory_options;
};
-
OptionDefinition
g_memory_write_option_table[] =
{
-{ LLDB_OPT_SET_1, true, "infile", 'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFilename, "Write memory using the contents of a file."},
-{ LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOffset, "Start writing bytes from an offset within the input file."},
+{ LLDB_OPT_SET_1, true, "infile", 'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename, "Write memory using the contents of a file."},
+{ LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOffset, "Start writing bytes from an offset within the input file."},
};
//----------------------------------------------------------------------
@@ -1260,7 +1251,6 @@ g_memory_write_option_table[] =
class CommandObjectMemoryWrite : public CommandObjectParsed
{
public:
-
class OptionGroupWriteMemory : public OptionGroup
{
public:
@@ -1269,9 +1259,7 @@ public:
{
}
- ~OptionGroupWriteMemory () override
- {
- }
+ ~OptionGroupWriteMemory() override = default;
uint32_t
GetNumDefinitions () override
@@ -1333,15 +1321,12 @@ public:
off_t m_infile_offset;
};
- CommandObjectMemoryWrite (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "memory write",
- "Write to the memory of the process being debugged.",
- NULL,
- eCommandRequiresProcess | eCommandProcessMustBeLaunched),
- m_option_group (interpreter),
- m_format_options (eFormatBytes, 1, UINT64_MAX),
- m_memory_options ()
+ CommandObjectMemoryWrite(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "memory write", "Write to the memory of the current target process.",
+ nullptr, eCommandRequiresProcess | eCommandProcessMustBeLaunched),
+ m_option_group(interpreter),
+ m_format_options(eFormatBytes, 1, UINT64_MAX),
+ m_memory_options()
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -1370,12 +1355,9 @@ public:
m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_SIZE , LLDB_OPT_SET_1|LLDB_OPT_SET_2);
m_option_group.Append (&m_memory_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_2);
m_option_group.Finalize();
-
}
- ~CommandObjectMemoryWrite () override
- {
- }
+ ~CommandObjectMemoryWrite() override = default;
Options *
GetOptions () override
@@ -1551,7 +1533,6 @@ protected:
case eFormatHex:
case eFormatHexUppercase:
case eFormatPointer:
-
// Decode hex bytes
uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 16, &success);
if (!success)
@@ -1699,13 +1680,12 @@ protected:
class CommandObjectMemoryHistory : public CommandObjectParsed
{
public:
-
- CommandObjectMemoryHistory (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "memory history",
- "Prints out the recorded stack traces for allocation/deallocation of a memory address.",
- NULL,
- eCommandRequiresTarget | eCommandRequiresProcess | eCommandProcessMustBePaused | eCommandProcessMustBeLaunched)
+ CommandObjectMemoryHistory(CommandInterpreter &interpreter)
+ : CommandObjectParsed(
+ interpreter, "memory history",
+ "Print recorded stack traces for allocation/deallocation events associated with an address.", nullptr,
+ eCommandRequiresTarget | eCommandRequiresProcess | eCommandProcessMustBePaused |
+ eCommandProcessMustBeLaunched)
{
CommandArgumentEntry arg1;
CommandArgumentData addr_arg;
@@ -1720,11 +1700,9 @@ public:
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back (arg1);
}
-
- ~CommandObjectMemoryHistory () override
- {
- }
-
+
+ ~CommandObjectMemoryHistory() override = default;
+
const char *
GetRepeatCommand (Args &current_command_args, uint32_t index) override
{
@@ -1763,7 +1741,7 @@ protected:
const ProcessSP &process_sp = m_exe_ctx.GetProcessSP();
const MemoryHistorySP &memory_history = MemoryHistory::FindPlugin(process_sp);
- if (! memory_history.get())
+ if (!memory_history)
{
result.AppendError("no available memory history provider");
result.SetStatus(eReturnStatusFailed);
@@ -1780,26 +1758,124 @@ protected:
return true;
}
-
};
+//-------------------------------------------------------------------------
+// CommandObjectMemoryRegion
+//-------------------------------------------------------------------------
+#pragma mark CommandObjectMemoryRegion
+
+class CommandObjectMemoryRegion : public CommandObjectParsed
+{
+public:
+ CommandObjectMemoryRegion(CommandInterpreter &interpreter)
+ : CommandObjectParsed(
+ interpreter, "memory region",
+ "Get information on the memory region containing an address in the current target process.",
+ "memory region ADDR", eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched),
+ m_prev_end_addr(LLDB_INVALID_ADDRESS)
+ {
+ }
+
+ ~CommandObjectMemoryRegion() override = default;
+
+protected:
+ bool
+ DoExecute(Args &command, CommandReturnObject &result) override
+ {
+ ProcessSP process_sp = m_exe_ctx.GetProcessSP();
+ if (process_sp)
+ {
+ Error error;
+ lldb::addr_t load_addr = m_prev_end_addr;
+ m_prev_end_addr = LLDB_INVALID_ADDRESS;
+
+ const size_t argc = command.GetArgumentCount();
+ if (argc > 1 || (argc == 0 && load_addr == LLDB_INVALID_ADDRESS))
+ {
+ result.AppendErrorWithFormat("'%s' takes one argument:\nUsage: %s\n", m_cmd_name.c_str(),
+ m_cmd_syntax.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ }
+ else
+ {
+ const char *load_addr_cstr = command.GetArgumentAtIndex(0);
+ if (command.GetArgumentCount() == 1)
+ {
+ load_addr = Args::StringToAddress(&m_exe_ctx, load_addr_cstr, LLDB_INVALID_ADDRESS, &error);
+ if (error.Fail() || load_addr == LLDB_INVALID_ADDRESS)
+ {
+ result.AppendErrorWithFormat("invalid address argument \"%s\": %s\n", load_addr_cstr,
+ error.AsCString());
+ result.SetStatus(eReturnStatusFailed);
+ }
+ }
+
+ lldb_private::MemoryRegionInfo range_info;
+ error = process_sp->GetMemoryRegionInfo(load_addr, range_info);
+ if (error.Success())
+ {
+ lldb_private::Address addr;
+ ConstString section_name;
+ if (process_sp->GetTarget().ResolveLoadAddress(load_addr, addr))
+ {
+ SectionSP section_sp(addr.GetSection());
+ if (section_sp)
+ {
+ // Got the top most section, not the deepest section
+ while (section_sp->GetParent())
+ section_sp = section_sp->GetParent();
+ section_name = section_sp->GetName();
+ }
+ }
+ result.AppendMessageWithFormat(
+ "[0x%16.16" PRIx64 "-0x%16.16" PRIx64 ") %c%c%c%s%s\n", range_info.GetRange().GetRangeBase(),
+ range_info.GetRange().GetRangeEnd(), range_info.GetReadable() ? 'r' : '-',
+ range_info.GetWritable() ? 'w' : '-', range_info.GetExecutable() ? 'x' : '-',
+ section_name ? " " : "", section_name ? section_name.AsCString() : "");
+ m_prev_end_addr = range_info.GetRange().GetRangeEnd();
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ }
+ else
+ {
+ result.SetStatus(eReturnStatusFailed);
+ result.AppendErrorWithFormat("%s\n", error.AsCString());
+ }
+ }
+ }
+ else
+ {
+ m_prev_end_addr = LLDB_INVALID_ADDRESS;
+ result.AppendError("invalid process");
+ result.SetStatus(eReturnStatusFailed);
+ }
+ return result.Succeeded();
+ }
+
+ const char *
+ GetRepeatCommand(Args &current_command_args, uint32_t index) override
+ {
+ // If we repeat this command, repeat it without any arguments so we can
+ // show the next memory range
+ return m_cmd_name.c_str();
+ }
+
+ lldb::addr_t m_prev_end_addr;
+};
//-------------------------------------------------------------------------
// CommandObjectMemory
//-------------------------------------------------------------------------
-CommandObjectMemory::CommandObjectMemory (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "memory",
- "A set of commands for operating on memory.",
- "memory <subcommand> [<subcommand-options>]")
+CommandObjectMemory::CommandObjectMemory(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "memory", "Commands for operating on memory in the current target process.",
+ "memory <subcommand> [<subcommand-options>]")
{
- LoadSubCommand ("find", CommandObjectSP (new CommandObjectMemoryFind (interpreter)));
- LoadSubCommand ("read", CommandObjectSP (new CommandObjectMemoryRead (interpreter)));
- LoadSubCommand ("write", CommandObjectSP (new CommandObjectMemoryWrite (interpreter)));
- LoadSubCommand ("history", CommandObjectSP (new CommandObjectMemoryHistory (interpreter)));
+ LoadSubCommand("find", CommandObjectSP(new CommandObjectMemoryFind(interpreter)));
+ LoadSubCommand("read", CommandObjectSP(new CommandObjectMemoryRead(interpreter)));
+ LoadSubCommand("write", CommandObjectSP(new CommandObjectMemoryWrite(interpreter)));
+ LoadSubCommand("history", CommandObjectSP(new CommandObjectMemoryHistory(interpreter)));
+ LoadSubCommand("region", CommandObjectSP(new CommandObjectMemoryRegion(interpreter)));
}
-CommandObjectMemory::~CommandObjectMemory ()
-{
-}
+CommandObjectMemory::~CommandObjectMemory() = default;
diff --git a/source/Commands/CommandObjectMultiword.cpp b/source/Commands/CommandObjectMultiword.cpp
index 206f3b6fb7dfe..c951e0bbfa0d9 100644
--- a/source/Commands/CommandObjectMultiword.cpp
+++ b/source/Commands/CommandObjectMultiword.cpp
@@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Interpreter/CommandObjectMultiword.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/Options.h"
@@ -24,22 +24,17 @@ using namespace lldb_private;
// CommandObjectMultiword
//-------------------------------------------------------------------------
-CommandObjectMultiword::CommandObjectMultiword
-(
- CommandInterpreter &interpreter,
- const char *name,
- const char *help,
- const char *syntax,
- uint32_t flags
-) :
+CommandObjectMultiword::CommandObjectMultiword(CommandInterpreter &interpreter,
+ const char *name,
+ const char *help,
+ const char *syntax,
+ uint32_t flags) :
CommandObject (interpreter, name, help, syntax, flags),
m_can_be_removed(false)
{
}
-CommandObjectMultiword::~CommandObjectMultiword ()
-{
-}
+CommandObjectMultiword::~CommandObjectMultiword() = default;
CommandObjectSP
CommandObjectMultiword::GetSubcommandSP (const char *sub_cmd, StringList *matches)
@@ -58,11 +53,10 @@ CommandObjectMultiword::GetSubcommandSP (const char *sub_cmd, StringList *matche
}
else
{
-
StringList local_matches;
- if (matches == NULL)
+ if (matches == nullptr)
matches = &local_matches;
- int num_matches = CommandObject::AddNamesMatchingPartialString (m_subcommand_dict, sub_cmd, *matches);
+ int num_matches = AddNamesMatchingPartialString (m_subcommand_dict, sub_cmd, *matches);
if (num_matches == 1)
{
@@ -86,12 +80,12 @@ CommandObjectMultiword::GetSubcommandObject (const char *sub_cmd, StringList *ma
}
bool
-CommandObjectMultiword::LoadSubCommand
-(
- const char *name,
- const CommandObjectSP& cmd_obj
-)
+CommandObjectMultiword::LoadSubCommand(const char *name,
+ const CommandObjectSP& cmd_obj)
{
+ if (cmd_obj)
+ assert((&GetCommandInterpreter() == &cmd_obj->GetCommandInterpreter()) && "tried to add a CommandObject from a different interpreter");
+
CommandMap::iterator pos;
bool success = true;
@@ -129,7 +123,7 @@ CommandObjectMultiword::Execute(const char *args_string, CommandReturnObject &re
{
StringList matches;
CommandObject *sub_cmd_obj = GetSubcommandObject(sub_command, &matches);
- if (sub_cmd_obj != NULL)
+ if (sub_cmd_obj != nullptr)
{
// Now call CommandObject::Execute to process and options in 'rest_of_line'. From there
// the command-specific version of Execute will be called, with the processed arguments.
@@ -184,10 +178,11 @@ CommandObjectMultiword::GenerateHelpText (Stream &output_stream)
// First time through here, generate the help text for the object and
// push it to the return result object as well
- output_stream.PutCString ("The following subcommands are supported:\n\n");
+ CommandObject::GenerateHelpText(output_stream);
+ output_stream.PutCString("\nThe following subcommands are supported:\n\n");
CommandMap::iterator pos;
- uint32_t max_len = m_interpreter.FindLongestCommandWord (m_subcommand_dict);
+ uint32_t max_len = FindLongestCommandWord (m_subcommand_dict);
if (max_len)
max_len += 4; // Indent the output by 4 spaces.
@@ -199,7 +194,7 @@ CommandObjectMultiword::GenerateHelpText (Stream &output_stream)
if (pos->second->WantsRawCommandString ())
{
std::string help_text (pos->second->GetHelp());
- help_text.append (" This command takes 'raw' input (no need to quote stuff).");
+ help_text.append(" Expects 'raw' input (see 'help raw-input'.)");
m_interpreter.OutputFormattedHelpText (output_stream,
indented_command.c_str(),
"--",
@@ -218,16 +213,13 @@ CommandObjectMultiword::GenerateHelpText (Stream &output_stream)
}
int
-CommandObjectMultiword::HandleCompletion
-(
- Args &input,
- int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches
-)
+CommandObjectMultiword::HandleCompletion(Args &input,
+ int &cursor_index,
+ int &cursor_char_position,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches)
{
// Any of the command matches will provide a complete word, otherwise the individual
// completers will override this.
@@ -236,18 +228,18 @@ CommandObjectMultiword::HandleCompletion
const char *arg0 = input.GetArgumentAtIndex(0);
if (cursor_index == 0)
{
- CommandObject::AddNamesMatchingPartialString (m_subcommand_dict,
- arg0,
- matches);
+ AddNamesMatchingPartialString (m_subcommand_dict,
+ arg0,
+ matches);
if (matches.GetSize() == 1
- && matches.GetStringAtIndex(0) != NULL
+ && matches.GetStringAtIndex(0) != nullptr
&& strcmp (arg0, matches.GetStringAtIndex(0)) == 0)
{
StringList temp_matches;
CommandObject *cmd_obj = GetSubcommandObject (arg0,
&temp_matches);
- if (cmd_obj != NULL)
+ if (cmd_obj != nullptr)
{
if (input.GetArgumentCount() == 1)
{
@@ -275,7 +267,7 @@ CommandObjectMultiword::HandleCompletion
{
CommandObject *sub_command_object = GetSubcommandObject (arg0,
&matches);
- if (sub_command_object == NULL)
+ if (sub_command_object == nullptr)
{
return matches.GetSize();
}
@@ -293,7 +285,6 @@ CommandObjectMultiword::HandleCompletion
word_complete,
matches);
}
-
}
}
@@ -302,14 +293,13 @@ CommandObjectMultiword::GetRepeatCommand (Args &current_command_args, uint32_t i
{
index++;
if (current_command_args.GetArgumentCount() <= index)
- return NULL;
+ return nullptr;
CommandObject *sub_command_object = GetSubcommandObject (current_command_args.GetArgumentAtIndex(index));
- if (sub_command_object == NULL)
- return NULL;
+ if (sub_command_object == nullptr)
+ return nullptr;
return sub_command_object->GetRepeatCommand(current_command_args, index);
}
-
void
CommandObjectMultiword::AproposAllSubCommands (const char *prefix,
const char *search_word,
@@ -340,8 +330,6 @@ CommandObjectMultiword::AproposAllSubCommands (const char *prefix,
}
}
-
-
CommandObjectProxy::CommandObjectProxy (CommandInterpreter &interpreter,
const char *name,
const char *help,
@@ -351,9 +339,7 @@ CommandObjectProxy::CommandObjectProxy (CommandInterpreter &interpreter,
{
}
-CommandObjectProxy::~CommandObjectProxy ()
-{
-}
+CommandObjectProxy::~CommandObjectProxy() = default;
const char *
CommandObjectProxy::GetHelpLong ()
@@ -361,7 +347,7 @@ CommandObjectProxy::GetHelpLong ()
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
return proxy_command->GetHelpLong();
- return NULL;
+ return nullptr;
}
bool
@@ -382,6 +368,15 @@ CommandObjectProxy::IsMultiwordObject ()
return false;
}
+CommandObjectMultiword*
+CommandObjectProxy::GetAsMultiwordCommand ()
+{
+ CommandObject *proxy_command = GetProxyCommandObject();
+ if (proxy_command)
+ return proxy_command->GetAsMultiwordCommand();
+ return nullptr;
+}
+
void
CommandObjectProxy::GenerateHelpText (Stream &result)
{
@@ -405,7 +400,7 @@ CommandObjectProxy::GetSubcommandObject (const char *sub_cmd, StringList *matche
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
return proxy_command->GetSubcommandObject(sub_cmd, matches);
- return NULL;
+ return nullptr;
}
void
@@ -450,17 +445,15 @@ CommandObjectProxy::WantsCompletion()
return false;
}
-
Options *
CommandObjectProxy::GetOptions ()
{
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
return proxy_command->GetOptions ();
- return NULL;
+ return nullptr;
}
-
int
CommandObjectProxy::HandleCompletion (Args &input,
int &cursor_index,
@@ -482,6 +475,7 @@ CommandObjectProxy::HandleCompletion (Args &input,
matches.Clear();
return 0;
}
+
int
CommandObjectProxy::HandleArgumentCompletion (Args &input,
int &cursor_index,
@@ -513,7 +507,7 @@ CommandObjectProxy::GetRepeatCommand (Args &current_command_args,
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
return proxy_command->GetRepeatCommand (current_command_args, index);
- return NULL;
+ return nullptr;
}
bool
@@ -527,5 +521,3 @@ CommandObjectProxy::Execute (const char *args_string,
result.SetStatus (eReturnStatusFailed);
return false;
}
-
-
diff --git a/source/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp
index aad8bea692e7e..99bd63b6bdbba 100644
--- a/source/Commands/CommandObjectPlatform.cpp
+++ b/source/Commands/CommandObjectPlatform.cpp
@@ -7,12 +7,12 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectPlatform.h"
-
// C Includes
// C++ Includes
+#include <mutex>
// Other libraries and framework includes
// Project includes
+#include "CommandObjectPlatform.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
@@ -64,19 +64,19 @@ ParsePermissionString(const char* permissions)
static OptionDefinition
g_permissions_options[] =
{
- { LLDB_OPT_SET_ALL, false, "permissions-value", 'v', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePermissionsNumber , "Give out the numeric value for permissions (e.g. 757)" },
- { LLDB_OPT_SET_ALL, false, "permissions-string", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePermissionsString , "Give out the string value for permissions (e.g. rwxr-xr--)." },
- { LLDB_OPT_SET_ALL, false, "user-read", 'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone , "Allow user to read." },
- { LLDB_OPT_SET_ALL, false, "user-write", 'w', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone , "Allow user to write." },
- { LLDB_OPT_SET_ALL, false, "user-exec", 'x', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone , "Allow user to execute." },
-
- { LLDB_OPT_SET_ALL, false, "group-read", 'R', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone , "Allow group to read." },
- { LLDB_OPT_SET_ALL, false, "group-write", 'W', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone , "Allow group to write." },
- { LLDB_OPT_SET_ALL, false, "group-exec", 'X', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone , "Allow group to execute." },
-
- { LLDB_OPT_SET_ALL, false, "world-read", 'd', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone , "Allow world to read." },
- { LLDB_OPT_SET_ALL, false, "world-write", 't', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone , "Allow world to write." },
- { LLDB_OPT_SET_ALL, false, "world-exec", 'e', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone , "Allow world to execute." },
+ { LLDB_OPT_SET_ALL, false, "permissions-value", 'v', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePermissionsNumber , "Give out the numeric value for permissions (e.g. 757)" },
+ { LLDB_OPT_SET_ALL, false, "permissions-string", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePermissionsString , "Give out the string value for permissions (e.g. rwxr-xr--)." },
+ { LLDB_OPT_SET_ALL, false, "user-read", 'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone , "Allow user to read." },
+ { LLDB_OPT_SET_ALL, false, "user-write", 'w', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone , "Allow user to write." },
+ { LLDB_OPT_SET_ALL, false, "user-exec", 'x', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone , "Allow user to execute." },
+
+ { LLDB_OPT_SET_ALL, false, "group-read", 'R', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone , "Allow group to read." },
+ { LLDB_OPT_SET_ALL, false, "group-write", 'W', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone , "Allow group to write." },
+ { LLDB_OPT_SET_ALL, false, "group-exec", 'X', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone , "Allow group to execute." },
+
+ { LLDB_OPT_SET_ALL, false, "world-read", 'd', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone , "Allow world to read." },
+ { LLDB_OPT_SET_ALL, false, "world-write", 't', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone , "Allow world to write." },
+ { LLDB_OPT_SET_ALL, false, "world-exec", 'e', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone , "Allow world to execute." },
};
class OptionPermissions : public lldb_private::OptionGroup
@@ -85,11 +85,9 @@ public:
OptionPermissions ()
{
}
-
- ~OptionPermissions () override
- {
- }
-
+
+ ~OptionPermissions() override = default;
+
lldb_private::Error
SetOptionValue (CommandInterpreter &interpreter,
uint32_t option_idx,
@@ -117,6 +115,7 @@ public:
else
m_permissions = perms;
}
+ break;
case 'r':
m_permissions |= lldb::eFilePermissionsUserRead;
break;
@@ -144,7 +143,6 @@ public:
case 'e':
m_permissions |= lldb::eFilePermissionsWorldExecute;
break;
-
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
break;
@@ -174,6 +172,7 @@ public:
// Instance variables to hold the values for command options.
uint32_t m_permissions;
+
private:
DISALLOW_COPY_AND_ASSIGN(OptionPermissions);
};
@@ -197,9 +196,7 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectPlatformSelect () override
- {
- }
+ ~CommandObjectPlatformSelect() override = default;
int
HandleCompletion (Args &input,
@@ -213,13 +210,13 @@ public:
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
- CommandCompletions::PlatformPluginNames (m_interpreter,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::PlatformPluginNames(m_interpreter,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -281,17 +278,15 @@ class CommandObjectPlatformList : public CommandObjectParsed
{
public:
CommandObjectPlatformList (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "platform list",
- "List all platforms that are available.",
- NULL,
- 0)
+ CommandObjectParsed(interpreter,
+ "platform list",
+ "List all platforms that are available.",
+ nullptr,
+ 0)
{
}
- ~CommandObjectPlatformList () override
- {
- }
+ ~CommandObjectPlatformList() override = default;
protected:
bool
@@ -309,10 +304,10 @@ protected:
for (idx = 0; 1; ++idx)
{
const char *plugin_name = PluginManager::GetPlatformPluginNameAtIndex (idx);
- if (plugin_name == NULL)
+ if (plugin_name == nullptr)
break;
const char *plugin_desc = PluginManager::GetPlatformPluginDescriptionAtIndex (idx);
- if (plugin_desc == NULL)
+ if (plugin_desc == nullptr)
break;
ostrm.Printf("%s: %s\n", plugin_name, plugin_desc);
}
@@ -334,18 +329,12 @@ protected:
class CommandObjectPlatformStatus : public CommandObjectParsed
{
public:
- CommandObjectPlatformStatus (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "platform status",
- "Display status for the currently selected platform.",
- NULL,
- 0)
+ CommandObjectPlatformStatus(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "platform status", "Display status for the current platform.", nullptr, 0)
{
}
- ~CommandObjectPlatformStatus () override
- {
- }
+ ~CommandObjectPlatformStatus() override = default;
protected:
bool
@@ -383,18 +372,14 @@ protected:
class CommandObjectPlatformConnect : public CommandObjectParsed
{
public:
- CommandObjectPlatformConnect (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "platform connect",
- "Connect a platform by name to be the currently selected platform.",
- "platform connect <connect-url>",
- 0)
+ CommandObjectPlatformConnect(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "platform connect",
+ "Select the current platform by providing a connection URL.",
+ "platform connect <connect-url>", 0)
{
}
- ~CommandObjectPlatformConnect () override
- {
- }
+ ~CommandObjectPlatformConnect() override = default;
protected:
bool
@@ -436,16 +421,15 @@ protected:
GetOptions () override
{
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
- OptionGroupOptions* m_platform_options = NULL;
+ OptionGroupOptions* m_platform_options = nullptr;
if (platform_sp)
{
m_platform_options = platform_sp->GetConnectionOptions(m_interpreter);
- if (m_platform_options != NULL && !m_platform_options->m_did_finalize)
+ if (m_platform_options != nullptr && !m_platform_options->m_did_finalize)
m_platform_options->Finalize();
}
return m_platform_options;
}
-
};
//----------------------------------------------------------------------
@@ -454,18 +438,13 @@ protected:
class CommandObjectPlatformDisconnect : public CommandObjectParsed
{
public:
- CommandObjectPlatformDisconnect (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "platform disconnect",
- "Disconnect a platform by name to be the currently selected platform.",
- "platform disconnect",
- 0)
+ CommandObjectPlatformDisconnect(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "platform disconnect", "Disconnect from the current platform.",
+ "platform disconnect", 0)
{
}
- ~CommandObjectPlatformDisconnect () override
- {
- }
+ ~CommandObjectPlatformDisconnect() override = default;
protected:
bool
@@ -543,11 +522,9 @@ public:
{
m_options.Append (&m_option_working_dir, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
}
-
- ~CommandObjectPlatformSettings () override
- {
- }
-
+
+ ~CommandObjectPlatformSettings() override = default;
+
protected:
bool
DoExecute (Args& args, CommandReturnObject &result) override
@@ -569,18 +546,16 @@ protected:
Options *
GetOptions () override
{
- if (m_options.DidFinalize() == false)
+ if (!m_options.DidFinalize())
m_options.Finalize();
return &m_options;
}
+
protected:
-
OptionGroupOptions m_options;
OptionGroupFile m_option_working_dir;
-
};
-
//----------------------------------------------------------------------
// "platform mkdir"
//----------------------------------------------------------------------
@@ -588,19 +563,17 @@ class CommandObjectPlatformMkDir : public CommandObjectParsed
{
public:
CommandObjectPlatformMkDir (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "platform mkdir",
- "Make a new directory on the remote end.",
- NULL,
- 0),
- m_options(interpreter)
+ CommandObjectParsed(interpreter,
+ "platform mkdir",
+ "Make a new directory on the remote end.",
+ nullptr,
+ 0),
+ m_options(interpreter)
{
}
-
- ~CommandObjectPlatformMkDir () override
- {
- }
-
+
+ ~CommandObjectPlatformMkDir() override = default;
+
bool
DoExecute (Args& args, CommandReturnObject &result) override
{
@@ -637,15 +610,15 @@ public:
Options *
GetOptions () override
{
- if (m_options.DidFinalize() == false)
+ if (!m_options.DidFinalize())
{
m_options.Append(new OptionPermissions());
m_options.Finalize();
}
return &m_options;
}
+
OptionGroupOptions m_options;
-
};
//----------------------------------------------------------------------
@@ -655,19 +628,17 @@ class CommandObjectPlatformFOpen : public CommandObjectParsed
{
public:
CommandObjectPlatformFOpen (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "platform file open",
- "Open a file on the remote end.",
- NULL,
- 0),
- m_options(interpreter)
- {
- }
-
- ~CommandObjectPlatformFOpen () override
+ CommandObjectParsed(interpreter,
+ "platform file open",
+ "Open a file on the remote end.",
+ nullptr,
+ 0),
+ m_options(interpreter)
{
}
-
+
+ ~CommandObjectPlatformFOpen() override = default;
+
bool
DoExecute (Args& args, CommandReturnObject &result) override
{
@@ -706,16 +677,18 @@ public:
}
return result.Succeeded();
}
+
Options *
GetOptions () override
{
- if (m_options.DidFinalize() == false)
+ if (!m_options.DidFinalize())
{
m_options.Append(new OptionPermissions());
m_options.Finalize();
}
return &m_options;
}
+
OptionGroupOptions m_options;
};
@@ -726,18 +699,16 @@ class CommandObjectPlatformFClose : public CommandObjectParsed
{
public:
CommandObjectPlatformFClose (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "platform file close",
- "Close a file on the remote end.",
- NULL,
- 0)
+ CommandObjectParsed(interpreter,
+ "platform file close",
+ "Close a file on the remote end.",
+ nullptr,
+ 0)
{
}
-
- ~CommandObjectPlatformFClose () override
- {
- }
-
+
+ ~CommandObjectPlatformFClose() override = default;
+
bool
DoExecute (Args& args, CommandReturnObject &result) override
{
@@ -776,19 +747,17 @@ class CommandObjectPlatformFRead : public CommandObjectParsed
{
public:
CommandObjectPlatformFRead (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "platform file read",
- "Read data from a file on the remote end.",
- NULL,
- 0),
- m_options (interpreter)
- {
- }
-
- ~CommandObjectPlatformFRead () override
+ CommandObjectParsed(interpreter,
+ "platform file read",
+ "Read data from a file on the remote end.",
+ nullptr,
+ 0),
+ m_options (interpreter)
{
}
-
+
+ ~CommandObjectPlatformFRead() override = default;
+
bool
DoExecute (Args& args, CommandReturnObject &result) override
{
@@ -812,6 +781,7 @@ public:
}
return result.Succeeded();
}
+
Options *
GetOptions () override
{
@@ -822,16 +792,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
{
@@ -851,7 +818,6 @@ protected:
if (!success)
error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
break;
-
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
break;
@@ -882,17 +848,18 @@ protected:
uint32_t m_offset;
uint32_t m_count;
};
+
CommandOptions m_options;
};
+
OptionDefinition
CommandObjectPlatformFRead::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "offset" , 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeIndex , "Offset into the file at which to start reading." },
- { LLDB_OPT_SET_1, false, "count" , 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount , "Number of bytes to read from the file." },
- { 0 , false, NULL , 0 , 0 , NULL, NULL, 0, eArgTypeNone , NULL }
+ { LLDB_OPT_SET_1, false, "offset" , 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeIndex , "Offset into the file at which to start reading." },
+ { LLDB_OPT_SET_1, false, "count" , 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount , "Number of bytes to read from the file." },
+ { 0 , false, nullptr , 0 , 0 , nullptr, nullptr, 0, eArgTypeNone , nullptr }
};
-
//----------------------------------------------------------------------
// "platform fwrite"
//----------------------------------------------------------------------
@@ -900,19 +867,17 @@ class CommandObjectPlatformFWrite : public CommandObjectParsed
{
public:
CommandObjectPlatformFWrite (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "platform file write",
- "Write data to a file on the remote end.",
- NULL,
- 0),
- m_options (interpreter)
- {
- }
-
- ~CommandObjectPlatformFWrite () override
+ CommandObjectParsed(interpreter,
+ "platform file write",
+ "Write data to a file on the remote end.",
+ nullptr,
+ 0),
+ m_options (interpreter)
{
}
-
+
+ ~CommandObjectPlatformFWrite() override = default;
+
bool
DoExecute (Args& args, CommandReturnObject &result) override
{
@@ -938,6 +903,7 @@ public:
}
return result.Succeeded();
}
+
Options *
GetOptions () override
{
@@ -948,16 +914,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
{
@@ -975,7 +938,6 @@ protected:
case 'd':
m_data.assign(option_arg);
break;
-
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
break;
@@ -1006,14 +968,16 @@ protected:
uint32_t m_offset;
std::string m_data;
};
+
CommandOptions m_options;
};
+
OptionDefinition
CommandObjectPlatformFWrite::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "offset" , 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeIndex , "Offset into the file at which to start reading." },
- { LLDB_OPT_SET_1, false, "data" , 'd', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeValue , "Text to write to the file." },
- { 0 , false, NULL , 0 , 0 , NULL, NULL, 0, eArgTypeNone , NULL }
+ { LLDB_OPT_SET_1, false, "offset" , 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeIndex , "Offset into the file at which to start reading." },
+ { LLDB_OPT_SET_1, false, "data" , 'd', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeValue , "Text to write to the file." },
+ { 0 , false, nullptr , 0 , 0 , nullptr, nullptr, 0, eArgTypeNone , nullptr }
};
class CommandObjectPlatformFile : public CommandObjectMultiword
@@ -1022,22 +986,18 @@ public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- CommandObjectPlatformFile (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "platform file",
- "A set of commands to manage file access through a platform",
- "platform file [open|close|read|write] ...")
+ CommandObjectPlatformFile(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "platform file", "Commands to access files on the current platform.",
+ "platform file [open|close|read|write] ...")
{
LoadSubCommand ("open", CommandObjectSP (new CommandObjectPlatformFOpen (interpreter)));
LoadSubCommand ("close", CommandObjectSP (new CommandObjectPlatformFClose (interpreter)));
LoadSubCommand ("read", CommandObjectSP (new CommandObjectPlatformFRead (interpreter)));
LoadSubCommand ("write", CommandObjectSP (new CommandObjectPlatformFWrite (interpreter)));
}
-
- ~CommandObjectPlatformFile () override
- {
- }
-
+
+ ~CommandObjectPlatformFile() override = default;
+
private:
//------------------------------------------------------------------
// For CommandObjectPlatform only
@@ -1085,11 +1045,9 @@ R"(Examples:
m_arguments.push_back (arg1);
m_arguments.push_back (arg2);
}
-
- ~CommandObjectPlatformGetFile () override
- {
- }
-
+
+ ~CommandObjectPlatformGetFile() override = default;
+
bool
DoExecute (Args& args, CommandReturnObject &result) override
{
@@ -1162,11 +1120,9 @@ R"(Examples:
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back (arg1);
}
-
- ~CommandObjectPlatformGetSize () override
- {
- }
-
+
+ ~CommandObjectPlatformGetSize() override = default;
+
bool
DoExecute (Args& args, CommandReturnObject &result) override
{
@@ -1210,18 +1166,16 @@ class CommandObjectPlatformPutFile : public CommandObjectParsed
{
public:
CommandObjectPlatformPutFile (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "platform put-file",
- "Transfer a file from this system to the remote end.",
- NULL,
- 0)
+ CommandObjectParsed(interpreter,
+ "platform put-file",
+ "Transfer a file from this system to the remote end.",
+ nullptr,
+ 0)
{
}
-
- ~CommandObjectPlatformPutFile () override
- {
- }
-
+
+ ~CommandObjectPlatformPutFile() override = default;
+
bool
DoExecute (Args& args, CommandReturnObject &result) override
{
@@ -1269,11 +1223,9 @@ public:
m_options (interpreter)
{
}
-
- ~CommandObjectPlatformProcessLaunch () override
- {
- }
-
+
+ ~CommandObjectPlatformProcessLaunch() override = default;
+
Options *
GetOptions () override
{
@@ -1368,8 +1320,6 @@ protected:
ProcessLaunchCommandOptions m_options;
};
-
-
//----------------------------------------------------------------------
// "platform process list"
//----------------------------------------------------------------------
@@ -1385,11 +1335,9 @@ public:
m_options (interpreter)
{
}
-
- ~CommandObjectPlatformProcessList () override
- {
- }
-
+
+ ~CommandObjectPlatformProcessList() override = default;
+
Options *
GetOptions () override
{
@@ -1416,7 +1364,6 @@ protected:
Error error;
if (args.GetArgumentCount() == 0)
{
-
if (platform_sp)
{
Stream &ostrm = result.GetOutputStream();
@@ -1441,7 +1388,7 @@ protected:
{
ProcessInstanceInfoList proc_infos;
const uint32_t matches = platform_sp->FindProcesses (m_options.match_info, proc_infos);
- const char *match_desc = NULL;
+ const char *match_desc = nullptr;
const char *match_name = m_options.match_info.GetProcessInfo().GetName();
if (match_name && match_name[0])
{
@@ -1504,17 +1451,34 @@ protected:
class CommandOptions : public Options
{
public:
-
- CommandOptions (CommandInterpreter &interpreter) :
- Options (interpreter),
- match_info ()
- {
- }
-
- ~CommandOptions () override
- {
+ CommandOptions(CommandInterpreter &interpreter) :
+ Options(interpreter),
+ match_info(),
+ show_args(false),
+ verbose(false)
+ {
+ static std::once_flag g_once_flag;
+ std::call_once(g_once_flag, []() {
+ PosixPlatformCommandOptionValidator *posix_validator = new PosixPlatformCommandOptionValidator();
+ for (size_t i=0; g_option_table[i].short_option != 0; ++i)
+ {
+ switch (g_option_table[i].short_option)
+ {
+ case 'u':
+ case 'U':
+ case 'g':
+ case 'G':
+ g_option_table[i].validator = posix_validator;
+ break;
+ default:
+ break;
+ }
+ }
+ });
}
-
+
+ ~CommandOptions() override = default;
+
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -1622,39 +1586,35 @@ protected:
// Options table: Required for subclasses of Options.
static OptionDefinition g_option_table[];
-
+
// Instance variables to hold the values for command options.
ProcessInstanceInfoMatch match_info;
bool show_args;
bool verbose;
};
+
CommandOptions m_options;
};
-namespace
-{
- PosixPlatformCommandOptionValidator g_posix_validator;
-}
-
OptionDefinition
CommandObjectPlatformProcessList::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1 , false, "pid" , 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePid , "List the process info for a specific process ID." },
-{ LLDB_OPT_SET_2 , true , "name" , 'n', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeProcessName , "Find processes with executable basenames that match a string." },
-{ LLDB_OPT_SET_3 , true , "ends-with" , 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeProcessName , "Find processes with executable basenames that end with a string." },
-{ LLDB_OPT_SET_4 , true , "starts-with", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeProcessName , "Find processes with executable basenames that start with a string." },
-{ LLDB_OPT_SET_5 , true , "contains" , 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeProcessName , "Find processes with executable basenames that contain a string." },
-{ LLDB_OPT_SET_6 , true , "regex" , 'r', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeRegularExpression, "Find processes with executable basenames that match a regular expression." },
-{ LLDB_OPT_SET_FROM_TO(2, 6), false, "parent" , 'P', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePid , "Find processes that have a matching parent process ID." },
-{ LLDB_OPT_SET_FROM_TO(2, 6), false, "uid" , 'u', OptionParser::eRequiredArgument, &g_posix_validator, NULL, 0, eArgTypeUnsignedInteger , "Find processes that have a matching user ID." },
-{ LLDB_OPT_SET_FROM_TO(2, 6), false, "euid" , 'U', OptionParser::eRequiredArgument, &g_posix_validator, NULL, 0, eArgTypeUnsignedInteger , "Find processes that have a matching effective user ID." },
-{ LLDB_OPT_SET_FROM_TO(2, 6), false, "gid" , 'g', OptionParser::eRequiredArgument, &g_posix_validator, NULL, 0, eArgTypeUnsignedInteger , "Find processes that have a matching group ID." },
-{ LLDB_OPT_SET_FROM_TO(2, 6), false, "egid" , 'G', OptionParser::eRequiredArgument, &g_posix_validator, NULL, 0, eArgTypeUnsignedInteger , "Find processes that have a matching effective group ID." },
-{ LLDB_OPT_SET_FROM_TO(2, 6), false, "arch" , 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeArchitecture , "Find processes that have a matching architecture." },
-{ LLDB_OPT_SET_FROM_TO(1, 6), false, "show-args" , 'A', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone , "Show process arguments instead of the process executable basename." },
-{ LLDB_OPT_SET_FROM_TO(1, 6), false, "verbose" , 'v', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone , "Enable verbose output." },
-{ 0 , false, NULL , 0 , 0 , NULL, NULL, 0, eArgTypeNone , NULL }
+{ LLDB_OPT_SET_1 , false, "pid" , 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePid , "List the process info for a specific process ID." },
+{ LLDB_OPT_SET_2 , true , "name" , 'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeProcessName , "Find processes with executable basenames that match a string." },
+{ LLDB_OPT_SET_3 , true , "ends-with" , 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeProcessName , "Find processes with executable basenames that end with a string." },
+{ LLDB_OPT_SET_4 , true , "starts-with", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeProcessName , "Find processes with executable basenames that start with a string." },
+{ LLDB_OPT_SET_5 , true , "contains" , 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeProcessName , "Find processes with executable basenames that contain a string." },
+{ LLDB_OPT_SET_6 , true , "regex" , 'r', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeRegularExpression, "Find processes with executable basenames that match a regular expression." },
+{ LLDB_OPT_SET_FROM_TO(2, 6), false, "parent" , 'P', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePid , "Find processes that have a matching parent process ID." },
+{ LLDB_OPT_SET_FROM_TO(2, 6), false, "uid" , 'u', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeUnsignedInteger , "Find processes that have a matching user ID." },
+{ LLDB_OPT_SET_FROM_TO(2, 6), false, "euid" , 'U', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeUnsignedInteger , "Find processes that have a matching effective user ID." },
+{ LLDB_OPT_SET_FROM_TO(2, 6), false, "gid" , 'g', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeUnsignedInteger , "Find processes that have a matching group ID." },
+{ LLDB_OPT_SET_FROM_TO(2, 6), false, "egid" , 'G', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeUnsignedInteger , "Find processes that have a matching effective group ID." },
+{ LLDB_OPT_SET_FROM_TO(2, 6), false, "arch" , 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeArchitecture , "Find processes that have a matching architecture." },
+{ LLDB_OPT_SET_FROM_TO(1, 6), false, "show-args" , 'A', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone , "Show process arguments instead of the process executable basename." },
+{ LLDB_OPT_SET_FROM_TO(1, 6), false, "verbose" , 'v', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone , "Enable verbose output." },
+{ 0 , false, nullptr , 0 , 0 , nullptr, nullptr, 0, eArgTypeNone , nullptr }
};
//----------------------------------------------------------------------
@@ -1683,11 +1643,9 @@ public:
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back (arg);
}
-
- ~CommandObjectPlatformProcessInfo () override
- {
- }
-
+
+ ~CommandObjectPlatformProcessInfo() override = default;
+
protected:
bool
DoExecute (Args& args, CommandReturnObject &result) override
@@ -1766,22 +1724,18 @@ protected:
class CommandObjectPlatformProcessAttach : public CommandObjectParsed
{
public:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options(interpreter)
{
// Keep default values of all options in one place: OptionParsingStarting ()
OptionParsingStarting ();
}
-
- ~CommandOptions () override
- {
- }
-
+
+ ~CommandOptions() override = default;
+
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -1859,7 +1813,7 @@ public:
// Look to see if there is a -P argument provided, and if so use that plugin, otherwise
// use the default plugin.
- const char *partial_name = NULL;
+ const char *partial_name = nullptr;
partial_name = input.GetArgumentAtIndex(opt_arg_pos);
PlatformSP platform_sp (m_interpreter.GetPlatform (true));
@@ -1905,11 +1859,9 @@ public:
m_options (interpreter)
{
}
-
- ~CommandObjectPlatformProcessAttach () override
- {
- }
-
+
+ ~CommandObjectPlatformProcessAttach() override = default;
+
bool
DoExecute (Args& command,
CommandReturnObject &result) override
@@ -1919,13 +1871,13 @@ public:
{
Error err;
ProcessSP remote_process_sp =
- platform_sp->Attach(m_options.attach_info, m_interpreter.GetDebugger(), NULL, err);
+ platform_sp->Attach(m_options.attach_info, m_interpreter.GetDebugger(), nullptr, err);
if (err.Fail())
{
result.AppendError(err.AsCString());
result.SetStatus (eReturnStatusFailed);
}
- else if (remote_process_sp.get() == NULL)
+ else if (!remote_process_sp)
{
result.AppendError("could not attach: unknown reason");
result.SetStatus (eReturnStatusFailed);
@@ -1948,45 +1900,38 @@ public:
}
protected:
-
CommandOptions m_options;
};
-
OptionDefinition
CommandObjectPlatformProcessAttach::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "plugin", 'P' , OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
- { LLDB_OPT_SET_1, false, "pid", 'p' , OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePid, "The process ID of an existing process to attach to."},
- { LLDB_OPT_SET_2, false, "name", 'n' , OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeProcessName, "The name of the process to attach to."},
- { LLDB_OPT_SET_2, false, "waitfor", 'w' , OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Wait for the process with <process-name> to launch."},
- { 0, false, NULL , 0 , 0 , NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "plugin", 'P' , OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
+ { LLDB_OPT_SET_1, false, "pid", 'p' , OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePid, "The process ID of an existing process to attach to."},
+ { LLDB_OPT_SET_2, false, "name", 'n' , OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeProcessName, "The name of the process to attach to."},
+ { LLDB_OPT_SET_2, false, "waitfor", 'w' , OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Wait for the process with <process-name> to launch."},
+ { 0, false, nullptr , 0 , 0 , nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
class CommandObjectPlatformProcess : public CommandObjectMultiword
{
public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- CommandObjectPlatformProcess (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "platform process",
- "A set of commands to query, launch and attach to platform processes",
- "platform process [attach|launch|list] ...")
+ CommandObjectPlatformProcess(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "platform process",
+ "Commands to query, launch and attach to processes on the current platform.",
+ "platform process [attach|launch|list] ...")
{
LoadSubCommand ("attach", CommandObjectSP (new CommandObjectPlatformProcessAttach (interpreter)));
LoadSubCommand ("launch", CommandObjectSP (new CommandObjectPlatformProcessLaunch (interpreter)));
LoadSubCommand ("info" , CommandObjectSP (new CommandObjectPlatformProcessInfo (interpreter)));
LoadSubCommand ("list" , CommandObjectSP (new CommandObjectPlatformProcessList (interpreter)));
-
- }
-
- ~CommandObjectPlatformProcess () override
- {
}
-
+
+ ~CommandObjectPlatformProcess() override = default;
+
private:
//------------------------------------------------------------------
// For CommandObjectPlatform only
@@ -2000,21 +1945,17 @@ private:
class CommandObjectPlatformShell : public CommandObjectRaw
{
public:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options(interpreter),
timeout(10)
{
}
-
- ~CommandOptions () override
- {
- }
-
+
+ ~CommandOptions() override = default;
+
virtual uint32_t
GetNumDefinitions ()
{
@@ -2063,21 +2004,16 @@ public:
static OptionDefinition g_option_table[];
uint32_t timeout;
};
-
- CommandObjectPlatformShell (CommandInterpreter &interpreter) :
- CommandObjectRaw (interpreter,
- "platform shell",
- "Run a shell command on the selected platform.",
- "platform shell <shell-command>",
- 0),
- m_options(interpreter)
- {
- }
-
- ~CommandObjectPlatformShell () override
+
+ CommandObjectPlatformShell(CommandInterpreter &interpreter)
+ : CommandObjectRaw(interpreter, "platform shell", "Run a shell command on the current platform.",
+ "platform shell <shell-command>", 0),
+ m_options(interpreter)
{
}
-
+
+ ~CommandObjectPlatformShell() override = default;
+
Options *
GetOptions () override
{
@@ -2089,7 +2025,7 @@ public:
{
m_options.NotifyOptionParsingStarting();
- const char* expr = NULL;
+ const char* expr = nullptr;
// Print out an usage syntax on an empty command line.
if (raw_command_line[0] == '\0')
@@ -2101,7 +2037,7 @@ public:
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])
{
@@ -2128,7 +2064,7 @@ public:
}
}
- if (expr == NULL)
+ if (expr == nullptr)
expr = raw_command_line;
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
@@ -2173,17 +2109,17 @@ public:
}
return true;
}
+
CommandOptions m_options;
};
OptionDefinition
CommandObjectPlatformShell::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "timeout", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeValue, "Seconds to wait for the remote host to finish running the command."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "timeout", 't', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeValue, "Seconds to wait for the remote host to finish running the command."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
//----------------------------------------------------------------------
// "platform install" - install a target to a remote end
//----------------------------------------------------------------------
@@ -2198,11 +2134,9 @@ public:
0)
{
}
-
- ~CommandObjectPlatformInstall () override
- {
- }
-
+
+ ~CommandObjectPlatformInstall() override = default;
+
bool
DoExecute (Args& args, CommandReturnObject &result) override
{
@@ -2215,7 +2149,7 @@ public:
// TODO: move the bulk of this code over to the platform itself
FileSpec src(args.GetArgumentAtIndex(0), true);
FileSpec dst(args.GetArgumentAtIndex(1), false);
- if (src.Exists() == false)
+ if (!src.Exists())
{
result.AppendError("source location does not exist or is not accessible");
result.SetStatus(eReturnStatusFailed);
@@ -2241,18 +2175,11 @@ public:
}
return result.Succeeded();
}
-private:
-
};
-//----------------------------------------------------------------------
-// CommandObjectPlatform constructor
-//----------------------------------------------------------------------
-CommandObjectPlatform::CommandObjectPlatform(CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "platform",
- "A set of commands to manage and create platforms.",
- "platform [connect|disconnect|info|list|status|select] ...")
+CommandObjectPlatform::CommandObjectPlatform(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "platform", "Commands to manage and create platforms.",
+ "platform [connect|disconnect|info|list|status|select] ...")
{
LoadSubCommand ("select", CommandObjectSP (new CommandObjectPlatformSelect (interpreter)));
LoadSubCommand ("list" , CommandObjectSP (new CommandObjectPlatformList (interpreter)));
@@ -2270,9 +2197,4 @@ CommandObjectPlatform::CommandObjectPlatform(CommandInterpreter &interpreter) :
LoadSubCommand ("target-install", CommandObjectSP (new CommandObjectPlatformInstall (interpreter)));
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-CommandObjectPlatform::~CommandObjectPlatform()
-{
-}
+CommandObjectPlatform::~CommandObjectPlatform() = default;
diff --git a/source/Commands/CommandObjectPlugin.cpp b/source/Commands/CommandObjectPlugin.cpp
index 4c5a089dbcec2..221c9a67d8488 100644
--- a/source/Commands/CommandObjectPlugin.cpp
+++ b/source/Commands/CommandObjectPlugin.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectPlugin.cpp ----------------------------------*- C++ -*-===//
+//===-- CommandObjectPlugin.cpp ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,10 +7,12 @@
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "CommandObjectPlugin.h"
-
#include "lldb/Host/Host.h"
-
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -19,13 +21,12 @@ using namespace lldb_private;
class CommandObjectPluginLoad : public CommandObjectParsed
{
-private:
public:
CommandObjectPluginLoad (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "plugin load",
- "Import a dylib that implements an LLDB plugin.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "plugin load",
+ "Import a dylib that implements an LLDB plugin.",
+ nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentData cmd_arg;
@@ -40,11 +41,9 @@ public:
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back (arg1);
}
-
- ~CommandObjectPluginLoad () override
- {
- }
-
+
+ ~CommandObjectPluginLoad() override = default;
+
int
HandleArgumentCompletion (Args &input,
int &cursor_index,
@@ -58,14 +57,14 @@ public:
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eDiskFileCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eDiskFileCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -100,15 +99,11 @@ protected:
}
};
-CommandObjectPlugin::CommandObjectPlugin (CommandInterpreter &interpreter) :
-CommandObjectMultiword (interpreter,
- "plugin",
- "A set of commands for managing or customizing plugin commands.",
- "plugin <subcommand> [<subcommand-options>]")
+CommandObjectPlugin::CommandObjectPlugin(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "plugin", "Commands for managing LLDB plugins.",
+ "plugin <subcommand> [<subcommand-options>]")
{
LoadSubCommand ("load", CommandObjectSP (new CommandObjectPluginLoad (interpreter)));
}
-CommandObjectPlugin::~CommandObjectPlugin ()
-{
-}
+CommandObjectPlugin::~CommandObjectPlugin() = default;
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index a85ea179abb89..106e2d86b18c1 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectProcess.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "CommandObjectProcess.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointSite.h"
@@ -46,8 +45,9 @@ public:
const char *new_process_action) :
CommandObjectParsed (interpreter, name, help, syntax, flags),
m_new_process_action (new_process_action) {}
-
- ~CommandObjectProcessLaunchOrAttach () override {}
+
+ ~CommandObjectProcessLaunchOrAttach() override = default;
+
protected:
bool
StopProcessIfNecessary (Process *process, StateType &state, CommandReturnObject &result)
@@ -81,7 +81,7 @@ protected:
if (detach_error.Success())
{
result.SetStatus (eReturnStatusSuccessFinishResult);
- process = NULL;
+ process = nullptr;
}
else
{
@@ -95,7 +95,7 @@ protected:
if (destroy_error.Success())
{
result.SetStatus (eReturnStatusSuccessFinishResult);
- process = NULL;
+ process = nullptr;
}
else
{
@@ -108,8 +108,10 @@ protected:
}
return result.Succeeded();
}
+
std::string m_new_process_action;
};
+
//-------------------------------------------------------------------------
// CommandObjectProcessLaunch
//-------------------------------------------------------------------------
@@ -117,14 +119,13 @@ protected:
class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach
{
public:
-
CommandObjectProcessLaunch (CommandInterpreter &interpreter) :
- CommandObjectProcessLaunchOrAttach (interpreter,
- "process launch",
- "Launch the executable in the debugger.",
- NULL,
- eCommandRequiresTarget,
- "restart"),
+ CommandObjectProcessLaunchOrAttach(interpreter,
+ "process launch",
+ "Launch the executable in the debugger.",
+ nullptr,
+ eCommandRequiresTarget,
+ "restart"),
m_options (interpreter)
{
CommandArgumentEntry arg;
@@ -141,10 +142,7 @@ public:
m_arguments.push_back (arg);
}
-
- ~CommandObjectProcessLaunch () override
- {
- }
+ ~CommandObjectProcessLaunch() override = default;
int
HandleArgumentCompletion (Args &input,
@@ -159,14 +157,14 @@ public:
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eDiskFileCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eDiskFileCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -189,10 +187,10 @@ protected:
{
Debugger &debugger = m_interpreter.GetDebugger();
Target *target = debugger.GetSelectedTarget().get();
- // If our listener is NULL, users aren't allows to launch
+ // If our listener is nullptr, users aren't allows to launch
ModuleSP exe_module_sp = target->GetExecutableModule();
- if (exe_module_sp == NULL)
+ if (exe_module_sp == nullptr)
{
result.AppendError ("no file in target, create a debug target using the 'target create' command");
result.SetStatus (eReturnStatusFailed);
@@ -305,15 +303,15 @@ protected:
//OptionDefinition
//CommandObjectProcessLaunch::CommandOptions::g_option_table[] =
//{
-//{ SET1 | SET2 | SET3, false, "stop-at-entry", 's', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."},
-//{ SET1 , false, "stdin", 'i', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stdin for the process to <path>."},
-//{ SET1 , false, "stdout", 'o', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stdout for the process to <path>."},
-//{ SET1 , false, "stderr", 'e', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stderr for the process to <path>."},
-//{ SET1 | SET2 | SET3, false, "plugin", 'p', OptionParser::eRequiredArgument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
-//{ SET2 , false, "tty", 't', OptionParser::eOptionalArgument, NULL, 0, eArgTypeDirectoryName, "Start the process in a terminal. If <path> is specified, look for a terminal whose name contains <path>, else start the process in a new terminal."},
-//{ SET3, false, "no-stdio", 'n', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."},
-//{ SET1 | SET2 | SET3, false, "working-dir", 'w', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Set the current working directory to <path> when running the inferior."},
-//{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+//{ SET1 | SET2 | SET3, false, "stop-at-entry", 's', OptionParser::eNoArgument, nullptr, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."},
+//{ SET1 , false, "stdin", 'i', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Redirect stdin for the process to <path>."},
+//{ SET1 , false, "stdout", 'o', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Redirect stdout for the process to <path>."},
+//{ SET1 , false, "stderr", 'e', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Redirect stderr for the process to <path>."},
+//{ SET1 | SET2 | SET3, false, "plugin", 'p', OptionParser::eRequiredArgument, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
+//{ SET2 , false, "tty", 't', OptionParser::eOptionalArgument, nullptr, 0, eArgTypeDirectoryName, "Start the process in a terminal. If <path> is specified, look for a terminal whose name contains <path>, else start the process in a new terminal."},
+//{ SET3, false, "no-stdio", 'n', OptionParser::eNoArgument, nullptr, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."},
+//{ SET1 | SET2 | SET3, false, "working-dir", 'w', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Set the current working directory to <path> when running the inferior."},
+//{ 0, false, nullptr, 0, 0, nullptr, 0, eArgTypeNone, nullptr }
//};
//
//#undef SET1
@@ -327,11 +325,9 @@ protected:
class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach
{
public:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options(interpreter)
{
@@ -339,9 +335,7 @@ public:
OptionParsingStarting ();
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -428,7 +422,7 @@ public:
// Look to see if there is a -P argument provided, and if so use that plugin, otherwise
// use the default plugin.
- const char *partial_name = NULL;
+ const char *partial_name = nullptr;
partial_name = input.GetArgumentAtIndex(opt_arg_pos);
PlatformSP platform_sp (m_interpreter.GetPlatform (true));
@@ -445,7 +439,7 @@ public:
const size_t num_matches = process_infos.GetSize();
if (num_matches > 0)
{
- for (size_t i=0; i<num_matches; ++i)
+ for (size_t i = 0; i < num_matches; ++i)
{
matches.AppendString (process_infos.GetProcessNameAtIndex(i),
process_infos.GetProcessNameLengthAtIndex(i));
@@ -477,9 +471,7 @@ public:
{
}
- ~CommandObjectProcessAttach () override
- {
- }
+ ~CommandObjectProcessAttach() override = default;
Options *
GetOptions () override
@@ -504,20 +496,20 @@ protected:
if (!StopProcessIfNecessary (process, state, result))
return false;
- if (target == NULL)
+ if (target == nullptr)
{
// If there isn't a current target create one.
TargetSP new_target_sp;
Error error;
- error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(),
- NULL,
- NULL,
- false,
- NULL, // No platform options
- new_target_sp);
+ error = m_interpreter.GetDebugger().GetTargetList().CreateTarget(m_interpreter.GetDebugger(),
+ nullptr,
+ nullptr,
+ false,
+ nullptr, // No platform options
+ new_target_sp);
target = new_target_sp.get();
- if (target == NULL || error.Fail())
+ if (target == nullptr || error.Fail())
{
result.AppendError(error.AsCString("Error creating target"));
return false;
@@ -611,17 +603,16 @@ protected:
CommandOptions m_options;
};
-
OptionDefinition
CommandObjectProcessAttach::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_ALL, false, "continue",'c', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Immediately continue the process once attached."},
-{ LLDB_OPT_SET_ALL, false, "plugin", 'P', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
-{ LLDB_OPT_SET_1, false, "pid", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePid, "The process ID of an existing process to attach to."},
-{ LLDB_OPT_SET_2, false, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeProcessName, "The name of the process to attach to."},
-{ LLDB_OPT_SET_2, false, "include-existing", 'i', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Include existing processes when doing attach -w."},
-{ LLDB_OPT_SET_2, false, "waitfor", 'w', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Wait for the process with <process-name> to launch."},
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_ALL, false, "continue",'c', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Immediately continue the process once attached."},
+{ LLDB_OPT_SET_ALL, false, "plugin", 'P', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
+{ LLDB_OPT_SET_1, false, "pid", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePid, "The process ID of an existing process to attach to."},
+{ LLDB_OPT_SET_2, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeProcessName, "The name of the process to attach to."},
+{ LLDB_OPT_SET_2, false, "include-existing", 'i', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Include existing processes when doing attach -w."},
+{ LLDB_OPT_SET_2, false, "waitfor", 'w', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Wait for the process with <process-name> to launch."},
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -632,7 +623,6 @@ CommandObjectProcessAttach::CommandOptions::g_option_table[] =
class CommandObjectProcessContinue : public CommandObjectParsed
{
public:
-
CommandObjectProcessContinue (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
"process continue",
@@ -646,17 +636,12 @@ public:
{
}
-
- ~CommandObjectProcessContinue () override
- {
- }
+ ~CommandObjectProcessContinue() override = default;
protected:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options(interpreter)
{
@@ -664,9 +649,7 @@ protected:
OptionParsingStarting ();
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -725,7 +708,7 @@ protected:
if (m_options.m_ignore > 0)
{
- ThreadSP sel_thread_sp(process->GetThreadList().GetSelectedThread());
+ ThreadSP sel_thread_sp(GetDefaultThread()->shared_from_this());
if (sel_thread_sp)
{
StopInfoSP stop_info_sp = sel_thread_sp->GetStopInfo();
@@ -750,7 +733,7 @@ protected:
}
{ // Scope for thread list mutex:
- Mutex::Locker locker (process->GetThreadList().GetMutex());
+ std::lock_guard<std::recursive_mutex> guard(process->GetThreadList().GetMutex());
const uint32_t num_threads = process->GetThreadList().GetSize();
// Set the actions that the threads should each take when resuming
@@ -814,15 +797,14 @@ protected:
}
CommandOptions m_options;
-
};
OptionDefinition
CommandObjectProcessContinue::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_ALL, false, "ignore-count",'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeUnsignedInteger,
+{ LLDB_OPT_SET_ALL, false, "ignore-count",'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeUnsignedInteger,
"Ignore <N> crossings of the breakpoint (if it exists) for the currently selected thread."},
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -836,16 +818,13 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter)
{
OptionParsingStarting ();
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -896,21 +875,15 @@ public:
LazyBool m_keep_stopped;
};
- CommandObjectProcessDetach (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "process detach",
- "Detach from the current process being debugged.",
- "process detach",
- eCommandRequiresProcess |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched),
- m_options(interpreter)
+ CommandObjectProcessDetach(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "process detach", "Detach from the current target process.",
+ "process detach",
+ eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched),
+ m_options(interpreter)
{
}
- ~CommandObjectProcessDetach () override
- {
- }
+ ~CommandObjectProcessDetach() override = default;
Options *
GetOptions () override
@@ -918,7 +891,6 @@ public:
return &m_options;
}
-
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -929,10 +901,7 @@ protected:
if (m_options.m_keep_stopped == eLazyBoolCalculate)
{
// Check the process default:
- if (process->GetDetachKeepsStopped())
- keep_stopped = true;
- else
- keep_stopped = false;
+ keep_stopped = process->GetDetachKeepsStopped();
}
else if (m_options.m_keep_stopped == eLazyBoolYes)
keep_stopped = true;
@@ -959,8 +928,8 @@ protected:
OptionDefinition
CommandObjectProcessDetach::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, false, "keep-stopped", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." },
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_1, false, "keep-stopped", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." },
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -971,22 +940,18 @@ CommandObjectProcessDetach::CommandOptions::g_option_table[] =
class CommandObjectProcessConnect : public CommandObjectParsed
{
public:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options(interpreter)
{
// Keep default values of all options in one place: OptionParsingStarting ()
OptionParsingStarting ();
}
-
- ~CommandOptions () override
- {
- }
-
+
+ ~CommandOptions() override = default;
+
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -1036,12 +1001,9 @@ public:
m_options (interpreter)
{
}
-
- ~CommandObjectProcessConnect () override
- {
- }
-
+ ~CommandObjectProcessConnect() override = default;
+
Options *
GetOptions () override
{
@@ -1061,7 +1023,6 @@ protected:
return false;
}
-
Process *process = m_exe_ctx.GetProcessPtr();
if (process && process->IsAlive())
{
@@ -1098,8 +1059,8 @@ protected:
OptionDefinition
CommandObjectProcessConnect::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "plugin", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
- { 0, false, NULL, 0 , 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "plugin", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
+ { 0, false, nullptr, 0 , 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -1110,31 +1071,24 @@ CommandObjectProcessConnect::CommandOptions::g_option_table[] =
class CommandObjectProcessPlugin : public CommandObjectProxy
{
public:
-
- CommandObjectProcessPlugin (CommandInterpreter &interpreter) :
- CommandObjectProxy (interpreter,
- "process plugin",
- "Send a custom command to the current process plug-in.",
- "process plugin <args>",
- 0)
- {
- }
-
- ~CommandObjectProcessPlugin () override
+ CommandObjectProcessPlugin(CommandInterpreter &interpreter)
+ : CommandObjectProxy(interpreter, "process plugin",
+ "Send a custom command to the current target process plug-in.", "process plugin <args>", 0)
{
}
+ ~CommandObjectProcessPlugin() override = default;
+
CommandObject *
GetProxyCommandObject() override
{
Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process)
return process->GetPluginCommandObject();
- return NULL;
+ return nullptr;
}
};
-
//-------------------------------------------------------------------------
// CommandObjectProcessLoad
//-------------------------------------------------------------------------
@@ -1153,7 +1107,7 @@ public:
OptionParsingStarting ();
}
- ~CommandOptions () override = default;
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -1208,7 +1162,7 @@ public:
{
}
- ~CommandObjectProcessLoad () override = default;
+ ~CommandObjectProcessLoad() override = default;
Options *
GetOptions () override
@@ -1223,7 +1177,7 @@ protected:
Process *process = m_exe_ctx.GetProcessPtr();
const size_t argc = command.GetArgumentCount();
- for (uint32_t i=0; i<argc; ++i)
+ for (uint32_t i = 0; i < argc; ++i)
{
Error error;
PlatformSP platform = process->GetTarget().GetPlatform();
@@ -1293,9 +1247,7 @@ public:
{
}
- ~CommandObjectProcessUnload () override
- {
- }
+ ~CommandObjectProcessUnload() override = default;
protected:
bool
@@ -1305,7 +1257,7 @@ protected:
const size_t argc = command.GetArgumentCount();
- for (uint32_t i=0; i<argc; ++i)
+ for (uint32_t i = 0; i < argc; ++i)
{
const char *image_token_cstr = command.GetArgumentAtIndex(i);
uint32_t image_token = StringConvert::ToUInt32(image_token_cstr, LLDB_INVALID_IMAGE_TOKEN, 0);
@@ -1343,13 +1295,9 @@ protected:
class CommandObjectProcessSignal : public CommandObjectParsed
{
public:
-
- CommandObjectProcessSignal (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "process signal",
- "Send a UNIX signal to the current process being debugged.",
- NULL,
- eCommandRequiresProcess | eCommandTryTargetAPILock)
+ CommandObjectProcessSignal(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "process signal", "Send a UNIX signal to the current target process.",
+ nullptr, eCommandRequiresProcess | eCommandTryTargetAPILock)
{
CommandArgumentEntry arg;
CommandArgumentData signal_arg;
@@ -1365,9 +1313,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectProcessSignal () override
- {
- }
+ ~CommandObjectProcessSignal() override = default;
protected:
bool
@@ -1414,7 +1360,6 @@ protected:
}
};
-
//-------------------------------------------------------------------------
// CommandObjectProcessInterrupt
//-------------------------------------------------------------------------
@@ -1423,29 +1368,21 @@ protected:
class CommandObjectProcessInterrupt : public CommandObjectParsed
{
public:
-
-
- CommandObjectProcessInterrupt (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "process interrupt",
- "Interrupt the current process being debugged.",
- "process interrupt",
- eCommandRequiresProcess |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched)
+ CommandObjectProcessInterrupt(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "process interrupt", "Interrupt the current target process.",
+ "process interrupt",
+ eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched)
{
}
- ~CommandObjectProcessInterrupt () override
- {
- }
+ ~CommandObjectProcessInterrupt() override = default;
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
{
Process *process = m_exe_ctx.GetProcessPtr();
- if (process == NULL)
+ if (process == nullptr)
{
result.AppendError ("no process to halt");
result.SetStatus (eReturnStatusFailed);
@@ -1485,28 +1422,20 @@ protected:
class CommandObjectProcessKill : public CommandObjectParsed
{
public:
-
- CommandObjectProcessKill (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "process kill",
- "Terminate the current process being debugged.",
- "process kill",
- eCommandRequiresProcess |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched)
+ CommandObjectProcessKill(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "process kill", "Terminate the current target process.", "process kill",
+ eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched)
{
}
- ~CommandObjectProcessKill () override
- {
- }
+ ~CommandObjectProcessKill() override = default;
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
{
Process *process = m_exe_ctx.GetProcessPtr();
- if (process == NULL)
+ if (process == nullptr)
{
result.AppendError ("no process to kill");
result.SetStatus (eReturnStatusFailed);
@@ -1545,7 +1474,6 @@ protected:
class CommandObjectProcessSaveCore : public CommandObjectParsed
{
public:
-
CommandObjectProcessSaveCore (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
"process save-core",
@@ -1556,11 +1484,9 @@ public:
eCommandProcessMustBeLaunched)
{
}
-
- ~CommandObjectProcessSaveCore () override
- {
- }
-
+
+ ~CommandObjectProcessSaveCore() override = default;
+
protected:
bool
DoExecute (Args& command,
@@ -1610,19 +1536,14 @@ protected:
class CommandObjectProcessStatus : public CommandObjectParsed
{
public:
- CommandObjectProcessStatus (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "process status",
- "Show the current status and location of executing process.",
- "process status",
- eCommandRequiresProcess | eCommandTryTargetAPILock)
- {
- }
-
- ~CommandObjectProcessStatus() override
+ CommandObjectProcessStatus(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "process status",
+ "Show status and stop location for the current target process.", "process status",
+ eCommandRequiresProcess | eCommandTryTargetAPILock)
{
}
+ ~CommandObjectProcessStatus() override = default;
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -1653,20 +1574,16 @@ public:
class CommandObjectProcessHandle : public CommandObjectParsed
{
public:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter)
{
OptionParsingStarting ();
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -1717,13 +1634,12 @@ public:
std::string pass;
};
-
- CommandObjectProcessHandle (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "process handle",
- "Show or update what the process and debugger should do with various signals received from the OS.",
- NULL),
- m_options (interpreter)
+ CommandObjectProcessHandle(CommandInterpreter &interpreter)
+ : CommandObjectParsed(
+ interpreter, "process handle",
+ "Manage LLDB handling of OS signals for the current target process. Defaults to showing current policy.",
+ nullptr),
+ m_options(interpreter)
{
SetHelpLong ("\nIf no signals are specified, update them all. If no update "
"option is specified, list the current values.");
@@ -1738,9 +1654,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectProcessHandle () override
- {
- }
+ ~CommandObjectProcessHandle() override = default;
Options *
GetOptions () override
@@ -1752,7 +1666,6 @@ public:
VerifyCommandOptionValue (const std::string &option, int &real_value)
{
bool okay = true;
-
bool success = false;
bool tmp_value = Args::StringToBoolean (option.c_str(), false, &success);
@@ -1945,21 +1858,19 @@ protected:
OptionDefinition
CommandObjectProcessHandle::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, false, "stop", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Whether or not the process should be stopped if the signal is received." },
-{ LLDB_OPT_SET_1, false, "notify", 'n', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Whether or not the debugger should notify the user if the signal is received." },
-{ LLDB_OPT_SET_1, false, "pass", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Whether or not the signal should be passed to the process." },
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_1, false, "stop", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the process should be stopped if the signal is received." },
+{ LLDB_OPT_SET_1, false, "notify", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the debugger should notify the user if the signal is received." },
+{ LLDB_OPT_SET_1, false, "pass", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the signal should be passed to the process." },
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
// CommandObjectMultiwordProcess
//-------------------------------------------------------------------------
-CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "process",
- "A set of commands for operating on a process.",
- "process <subcommand> [<subcommand-options>]")
+CommandObjectMultiwordProcess::CommandObjectMultiwordProcess(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "process", "Commands for interacting with processes on the current platform.",
+ "process <subcommand> [<subcommand-options>]")
{
LoadSubCommand ("attach", CommandObjectSP (new CommandObjectProcessAttach (interpreter)));
LoadSubCommand ("launch", CommandObjectSP (new CommandObjectProcessLaunch (interpreter)));
@@ -1977,7 +1888,4 @@ CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter
LoadSubCommand ("save-core", CommandObjectSP (new CommandObjectProcessSaveCore (interpreter)));
}
-CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess ()
-{
-}
-
+CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess() = default;
diff --git a/source/Commands/CommandObjectQuit.cpp b/source/Commands/CommandObjectQuit.cpp
index 31f82b987c1c7..a650398724fea 100644
--- a/source/Commands/CommandObjectQuit.cpp
+++ b/source/Commands/CommandObjectQuit.cpp
@@ -24,8 +24,8 @@ using namespace lldb_private;
// CommandObjectQuit
//-------------------------------------------------------------------------
-CommandObjectQuit::CommandObjectQuit (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter, "quit", "Quit out of the LLDB debugger.", "quit")
+CommandObjectQuit::CommandObjectQuit(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "quit", "Quit the LLDB debugger.", "quit")
{
}
diff --git a/source/Commands/CommandObjectRegister.cpp b/source/Commands/CommandObjectRegister.cpp
index 23a2157637385..ff8df2a6acaad 100644
--- a/source/Commands/CommandObjectRegister.cpp
+++ b/source/Commands/CommandObjectRegister.cpp
@@ -7,12 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectRegister.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
+#include "llvm/ADT/STLExtras.h"
+
// Project includes
+#include "CommandObjectRegister.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
@@ -30,7 +31,6 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Thread.h"
-#include "llvm/ADT/STLExtras.h"
using namespace lldb;
using namespace lldb_private;
@@ -42,14 +42,14 @@ class CommandObjectRegisterRead : public CommandObjectParsed
{
public:
CommandObjectRegisterRead (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "register read",
- "Dump the contents of one or more register values from the current frame. If no register is specified, dumps them all.",
- NULL,
- eCommandRequiresFrame |
- eCommandRequiresRegContext |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused ),
+ CommandObjectParsed(interpreter,
+ "register read",
+ "Dump the contents of one or more register values from the current frame. If no register is specified, dumps them all.",
+ nullptr,
+ eCommandRequiresFrame |
+ eCommandRequiresRegContext |
+ eCommandProcessMustBeLaunched |
+ eCommandProcessMustBePaused ),
m_option_group (interpreter),
m_format_options (eFormatDefault),
m_command_options ()
@@ -71,12 +71,9 @@ public:
m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT | OptionGroupFormat::OPTION_GROUP_GDB_FMT, LLDB_OPT_SET_ALL);
m_option_group.Append (&m_command_options);
m_option_group.Finalize();
-
}
- ~CommandObjectRegisterRead () override
- {
- }
+ ~CommandObjectRegisterRead() override = default;
Options *
GetOptions () override
@@ -175,7 +172,7 @@ protected:
Stream &strm = result.GetOutputStream();
RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext ();
- const RegisterInfo *reg_info = NULL;
+ const RegisterInfo *reg_info = nullptr;
if (command.GetArgumentCount() == 0)
{
size_t set_idx;
@@ -184,9 +181,9 @@ protected:
const size_t set_array_size = m_command_options.set_indexes.GetSize();
if (set_array_size > 0)
{
- for (size_t i=0; i<set_array_size; ++i)
+ for (size_t i = 0; i < set_array_size; ++i)
{
- set_idx = m_command_options.set_indexes[i]->GetUInt64Value (UINT32_MAX, NULL);
+ set_idx = m_command_options.set_indexes[i]->GetUInt64Value(UINT32_MAX, nullptr);
if (set_idx < reg_ctx->GetRegisterSetCount())
{
if (!DumpRegisterSet (m_exe_ctx, strm, reg_ctx, set_idx))
@@ -234,7 +231,7 @@ protected:
else
{
const char *arg_cstr;
- for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx)
+ for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; ++arg_idx)
{
// in most LLDB commands we accept $rbx as the name for register RBX - and here we would
// reject it and non-existant. we should be more consistent towards the user and allow them
@@ -269,12 +266,9 @@ protected:
alternate_name (false, false)
{
}
-
- ~CommandOptions () override
- {
- }
-
-
+
+ ~CommandOptions() override = default;
+
uint32_t
GetNumDefinitions () override;
@@ -350,9 +344,9 @@ protected:
const OptionDefinition
CommandObjectRegisterRead::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "alternate", 'A', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone , "Display register names using the alternate register name if there is one."},
- { LLDB_OPT_SET_1 , false, "set" , 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeIndex , "Specify which register sets to dump by index."},
- { LLDB_OPT_SET_2 , false, "all" , 'a', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone , "Show all register sets."},
+ { LLDB_OPT_SET_ALL, false, "alternate", 'A', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone , "Display register names using the alternate register name if there is one."},
+ { LLDB_OPT_SET_1 , false, "set" , 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeIndex , "Specify which register sets to dump by index."},
+ { LLDB_OPT_SET_2 , false, "all" , 'a', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone , "Show all register sets."},
};
uint32_t
@@ -361,7 +355,6 @@ CommandObjectRegisterRead::CommandOptions::GetNumDefinitions ()
return llvm::array_lengthof(g_option_table);
}
-
//----------------------------------------------------------------------
// "register write"
//----------------------------------------------------------------------
@@ -369,14 +362,14 @@ class CommandObjectRegisterWrite : public CommandObjectParsed
{
public:
CommandObjectRegisterWrite (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "register write",
- "Modify a single register value.",
- NULL,
- eCommandRequiresFrame |
- eCommandRequiresRegContext |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused)
+ CommandObjectParsed(interpreter,
+ "register write",
+ "Modify a single register value.",
+ nullptr,
+ eCommandRequiresFrame |
+ eCommandRequiresRegContext |
+ eCommandProcessMustBeLaunched |
+ eCommandProcessMustBePaused)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -402,9 +395,7 @@ public:
m_arguments.push_back (arg2);
}
- ~CommandObjectRegisterWrite () override
- {
- }
+ ~CommandObjectRegisterWrite() override = default;
protected:
bool
@@ -422,8 +413,7 @@ protected:
{
const char *reg_name = command.GetArgumentAtIndex(0);
const char *value_str = command.GetArgumentAtIndex(1);
-
-
+
// in most LLDB commands we accept $rbx as the name for register RBX - and here we would
// reject it and non-existant. we should be more consistent towards the user and allow them
// to say reg write $rbx - internally, however, we should be strict and not allow ourselves
@@ -474,24 +464,16 @@ protected:
}
};
-
//----------------------------------------------------------------------
// CommandObjectRegister constructor
//----------------------------------------------------------------------
-CommandObjectRegister::CommandObjectRegister(CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "register",
- "A set of commands to access thread registers.",
- "register [read|write] ...")
+CommandObjectRegister::CommandObjectRegister(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "register",
+ "Commands to access registers for the current thread and stack frame.",
+ "register [read|write] ...")
{
LoadSubCommand ("read", CommandObjectSP (new CommandObjectRegisterRead (interpreter)));
LoadSubCommand ("write", CommandObjectSP (new CommandObjectRegisterWrite (interpreter)));
}
-
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-CommandObjectRegister::~CommandObjectRegister()
-{
-}
+CommandObjectRegister::~CommandObjectRegister() = default;
diff --git a/source/Commands/CommandObjectSettings.cpp b/source/Commands/CommandObjectSettings.cpp
index 890d77028a998..b76af20752556 100644
--- a/source/Commands/CommandObjectSettings.cpp
+++ b/source/Commands/CommandObjectSettings.cpp
@@ -12,6 +12,8 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
+#include "llvm/ADT/StringRef.h"
+
// Project includes
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -20,7 +22,6 @@
using namespace lldb;
using namespace lldb_private;
-#include "llvm/ADT/StringRef.h"
//-------------------------------------------------------------------------
// CommandObjectSettingsSet
@@ -29,12 +30,9 @@ using namespace lldb_private;
class CommandObjectSettingsSet : public CommandObjectRaw
{
public:
- CommandObjectSettingsSet (CommandInterpreter &interpreter) :
- CommandObjectRaw (interpreter,
- "settings set",
- "Set or change the value of a single debugger setting variable.",
- NULL),
- m_options (interpreter)
+ CommandObjectSettingsSet(CommandInterpreter &interpreter)
+ : CommandObjectRaw(interpreter, "settings set", "Set the value of the specified debugger setting.", nullptr),
+ m_options(interpreter)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -82,8 +80,7 @@ insert-before or insert-after."
}
-
- ~CommandObjectSettingsSet () override {}
+ ~CommandObjectSettingsSet() override = default;
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
bool
@@ -98,14 +95,13 @@ insert-before or insert-after."
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_global (false)
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -160,7 +156,7 @@ insert-before or insert-after."
std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
const size_t argc = input.GetArgumentCount();
- const char *arg = NULL;
+ const char *arg = nullptr;
int setting_var_idx;
for (setting_var_idx = 1; setting_var_idx < static_cast<int>(argc);
++setting_var_idx)
@@ -172,14 +168,14 @@ insert-before or insert-after."
if (cursor_index == setting_var_idx)
{
// Attempting to complete setting variable name
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eSettingsNameCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
}
else
{
@@ -231,7 +227,7 @@ protected:
}
const char *var_name = cmd_args.GetArgumentAtIndex (0);
- if ((var_name == NULL) || (var_name[0] == '\0'))
+ if ((var_name == nullptr) || (var_name[0] == '\0'))
{
result.AppendError ("'settings set' command requires a valid variable name");
result.SetStatus (eReturnStatusFailed);
@@ -246,10 +242,10 @@ protected:
Error error;
if (m_options.m_global)
{
- error = m_interpreter.GetDebugger().SetPropertyValue (NULL,
- eVarSetOperationAssign,
- var_name,
- var_value_cstr);
+ error = m_interpreter.GetDebugger().SetPropertyValue(nullptr,
+ eVarSetOperationAssign,
+ var_name,
+ var_value_cstr);
}
if (error.Success())
@@ -280,6 +276,7 @@ protected:
return result.Succeeded();
}
+
private:
CommandOptions m_options;
};
@@ -287,11 +284,10 @@ private:
OptionDefinition
CommandObjectSettingsSet::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_2, false, "global", 'g', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Apply the new value to the global default value." },
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_2, false, "global", 'g', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Apply the new value to the global default value." },
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
//-------------------------------------------------------------------------
// CommandObjectSettingsShow -- Show current values
//-------------------------------------------------------------------------
@@ -299,11 +295,10 @@ CommandObjectSettingsSet::CommandOptions::g_option_table[] =
class CommandObjectSettingsShow : public CommandObjectParsed
{
public:
- CommandObjectSettingsShow (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "settings show",
- "Show the specified internal debugger setting variable and its value, or show all the currently set variables and their values, if nothing is specified.",
- NULL)
+ CommandObjectSettingsShow(CommandInterpreter &interpreter)
+ : CommandObjectParsed(
+ interpreter, "settings show",
+ "Show matching debugger settings and their current values. Defaults to showing all settings.", nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentData var_name_arg;
@@ -319,8 +314,7 @@ public:
m_arguments.push_back (arg1);
}
- ~CommandObjectSettingsShow () override {}
-
+ ~CommandObjectSettingsShow() override = default;
int
HandleArgumentCompletion (Args &input,
@@ -334,14 +328,14 @@ public:
{
std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eSettingsNameCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -354,7 +348,7 @@ protected:
const size_t argc = args.GetArgumentCount ();
if (argc > 0)
{
- for (size_t i=0; i<argc; ++i)
+ for (size_t i = 0; i < argc; ++i)
{
const char *property_path = args.GetArgumentAtIndex (i);
@@ -385,12 +379,11 @@ protected:
class CommandObjectSettingsList : public CommandObjectParsed
{
-public:
- CommandObjectSettingsList (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "settings list",
- "List and describe all the internal debugger settings variables that are available to the user to 'set' or 'show', or describe a particular variable or set of variables (by specifying the variable name or a common prefix).",
- NULL)
+public:
+ CommandObjectSettingsList(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "settings list",
+ "List and describe matching debugger settings. Defaults to all listing all settings.",
+ nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData var_name_arg;
@@ -411,7 +404,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectSettingsList () override {}
+ ~CommandObjectSettingsList() override = default;
int
HandleArgumentCompletion (Args &input,
@@ -425,14 +418,14 @@ public:
{
std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eSettingsNameCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -448,7 +441,7 @@ protected:
{
const bool dump_qualified_name = true;
- for (size_t i=0; i<argc; ++i)
+ for (size_t i = 0; i < argc; ++i)
{
const char *property_path = args.GetArgumentAtIndex (i);
@@ -481,11 +474,9 @@ protected:
class CommandObjectSettingsRemove : public CommandObjectRaw
{
public:
- CommandObjectSettingsRemove (CommandInterpreter &interpreter) :
- CommandObjectRaw (interpreter,
- "settings remove",
- "Remove the specified element from an array or dictionary settings variable.",
- NULL)
+ CommandObjectSettingsRemove(CommandInterpreter &interpreter)
+ : CommandObjectRaw(interpreter, "settings remove",
+ "Remove a value from a setting, specified by array index or dictionary key.", nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -517,7 +508,7 @@ public:
m_arguments.push_back (arg2);
}
- ~CommandObjectSettingsRemove () override {}
+ ~CommandObjectSettingsRemove() override = default;
int
HandleArgumentCompletion (Args &input,
@@ -533,14 +524,14 @@ public:
// Attempting to complete variable name
if (cursor_index < 2)
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eSettingsNameCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -566,7 +557,7 @@ protected:
}
const char *var_name = cmd_args.GetArgumentAtIndex (0);
- if ((var_name == NULL) || (var_name[0] == '\0'))
+ if ((var_name == nullptr) || (var_name[0] == '\0'))
{
result.AppendError ("'settings set' command requires a valid variable name");
result.SetStatus (eReturnStatusFailed);
@@ -600,11 +591,9 @@ protected:
class CommandObjectSettingsReplace : public CommandObjectRaw
{
public:
- CommandObjectSettingsReplace (CommandInterpreter &interpreter) :
- CommandObjectRaw (interpreter,
- "settings replace",
- "Replace the specified element from an internal debugger settings array or dictionary variable with the specified new value.",
- NULL)
+ CommandObjectSettingsReplace(CommandInterpreter &interpreter)
+ : CommandObjectRaw(interpreter, "settings replace",
+ "Replace the debugger setting value specified by array index or dictionary key.", nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -646,8 +635,7 @@ public:
m_arguments.push_back (arg3);
}
-
- ~CommandObjectSettingsReplace () override {}
+ ~CommandObjectSettingsReplace() override = default;
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
bool
@@ -667,14 +655,14 @@ public:
// Attempting to complete variable name
if (cursor_index < 2)
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eSettingsNameCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -687,14 +675,13 @@ protected:
Args cmd_args(command);
const char *var_name = cmd_args.GetArgumentAtIndex (0);
- if ((var_name == NULL) || (var_name[0] == '\0'))
+ if ((var_name == nullptr) || (var_name[0] == '\0'))
{
result.AppendError ("'settings replace' command requires a valid variable name; No value supplied");
result.SetStatus (eReturnStatusFailed);
return false;
}
-
// Split the raw command into var_name, index_value, and value triple.
llvm::StringRef raw_str(command);
std::string var_value_string = raw_str.split(var_name).second.str();
@@ -727,11 +714,11 @@ protected:
class CommandObjectSettingsInsertBefore : public CommandObjectRaw
{
public:
- CommandObjectSettingsInsertBefore (CommandInterpreter &interpreter) :
- CommandObjectRaw (interpreter,
- "settings insert-before",
- "Insert value(s) into an internal debugger settings array variable, immediately before the specified element.",
- NULL)
+ CommandObjectSettingsInsertBefore(CommandInterpreter &interpreter)
+ : CommandObjectRaw(interpreter, "settings insert-before", "Insert one or more values into an debugger array "
+ "setting immediately before the specified element "
+ "index.",
+ nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -767,7 +754,7 @@ public:
m_arguments.push_back (arg3);
}
- ~CommandObjectSettingsInsertBefore () override {}
+ ~CommandObjectSettingsInsertBefore() override = default;
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
bool
@@ -787,14 +774,14 @@ public:
// Attempting to complete variable name
if (cursor_index < 2)
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eSettingsNameCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -816,7 +803,7 @@ protected:
}
const char *var_name = cmd_args.GetArgumentAtIndex (0);
- if ((var_name == NULL) || (var_name[0] == '\0'))
+ if ((var_name == nullptr) || (var_name[0] == '\0'))
{
result.AppendError ("'settings insert-before' command requires a valid variable name; No value supplied");
result.SetStatus (eReturnStatusFailed);
@@ -850,11 +837,10 @@ protected:
class CommandObjectSettingsInsertAfter : public CommandObjectRaw
{
public:
- CommandObjectSettingsInsertAfter (CommandInterpreter &interpreter) :
- CommandObjectRaw (interpreter,
- "settings insert-after",
- "Insert value(s) into an internal debugger settings array variable, immediately after the specified element.",
- NULL)
+ CommandObjectSettingsInsertAfter(CommandInterpreter &interpreter)
+ : CommandObjectRaw(
+ interpreter, "settings insert-after",
+ "Insert one or more values into a debugger array settings after the specified element index.", nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -890,7 +876,7 @@ public:
m_arguments.push_back (arg3);
}
- ~CommandObjectSettingsInsertAfter () override {}
+ ~CommandObjectSettingsInsertAfter() override = default;
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
bool
@@ -910,14 +896,14 @@ public:
// Attempting to complete variable name
if (cursor_index < 2)
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eSettingsNameCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -939,7 +925,7 @@ protected:
}
const char *var_name = cmd_args.GetArgumentAtIndex (0);
- if ((var_name == NULL) || (var_name[0] == '\0'))
+ if ((var_name == nullptr) || (var_name[0] == '\0'))
{
result.AppendError ("'settings insert-after' command requires a valid variable name; No value supplied");
result.SetStatus (eReturnStatusFailed);
@@ -973,11 +959,9 @@ protected:
class CommandObjectSettingsAppend : public CommandObjectRaw
{
public:
- CommandObjectSettingsAppend (CommandInterpreter &interpreter) :
- CommandObjectRaw (interpreter,
- "settings append",
- "Append a new value to the end of an internal debugger settings array, dictionary or string variable.",
- NULL)
+ CommandObjectSettingsAppend(CommandInterpreter &interpreter)
+ : CommandObjectRaw(interpreter, "settings append",
+ "Append one or more values to a debugger array, dictionary, or string setting.", nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -1003,7 +987,7 @@ public:
m_arguments.push_back (arg2);
}
- ~CommandObjectSettingsAppend () override {}
+ ~CommandObjectSettingsAppend() override = default;
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
bool
@@ -1023,14 +1007,14 @@ public:
// Attempting to complete variable name
if (cursor_index < 2)
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eSettingsNameCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -1051,7 +1035,7 @@ protected:
}
const char *var_name = cmd_args.GetArgumentAtIndex (0);
- if ((var_name == NULL) || (var_name[0] == '\0'))
+ if ((var_name == nullptr) || (var_name[0] == '\0'))
{
result.AppendError ("'settings append' command requires a valid variable name; No value supplied");
result.SetStatus (eReturnStatusFailed);
@@ -1088,11 +1072,9 @@ protected:
class CommandObjectSettingsClear : public CommandObjectParsed
{
public:
- CommandObjectSettingsClear (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "settings clear",
- "Erase all the contents of an internal debugger settings variables; this is only valid for variables with clearable types, i.e. strings, arrays or dictionaries.",
- NULL)
+ CommandObjectSettingsClear(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "settings clear", "Clear a debugger setting array, dictionary, or string.",
+ nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData var_name_arg;
@@ -1108,7 +1090,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectSettingsClear () override {}
+ ~CommandObjectSettingsClear() override = default;
int
HandleArgumentCompletion (Args &input,
@@ -1124,14 +1106,14 @@ public:
// Attempting to complete variable name
if (cursor_index < 2)
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eSettingsNameCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eSettingsNameCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -1151,17 +1133,17 @@ protected:
}
const char *var_name = command.GetArgumentAtIndex (0);
- if ((var_name == NULL) || (var_name[0] == '\0'))
+ if ((var_name == nullptr) || (var_name[0] == '\0'))
{
result.AppendError ("'settings clear' command requires a valid variable name; No value supplied");
result.SetStatus (eReturnStatusFailed);
return false;
}
- Error error (m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
- eVarSetOperationClear,
- var_name,
- NULL));
+ Error error(m_interpreter.GetDebugger().SetPropertyValue(&m_exe_ctx,
+ eVarSetOperationClear,
+ var_name,
+ nullptr));
if (error.Fail())
{
result.AppendError (error.AsCString());
@@ -1177,11 +1159,9 @@ protected:
// CommandObjectMultiwordSettings
//-------------------------------------------------------------------------
-CommandObjectMultiwordSettings::CommandObjectMultiwordSettings (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "settings",
- "A set of commands for manipulating internal settable debugger variables.",
- "settings <command> [<command-options>]")
+CommandObjectMultiwordSettings::CommandObjectMultiwordSettings(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "settings", "Commands for managing LLDB settings.",
+ "settings <subcommand> [<command-options>]")
{
LoadSubCommand ("set", CommandObjectSP (new CommandObjectSettingsSet (interpreter)));
LoadSubCommand ("show", CommandObjectSP (new CommandObjectSettingsShow (interpreter)));
@@ -1194,6 +1174,4 @@ CommandObjectMultiwordSettings::CommandObjectMultiwordSettings (CommandInterpret
LoadSubCommand ("clear", CommandObjectSP (new CommandObjectSettingsClear (interpreter)));
}
-CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings ()
-{
-}
+CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings() = default;
diff --git a/source/Commands/CommandObjectSource.cpp b/source/Commands/CommandObjectSource.cpp
index a9e52d1a76f3f..cef9d09d0e559 100644
--- a/source/Commands/CommandObjectSource.cpp
+++ b/source/Commands/CommandObjectSource.cpp
@@ -35,7 +35,6 @@
using namespace lldb;
using namespace lldb_private;
-
#pragma mark CommandObjectSourceInfo
//----------------------------------------------------------------------
// CommandObjectSourceInfo - debug line entries dumping command
@@ -43,13 +42,12 @@ using namespace lldb_private;
class CommandObjectSourceInfo : 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
@@ -119,6 +117,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed
{
return g_option_table;
}
+
static OptionDefinition g_option_table[];
// Instance variables to hold the values for command options.
@@ -133,15 +132,16 @@ class CommandObjectSourceInfo : public CommandObjectParsed
};
public:
- CommandObjectSourceInfo (CommandInterpreter &interpreter)
- : CommandObjectParsed(interpreter, "source info", "Display source line information (as specified) based "
- "on the current executable's debug info.",
- NULL, eCommandRequiresTarget),
+ CommandObjectSourceInfo(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "source info", "Display source line information for the current target "
+ "process. Defaults to instruction pointer in current stack "
+ "frame.",
+ nullptr, eCommandRequiresTarget),
m_options(interpreter)
{
}
- ~CommandObjectSourceInfo () override {}
+ ~CommandObjectSourceInfo() override = default;
Options *
GetOptions () override
@@ -150,7 +150,6 @@ public:
}
protected:
-
// Dump the line entries in each symbol context.
// Return the number of entries found.
// If module_list is set, only dump lines contained in one of the modules.
@@ -172,7 +171,7 @@ protected:
if (file_spec)
{
assert(file_spec.GetFilename().AsCString());
- has_path = (file_spec.GetDirectory().AsCString() != 0);
+ has_path = (file_spec.GetDirectory().AsCString() != nullptr);
}
// Dump all the line entries for the file in the list.
@@ -240,7 +239,7 @@ protected:
if (cu)
{
assert(file_spec.GetFilename().AsCString());
- bool has_path = (file_spec.GetDirectory().AsCString() != 0);
+ bool has_path = (file_spec.GetDirectory().AsCString() != nullptr);
const FileSpecList &cu_file_list = cu->GetSupportFiles();
size_t file_idx = cu_file_list.FindFileIndex(0, file_spec, has_path);
if (file_idx != UINT32_MAX)
@@ -390,7 +389,7 @@ protected:
else
{
StreamString addr_strm;
- so_addr.Dump(&addr_strm, NULL, Address::DumpStyleModuleWithFileAddress);
+ so_addr.Dump(&addr_strm, nullptr, Address::DumpStyleModuleWithFileAddress);
error_strm.Printf("Address 0x%" PRIx64 " resolves to %s, but there is"
" no source information available for this address.\n",
addr, addr_strm.GetData());
@@ -399,7 +398,7 @@ protected:
else
{
StreamString addr_strm;
- so_addr.Dump(&addr_strm, NULL, Address::DumpStyleModuleWithFileAddress);
+ so_addr.Dump(&addr_strm, nullptr, Address::DumpStyleModuleWithFileAddress);
error_strm.Printf("Address 0x%" PRIx64 " resolves to %s, but it cannot"
" be found in any modules.\n",
addr, addr_strm.GetData());
@@ -573,7 +572,7 @@ protected:
DumpLinesForFrame (CommandReturnObject &result)
{
StackFrame *cur_frame = m_exe_ctx.GetFramePtr();
- if (cur_frame == NULL)
+ if (cur_frame == nullptr)
{
result.AppendError("No selected frame to use to find the default source.");
return false;
@@ -613,10 +612,10 @@ protected:
}
Target *target = m_exe_ctx.GetTargetPtr();
- if (target == NULL)
+ if (target == nullptr)
{
target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError("invalid target, create a debug target using the "
"'target create' command.");
@@ -631,7 +630,7 @@ protected:
// Collect the list of modules to search.
m_module_list.Clear();
- if (m_options.modules.size() > 0)
+ if (!m_options.modules.empty())
{
for (size_t i = 0, e = m_options.modules.size(); i < e; ++i)
{
@@ -699,27 +698,26 @@ protected:
};
OptionDefinition CommandObjectSourceInfo::CommandOptions::g_option_table[] = {
- {LLDB_OPT_SET_ALL, false, "count", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount,
+ {LLDB_OPT_SET_ALL, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount,
"The number of line entries to display."},
- {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "shlib", 's', OptionParser::eRequiredArgument, NULL, NULL,
+ {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "shlib", 's', OptionParser::eRequiredArgument, nullptr, nullptr,
CommandCompletions::eModuleCompletion, eArgTypeShlibName,
"Look up the source in the given module or shared library (can be "
"specified more than once)."},
- {LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL,
+ {LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr,
CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "The file from which to display source."},
- {LLDB_OPT_SET_1, false, "line", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum,
+ {LLDB_OPT_SET_1, false, "line", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum,
"The line number at which to start the displaying lines."},
- {LLDB_OPT_SET_1, false, "end-line", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum,
+ {LLDB_OPT_SET_1, false, "end-line", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum,
"The line number at which to stop displaying lines."},
- {LLDB_OPT_SET_2, false, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL,
+ {LLDB_OPT_SET_2, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, nullptr,
CommandCompletions::eSymbolCompletion, eArgTypeSymbol, "The name of a function whose source to display."},
- {LLDB_OPT_SET_3, false, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression,
+ {LLDB_OPT_SET_3, false, "address", 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddressOrExpression,
"Lookup the address and display the source information for the "
"corresponding file and line."},
- {0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL}
+ {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}
};
-
#pragma mark CommandObjectSourceList
//-------------------------------------------------------------------------
// CommandObjectSourceList
@@ -727,7 +725,6 @@ OptionDefinition CommandObjectSourceInfo::CommandOptions::g_option_table[] = {
class CommandObjectSourceList : public CommandObjectParsed
{
-
class CommandOptions : public Options
{
public:
@@ -736,9 +733,7 @@ class CommandObjectSourceList : public CommandObjectParsed
{
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -810,6 +805,7 @@ class CommandObjectSourceList : public CommandObjectParsed
{
return g_option_table;
}
+
static OptionDefinition g_option_table[];
// Instance variables to hold the values for command options.
@@ -823,22 +819,17 @@ class CommandObjectSourceList : public CommandObjectParsed
bool show_bp_locs;
bool reverse;
};
-
-public:
- CommandObjectSourceList(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "source list",
- "Display source code (as specified) based on the current executable's debug info.",
- NULL,
- eCommandRequiresTarget),
- m_options (interpreter)
- {
- }
- ~CommandObjectSourceList () override
+public:
+ CommandObjectSourceList(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "source list",
+ "Display source code for the current target process as specified by options.", nullptr,
+ eCommandRequiresTarget),
+ m_options(interpreter)
{
}
+ ~CommandObjectSourceList() override = default;
Options *
GetOptions () override
@@ -853,7 +844,7 @@ public:
// values for this invocation... I have to scan the arguments directly.
size_t num_args = current_command_args.GetArgumentCount();
bool is_reverse = false;
- for (size_t i = 0 ; i < num_args; i++)
+ for (size_t i = 0; i < num_args; i++)
{
const char *arg = current_command_args.GetArgumentAtIndex(i);
if (arg && (strcmp(arg, "-r") == 0 || strcmp(arg, "--reverse") == 0))
@@ -875,7 +866,6 @@ public:
}
protected:
-
struct SourceInfo
{
ConstString function;
@@ -903,7 +893,7 @@ protected:
operator == (const SourceInfo &rhs) const
{
return function == rhs.function &&
- line_entry.file == rhs.line_entry.file &&
+ line_entry.original_file == rhs.line_entry.original_file &&
line_entry.line == rhs.line_entry.line;
}
@@ -911,7 +901,7 @@ protected:
operator != (const SourceInfo &rhs) const
{
return function != rhs.function ||
- line_entry.file != rhs.line_entry.file ||
+ line_entry.original_file != rhs.line_entry.original_file ||
line_entry.line != rhs.line_entry.line;
}
@@ -950,7 +940,7 @@ protected:
uint32_t end_line;
FileSpec end_file;
- if (sc.block == NULL)
+ if (sc.block == nullptr)
{
// Not an inlined function
sc.function->GetStartLineSourceInfo (start_file, start_line);
@@ -1194,7 +1184,7 @@ protected:
// in all modules
const ModuleList &module_list = target->GetImages();
const size_t num_modules = module_list.GetSize();
- for (size_t i=0; i<num_modules; ++i)
+ for (size_t i = 0; i < num_modules; ++i)
{
ModuleSP module_sp (module_list.GetModuleAtIndex(i));
if (module_sp && module_sp->ResolveFileAddress(m_options.address, so_addr))
@@ -1231,7 +1221,7 @@ protected:
}
else
{
- so_addr.Dump(&error_strm, NULL, Address::DumpStyleModuleWithFileAddress);
+ so_addr.Dump(&error_strm, nullptr, Address::DumpStyleModuleWithFileAddress);
result.AppendErrorWithFormat("address resolves to %s, but there is no line table information available for this address.\n",
error_strm.GetData());
result.SetStatus (eReturnStatusFailed);
@@ -1248,7 +1238,7 @@ protected:
}
}
uint32_t num_matches = sc_list.GetSize();
- for (uint32_t i=0; i<num_matches; ++i)
+ for (uint32_t i = 0; i < num_matches; ++i)
{
SymbolContext sc;
sc_list.GetContextAtIndex(i, sc);
@@ -1339,7 +1329,6 @@ protected:
{
result.SetStatus (eReturnStatusSuccessFinishResult);
}
-
}
}
else
@@ -1350,7 +1339,7 @@ protected:
SymbolContextList sc_list;
size_t num_matches = 0;
- if (m_options.modules.size() > 0)
+ if (!m_options.modules.empty())
{
ModuleList matching_modules;
for (size_t i = 0, e = m_options.modules.size(); i < e; ++i)
@@ -1389,7 +1378,7 @@ protected:
if (num_matches > 1)
{
bool got_multiple = false;
- FileSpec *test_cu_spec = NULL;
+ FileSpec *test_cu_spec = nullptr;
for (unsigned i = 0; i < num_matches; i++)
{
@@ -1461,27 +1450,27 @@ protected:
{
if (m_breakpoint_locations.GetFileLineMatches().GetSize() > 0)
return &m_breakpoint_locations.GetFileLineMatches();
- return NULL;
+ return nullptr;
}
+
CommandOptions m_options;
FileLineResolver m_breakpoint_locations;
std::string m_reverse_name;
-
};
OptionDefinition
CommandObjectSourceList::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_ALL, false, "count", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount, "The number of source lines to display."},
+{ LLDB_OPT_SET_ALL, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount, "The number of source lines to display."},
{ LLDB_OPT_SET_1 |
- LLDB_OPT_SET_2 , false, "shlib", 's', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Look up the source file in the given shared library."},
-{ LLDB_OPT_SET_ALL, false, "show-breakpoints", 'b', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Show the line table locations from the debug information that indicate valid places to set source level breakpoints."},
-{ LLDB_OPT_SET_1 , false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "The file from which to display source."},
-{ LLDB_OPT_SET_1 , false, "line", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum, "The line number at which to start the display source."},
-{ LLDB_OPT_SET_2 , false, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeSymbol, "The name of a function whose source to display."},
-{ LLDB_OPT_SET_3 , false, "address",'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, "Lookup the address and display the source information for the corresponding file and line."},
-{ LLDB_OPT_SET_4, false, "reverse", 'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Reverse the listing to look backwards from the last displayed block of source."},
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ LLDB_OPT_SET_2 , false, "shlib", 's', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Look up the source file in the given shared library."},
+{ LLDB_OPT_SET_ALL, false, "show-breakpoints", 'b', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Show the line table locations from the debug information that indicate valid places to set source level breakpoints."},
+{ LLDB_OPT_SET_1 , false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "The file from which to display source."},
+{ LLDB_OPT_SET_1 , false, "line", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum, "The line number at which to start the display source."},
+{ LLDB_OPT_SET_2 , false, "name", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSymbolCompletion, eArgTypeSymbol, "The name of a function whose source to display."},
+{ LLDB_OPT_SET_3 , false, "address",'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Lookup the address and display the source information for the corresponding file and line."},
+{ LLDB_OPT_SET_4, false, "reverse", 'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Reverse the listing to look backwards from the last displayed block of source."},
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
#pragma mark CommandObjectMultiwordSource
@@ -1489,17 +1478,14 @@ CommandObjectSourceList::CommandOptions::g_option_table[] =
// CommandObjectMultiwordSource
//-------------------------------------------------------------------------
-CommandObjectMultiwordSource::CommandObjectMultiwordSource (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "source",
- "A set of commands for accessing source file information",
- "source <subcommand> [<subcommand-options>]")
+CommandObjectMultiwordSource::CommandObjectMultiwordSource(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(
+ interpreter, "source",
+ "Commands for examining source code described by debug information for the current target process.",
+ "source <subcommand> [<subcommand-options>]")
{
LoadSubCommand ("info", CommandObjectSP (new CommandObjectSourceInfo (interpreter)));
LoadSubCommand ("list", CommandObjectSP (new CommandObjectSourceList (interpreter)));
}
-CommandObjectMultiwordSource::~CommandObjectMultiwordSource ()
-{
-}
-
+CommandObjectMultiwordSource::~CommandObjectMultiwordSource() = default;
diff --git a/source/Commands/CommandObjectSyntax.cpp b/source/Commands/CommandObjectSyntax.cpp
index e9fa084fc0b5a..c238bccfb5dd5 100644
--- a/source/Commands/CommandObjectSyntax.cpp
+++ b/source/Commands/CommandObjectSyntax.cpp
@@ -7,15 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectSyntax.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "CommandObjectSyntax.h"
+#include "CommandObjectHelp.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/Options.h"
-
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -47,10 +46,7 @@ CommandObjectSyntax::CommandObjectSyntax (CommandInterpreter &interpreter) :
m_arguments.push_back (arg);
}
-CommandObjectSyntax::~CommandObjectSyntax()
-{
-}
-
+CommandObjectSyntax::~CommandObjectSyntax() = default;
bool
CommandObjectSyntax::DoExecute (Args& command, CommandReturnObject &result)
@@ -82,10 +78,10 @@ CommandObjectSyntax::DoExecute (Args& command, CommandReturnObject &result)
}
}
- if (all_okay && (cmd_obj != NULL))
+ if (all_okay && (cmd_obj != nullptr))
{
Stream &output_strm = result.GetOutputStream();
- if (cmd_obj->GetOptions() != NULL)
+ if (cmd_obj->GetOptions() != nullptr)
{
output_strm.Printf ("\nSyntax: %s\n", cmd_obj->GetSyntax());
output_strm.Printf ("(Try 'help %s' for more information on command options syntax.)\n",
@@ -102,8 +98,17 @@ CommandObjectSyntax::DoExecute (Args& command, CommandReturnObject &result)
{
std::string cmd_string;
command.GetCommandString (cmd_string);
- result.AppendErrorWithFormat ("'%s' is not a known command.\n", cmd_string.c_str());
- result.AppendError ("Try 'help' to see a current list of commands.");
+
+ StreamString error_msg_stream;
+ const bool generate_apropos = true;
+ const bool generate_type_lookup = false;
+ CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage(&error_msg_stream,
+ cmd_string.c_str(),
+ nullptr,
+ nullptr,
+ generate_apropos,
+ generate_type_lookup);
+ result.AppendErrorWithFormat ("%s", error_msg_stream.GetData());
result.SetStatus (eReturnStatusFailed);
}
}
diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp
index 57ec1c953fcfa..9e535ba8ebd85 100644
--- a/source/Commands/CommandObjectTarget.cpp
+++ b/source/Commands/CommandObjectTarget.cpp
@@ -10,9 +10,9 @@
#include "CommandObjectTarget.h"
// C Includes
-#include <errno.h>
-
// C++ Includes
+#include <cerrno>
+
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/Args.h"
@@ -58,8 +58,6 @@
using namespace lldb;
using namespace lldb_private;
-
-
static void
DumpTargetInfo (uint32_t target_idx, Target *target, const char *prefix_cstr, bool show_stopped_process_status, Stream &strm)
{
@@ -128,7 +126,7 @@ DumpTargetList (TargetList &target_list, bool show_stopped_process_status, Strea
{
TargetSP selected_target_sp (target_list.GetSelectedTarget());
strm.PutCString ("Current targets:\n");
- for (uint32_t i=0; i<num_targets; ++i)
+ for (uint32_t i = 0; i < num_targets; ++i)
{
TargetSP target_sp (target_list.GetTargetAtIndex (i));
if (target_sp)
@@ -144,6 +142,7 @@ DumpTargetList (TargetList &target_list, bool show_stopped_process_status, Strea
}
return num_targets;
}
+
#pragma mark CommandObjectTargetCreate
//-------------------------------------------------------------------------
@@ -154,10 +153,10 @@ class CommandObjectTargetCreate : public CommandObjectParsed
{
public:
CommandObjectTargetCreate(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "target create",
- "Create a target using the argument as the main executable.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "target create",
+ "Create a target using the argument as the main executable.",
+ nullptr),
m_option_group (interpreter),
m_arch_option (),
m_core_file (LLDB_OPT_SET_1, false, "core", 'c', 0, eArgTypeFilename, "Fullpath to a core file to use for this target."),
@@ -188,9 +187,7 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectTargetCreate () override
- {
- }
+ ~CommandObjectTargetCreate() override = default;
Options *
GetOptions () override
@@ -211,14 +208,14 @@ public:
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eDiskFileCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eDiskFileCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -285,12 +282,12 @@ protected:
TargetSP target_sp;
const char *arch_cstr = m_arch_option.GetArchitectureName();
const bool get_dependent_files = m_add_dependents.GetOptionValue().GetCurrentValue();
- Error error (debugger.GetTargetList().CreateTarget (debugger,
- file_path,
- arch_cstr,
- get_dependent_files,
- NULL,
- target_sp));
+ Error error(debugger.GetTargetList().CreateTarget(debugger,
+ file_path,
+ arch_cstr,
+ get_dependent_files,
+ nullptr,
+ target_sp));
if (target_sp)
{
@@ -398,7 +395,7 @@ protected:
core_file_dir.GetDirectory() = core_file.GetDirectory();
target_sp->GetExecutableSearchPaths ().Append (core_file_dir);
- ProcessSP process_sp (target_sp->CreateProcess (m_interpreter.GetDebugger().GetListener(), NULL, &core_file));
+ ProcessSP process_sp(target_sp->CreateProcess(m_interpreter.GetDebugger().GetListener(), nullptr, &core_file));
if (process_sp)
{
@@ -470,17 +467,14 @@ class CommandObjectTargetList : public CommandObjectParsed
{
public:
CommandObjectTargetList (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "target list",
- "List all current targets in the current debug session.",
- NULL,
- 0)
+ CommandObjectParsed(interpreter,
+ "target list",
+ "List all current targets in the current debug session.",
+ nullptr)
{
}
- ~CommandObjectTargetList () override
- {
- }
+ ~CommandObjectTargetList() override = default;
protected:
bool
@@ -506,7 +500,6 @@ protected:
}
};
-
#pragma mark CommandObjectTargetSelect
//----------------------------------------------------------------------
@@ -517,17 +510,14 @@ class CommandObjectTargetSelect : public CommandObjectParsed
{
public:
CommandObjectTargetSelect (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "target select",
- "Select a target as the current target by target index.",
- NULL,
- 0)
+ CommandObjectParsed(interpreter,
+ "target select",
+ "Select a target as the current target by target index.",
+ nullptr)
{
}
- ~CommandObjectTargetSelect () override
- {
- }
+ ~CommandObjectTargetSelect() override = default;
protected:
bool
@@ -566,7 +556,8 @@ protected:
result.AppendErrorWithFormat ("index %u is out of range, valid target indexes are 0 - %u\n",
target_idx,
num_targets - 1);
- } else
+ }
+ else
{
result.AppendErrorWithFormat ("index %u is out of range since there are no active targets\n",
target_idx);
@@ -599,11 +590,10 @@ class CommandObjectTargetDelete : public CommandObjectParsed
{
public:
CommandObjectTargetDelete (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "target delete",
- "Delete one or more targets by target index.",
- NULL,
- 0),
+ CommandObjectParsed(interpreter,
+ "target delete",
+ "Delete one or more targets by target index.",
+ nullptr),
m_option_group(interpreter),
m_all_option(LLDB_OPT_SET_1, false, "all", 'a', "Delete all targets.", false, true),
m_cleanup_option(
@@ -621,9 +611,7 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectTargetDelete () override
- {
- }
+ ~CommandObjectTargetDelete() override = default;
Options *
GetOptions () override
@@ -724,7 +712,6 @@ protected:
OptionGroupBoolean m_cleanup_option;
};
-
#pragma mark CommandObjectTargetVariable
//----------------------------------------------------------------------
@@ -737,22 +724,20 @@ class CommandObjectTargetVariable : public CommandObjectParsed
static const uint32_t SHORT_OPTION_SHLB = 0x73686c62; // 'shlb'
public:
- CommandObjectTargetVariable (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "target variable",
- "Read global variable(s) prior to, or while running your binary.",
- NULL,
- eCommandRequiresTarget),
- m_option_group (interpreter),
- m_option_variable (false), // Don't include frame options
- m_option_format (eFormatDefault),
- m_option_compile_units (LLDB_OPT_SET_1, false, "file",
- SHORT_OPTION_FILE, 0, eArgTypeFilename,
- "A basename or fullpath to a file that contains global variables. This option can be specified multiple times."),
- m_option_shared_libraries (LLDB_OPT_SET_1, false, "shlib",
- SHORT_OPTION_SHLB, 0, eArgTypeFilename,
- "A basename or fullpath to a shared library to use in the search for global variables. This option can be specified multiple times."),
- m_varobj_options()
+ CommandObjectTargetVariable(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "target variable",
+ "Read global variables for the current target, before or while running a process.",
+ nullptr, eCommandRequiresTarget),
+ m_option_group(interpreter),
+ m_option_variable(false), // Don't include frame options
+ m_option_format(eFormatDefault),
+ m_option_compile_units(LLDB_OPT_SET_1, false, "file", SHORT_OPTION_FILE, 0, eArgTypeFilename,
+ "A basename or fullpath to a file that contains global variables. This option can be "
+ "specified multiple times."),
+ m_option_shared_libraries(LLDB_OPT_SET_1, false, "shlib", SHORT_OPTION_SHLB, 0, eArgTypeFilename,
+ "A basename or fullpath to a shared library to use in the search for global "
+ "variables. This option can be specified multiple times."),
+ m_varobj_options()
{
CommandArgumentEntry arg;
CommandArgumentData var_name_arg;
@@ -775,17 +760,15 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectTargetVariable () override
- {
- }
+ ~CommandObjectTargetVariable() override = default;
void
DumpValueObject (Stream &s, VariableSP &var_sp, ValueObjectSP &valobj_sp, const char *root_name)
{
DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions());
- if (false == valobj_sp->GetTargetSP()->GetDisplayRuntimeSupportValues() &&
- true == valobj_sp->IsRuntimeSupportValue())
+ if (!valobj_sp->GetTargetSP()->GetDisplayRuntimeSupportValues() &&
+ valobj_sp->IsRuntimeSupportValue())
return;
switch (var_sp->GetScope())
@@ -810,6 +793,11 @@ public:
s.PutCString(" LOCAL: ");
break;
+ case eValueTypeVariableThreadLocal:
+ if (m_option_variable.show_scope)
+ s.PutCString("THREAD: ");
+ break;
+
default:
break;
}
@@ -879,7 +867,7 @@ protected:
sc.comp_unit->GetPath().c_str());
}
- for (uint32_t i=0; i<count; ++i)
+ for (uint32_t i = 0; i < count; ++i)
{
VariableSP var_sp (variable_list.GetVariableAtIndex(i));
if (var_sp)
@@ -891,8 +879,8 @@ protected:
}
}
}
-
}
+
bool
DoExecute (Args& args, CommandReturnObject &result) override
{
@@ -972,7 +960,7 @@ protected:
{
bool success = false;
StackFrame *frame = m_exe_ctx.GetFramePtr();
- CompileUnit *comp_unit = NULL;
+ CompileUnit *comp_unit = nullptr;
if (frame)
{
SymbolContext sc = frame->GetSymbolContext (eSymbolContextCompUnit);
@@ -1093,21 +1081,18 @@ protected:
OptionGroupFileList m_option_compile_units;
OptionGroupFileList m_option_shared_libraries;
OptionGroupValueObjectDisplay m_varobj_options;
-
};
-
#pragma mark CommandObjectTargetModulesSearchPathsAdd
class CommandObjectTargetModulesSearchPathsAdd : public CommandObjectParsed
{
public:
-
CommandObjectTargetModulesSearchPathsAdd (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "target modules search-paths add",
- "Add new image search paths substitution pairs to the current target.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "target modules search-paths add",
+ "Add new image search paths substitution pairs to the current target.",
+ nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData old_prefix_arg;
@@ -1131,9 +1116,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectTargetModulesSearchPathsAdd () override
- {
- }
+ ~CommandObjectTargetModulesSearchPathsAdd() override = default;
protected:
bool
@@ -1150,7 +1133,7 @@ protected:
}
else
{
- for (size_t i=0; i<argc; i+=2)
+ for (size_t i = 0; i < argc; i+=2)
{
const char *from = command.GetArgumentAtIndex(i);
const char *to = command.GetArgumentAtIndex(i+1);
@@ -1194,7 +1177,6 @@ protected:
class CommandObjectTargetModulesSearchPathsClear : public CommandObjectParsed
{
public:
-
CommandObjectTargetModulesSearchPathsClear (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
"target modules search-paths clear",
@@ -1203,9 +1185,7 @@ public:
{
}
- ~CommandObjectTargetModulesSearchPathsClear () override
- {
- }
+ ~CommandObjectTargetModulesSearchPathsClear() override = default;
protected:
bool
@@ -1232,12 +1212,11 @@ protected:
class CommandObjectTargetModulesSearchPathsInsert : public CommandObjectParsed
{
public:
-
CommandObjectTargetModulesSearchPathsInsert (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "target modules search-paths insert",
- "Insert a new image search path substitution pair into the current target at the specified index.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "target modules search-paths insert",
+ "Insert a new image search path substitution pair into the current target at the specified index.",
+ nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -1272,9 +1251,7 @@ public:
m_arguments.push_back (arg2);
}
- ~CommandObjectTargetModulesSearchPathsInsert () override
- {
- }
+ ~CommandObjectTargetModulesSearchPathsInsert() override = default;
protected:
bool
@@ -1302,7 +1279,7 @@ protected:
command.Shift();
argc = command.GetArgumentCount();
- for (uint32_t i=0; i<argc; i+=2, ++insert_idx)
+ for (uint32_t i = 0; i < argc; i += 2, ++insert_idx)
{
const char *from = command.GetArgumentAtIndex(i);
const char *to = command.GetArgumentAtIndex(i+1);
@@ -1344,14 +1321,11 @@ protected:
}
};
-
#pragma mark CommandObjectTargetModulesSearchPathsList
-
class CommandObjectTargetModulesSearchPathsList : public CommandObjectParsed
{
public:
-
CommandObjectTargetModulesSearchPathsList (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
"target modules search-paths list",
@@ -1360,9 +1334,7 @@ public:
{
}
- ~CommandObjectTargetModulesSearchPathsList () override
- {
- }
+ ~CommandObjectTargetModulesSearchPathsList() override = default;
protected:
bool
@@ -1395,12 +1367,11 @@ protected:
class CommandObjectTargetModulesSearchPathsQuery : public CommandObjectParsed
{
public:
-
CommandObjectTargetModulesSearchPathsQuery (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "target modules search-paths query",
- "Transform a path using the first applicable image search path.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "target modules search-paths query",
+ "Transform a path using the first applicable image search path.",
+ nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData path_arg;
@@ -1416,9 +1387,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectTargetModulesSearchPathsQuery () override
- {
- }
+ ~CommandObjectTargetModulesSearchPathsQuery() override = default;
protected:
bool
@@ -1501,7 +1470,7 @@ DumpCompileUnitLineTable (CommandInterpreter &interpreter,
eSymbolContextCompUnit,
sc_list);
- for (uint32_t i=0; i<num_matches; ++i)
+ for (uint32_t i = 0; i < num_matches; ++i)
{
SymbolContext sc;
if (sc_list.GetContextAtIndex(i, sc))
@@ -1578,6 +1547,34 @@ DumpBasename (Stream &strm, const FileSpec *file_spec_ptr, uint32_t width)
strm.Printf("%-*s", width, "");
}
+static size_t
+DumpModuleObjfileHeaders(Stream &strm, ModuleList &module_list)
+{
+ size_t num_dumped = 0;
+ std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
+ const size_t num_modules = module_list.GetSize();
+ if (num_modules > 0)
+ {
+ strm.Printf("Dumping headers for %" PRIu64 " module(s).\n", static_cast<uint64_t>(num_modules));
+ strm.IndentMore();
+ for (size_t image_idx = 0; image_idx < num_modules; ++image_idx)
+ {
+ Module *module = module_list.GetModulePointerAtIndexUnlocked(image_idx);
+ if (module)
+ {
+ if (num_dumped++ > 0)
+ {
+ strm.EOL();
+ strm.EOL();
+ }
+ ObjectFile *objfile = module->GetObjectFile();
+ objfile->Dump(&strm);
+ }
+ }
+ strm.IndentLess();
+ }
+ return num_dumped;
+}
static void
DumpModuleSymtab (CommandInterpreter &interpreter, Stream &strm, Module *module, SortOrder sort_order)
@@ -1717,7 +1714,6 @@ LookupSymbolInModule (CommandInterpreter &interpreter, Stream &strm, Module *mod
Symtab *symtab = sym_vendor->GetSymtab();
if (symtab)
{
- uint32_t i;
std::vector<uint32_t> match_indexes;
ConstString symbol_name (name);
uint32_t num_matches = 0;
@@ -1741,7 +1737,7 @@ LookupSymbolInModule (CommandInterpreter &interpreter, Stream &strm, Module *mod
DumpFullpath (strm, &module->GetFileSpec(), 0);
strm.PutCString(":\n");
strm.IndentMore ();
- for (i=0; i < num_matches; ++i)
+ for (uint32_t i = 0; i < num_matches; ++i)
{
Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]);
if (symbol && symbol->ValueIsAddress())
@@ -1761,15 +1757,14 @@ LookupSymbolInModule (CommandInterpreter &interpreter, Stream &strm, Module *mod
return 0;
}
-
static void
DumpSymbolContextList (ExecutionContextScope *exe_scope, Stream &strm, SymbolContextList &sc_list, bool verbose)
{
strm.IndentMore ();
- uint32_t i;
+
const uint32_t num_matches = sc_list.GetSize();
- for (i=0; i<num_matches; ++i)
+ for (uint32_t i = 0; i < num_matches; ++i)
{
SymbolContext sc;
if (sc_list.GetContextAtIndex(i, sc))
@@ -1814,13 +1809,13 @@ LookupFunctionInModule (CommandInterpreter &interpreter,
else
{
ConstString function_name (name);
- num_matches = module->FindFunctions (function_name,
- NULL,
- eFunctionNameTypeAuto,
- include_symbols,
- include_inlines,
- append,
- sc_list);
+ num_matches = module->FindFunctions(function_name,
+ nullptr,
+ eFunctionNameTypeAuto,
+ include_symbols,
+ include_inlines,
+ append,
+ sc_list);
}
if (num_matches)
@@ -1852,7 +1847,8 @@ LookupTypeInModule (CommandInterpreter &interpreter,
SymbolContext sc;
ConstString name(name_cstr);
- num_matches = module->FindTypes(sc, name, name_is_fully_qualified, max_num_matches, type_list);
+ llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
+ num_matches = module->FindTypes(sc, name, name_is_fully_qualified, max_num_matches, searched_symbol_files, type_list);
if (num_matches)
{
@@ -1905,7 +1901,8 @@ LookupTypeHere (CommandInterpreter &interpreter,
bool name_is_fully_qualified = false;
ConstString name(name_cstr);
- num_matches = sym_ctx.module_sp->FindTypes(sym_ctx, name, name_is_fully_qualified, max_num_matches, type_list);
+ llvm::DenseSet<SymbolFile *> searched_symbol_files;
+ num_matches = sym_ctx.module_sp->FindTypes(sym_ctx, name, name_is_fully_qualified, max_num_matches, searched_symbol_files, type_list);
if (num_matches)
{
@@ -1970,14 +1967,12 @@ LookupFileAndLineInModule (CommandInterpreter &interpreter,
return 0;
}
-
static size_t
FindModulesByName (Target *target,
const char *module_name,
ModuleList &module_list,
bool check_global_list)
{
-// Dump specified images (by basename or fullpath)
FileSpec module_file_spec(module_name, false);
ModuleSpec module_spec (module_file_spec);
@@ -1986,7 +1981,7 @@ FindModulesByName (Target *target,
if (check_global_list)
{
// Check the global list
- Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex());
+ std::lock_guard<std::recursive_mutex> guard(Module::GetAllocationModuleCollectionMutex());
const size_t num_modules = Module::GetNumberAllocatedModules();
ModuleSP module_sp;
for (size_t image_idx = 0; image_idx<num_modules; ++image_idx)
@@ -2057,9 +2052,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectTargetModulesModuleAutoComplete () override
- {
- }
+ ~CommandObjectTargetModulesModuleAutoComplete() override = default;
int
HandleArgumentCompletion (Args &input,
@@ -2075,14 +2068,14 @@ public:
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eModuleCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eModuleCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
};
@@ -2118,9 +2111,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectTargetModulesSourceFileAutoComplete () override
- {
- }
+ ~CommandObjectTargetModulesSourceFileAutoComplete() override = default;
int
HandleArgumentCompletion (Args &input,
@@ -2136,37 +2127,104 @@ public:
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eSourceFileCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eSourceFileCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
};
+#pragma mark CommandObjectTargetModulesDumpObjfile
-#pragma mark CommandObjectTargetModulesDumpSymtab
+class CommandObjectTargetModulesDumpObjfile : public CommandObjectTargetModulesModuleAutoComplete
+{
+public:
+ CommandObjectTargetModulesDumpObjfile(CommandInterpreter &interpreter)
+ : CommandObjectTargetModulesModuleAutoComplete(interpreter, "target modules dump objfile",
+ "Dump the object file headers from one or more target modules.",
+ nullptr)
+ {
+ }
+ ~CommandObjectTargetModulesDumpObjfile() override = default;
+
+protected:
+ bool
+ DoExecute(Args &command, CommandReturnObject &result) override
+ {
+ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ if (target == nullptr)
+ {
+ result.AppendError("invalid target, create a debug target using the 'target create' command");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize();
+ result.GetOutputStream().SetAddressByteSize(addr_byte_size);
+ result.GetErrorStream().SetAddressByteSize(addr_byte_size);
+
+ size_t num_dumped = 0;
+ if (command.GetArgumentCount() == 0)
+ {
+ // Dump all headers for all modules images
+ num_dumped = DumpModuleObjfileHeaders(result.GetOutputStream(), target->GetImages());
+ if (num_dumped == 0)
+ {
+ result.AppendError("the target has no associated executable images");
+ result.SetStatus(eReturnStatusFailed);
+ }
+ }
+ else
+ {
+ // Find the modules that match the basename or full path.
+ ModuleList module_list;
+ const char *arg_cstr;
+ for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; ++arg_idx)
+ {
+ size_t num_matched = FindModulesByName(target, arg_cstr, module_list, true);
+ if (num_matched == 0)
+ {
+ result.AppendWarningWithFormat("Unable to find an image that matches '%s'.\n", arg_cstr);
+ }
+ }
+ // Dump all the modules we found.
+ num_dumped = DumpModuleObjfileHeaders(result.GetOutputStream(), module_list);
+ }
+
+ if (num_dumped > 0)
+ {
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ }
+ else
+ {
+ result.AppendError("no matching executable images found");
+ result.SetStatus(eReturnStatusFailed);
+ }
+ return result.Succeeded();
+ }
+};
+
+#pragma mark CommandObjectTargetModulesDumpSymtab
class CommandObjectTargetModulesDumpSymtab : public CommandObjectTargetModulesModuleAutoComplete
{
public:
CommandObjectTargetModulesDumpSymtab (CommandInterpreter &interpreter) :
- CommandObjectTargetModulesModuleAutoComplete (interpreter,
- "target modules dump symtab",
- "Dump the symbol table from one or more target modules.",
- NULL),
- m_options (interpreter)
+ CommandObjectTargetModulesModuleAutoComplete(interpreter,
+ "target modules dump symtab",
+ "Dump the symbol table from one or more target modules.",
+ nullptr),
+ m_options(interpreter)
{
}
- ~CommandObjectTargetModulesDumpSymtab () override
- {
- }
+ ~CommandObjectTargetModulesDumpSymtab() override = default;
Options *
GetOptions () override
@@ -2183,9 +2241,7 @@ public:
{
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -2205,7 +2261,6 @@ public:
default:
error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
break;
-
}
return error;
}
@@ -2233,7 +2288,7 @@ protected:
DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("invalid target, create a debug target using the 'target create' command");
result.SetStatus (eReturnStatusFailed);
@@ -2250,7 +2305,7 @@ protected:
if (command.GetArgumentCount() == 0)
{
// Dump all sections for all modules images
- Mutex::Locker modules_locker(target->GetImages().GetMutex());
+ std::lock_guard<std::recursive_mutex> guard(target->GetImages().GetMutex());
const size_t num_modules = target->GetImages().GetSize();
if (num_modules > 0)
{
@@ -2280,13 +2335,13 @@ protected:
{
// Dump specified images (by basename or fullpath)
const char *arg_cstr;
- for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx)
+ for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; ++arg_idx)
{
ModuleList module_list;
const size_t num_matches = FindModulesByName (target, arg_cstr, module_list, true);
if (num_matches > 0)
{
- for (size_t i=0; i<num_matches; ++i)
+ for (size_t i = 0; i < num_matches; ++i)
{
Module *module = module_list.GetModulePointerAtIndex(i);
if (module)
@@ -2326,15 +2381,14 @@ g_sort_option_enumeration[4] =
{ eSortOrderNone, "none", "No sorting, use the original symbol table order."},
{ eSortOrderByAddress, "address", "Sort output by symbol address."},
{ eSortOrderByName, "name", "Sort output by symbol name."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
-
OptionDefinition
CommandObjectTargetModulesDumpSymtab::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "sort", 's', OptionParser::eRequiredArgument, NULL, g_sort_option_enumeration, 0, eArgTypeSortOrder, "Supply a sort order when dumping the symbol table."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_1, false, "sort", 's', OptionParser::eRequiredArgument, nullptr, g_sort_option_enumeration, 0, eArgTypeSortOrder, "Supply a sort order when dumping the symbol table."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
#pragma mark CommandObjectTargetModulesDumpSections
@@ -2347,24 +2401,22 @@ class CommandObjectTargetModulesDumpSections : public CommandObjectTargetModules
{
public:
CommandObjectTargetModulesDumpSections (CommandInterpreter &interpreter) :
- CommandObjectTargetModulesModuleAutoComplete (interpreter,
- "target modules dump sections",
- "Dump the sections from one or more target modules.",
- //"target modules dump sections [<file1> ...]")
- NULL)
+ CommandObjectTargetModulesModuleAutoComplete(interpreter,
+ "target modules dump sections",
+ "Dump the sections from one or more target modules.",
+ //"target modules dump sections [<file1> ...]")
+ nullptr)
{
}
- ~CommandObjectTargetModulesDumpSections () override
- {
- }
+ ~CommandObjectTargetModulesDumpSections() override = default;
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("invalid target, create a debug target using the 'target create' command");
result.SetStatus (eReturnStatusFailed);
@@ -2402,13 +2454,13 @@ protected:
{
// Dump specified images (by basename or fullpath)
const char *arg_cstr;
- for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx)
+ for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; ++arg_idx)
{
ModuleList module_list;
const size_t num_matches = FindModulesByName (target, arg_cstr, module_list, true);
if (num_matches > 0)
{
- for (size_t i=0; i<num_matches; ++i)
+ for (size_t i = 0; i < num_matches; ++i)
{
Module *module = module_list.GetModulePointerAtIndex(i);
if (module)
@@ -2421,7 +2473,7 @@ protected:
else
{
// Check the global list
- Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex());
+ std::lock_guard<std::recursive_mutex> guard(Module::GetAllocationModuleCollectionMutex());
result.AppendWarningWithFormat("Unable to find an image that matches '%s'.\n", arg_cstr);
}
@@ -2440,7 +2492,6 @@ protected:
}
};
-
#pragma mark CommandObjectTargetModulesDumpSymfile
//----------------------------------------------------------------------
@@ -2451,24 +2502,22 @@ class CommandObjectTargetModulesDumpSymfile : public CommandObjectTargetModulesM
{
public:
CommandObjectTargetModulesDumpSymfile (CommandInterpreter &interpreter) :
- CommandObjectTargetModulesModuleAutoComplete (interpreter,
- "target modules dump symfile",
- "Dump the debug symbol file for one or more target modules.",
- //"target modules dump symfile [<file1> ...]")
- NULL)
+ CommandObjectTargetModulesModuleAutoComplete(interpreter,
+ "target modules dump symfile",
+ "Dump the debug symbol file for one or more target modules.",
+ //"target modules dump symfile [<file1> ...]")
+ nullptr)
{
}
- ~CommandObjectTargetModulesDumpSymfile () override
- {
- }
+ ~CommandObjectTargetModulesDumpSymfile() override = default;
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("invalid target, create a debug target using the 'target create' command");
result.SetStatus (eReturnStatusFailed);
@@ -2486,7 +2535,7 @@ protected:
{
// Dump all sections for all modules images
const ModuleList &target_modules = target->GetImages();
- Mutex::Locker modules_locker (target_modules.GetMutex());
+ std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
const size_t num_modules = target_modules.GetSize();
if (num_modules > 0)
{
@@ -2508,13 +2557,13 @@ protected:
{
// Dump specified images (by basename or fullpath)
const char *arg_cstr;
- for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx)
+ for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; ++arg_idx)
{
ModuleList module_list;
const size_t num_matches = FindModulesByName (target, arg_cstr, module_list, true);
if (num_matches > 0)
{
- for (size_t i=0; i<num_matches; ++i)
+ for (size_t i = 0; i < num_matches; ++i)
{
Module *module = module_list.GetModulePointerAtIndex(i);
if (module)
@@ -2541,7 +2590,6 @@ protected:
}
};
-
#pragma mark CommandObjectTargetModulesDumpLineTable
//----------------------------------------------------------------------
@@ -2552,17 +2600,15 @@ class CommandObjectTargetModulesDumpLineTable : public CommandObjectTargetModule
{
public:
CommandObjectTargetModulesDumpLineTable (CommandInterpreter &interpreter) :
- CommandObjectTargetModulesSourceFileAutoComplete (interpreter,
- "target modules dump line-table",
- "Dump the line table for one or more compilation units.",
- NULL,
- eCommandRequiresTarget)
+ CommandObjectTargetModulesSourceFileAutoComplete(interpreter,
+ "target modules dump line-table",
+ "Dump the line table for one or more compilation units.",
+ nullptr,
+ eCommandRequiresTarget)
{
}
- ~CommandObjectTargetModulesDumpLineTable () override
- {
- }
+ ~CommandObjectTargetModulesDumpLineTable() override = default;
protected:
bool
@@ -2585,12 +2631,12 @@ protected:
{
// Dump specified images (by basename or fullpath)
const char *arg_cstr;
- for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx)
+ for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; ++arg_idx)
{
FileSpec file_spec(arg_cstr, false);
const ModuleList &target_modules = target->GetImages();
- Mutex::Locker modules_locker(target_modules.GetMutex());
+ std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
const size_t num_modules = target_modules.GetSize();
if (num_modules > 0)
{
@@ -2623,7 +2669,6 @@ protected:
}
};
-
#pragma mark CommandObjectTargetModulesDump
//----------------------------------------------------------------------
@@ -2636,21 +2681,19 @@ public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- CommandObjectTargetModulesDump(CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "target modules dump",
- "A set of commands for dumping information about one or more target modules.",
- "target modules dump [symtab|sections|symfile|line-table] [<file1> <file2> ...]")
+ CommandObjectTargetModulesDump(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(
+ interpreter, "target modules dump", "Commands for dumping information about one or more target modules.",
+ "target modules dump [headers|symtab|sections|symfile|line-table] [<file1> <file2> ...]")
{
+ LoadSubCommand("objfile", CommandObjectSP(new CommandObjectTargetModulesDumpObjfile(interpreter)));
LoadSubCommand ("symtab", CommandObjectSP (new CommandObjectTargetModulesDumpSymtab (interpreter)));
LoadSubCommand ("sections", CommandObjectSP (new CommandObjectTargetModulesDumpSections (interpreter)));
LoadSubCommand ("symfile", CommandObjectSP (new CommandObjectTargetModulesDumpSymfile (interpreter)));
LoadSubCommand ("line-table", CommandObjectSP (new CommandObjectTargetModulesDumpLineTable (interpreter)));
}
- ~CommandObjectTargetModulesDump() override
- {
- }
+ ~CommandObjectTargetModulesDump() override = default;
};
class CommandObjectTargetModulesAdd : public CommandObjectParsed
@@ -2669,9 +2712,7 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectTargetModulesAdd () override
- {
- }
+ ~CommandObjectTargetModulesAdd() override = default;
Options *
GetOptions () override
@@ -2692,14 +2733,14 @@ public:
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eDiskFileCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eDiskFileCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -2712,7 +2753,7 @@ protected:
DoExecute (Args& args, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("invalid target, create a debug target using the 'target create' command");
result.SetStatus (eReturnStatusFailed);
@@ -2787,7 +2828,7 @@ protected:
}
else
{
- for (size_t i=0; i<argc; ++i)
+ for (size_t i = 0; i < argc; ++i)
{
const char *path = args.GetArgumentAtIndex(i);
if (path)
@@ -2849,7 +2890,6 @@ protected:
return result.Succeeded();
}
-
};
class CommandObjectTargetModulesLoad : public CommandObjectTargetModulesModuleAutoComplete
@@ -2870,9 +2910,7 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectTargetModulesLoad () override
- {
- }
+ ~CommandObjectTargetModulesLoad() override = default;
Options *
GetOptions () override
@@ -2885,7 +2923,7 @@ protected:
DoExecute (Args& args, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("invalid target, create a debug target using the 'target create' command");
result.SetStatus (eReturnStatusFailed);
@@ -2969,7 +3007,7 @@ protected:
return false;
}
- for (size_t i=0; i<argc; i += 2)
+ for (size_t i = 0; i < argc; i += 2)
{
const char *sect_name = args.GetArgumentAtIndex(i);
const char *load_addr_cstr = args.GetArgumentAtIndex(i+1);
@@ -3075,7 +3113,7 @@ protected:
path,
!uuid_str.empty() ? " uuid=" : "",
uuid_str.c_str());
- for (size_t i=0; i<num_matches; ++i)
+ for (size_t i = 0; i < num_matches; ++i)
{
if (matching_modules.GetModulePointerAtIndex(i)->GetFileSpec().GetPath (path, sizeof(path)))
result.AppendMessageWithFormat("%s\n", path);
@@ -3125,9 +3163,7 @@ public:
{
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -3148,7 +3184,7 @@ public:
{
unsigned long width = 0;
if (option_arg)
- width = strtoul (option_arg, NULL, 0);
+ width = strtoul(option_arg, nullptr, 0);
m_format_array.push_back(std::make_pair(short_option, width));
}
return error;
@@ -3188,9 +3224,7 @@ public:
{
}
- ~CommandObjectTargetModulesList () override
- {
- }
+ ~CommandObjectTargetModulesList() override = default;
Options *
GetOptions () override
@@ -3208,7 +3242,7 @@ protected:
// object which might lock its contents below (through the "module_list_ptr"
// variable).
ModuleList module_list;
- if (target == NULL && use_global_module_list == false)
+ if (target == nullptr && !use_global_module_list)
{
result.AppendError ("invalid target, create a debug target using the 'target create' command");
result.SetStatus (eReturnStatusFailed);
@@ -3259,16 +3293,19 @@ protected:
}
size_t num_modules = 0;
- Mutex::Locker locker; // This locker will be locked on the mutex in module_list_ptr if it is non-NULL.
- // Otherwise it will lock the AllocationModuleCollectionMutex when accessing
- // the global module list directly.
- const ModuleList *module_list_ptr = NULL;
+
+ // This locker will be locked on the mutex in module_list_ptr if it is non-nullptr.
+ // Otherwise it will lock the AllocationModuleCollectionMutex when accessing
+ // the global module list directly.
+ std::unique_lock<std::recursive_mutex> guard(Module::GetAllocationModuleCollectionMutex(), std::defer_lock);
+
+ const ModuleList *module_list_ptr = nullptr;
const size_t argc = command.GetArgumentCount();
if (argc == 0)
{
if (use_global_module_list)
{
- locker.Lock (Module::GetAllocationModuleCollectionMutex());
+ guard.lock();
num_modules = Module::GetNumberAllocatedModules();
}
else
@@ -3278,7 +3315,7 @@ protected:
}
else
{
- for (size_t i=0; i<argc; ++i)
+ for (size_t i = 0; i < argc; ++i)
{
// Dump specified images (by basename or fullpath)
const char *arg_cstr = command.GetArgumentAtIndex(i);
@@ -3297,9 +3334,11 @@ protected:
module_list_ptr = &module_list;
}
- if (module_list_ptr != NULL)
+ std::unique_lock<std::recursive_mutex> lock;
+ if (module_list_ptr != nullptr)
{
- locker.Lock(module_list_ptr->GetMutex());
+ lock = std::unique_lock<std::recursive_mutex>(module_list_ptr->GetMutex());
+
num_modules = module_list_ptr->GetSize();
}
@@ -3352,8 +3391,7 @@ protected:
void
PrintModule (Target *target, Module *module, int indent, Stream &strm)
{
-
- if (module == NULL)
+ if (module == nullptr)
{
strm.PutCString("Null module");
return;
@@ -3369,7 +3407,7 @@ protected:
}
const size_t num_entries = m_options.m_format_array.size();
bool print_space = false;
- for (size_t i=0; i<num_entries; ++i)
+ for (size_t i = 0; i < num_entries; ++i)
{
if (print_space)
strm.PutChar(' ');
@@ -3442,6 +3480,7 @@ protected:
strm.Printf ("%*s", addr_nibble_width + 2, "");
}
break;
+
case 'r':
{
size_t ref_count = 0;
@@ -3499,7 +3538,6 @@ protected:
default:
break;
}
-
}
if (dump_object_name)
{
@@ -3516,22 +3554,22 @@ protected:
OptionDefinition
CommandObjectTargetModulesList::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, "Display the image at this address."},
- { LLDB_OPT_SET_1, false, "arch", 'A', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth, "Display the architecture when listing images."},
- { LLDB_OPT_SET_1, false, "triple", 't', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth, "Display the triple when listing images."},
- { LLDB_OPT_SET_1, false, "header", 'h', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display the image header address as a load address if debugging, a file address otherwise."},
- { LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display the image header address offset from the header file address (the slide amount)."},
- { LLDB_OPT_SET_1, false, "uuid", 'u', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display the UUID when listing images."},
- { LLDB_OPT_SET_1, false, "fullpath", 'f', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth, "Display the fullpath to the image object file."},
- { LLDB_OPT_SET_1, false, "directory", 'd', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth, "Display the directory with optional width for the image object file."},
- { LLDB_OPT_SET_1, false, "basename", 'b', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth, "Display the basename with optional width for the image object file."},
- { LLDB_OPT_SET_1, false, "symfile", 's', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth, "Display the fullpath to the image symbol file with optional width."},
- { LLDB_OPT_SET_1, false, "symfile-unique", 'S', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth, "Display the symbol file with optional width only if it is different from the executable object file."},
- { LLDB_OPT_SET_1, false, "mod-time", 'm', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth, "Display the modification time with optional width of the module."},
- { LLDB_OPT_SET_1, false, "ref-count", 'r', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth, "Display the reference count if the module is still in the shared module cache."},
- { LLDB_OPT_SET_1, false, "pointer", 'p', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeNone, "Display the module pointer."},
- { LLDB_OPT_SET_1, false, "global", 'g', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display the modules from the global module list, not just the current target."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Display the image at this address."},
+ { LLDB_OPT_SET_1, false, "arch", 'A', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth, "Display the architecture when listing images."},
+ { LLDB_OPT_SET_1, false, "triple", 't', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth, "Display the triple when listing images."},
+ { LLDB_OPT_SET_1, false, "header", 'h', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display the image header address as a load address if debugging, a file address otherwise."},
+ { LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display the image header address offset from the header file address (the slide amount)."},
+ { LLDB_OPT_SET_1, false, "uuid", 'u', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display the UUID when listing images."},
+ { LLDB_OPT_SET_1, false, "fullpath", 'f', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth, "Display the fullpath to the image object file."},
+ { LLDB_OPT_SET_1, false, "directory", 'd', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth, "Display the directory with optional width for the image object file."},
+ { LLDB_OPT_SET_1, false, "basename", 'b', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth, "Display the basename with optional width for the image object file."},
+ { LLDB_OPT_SET_1, false, "symfile", 's', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth, "Display the fullpath to the image symbol file with optional width."},
+ { LLDB_OPT_SET_1, false, "symfile-unique", 'S', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth, "Display the symbol file with optional width only if it is different from the executable object file."},
+ { LLDB_OPT_SET_1, false, "mod-time", 'm', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth, "Display the modification time with optional width of the module."},
+ { LLDB_OPT_SET_1, false, "ref-count", 'r', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth, "Display the reference count if the module is still in the shared module cache."},
+ { LLDB_OPT_SET_1, false, "pointer", 'p', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeNone, "Display the module pointer."},
+ { LLDB_OPT_SET_1, false, "global", 'g', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display the modules from the global module list, not just the current target."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
#pragma mark CommandObjectTargetModulesShowUnwind
@@ -3543,7 +3581,6 @@ CommandObjectTargetModulesList::CommandOptions::g_option_table[] =
class CommandObjectTargetModulesShowUnwind : public CommandObjectParsed
{
public:
-
enum
{
eLookupTypeInvalid = -1,
@@ -3557,7 +3594,6 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options(interpreter),
m_type(eLookupTypeInvalid),
@@ -3566,9 +3602,7 @@ public:
{
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -3591,11 +3625,9 @@ public:
}
case 'n':
- {
m_str = option_arg;
m_type = eLookupTypeFunctionOrSymbol;
break;
- }
default:
error.SetErrorStringWithFormat ("unrecognized option %c.", short_option);
@@ -3631,21 +3663,19 @@ public:
};
CommandObjectTargetModulesShowUnwind (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "target modules show-unwind",
- "Show synthesized unwind instructions for a function.",
- NULL,
- eCommandRequiresTarget |
- eCommandRequiresProcess |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused ),
+ CommandObjectParsed(interpreter,
+ "target modules show-unwind",
+ "Show synthesized unwind instructions for a function.",
+ nullptr,
+ eCommandRequiresTarget |
+ eCommandRequiresProcess |
+ eCommandProcessMustBeLaunched |
+ eCommandProcessMustBePaused ),
m_options (interpreter)
{
}
- ~CommandObjectTargetModulesShowUnwind () override
- {
- }
+ ~CommandObjectTargetModulesShowUnwind() override = default;
Options *
GetOptions () override
@@ -3659,11 +3689,11 @@ protected:
{
Target *target = m_exe_ctx.GetTargetPtr();
Process *process = m_exe_ctx.GetProcessPtr();
- ABI *abi = NULL;
+ ABI *abi = nullptr;
if (process)
abi = process->GetABI().get();
- if (process == NULL)
+ if (process == nullptr)
{
result.AppendError ("You must have a process running to use this command.");
result.SetStatus (eReturnStatusFailed);
@@ -3679,7 +3709,7 @@ protected:
}
ThreadSP thread(threads.GetThreadAtIndex(0));
- if (thread.get() == NULL)
+ if (!thread)
{
result.AppendError ("The process must be paused to use this command.");
result.SetStatus (eReturnStatusFailed);
@@ -3726,9 +3756,9 @@ protected:
{
SymbolContext sc;
sc_list.GetContextAtIndex(idx, sc);
- if (sc.symbol == NULL && sc.function == NULL)
+ if (sc.symbol == nullptr && sc.function == nullptr)
continue;
- if (sc.module_sp.get() == NULL || sc.module_sp->GetObjectFile() == NULL)
+ if (!sc.module_sp || sc.module_sp->GetObjectFile() == nullptr)
continue;
AddressRange range;
if (!sc.GetAddressRange (eSymbolContextFunction | eSymbolContextSymbol, 0, false, range))
@@ -3743,37 +3773,36 @@ protected:
start_addr = abi->FixCodeAddress(start_addr);
FuncUnwindersSP func_unwinders_sp (sc.module_sp->GetObjectFile()->GetUnwindTable().GetUncachedFuncUnwindersContainingAddress(start_addr, sc));
- if (func_unwinders_sp.get() == NULL)
+ if (!func_unwinders_sp)
continue;
result.GetOutputStream().Printf("UNWIND PLANS for %s`%s (start addr 0x%" PRIx64 ")\n\n", sc.module_sp->GetPlatformFileSpec().GetFilename().AsCString(), funcname.AsCString(), start_addr);
- UnwindPlanSP non_callsite_unwind_plan = func_unwinders_sp->GetUnwindPlanAtNonCallSite(*target, *thread.get(), -1);
- if (non_callsite_unwind_plan.get())
+ UnwindPlanSP non_callsite_unwind_plan = func_unwinders_sp->GetUnwindPlanAtNonCallSite(*target, *thread, -1);
+ if (non_callsite_unwind_plan)
{
result.GetOutputStream().Printf("Asynchronous (not restricted to call-sites) UnwindPlan is '%s'\n", non_callsite_unwind_plan->GetSourceName().AsCString());
}
UnwindPlanSP callsite_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(*target, -1);
- if (callsite_unwind_plan.get())
+ if (callsite_unwind_plan)
{
result.GetOutputStream().Printf("Synchronous (restricted to call-sites) UnwindPlan is '%s'\n", callsite_unwind_plan->GetSourceName().AsCString());
}
- UnwindPlanSP fast_unwind_plan = func_unwinders_sp->GetUnwindPlanFastUnwind(*target, *thread.get());
- if (fast_unwind_plan.get())
+ UnwindPlanSP fast_unwind_plan = func_unwinders_sp->GetUnwindPlanFastUnwind(*target, *thread);
+ if (fast_unwind_plan)
{
result.GetOutputStream().Printf("Fast UnwindPlan is '%s'\n", fast_unwind_plan->GetSourceName().AsCString());
}
result.GetOutputStream().Printf("\n");
- UnwindPlanSP assembly_sp = func_unwinders_sp->GetAssemblyUnwindPlan(*target, *thread.get(), 0);
+ UnwindPlanSP assembly_sp = func_unwinders_sp->GetAssemblyUnwindPlan(*target, *thread, 0);
if (assembly_sp)
{
result.GetOutputStream().Printf("Assembly language inspection UnwindPlan:\n");
assembly_sp->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS);
result.GetOutputStream().Printf("\n");
}
-
UnwindPlanSP ehframe_sp = func_unwinders_sp->GetEHFrameUnwindPlan(*target, 0);
if (ehframe_sp)
@@ -3783,7 +3812,7 @@ protected:
result.GetOutputStream().Printf("\n");
}
- UnwindPlanSP ehframe_augmented_sp = func_unwinders_sp->GetEHFrameAugmentedUnwindPlan(*target, *thread.get(), 0);
+ UnwindPlanSP ehframe_augmented_sp = func_unwinders_sp->GetEHFrameAugmentedUnwindPlan(*target, *thread, 0);
if (ehframe_augmented_sp)
{
result.GetOutputStream().Printf("eh_frame augmented UnwindPlan:\n");
@@ -3845,9 +3874,9 @@ protected:
OptionDefinition
CommandObjectTargetModulesShowUnwind::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFunctionName, "Show unwind instructions for a function or symbol name."},
- { LLDB_OPT_SET_2, false, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, "Show unwind instructions for a function or symbol containing an address"},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_1, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFunctionName, "Show unwind instructions for a function or symbol name."},
+ { LLDB_OPT_SET_2, false, "address", 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Show unwind instructions for a function or symbol containing an address"},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//----------------------------------------------------------------------
@@ -3877,9 +3906,7 @@ public:
OptionParsingStarting();
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -3995,11 +4022,11 @@ public:
};
CommandObjectTargetModulesLookup (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "target modules lookup",
- "Look up information within executable and dependent shared library images.",
- NULL,
- eCommandRequiresTarget),
+ CommandObjectParsed(interpreter,
+ "target modules lookup",
+ "Look up information within executable and dependent shared library images.",
+ nullptr,
+ eCommandRequiresTarget),
m_options (interpreter)
{
CommandArgumentEntry arg;
@@ -4016,9 +4043,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectTargetModulesLookup () override
- {
- }
+ ~CommandObjectTargetModulesLookup() override = default;
Options *
GetOptions () override
@@ -4083,11 +4108,11 @@ public:
case eLookupTypeAddress:
if (m_options.m_addr != LLDB_INVALID_ADDRESS)
{
- if (LookupAddressInModule (m_interpreter,
- result.GetOutputStream(),
- module,
- eSymbolContextEverything | (m_options.m_verbose ? eSymbolContextVariable : 0),
- m_options.m_addr,
+ if (LookupAddressInModule (m_interpreter,
+ result.GetOutputStream(),
+ module,
+ eSymbolContextEverything | (m_options.m_verbose ? static_cast<int>(eSymbolContextVariable) : 0),
+ m_options.m_addr,
m_options.m_offset,
m_options.m_verbose))
{
@@ -4179,7 +4204,7 @@ protected:
DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("invalid target, create a debug target using the 'target create' command");
result.SetStatus (eReturnStatusFailed);
@@ -4216,11 +4241,11 @@ protected:
// Dump all sections for all other modules
const ModuleList &target_modules = target->GetImages();
- Mutex::Locker modules_locker(target_modules.GetMutex());
+ std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
const size_t num_modules = target_modules.GetSize();
if (num_modules > 0)
{
- for (i = 0; i<num_modules && syntax_error == false; ++i)
+ for (i = 0; i < num_modules && !syntax_error; ++i)
{
Module *module_pointer = target_modules.GetModulePointerAtIndexUnlocked(i);
@@ -4243,7 +4268,7 @@ protected:
{
// Dump specified images (by basename or fullpath)
const char *arg_cstr;
- for (i = 0; (arg_cstr = command.GetArgumentAtIndex(i)) != NULL && syntax_error == false; ++i)
+ for (i = 0; (arg_cstr = command.GetArgumentAtIndex(i)) != nullptr && !syntax_error; ++i)
{
ModuleList module_list;
const size_t num_matches = FindModulesByName (target, arg_cstr, module_list, false);
@@ -4281,25 +4306,24 @@ protected:
OptionDefinition
CommandObjectTargetModulesLookup::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, true, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, "Lookup an address in one or more target modules."},
- { LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOffset, "When looking up an address subtract <offset> from any addresses before doing the lookup."},
+ { LLDB_OPT_SET_1, true, "address", 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Lookup an address in one or more target modules."},
+ { LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOffset, "When looking up an address subtract <offset> from any addresses before doing the lookup."},
{ LLDB_OPT_SET_2| LLDB_OPT_SET_4 | LLDB_OPT_SET_5
/* FIXME: re-enable this for types when the LookupTypeInModule actually uses the regex option: | LLDB_OPT_SET_6 */ ,
- false, "regex", 'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "The <name> argument for name lookups are regular expressions."},
- { LLDB_OPT_SET_2, true, "symbol", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeSymbol, "Lookup a symbol by name in the symbol tables in one or more target modules."},
- { LLDB_OPT_SET_3, true, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFilename, "Lookup a file by fullpath or basename in one or more target modules."},
- { LLDB_OPT_SET_3, false, "line", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum, "Lookup a line number in a file (must be used in conjunction with --file)."},
+ false, "regex", 'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "The <name> argument for name lookups are regular expressions."},
+ { LLDB_OPT_SET_2, true, "symbol", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeSymbol, "Lookup a symbol by name in the symbol tables in one or more target modules."},
+ { LLDB_OPT_SET_3, true, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename, "Lookup a file by fullpath or basename in one or more target modules."},
+ { LLDB_OPT_SET_3, false, "line", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum, "Lookup a line number in a file (must be used in conjunction with --file)."},
{ LLDB_OPT_SET_FROM_TO(3,5),
- false, "no-inlines", 'i', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Ignore inline entries (must be used in conjunction with --file or --function)."},
- { LLDB_OPT_SET_4, true, "function", 'F', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFunctionName, "Lookup a function by name in the debug symbols in one or more target modules."},
- { LLDB_OPT_SET_5, true, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFunctionOrSymbol, "Lookup a function or symbol by name in one or more target modules."},
- { LLDB_OPT_SET_6, true, "type", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Lookup a type by name in the debug symbols in one or more target modules."},
- { LLDB_OPT_SET_ALL, false, "verbose", 'v', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable verbose lookup information."},
- { LLDB_OPT_SET_ALL, false, "all", 'A', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Print all matches, not just the best match, if a best match is available."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ false, "no-inlines", 'i', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Ignore inline entries (must be used in conjunction with --file or --function)."},
+ { LLDB_OPT_SET_4, true, "function", 'F', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFunctionName, "Lookup a function by name in the debug symbols in one or more target modules."},
+ { LLDB_OPT_SET_5, true, "name", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFunctionOrSymbol, "Lookup a function or symbol by name in one or more target modules."},
+ { LLDB_OPT_SET_6, true, "type", 't', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "Lookup a type by name in the debug symbols in one or more target modules."},
+ { LLDB_OPT_SET_ALL, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable verbose lookup information."},
+ { LLDB_OPT_SET_ALL, false, "all", 'A', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Print all matches, not just the best match, if a best match is available."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
#pragma mark CommandObjectMultiwordImageSearchPaths
//-------------------------------------------------------------------------
@@ -4309,11 +4333,10 @@ CommandObjectTargetModulesLookup::CommandOptions::g_option_table[] =
class CommandObjectTargetModulesImageSearchPaths : public CommandObjectMultiword
{
public:
- CommandObjectTargetModulesImageSearchPaths (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "target modules search-paths",
- "A set of commands for operating on debugger target image search paths.",
- "target modules search-paths <subcommand> [<subcommand-options>]")
+ CommandObjectTargetModulesImageSearchPaths(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "target modules search-paths",
+ "Commands for managing module search paths for a target.",
+ "target modules search-paths <subcommand> [<subcommand-options>]")
{
LoadSubCommand ("add", CommandObjectSP (new CommandObjectTargetModulesSearchPathsAdd (interpreter)));
LoadSubCommand ("clear", CommandObjectSP (new CommandObjectTargetModulesSearchPathsClear (interpreter)));
@@ -4322,13 +4345,9 @@ public:
LoadSubCommand ("query", CommandObjectSP (new CommandObjectTargetModulesSearchPathsQuery (interpreter)));
}
- ~CommandObjectTargetModulesImageSearchPaths() override
- {
- }
+ ~CommandObjectTargetModulesImageSearchPaths() override = default;
};
-
-
#pragma mark CommandObjectTargetModules
//-------------------------------------------------------------------------
@@ -4341,11 +4360,10 @@ public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- CommandObjectTargetModules(CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "target modules",
- "A set of commands for accessing information for one or more target modules.",
- "target modules <sub-command> ...")
+ CommandObjectTargetModules(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "target modules",
+ "Commands for accessing information for one or more target modules.",
+ "target modules <sub-command> ...")
{
LoadSubCommand ("add", CommandObjectSP (new CommandObjectTargetModulesAdd (interpreter)));
LoadSubCommand ("load", CommandObjectSP (new CommandObjectTargetModulesLoad (interpreter)));
@@ -4357,9 +4375,7 @@ public:
}
- ~CommandObjectTargetModules() override
- {
- }
+ ~CommandObjectTargetModules() override = default;
private:
//------------------------------------------------------------------
@@ -4368,8 +4384,6 @@ private:
DISALLOW_COPY_AND_ASSIGN (CommandObjectTargetModules);
};
-
-
class CommandObjectTargetSymbolsAdd : public CommandObjectParsed
{
public:
@@ -4389,9 +4403,7 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectTargetSymbolsAdd () override
- {
- }
+ ~CommandObjectTargetSymbolsAdd() override = default;
int
HandleArgumentCompletion (Args &input,
@@ -4406,14 +4418,14 @@ public:
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eDiskFileCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eDiskFileCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
@@ -4473,7 +4485,7 @@ protected:
// No matches yet, iterate through the module specs to find a UUID value that
// we can match up to an image in our target
const size_t num_symfile_module_specs = symfile_module_specs.GetSize();
- for (size_t i=0; i<num_symfile_module_specs && num_matches == 0; ++i)
+ for (size_t i = 0; i < num_symfile_module_specs && num_matches == 0; ++i)
{
if (symfile_module_specs.GetModuleSpecAtIndex(i, symfile_module_spec))
{
@@ -4606,8 +4618,8 @@ protected:
const bool uuid_option_set = m_uuid_option_group.GetOptionValue().OptionWasSet();
const bool file_option_set = m_file_option.GetOptionValue().OptionWasSet();
const bool frame_option_set = m_current_frame_option.GetOptionValue().OptionWasSet();
-
const size_t argc = args.GetArgumentCount();
+
if (argc == 0)
{
if (uuid_option_set || file_option_set || frame_option_set)
@@ -4682,7 +4694,7 @@ protected:
{
module_spec.GetArchitecture() = target->GetArchitecture();
}
- success |= module_spec.GetFileSpec().Exists();
+ success |= module_spec.GetUUID().IsValid() || module_spec.GetFileSpec().Exists();
}
}
@@ -4738,7 +4750,7 @@ protected:
{
PlatformSP platform_sp (target->GetPlatform());
- for (size_t i=0; i<argc; ++i)
+ for (size_t i = 0; i < argc; ++i)
{
const char *symfile_path = args.GetArgumentAtIndex(i);
if (symfile_path)
@@ -4793,7 +4805,6 @@ protected:
OptionGroupBoolean m_current_frame_option;
};
-
#pragma mark CommandObjectTargetSymbols
//-------------------------------------------------------------------------
@@ -4806,19 +4817,14 @@ public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- CommandObjectTargetSymbols(CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "target symbols",
- "A set of commands for adding and managing debug symbol files.",
- "target symbols <sub-command> ...")
+ CommandObjectTargetSymbols(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "target symbols", "Commands for adding and managing debug symbol files.",
+ "target symbols <sub-command> ...")
{
LoadSubCommand ("add", CommandObjectSP (new CommandObjectTargetSymbolsAdd (interpreter)));
-
}
- ~CommandObjectTargetSymbols() override
- {
- }
+ ~CommandObjectTargetSymbols() override = default;
private:
//------------------------------------------------------------------
@@ -4827,7 +4833,6 @@ private:
DISALLOW_COPY_AND_ASSIGN (CommandObjectTargetSymbols);
};
-
#pragma mark CommandObjectTargetStopHookAdd
//-------------------------------------------------------------------------
@@ -4839,7 +4844,6 @@ class CommandObjectTargetStopHookAdd :
public IOHandlerDelegateMultiline
{
public:
-
class CommandOptions : public Options
{
public:
@@ -4855,7 +4859,7 @@ public:
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
const OptionDefinition*
GetDefinitions () override
@@ -4875,7 +4879,7 @@ public:
case 'c':
m_class_name = option_arg;
m_sym_ctx_specified = true;
- break;
+ break;
case 'e':
m_line_end = StringConvert::ToUInt32 (option_arg, UINT_MAX, 0, &success);
@@ -4885,7 +4889,7 @@ public:
break;
}
m_sym_ctx_specified = true;
- break;
+ break;
case 'l':
m_line_start = StringConvert::ToUInt32 (option_arg, 0, 0, &success);
@@ -4895,57 +4899,60 @@ public:
break;
}
m_sym_ctx_specified = true;
- break;
+ break;
case 'i':
m_no_inlines = true;
- break;
+ break;
case 'n':
m_function_name = option_arg;
m_func_name_type_mask |= eFunctionNameTypeAuto;
m_sym_ctx_specified = true;
- break;
+ break;
case 'f':
m_file_name = option_arg;
m_sym_ctx_specified = true;
- break;
+ break;
+
case 's':
m_module_name = option_arg;
m_sym_ctx_specified = true;
- break;
+ break;
+
case 't' :
- {
m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
if (m_thread_id == LLDB_INVALID_THREAD_ID)
error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
m_thread_specified = true;
- }
- break;
+ break;
+
case 'T':
m_thread_name = option_arg;
m_thread_specified = true;
- break;
+ break;
+
case 'q':
m_queue_name = option_arg;
m_thread_specified = true;
break;
+
case 'x':
- {
m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_thread_id == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
m_thread_specified = true;
- }
- break;
+ break;
+
case 'o':
m_use_one_liner = true;
m_one_liner = option_arg;
- break;
+ break;
+
default:
error.SetErrorStringWithFormat ("unrecognized option %c.", short_option);
- break;
+ break;
}
return error;
}
@@ -4973,7 +4980,6 @@ public:
m_one_liner.clear();
}
-
static OptionDefinition g_option_table[];
std::string m_class_name;
@@ -4995,12 +5001,6 @@ public:
std::string m_one_liner;
};
- Options *
- GetOptions () override
- {
- return &m_options;
- }
-
CommandObjectTargetStopHookAdd (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
"target stop-hook add",
@@ -5011,8 +5011,12 @@ public:
{
}
- ~CommandObjectTargetStopHookAdd () override
+ ~CommandObjectTargetStopHookAdd() override = default;
+
+ Options *
+ GetOptions () override
{
+ return &m_options;
}
protected:
@@ -5106,7 +5110,7 @@ protected:
}
}
- if (specifier_ap.get())
+ if (specifier_ap)
new_hook_sp->SetSpecifier (specifier_ap.release());
// Next see if any of the thread options have been entered:
@@ -5141,10 +5145,10 @@ protected:
else
{
m_stop_hook_sp = new_hook_sp;
- m_interpreter.GetLLDBCommandsFromIOHandler ("> ", // Prompt
- *this, // IOHandlerDelegate
- true, // Run IOHandler in async mode
- NULL); // Baton for the "io_handler" that will be passed back into our IOHandlerDelegate functions
+ m_interpreter.GetLLDBCommandsFromIOHandler("> ", // Prompt
+ *this, // IOHandlerDelegate
+ true, // Run IOHandler in async mode
+ nullptr); // Baton for the "io_handler" that will be passed back into our IOHandlerDelegate functions
}
result.SetStatus (eReturnStatusSuccessFinishNoResult);
@@ -5157,6 +5161,7 @@ protected:
return result.Succeeded();
}
+
private:
CommandOptions m_options;
Target::StopHookSP m_stop_hook_sp;
@@ -5165,29 +5170,29 @@ private:
OptionDefinition
CommandObjectTargetStopHookAdd::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "one-liner", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOneLiner,
+ { LLDB_OPT_SET_ALL, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOneLiner,
"Specify a one-line breakpoint command inline. Be sure to surround it with quotes." },
- { LLDB_OPT_SET_ALL, false, "shlib", 's', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName,
+ { LLDB_OPT_SET_ALL, false, "shlib", 's', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eModuleCompletion, eArgTypeShlibName,
"Set the module within which the stop-hook is to be run."},
- { LLDB_OPT_SET_ALL, false, "thread-index", 'x', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadIndex,
+ { LLDB_OPT_SET_ALL, false, "thread-index", 'x', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadIndex,
"The stop hook is run only for the thread whose index matches this argument."},
- { LLDB_OPT_SET_ALL, false, "thread-id", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadID,
+ { LLDB_OPT_SET_ALL, false, "thread-id", 't', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadID,
"The stop hook is run only for the thread whose TID matches this argument."},
- { LLDB_OPT_SET_ALL, false, "thread-name", 'T', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadName,
+ { LLDB_OPT_SET_ALL, false, "thread-name", 'T', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadName,
"The stop hook is run only for the thread whose thread name matches this argument."},
- { LLDB_OPT_SET_ALL, false, "queue-name", 'q', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeQueueName,
+ { LLDB_OPT_SET_ALL, false, "queue-name", 'q', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeQueueName,
"The stop hook is run only for threads in the queue whose name is given by this argument."},
- { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
+ { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
"Specify the source file within which the stop-hook is to be run." },
- { LLDB_OPT_SET_1, false, "start-line", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum,
+ { LLDB_OPT_SET_1, false, "start-line", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum,
"Set the start of the line range for which the stop-hook is to be run."},
- { LLDB_OPT_SET_1, false, "end-line", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum,
+ { LLDB_OPT_SET_1, false, "end-line", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum,
"Set the end of the line range for which the stop-hook is to be run."},
- { LLDB_OPT_SET_2, false, "classname", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeClassName,
+ { LLDB_OPT_SET_2, false, "classname", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeClassName,
"Specify the class within which the stop-hook is to be run." },
- { LLDB_OPT_SET_3, false, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
+ { LLDB_OPT_SET_3, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
"Set the function name within which the stop hook will be run." },
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
#pragma mark CommandObjectTargetStopHookDelete
@@ -5199,7 +5204,6 @@ CommandObjectTargetStopHookAdd::CommandOptions::g_option_table[] =
class CommandObjectTargetStopHookDelete : public CommandObjectParsed
{
public:
-
CommandObjectTargetStopHookDelete (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
"target stop-hook delete",
@@ -5208,9 +5212,7 @@ public:
{
}
- ~CommandObjectTargetStopHookDelete () override
- {
- }
+ ~CommandObjectTargetStopHookDelete() override = default;
protected:
bool
@@ -5265,6 +5267,7 @@ protected:
return result.Succeeded();
}
};
+
#pragma mark CommandObjectTargetStopHookEnableDisable
//-------------------------------------------------------------------------
@@ -5274,7 +5277,6 @@ protected:
class CommandObjectTargetStopHookEnableDisable : public CommandObjectParsed
{
public:
-
CommandObjectTargetStopHookEnableDisable (CommandInterpreter &interpreter, bool enable, const char *name, const char *help, const char *syntax) :
CommandObjectParsed (interpreter,
name,
@@ -5284,9 +5286,7 @@ public:
{
}
- ~CommandObjectTargetStopHookEnableDisable () override
- {
- }
+ ~CommandObjectTargetStopHookEnableDisable() override = default;
protected:
bool
@@ -5345,7 +5345,6 @@ private:
class CommandObjectTargetStopHookList : public CommandObjectParsed
{
public:
-
CommandObjectTargetStopHookList (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
"target stop-hook list",
@@ -5354,9 +5353,7 @@ public:
{
}
- ~CommandObjectTargetStopHookList () override
- {
- }
+ ~CommandObjectTargetStopHookList() override = default;
protected:
bool
@@ -5391,6 +5388,7 @@ protected:
};
#pragma mark CommandObjectMultiwordTargetStopHooks
+
//-------------------------------------------------------------------------
// CommandObjectMultiwordTargetStopHooks
//-------------------------------------------------------------------------
@@ -5398,12 +5396,10 @@ protected:
class CommandObjectMultiwordTargetStopHooks : public CommandObjectMultiword
{
public:
-
- CommandObjectMultiwordTargetStopHooks (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "target stop-hook",
- "A set of commands for operating on debugger target stop-hooks.",
- "target stop-hook <subcommand> [<subcommand-options>]")
+ CommandObjectMultiwordTargetStopHooks(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "target stop-hook",
+ "Commands for operating on debugger target stop-hooks.",
+ "target stop-hook <subcommand> [<subcommand-options>]")
{
LoadSubCommand ("add", CommandObjectSP (new CommandObjectTargetStopHookAdd (interpreter)));
LoadSubCommand ("delete", CommandObjectSP (new CommandObjectTargetStopHookDelete (interpreter)));
@@ -5420,26 +5416,19 @@ public:
LoadSubCommand ("list", CommandObjectSP (new CommandObjectTargetStopHookList (interpreter)));
}
- ~CommandObjectMultiwordTargetStopHooks() override
- {
- }
+ ~CommandObjectMultiwordTargetStopHooks() override = default;
};
-
-
#pragma mark CommandObjectMultiwordTarget
//-------------------------------------------------------------------------
// CommandObjectMultiwordTarget
//-------------------------------------------------------------------------
-CommandObjectMultiwordTarget::CommandObjectMultiwordTarget (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "target",
- "A set of commands for operating on debugger targets.",
- "target <subcommand> [<subcommand-options>]")
+CommandObjectMultiwordTarget::CommandObjectMultiwordTarget(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "target", "Commands for operating on debugger targets.",
+ "target <subcommand> [<subcommand-options>]")
{
-
LoadSubCommand ("create", CommandObjectSP (new CommandObjectTargetCreate (interpreter)));
LoadSubCommand ("delete", CommandObjectSP (new CommandObjectTargetDelete (interpreter)));
LoadSubCommand ("list", CommandObjectSP (new CommandObjectTargetList (interpreter)));
@@ -5450,8 +5439,4 @@ CommandObjectMultiwordTarget::CommandObjectMultiwordTarget (CommandInterpreter &
LoadSubCommand ("variable", CommandObjectSP (new CommandObjectTargetVariable (interpreter)));
}
-CommandObjectMultiwordTarget::~CommandObjectMultiwordTarget ()
-{
-}
-
-
+CommandObjectMultiwordTarget::~CommandObjectMultiwordTarget() = default;
diff --git a/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp
index e932c9d96c35c..9e4bffdeb6a55 100644
--- a/source/Commands/CommandObjectThread.cpp
+++ b/source/Commands/CommandObjectThread.cpp
@@ -37,11 +37,9 @@
#include "lldb/Target/ThreadPlanStepRange.h"
#include "lldb/Target/ThreadPlanStepInRange.h"
-
using namespace lldb;
using namespace lldb_private;
-
//-------------------------------------------------------------------------
// CommandObjectThreadBacktrace
//-------------------------------------------------------------------------
@@ -58,7 +56,7 @@ public:
{
}
- ~CommandObjectIterateOverThreads() override {}
+ ~CommandObjectIterateOverThreads() override = default;
bool
DoExecute (Args& command, CommandReturnObject &result) override
@@ -68,34 +66,33 @@ public:
if (command.GetArgumentCount() == 0)
{
Thread *thread = m_exe_ctx.GetThreadPtr();
- if (!HandleOneThread (*thread, result))
+ if (!HandleOneThread (thread->GetID(), result))
return false;
+ return result.Succeeded();
}
- else if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0)
+
+ // Use tids instead of ThreadSPs to prevent deadlocking problems which result from JIT-ing
+ // code while iterating over the (locked) ThreadSP list.
+ std::vector<lldb::tid_t> tids;
+
+ if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0)
{
Process *process = m_exe_ctx.GetProcessPtr();
- uint32_t idx = 0;
- for (ThreadSP thread_sp : process->Threads())
- {
- if (idx != 0 && m_add_return)
- result.AppendMessage("");
- if (!HandleOneThread(*(thread_sp.get()), result))
- return false;
- ++idx;
- }
+ for (ThreadSP thread_sp : process->Threads())
+ tids.push_back(thread_sp->GetID());
}
else
{
const size_t num_args = command.GetArgumentCount();
Process *process = m_exe_ctx.GetProcessPtr();
- Mutex::Locker locker (process->GetThreadList().GetMutex());
- std::vector<ThreadSP> thread_sps;
+
+ std::lock_guard<std::recursive_mutex> guard(process->GetThreadList().GetMutex());
for (size_t i = 0; i < num_args; i++)
{
bool success;
-
+
uint32_t thread_idx = StringConvert::ToUInt32(command.GetArgumentAtIndex(i), 0, 0, &success);
if (!success)
{
@@ -103,32 +100,35 @@ public:
result.SetStatus (eReturnStatusFailed);
return false;
}
-
- thread_sps.push_back(process->GetThreadList().FindThreadByIndexID(thread_idx));
-
- if (!thread_sps[i])
+
+ ThreadSP thread = process->GetThreadList().FindThreadByIndexID(thread_idx);
+
+ if (!thread)
{
result.AppendErrorWithFormat ("no thread with index: \"%s\"\n", command.GetArgumentAtIndex(i));
result.SetStatus (eReturnStatusFailed);
return false;
}
-
- }
-
- for (uint32_t i = 0; i < num_args; i++)
- {
- if (!HandleOneThread (*(thread_sps[i].get()), result))
- return false;
- if (i < num_args - 1 && m_add_return)
- result.AppendMessage("");
+ tids.push_back(thread->GetID());
}
}
+
+ uint32_t idx = 0;
+ for (const lldb::tid_t &tid : tids)
+ {
+ if (idx != 0 && m_add_return)
+ result.AppendMessage("");
+
+ if (!HandleOneThread (tid, result))
+ return false;
+
+ ++idx;
+ }
return result.Succeeded();
}
protected:
-
// Override this to do whatever you need to do for one thread.
//
// If you return false, the iteration will stop, otherwise it will proceed.
@@ -137,11 +137,10 @@ protected:
// If m_add_return is true, a blank line will be inserted between each of the listings (except the last one.)
virtual bool
- HandleOneThread (Thread &thread, CommandReturnObject &result) = 0;
+ HandleOneThread (lldb::tid_t, CommandReturnObject &result) = 0;
ReturnStatus m_success_return = eReturnStatusSuccessFinishResult;
bool m_add_return = true;
-
};
//-------------------------------------------------------------------------
@@ -151,11 +150,9 @@ protected:
class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads
{
public:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options(interpreter)
{
@@ -163,9 +160,7 @@ public:
OptionParsingStarting ();
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -194,6 +189,7 @@ public:
if (!success)
error.SetErrorStringWithFormat("invalid integer value for option '%c'", short_option);
}
+ break;
case 'e':
{
bool success;
@@ -205,7 +201,6 @@ public:
default:
error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
break;
-
}
return error;
}
@@ -234,23 +229,18 @@ public:
bool m_extended_backtrace;
};
- CommandObjectThreadBacktrace (CommandInterpreter &interpreter) :
- CommandObjectIterateOverThreads (interpreter,
- "thread backtrace",
- "Show the stack for one or more threads. If no threads are specified, show the currently selected thread. Use the thread-index \"all\" to see all threads.",
- NULL,
- eCommandRequiresProcess |
- eCommandRequiresThread |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused ),
- m_options(interpreter)
+ CommandObjectThreadBacktrace(CommandInterpreter &interpreter)
+ : CommandObjectIterateOverThreads(
+ interpreter, "thread backtrace", "Show thread call stacks. Defaults to the current thread, thread "
+ "indexes can be specified as arguments. Use the thread-index \"all\" "
+ "to see all threads.",
+ nullptr, eCommandRequiresProcess | eCommandRequiresThread | eCommandTryTargetAPILock |
+ eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
+ m_options(interpreter)
{
}
- ~CommandObjectThreadBacktrace() override
- {
- }
+ ~CommandObjectThreadBacktrace() override = default;
Options *
GetOptions () override
@@ -286,25 +276,35 @@ protected:
}
bool
- HandleOneThread (Thread &thread, CommandReturnObject &result) override
+ HandleOneThread (lldb::tid_t tid, CommandReturnObject &result) override
{
+ ThreadSP thread_sp = m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
+ if (!thread_sp)
+ {
+ result.AppendErrorWithFormat ("thread disappeared while computing backtraces: 0x%" PRIx64 "\n", tid);
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+
+ Thread *thread = thread_sp.get();
+
Stream &strm = result.GetOutputStream();
// Don't show source context when doing backtraces.
const uint32_t num_frames_with_source = 0;
- if (!thread.GetStatus (strm,
- m_options.m_start,
- m_options.m_count,
- num_frames_with_source))
+ if (!thread->GetStatus (strm,
+ m_options.m_start,
+ m_options.m_count,
+ num_frames_with_source))
{
- result.AppendErrorWithFormat ("error displaying backtrace for thread: \"0x%4.4x\"\n", thread.GetIndexID());
+ result.AppendErrorWithFormat ("error displaying backtrace for thread: \"0x%4.4x\"\n", thread->GetIndexID());
result.SetStatus (eReturnStatusFailed);
return false;
}
if (m_options.m_extended_backtrace)
{
- DoExtendedBacktrace (&thread, result);
+ DoExtendedBacktrace (thread, result);
}
return true;
@@ -316,10 +316,10 @@ protected:
OptionDefinition
CommandObjectThreadBacktrace::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount, "How many frames to display (-1 for all)"},
-{ LLDB_OPT_SET_1, false, "start", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFrameIndex, "Frame in which to start the backtrace"},
-{ LLDB_OPT_SET_1, false, "extended", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Show the extended backtrace, if available"},
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount, "How many frames to display (-1 for all)"},
+{ LLDB_OPT_SET_1, false, "start", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFrameIndex, "Frame in which to start the backtrace"},
+{ LLDB_OPT_SET_1, false, "extended", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Show the extended backtrace, if available"},
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
enum StepScope
@@ -331,11 +331,9 @@ enum StepScope
class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed
{
public:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter)
{
@@ -343,9 +341,7 @@ public:
OptionParsingStarting ();
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -382,19 +378,16 @@ public:
break;
case 'c':
- {
- m_step_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
- if (m_step_count == UINT32_MAX)
- error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
- break;
- }
+ m_step_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
+ if (m_step_count == UINT32_MAX)
+ error.SetErrorStringWithFormat ("invalid step count '%s'", option_arg);
break;
+
case 'C':
- {
- m_class_name.clear();
- m_class_name.assign(option_arg);
- }
+ m_class_name.clear();
+ m_class_name.assign(option_arg);
break;
+
case 'm':
{
OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values;
@@ -402,24 +395,35 @@ public:
}
break;
- case 'r':
+ case 'e':
{
- m_avoid_regexp.clear();
- m_avoid_regexp.assign(option_arg);
+ if (strcmp(option_arg, "block") == 0)
+ {
+ m_end_line_is_block_end = 1;
+ break;
+ }
+ uint32_t tmp_end_line = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
+ if (tmp_end_line == UINT32_MAX)
+ error.SetErrorStringWithFormat ("invalid end line number '%s'", option_arg);
+ else
+ m_end_line = tmp_end_line;
+ break;
}
break;
- case 't':
- {
- m_step_in_target.clear();
- m_step_in_target.assign(option_arg);
+ case 'r':
+ m_avoid_regexp.clear();
+ m_avoid_regexp.assign(option_arg);
+ break;
- }
+ case 't':
+ m_step_in_target.clear();
+ m_step_in_target.assign(option_arg);
break;
+
default:
error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
break;
-
}
return error;
}
@@ -433,13 +437,15 @@ public:
// Check if we are in Non-Stop mode
lldb::TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget();
- if (target_sp.get() != nullptr && target_sp->GetNonStopModeEnabled())
+ if (target_sp && target_sp->GetNonStopModeEnabled())
m_run_mode = eOnlyThisThread;
m_avoid_regexp.clear();
m_step_in_target.clear();
m_class_name.clear();
m_step_count = 1;
+ m_end_line = LLDB_INVALID_LINE_NUMBER;
+ m_end_line_is_block_end = false;
}
const OptionDefinition*
@@ -460,6 +466,8 @@ public:
std::string m_step_in_target;
std::string m_class_name;
uint32_t m_step_count;
+ uint32_t m_end_line;
+ bool m_end_line_is_block_end;
};
CommandObjectThreadStepWithTypeAndScope (CommandInterpreter &interpreter,
@@ -492,9 +500,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectThreadStepWithTypeAndScope () override
- {
- }
+ ~CommandObjectThreadStepWithTypeAndScope() override = default;
Options *
GetOptions () override
@@ -510,12 +516,13 @@ protected:
bool synchronous_execution = m_interpreter.GetSynchronous();
const uint32_t num_threads = process->GetThreadList().GetSize();
- Thread *thread = NULL;
+ Thread *thread = nullptr;
if (command.GetArgumentCount() == 0)
{
- thread = process->GetThreadList().GetSelectedThread().get();
- if (thread == NULL)
+ thread = GetDefaultThread();
+
+ if (thread == nullptr)
{
result.AppendError ("no selected thread in process");
result.SetStatus (eReturnStatusFailed);
@@ -533,7 +540,7 @@ protected:
return false;
}
thread = process->GetThreadList().FindThreadByIndexID(step_thread_idx).get();
- if (thread == NULL)
+ if (thread == nullptr)
{
result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n",
step_thread_idx, num_threads);
@@ -558,6 +565,14 @@ protected:
}
}
+ if (m_options.m_end_line != LLDB_INVALID_LINE_NUMBER
+ && m_step_type != eStepTypeInto)
+ {
+ result.AppendErrorWithFormat("end line option is only valid for step into");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
const bool abort_other_plans = false;
const lldb::RunMode stop_other_threads = m_options.m_run_mode;
@@ -567,12 +582,7 @@ protected:
if (m_options.m_run_mode == eAllThreads)
bool_stop_other_threads = false;
else if (m_options.m_run_mode == eOnlyDuringStepping)
- {
- if (m_step_type == eStepTypeOut || m_step_type == eStepTypeScripted)
- bool_stop_other_threads = false;
- else
- bool_stop_other_threads = true;
- }
+ bool_stop_other_threads = (m_step_type != eStepTypeOut && m_step_type != eStepTypeScripted);
else
bool_stop_other_threads = true;
@@ -585,13 +595,54 @@ protected:
if (frame->HasDebugInformation ())
{
+ AddressRange range;
+ SymbolContext sc = frame->GetSymbolContext(eSymbolContextEverything);
+ if (m_options.m_end_line != LLDB_INVALID_LINE_NUMBER)
+ {
+ Error error;
+ if (!sc.GetAddressRangeFromHereToEndLine(m_options.m_end_line, range, error))
+ {
+ result.AppendErrorWithFormat("invalid end-line option: %s.", error.AsCString());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ }
+ else if (m_options.m_end_line_is_block_end)
+ {
+ Error error;
+ Block *block = frame->GetSymbolContext(eSymbolContextBlock).block;
+ if (!block)
+ {
+ result.AppendErrorWithFormat("Could not find the current block.");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ AddressRange block_range;
+ Address pc_address = frame->GetFrameCodeAddress();
+ block->GetRangeContainingAddress(pc_address, block_range);
+ if (!block_range.GetBaseAddress().IsValid())
+ {
+ result.AppendErrorWithFormat("Could not find the current block address.");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ lldb::addr_t pc_offset_in_block = pc_address.GetFileAddress() - block_range.GetBaseAddress().GetFileAddress();
+ lldb::addr_t range_length = block_range.GetByteSize() - pc_offset_in_block;
+ range = AddressRange(pc_address, range_length);
+ }
+ else
+ {
+ range = sc.line_entry.range;
+ }
+
new_plan_sp = thread->QueueThreadPlanForStepInRange (abort_other_plans,
- frame->GetSymbolContext(eSymbolContextEverything).line_entry,
- frame->GetSymbolContext(eSymbolContextEverything),
- m_options.m_step_in_target.c_str(),
- stop_other_threads,
- m_options.m_step_in_avoid_no_debug,
- m_options.m_step_out_avoid_no_debug);
+ range,
+ frame->GetSymbolContext(eSymbolContextEverything),
+ m_options.m_step_in_target.c_str(),
+ stop_other_threads,
+ m_options.m_step_in_avoid_no_debug,
+ m_options.m_step_out_avoid_no_debug);
if (new_plan_sp && !m_options.m_avoid_regexp.empty())
{
@@ -601,7 +652,6 @@ protected:
}
else
new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction (false, abort_other_plans, bool_stop_other_threads);
-
}
else if (m_step_type == eStepTypeOver)
{
@@ -617,7 +667,6 @@ protected:
new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction (true,
abort_other_plans,
bool_stop_other_threads);
-
}
else if (m_step_type == eStepTypeTrace)
{
@@ -629,14 +678,14 @@ protected:
}
else if (m_step_type == eStepTypeOut)
{
- new_plan_sp = thread->QueueThreadPlanForStepOut (abort_other_plans,
- NULL,
- false,
- bool_stop_other_threads,
- eVoteYes,
- eVoteNoOpinion,
- thread->GetSelectedFrameIndex(),
- m_options.m_step_out_avoid_no_debug);
+ new_plan_sp = thread->QueueThreadPlanForStepOut(abort_other_plans,
+ nullptr,
+ false,
+ bool_stop_other_threads,
+ eVoteYes,
+ eVoteNoOpinion,
+ thread->GetSelectedFrameIndex(),
+ m_options.m_step_out_avoid_no_debug);
}
else if (m_step_type == eStepTypeScripted)
{
@@ -667,7 +716,6 @@ protected:
}
}
-
process->GetThreadList().SetSelectedThreadByID (thread->GetID());
const uint32_t iohandler_id = process->GetIOHandlerID();
@@ -719,7 +767,7 @@ g_tri_running_mode[] =
{ eOnlyThisThread, "this-thread", "Run only this thread"},
{ eAllThreads, "all-threads", "Run all threads"},
{ eOnlyDuringStepping, "while-stepping", "Run only this thread while stepping"},
-{ 0, NULL, NULL }
+{ 0, nullptr, nullptr }
};
static OptionEnumValueElement
@@ -727,23 +775,25 @@ g_duo_running_mode[] =
{
{ eOnlyThisThread, "this-thread", "Run only this thread"},
{ eAllThreads, "all-threads", "Run all threads"},
-{ 0, NULL, NULL }
+{ 0, nullptr, nullptr }
};
OptionDefinition
CommandObjectThreadStepWithTypeAndScope::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, false, "step-in-avoids-no-debug", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "A boolean value that sets whether stepping into functions will step over functions with no debug information."},
-{ LLDB_OPT_SET_1, false, "step-out-avoids-no-debug", 'A', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "A boolean value, if true stepping out of functions will continue to step out till it hits a function with debug information."},
-{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, NULL, NULL, 1, eArgTypeCount, "How many times to perform the stepping operation - currently only supported for step-inst and next-inst."},
-{ LLDB_OPT_SET_1, false, "run-mode", 'm', OptionParser::eRequiredArgument, NULL, g_tri_running_mode, 0, eArgTypeRunMode, "Determine how to run other threads while stepping the current thread."},
-{ LLDB_OPT_SET_1, false, "step-over-regexp", 'r', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeRegularExpression, "A regular expression that defines function names to not to stop at when stepping in."},
-{ LLDB_OPT_SET_1, false, "step-in-target", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFunctionName, "The name of the directly called function step in should stop at when stepping into."},
-{ LLDB_OPT_SET_2, false, "python-class", 'C', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonClass, "The name of the class that will manage this step - only supported for Scripted Step."},
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_1, false, "step-in-avoids-no-debug", 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "A boolean value that sets whether stepping into functions will step over functions with no debug information."},
+{ LLDB_OPT_SET_1, false, "step-out-avoids-no-debug", 'A', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "A boolean value, if true stepping out of functions will continue to step out till it hits a function with debug information."},
+{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 1, eArgTypeCount, "How many times to perform the stepping operation - currently only supported for step-inst and next-inst."},
+{ LLDB_OPT_SET_1, false, "end-linenumber", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 1, eArgTypeLineNum, "The line at which to stop stepping - defaults to the next line and only supported for step-in and step-over."
+ " You can also pass the string 'block' to step to the end of the current block."
+ " This is particularly useful in conjunction with --step-target to step through a complex calling sequence."},
+{ LLDB_OPT_SET_1, false, "run-mode", 'm', OptionParser::eRequiredArgument, nullptr, g_tri_running_mode, 0, eArgTypeRunMode, "Determine how to run other threads while stepping the current thread."},
+{ LLDB_OPT_SET_1, false, "step-over-regexp", 'r', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeRegularExpression, "A regular expression that defines function names to not to stop at when stepping in."},
+{ LLDB_OPT_SET_1, false, "step-in-target", 't', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFunctionName, "The name of the directly called function step in should stop at when stepping into."},
+{ LLDB_OPT_SET_2, false, "python-class", 'C', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePythonClass, "The name of the class that will manage this step - only supported for Scripted Step."},
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
//-------------------------------------------------------------------------
// CommandObjectThreadContinue
//-------------------------------------------------------------------------
@@ -751,16 +801,12 @@ CommandObjectThreadStepWithTypeAndScope::CommandOptions::g_option_table[] =
class CommandObjectThreadContinue : public CommandObjectParsed
{
public:
-
- CommandObjectThreadContinue (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "thread continue",
- "Continue execution of one or more threads in an active process.",
- NULL,
- eCommandRequiresThread |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused)
+ CommandObjectThreadContinue(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "thread continue", "Continue execution of the current target process. One "
+ "or more threads may be specified, by default all "
+ "threads continue.",
+ nullptr, eCommandRequiresThread | eCommandTryTargetAPILock |
+ eCommandProcessMustBeLaunched | eCommandProcessMustBePaused)
{
CommandArgumentEntry arg;
CommandArgumentData thread_idx_arg;
@@ -776,17 +822,14 @@ public:
m_arguments.push_back (arg);
}
-
- ~CommandObjectThreadContinue () override
- {
- }
+ ~CommandObjectThreadContinue() override = default;
bool
DoExecute (Args& command, CommandReturnObject &result) override
{
bool synchronous_execution = m_interpreter.GetSynchronous ();
- if (!m_interpreter.GetDebugger().GetSelectedTarget().get())
+ if (!m_interpreter.GetDebugger().GetSelectedTarget())
{
result.AppendError ("invalid target, create a debug target using the 'target create' command");
result.SetStatus (eReturnStatusFailed);
@@ -794,7 +837,7 @@ public:
}
Process *process = m_exe_ctx.GetProcessPtr();
- if (process == NULL)
+ if (process == nullptr)
{
result.AppendError ("no process exists. Cannot continue");
result.SetStatus (eReturnStatusFailed);
@@ -810,10 +853,10 @@ public:
// These two lines appear at the beginning of both blocks in
// this if..else, but that is because we need to release the
// lock before calling process->Resume below.
- Mutex::Locker locker (process->GetThreadList().GetMutex());
+ std::lock_guard<std::recursive_mutex> guard(process->GetThreadList().GetMutex());
const uint32_t num_threads = process->GetThreadList().GetSize();
std::vector<Thread *> resume_threads;
- for (uint32_t i=0; i<argc; ++i)
+ for (uint32_t i = 0; i < argc; ++i)
{
bool success;
const int base = 0;
@@ -854,7 +897,7 @@ public:
else
result.AppendMessageWithFormat ("Resuming threads: ");
- for (uint32_t idx=0; idx<num_threads; ++idx)
+ for (uint32_t idx = 0; idx < num_threads; ++idx)
{
Thread *thread = process->GetThreadList().GetThreadAtIndex(idx).get();
std::vector<Thread *>::iterator this_thread_pos = find(resume_threads.begin(), resume_threads.end(), thread);
@@ -862,7 +905,7 @@ public:
if (this_thread_pos != resume_threads.end())
{
resume_threads.erase(this_thread_pos);
- if (resume_threads.size() > 0)
+ if (!resume_threads.empty())
result.AppendMessageWithFormat ("%u, ", thread->GetIndexID());
else
result.AppendMessageWithFormat ("%u ", thread->GetIndexID());
@@ -883,17 +926,17 @@ public:
// These two lines appear at the beginning of both blocks in
// this if..else, but that is because we need to release the
// lock before calling process->Resume below.
- Mutex::Locker locker (process->GetThreadList().GetMutex());
+ std::lock_guard<std::recursive_mutex> guard(process->GetThreadList().GetMutex());
const uint32_t num_threads = process->GetThreadList().GetSize();
- Thread *current_thread = process->GetThreadList().GetSelectedThread().get();
- if (current_thread == NULL)
+ Thread *current_thread = GetDefaultThread();
+ if (current_thread == nullptr)
{
result.AppendError ("the process doesn't have a current thread");
result.SetStatus (eReturnStatusFailed);
return false;
}
// Set the actions that the threads should each take when resuming
- for (uint32_t idx=0; idx<num_threads; ++idx)
+ for (uint32_t idx = 0; idx < num_threads; ++idx)
{
Thread *thread = process->GetThreadList().GetThreadAtIndex(idx).get();
if (thread == current_thread)
@@ -909,7 +952,6 @@ public:
}
}
-
StreamString stream;
Error error;
if (synchronous_execution)
@@ -950,7 +992,6 @@ public:
return result.Succeeded();
}
-
};
//-------------------------------------------------------------------------
@@ -960,7 +1001,6 @@ public:
class CommandObjectThreadUntil : public CommandObjectParsed
{
public:
-
class CommandOptions : public Options
{
public:
@@ -976,9 +1016,7 @@ public:
OptionParsingStarting ();
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -997,23 +1035,19 @@ public:
}
break;
case 't':
- {
m_thread_idx = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_INDEX32);
if (m_thread_idx == LLDB_INVALID_INDEX32)
{
error.SetErrorStringWithFormat ("invalid thread index '%s'", option_arg);
}
- }
- break;
+ break;
case 'f':
- {
m_frame_idx = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_FRAME_ID);
if (m_frame_idx == LLDB_INVALID_FRAME_ID)
{
error.SetErrorStringWithFormat ("invalid frame index '%s'", option_arg);
}
- }
- break;
+ break;
case 'm':
{
OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values;
@@ -1031,7 +1065,6 @@ public:
default:
error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
break;
-
}
return error;
}
@@ -1062,16 +1095,13 @@ public:
// Instance variables to hold the values for command options.
};
- CommandObjectThreadUntil (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "thread until",
- "Run the current or specified thread until it reaches a given line number or address or leaves the current function.",
- NULL,
- eCommandRequiresThread |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused ),
- m_options (interpreter)
+ CommandObjectThreadUntil(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "thread until", "Continue until a line number or address is reached by the "
+ "current or specified thread. Stops when returning from "
+ "the current function as a safety measure.",
+ nullptr, eCommandRequiresThread | eCommandTryTargetAPILock |
+ eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
+ m_options(interpreter)
{
CommandArgumentEntry arg;
CommandArgumentData line_num_arg;
@@ -1087,10 +1117,7 @@ public:
m_arguments.push_back (arg);
}
-
- ~CommandObjectThreadUntil () override
- {
- }
+ ~CommandObjectThreadUntil() override = default;
Options *
GetOptions () override
@@ -1105,7 +1132,7 @@ protected:
bool synchronous_execution = m_interpreter.GetSynchronous ();
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("invalid target, create a debug target using the 'target create' command");
result.SetStatus (eReturnStatusFailed);
@@ -1113,15 +1140,14 @@ protected:
}
Process *process = m_exe_ctx.GetProcessPtr();
- if (process == NULL)
+ if (process == nullptr)
{
result.AppendError ("need a valid process to step");
result.SetStatus (eReturnStatusFailed);
-
}
else
{
- Thread *thread = NULL;
+ Thread *thread = nullptr;
std::vector<uint32_t> line_numbers;
if (command.GetArgumentCount() >= 1)
@@ -1148,17 +1174,16 @@ protected:
return false;
}
-
if (m_options.m_thread_idx == LLDB_INVALID_THREAD_ID)
{
- thread = process->GetThreadList().GetSelectedThread().get();
+ thread = GetDefaultThread();
}
else
{
thread = process->GetThreadList().FindThreadByIndexID(m_options.m_thread_idx).get();
}
- if (thread == NULL)
+ if (thread == nullptr)
{
const uint32_t num_threads = process->GetThreadList().GetSize();
result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n",
@@ -1171,9 +1196,8 @@ protected:
const bool abort_other_plans = false;
StackFrame *frame = thread->GetStackFrameAtIndex(m_options.m_frame_idx).get();
- if (frame == NULL)
+ if (frame == nullptr)
{
-
result.AppendErrorWithFormat ("Frame index %u is out of range for thread %u.\n",
m_options.m_frame_idx,
m_options.m_thread_idx);
@@ -1187,11 +1211,11 @@ protected:
{
// Finally we got here... Translate the given line number to a bunch of addresses:
SymbolContext sc(frame->GetSymbolContext (eSymbolContextCompUnit));
- LineTable *line_table = NULL;
+ LineTable *line_table = nullptr;
if (sc.comp_unit)
line_table = sc.comp_unit->GetLineTable();
- if (line_table == NULL)
+ if (line_table == nullptr)
{
result.AppendErrorWithFormat ("Failed to resolve the line table for frame %u of thread index %u.\n",
m_options.m_frame_idx, m_options.m_thread_idx);
@@ -1246,7 +1270,7 @@ protected:
all_in_function = false;
}
- if (address_list.size() == 0)
+ if (address_list.empty())
{
if (all_in_function)
result.AppendErrorWithFormat ("No line entries matching until target.\n");
@@ -1275,11 +1299,8 @@ protected:
m_options.m_thread_idx);
result.SetStatus (eReturnStatusFailed);
return false;
-
}
-
-
process->GetThreadList().SetSelectedThreadByID (m_options.m_thread_idx);
StreamString stream;
@@ -1317,20 +1338,18 @@ protected:
}
CommandOptions m_options;
-
};
OptionDefinition
CommandObjectThreadUntil::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, false, "frame", 'f', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFrameIndex, "Frame index for until operation - defaults to 0"},
-{ LLDB_OPT_SET_1, false, "thread", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadIndex, "Thread index for the thread for until operation"},
-{ LLDB_OPT_SET_1, false, "run-mode",'m', OptionParser::eRequiredArgument, NULL, g_duo_running_mode, 0, eArgTypeRunMode, "Determine how to run other threads while stepping this one"},
-{ LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, "Run until we reach the specified address, or leave the function - can be specified multiple times."},
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_1, false, "frame", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFrameIndex, "Frame index for until operation - defaults to 0"},
+{ LLDB_OPT_SET_1, false, "thread", 't', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadIndex, "Thread index for the thread for until operation"},
+{ LLDB_OPT_SET_1, false, "run-mode",'m', OptionParser::eRequiredArgument, nullptr, g_duo_running_mode, 0, eArgTypeRunMode, "Determine how to run other threads while stepping this one"},
+{ LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Run until we reach the specified address, or leave the function - can be specified multiple times."},
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
//-------------------------------------------------------------------------
// CommandObjectThreadSelect
//-------------------------------------------------------------------------
@@ -1338,16 +1357,10 @@ CommandObjectThreadUntil::CommandOptions::g_option_table[] =
class CommandObjectThreadSelect : public CommandObjectParsed
{
public:
-
- CommandObjectThreadSelect (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "thread select",
- "Select a thread as the currently active thread.",
- NULL,
- eCommandRequiresProcess |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused )
+ CommandObjectThreadSelect(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "thread select", "Change the currently selected thread.", nullptr,
+ eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched |
+ eCommandProcessMustBePaused)
{
CommandArgumentEntry arg;
CommandArgumentData thread_idx_arg;
@@ -1363,17 +1376,14 @@ public:
m_arguments.push_back (arg);
}
-
- ~CommandObjectThreadSelect () override
- {
- }
+ ~CommandObjectThreadSelect() override = default;
protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
{
Process *process = m_exe_ctx.GetProcessPtr();
- if (process == NULL)
+ if (process == nullptr)
{
result.AppendError ("no process");
result.SetStatus (eReturnStatusFailed);
@@ -1389,7 +1399,7 @@ protected:
uint32_t index_id = StringConvert::ToUInt32(command.GetArgumentAtIndex(0), 0, 0);
Thread *new_thread = process->GetThreadList().FindThreadByIndexID(index_id).get();
- if (new_thread == NULL)
+ if (new_thread == nullptr)
{
result.AppendErrorWithFormat ("invalid thread #%s.\n", command.GetArgumentAtIndex(0));
result.SetStatus (eReturnStatusFailed);
@@ -1401,10 +1411,8 @@ protected:
return result.Succeeded();
}
-
};
-
//-------------------------------------------------------------------------
// CommandObjectThreadList
//-------------------------------------------------------------------------
@@ -1412,23 +1420,15 @@ protected:
class CommandObjectThreadList : public CommandObjectParsed
{
public:
-
-
- CommandObjectThreadList (CommandInterpreter &interpreter):
- CommandObjectParsed (interpreter,
- "thread list",
- "Show a summary of all current threads in a process.",
- "thread list",
- eCommandRequiresProcess |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused )
+ CommandObjectThreadList(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "thread list",
+ "Show a summary of each thread in the current target process.", "thread list",
+ eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched |
+ eCommandProcessMustBePaused)
{
}
- ~CommandObjectThreadList() override
- {
- }
+ ~CommandObjectThreadList() override = default;
protected:
bool
@@ -1458,31 +1458,17 @@ protected:
class CommandObjectThreadInfo : public CommandObjectIterateOverThreads
{
public:
-
- CommandObjectThreadInfo (CommandInterpreter &interpreter) :
- CommandObjectIterateOverThreads (interpreter,
- "thread info",
- "Show an extended summary of information about thread(s) in a process.",
- "thread info",
- eCommandRequiresProcess |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused),
- m_options (interpreter)
- {
- m_add_return = false;
- }
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter)
{
OptionParsingStarting ();
}
+ ~CommandOptions() override = default;
+
void
OptionParsingStarting () override
{
@@ -1490,10 +1476,6 @@ public:
m_json_stopinfo = false;
}
- ~CommandOptions () override
- {
- }
-
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -1512,7 +1494,6 @@ public:
default:
return Error("invalid short option character '%c'", short_option);
-
}
return error;
}
@@ -1529,23 +1510,42 @@ public:
static OptionDefinition g_option_table[];
};
- Options *
- GetOptions () override
+ CommandObjectThreadInfo(CommandInterpreter &interpreter)
+ : CommandObjectIterateOverThreads(
+ interpreter, "thread info",
+ "Show an extended summary of one or more threads. Defaults to the current thread.", "thread info",
+ eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched |
+ eCommandProcessMustBePaused),
+ m_options(interpreter)
{
- return &m_options;
+ m_add_return = false;
}
- ~CommandObjectThreadInfo () override
+ ~CommandObjectThreadInfo() override = default;
+
+ Options *
+ GetOptions () override
{
+ return &m_options;
}
bool
- HandleOneThread (Thread &thread, CommandReturnObject &result) override
+ HandleOneThread (lldb::tid_t tid, CommandReturnObject &result) override
{
+ ThreadSP thread_sp = m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
+ if (!thread_sp)
+ {
+ result.AppendErrorWithFormat ("thread no longer exists: 0x%" PRIx64 "\n", tid);
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+
+ Thread *thread = thread_sp.get();
+
Stream &strm = result.GetOutputStream();
- if (!thread.GetDescription (strm, eDescriptionLevelFull, m_options.m_json_thread, m_options.m_json_stopinfo))
+ if (!thread->GetDescription (strm, eDescriptionLevelFull, m_options.m_json_thread, m_options.m_json_stopinfo))
{
- result.AppendErrorWithFormat ("error displaying info for thread: \"%d\"\n", thread.GetIndexID());
+ result.AppendErrorWithFormat ("error displaying info for thread: \"%d\"\n", thread->GetIndexID());
result.SetStatus (eReturnStatusFailed);
return false;
}
@@ -1553,19 +1553,17 @@ public:
}
CommandOptions m_options;
-
};
OptionDefinition
CommandObjectThreadInfo::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "json",'j', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display the thread info in JSON format."},
- { LLDB_OPT_SET_ALL, false, "stop-info",'s', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display the extended stop info in JSON format."},
+ { LLDB_OPT_SET_ALL, false, "json",'j', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display the thread info in JSON format."},
+ { LLDB_OPT_SET_ALL, false, "stop-info",'s', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display the extended stop info in JSON format."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
//-------------------------------------------------------------------------
// CommandObjectThreadReturn
//-------------------------------------------------------------------------
@@ -1576,7 +1574,6 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_from_expression (false)
@@ -1585,9 +1582,7 @@ public:
OptionParsingStarting ();
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -1612,7 +1607,6 @@ public:
default:
error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
break;
-
}
return error;
}
@@ -1638,23 +1632,14 @@ public:
// Instance variables to hold the values for command options.
};
- Options *
- GetOptions () override
- {
- return &m_options;
- }
-
- CommandObjectThreadReturn (CommandInterpreter &interpreter) :
- CommandObjectRaw (interpreter,
- "thread return",
- "Return from the currently selected frame, short-circuiting execution of the frames below it, with an optional return value,"
- " or with the -x option from the innermost function evaluation.",
- "thread return",
- eCommandRequiresFrame |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused ),
- m_options (interpreter)
+ CommandObjectThreadReturn(CommandInterpreter &interpreter)
+ : CommandObjectRaw(interpreter, "thread return",
+ "Prematurely return from a stack frame, short-circuiting execution of newer frames "
+ "and optionally yielding a specified value. Defaults to the exiting the current stack "
+ "frame.",
+ "thread return", eCommandRequiresFrame | eCommandTryTargetAPILock |
+ eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
+ m_options(interpreter)
{
CommandArgumentEntry arg;
CommandArgumentData expression_arg;
@@ -1668,16 +1653,17 @@ public:
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back (arg);
-
-
}
-
- ~CommandObjectThreadReturn() override
+
+ ~CommandObjectThreadReturn() override = default;
+
+ Options *
+ GetOptions() override
{
+ return &m_options;
}
-
-protected:
+protected:
bool
DoExecute (const char *command, CommandReturnObject &result) override
{
@@ -1746,7 +1732,6 @@ protected:
result.AppendErrorWithFormat("Unknown error evaluating result expression.");
result.SetStatus (eReturnStatusFailed);
return false;
-
}
}
@@ -1766,13 +1751,13 @@ protected:
}
CommandOptions m_options;
-
};
+
OptionDefinition
CommandObjectThreadReturn::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_ALL, false, "from-expression", 'x', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Return from the innermost expression evaluation."},
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_ALL, false, "from-expression", 'x', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Return from the innermost expression evaluation."},
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -1785,13 +1770,14 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter)
{
OptionParsingStarting ();
}
+ ~CommandOptions() override = default;
+
void
OptionParsingStarting () override
{
@@ -1802,10 +1788,6 @@ public:
m_force = false;
}
- ~CommandOptions () override
- {
- }
-
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
{
@@ -1839,10 +1821,8 @@ public:
case 'r':
m_force = true;
break;
-
default:
return Error("invalid short option character '%c'", short_option);
-
}
return error;
}
@@ -1862,12 +1842,6 @@ public:
static OptionDefinition g_option_table[];
};
- Options *
- GetOptions () override
- {
- return &m_options;
- }
-
CommandObjectThreadJump (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
"thread jump",
@@ -1881,12 +1855,15 @@ public:
{
}
- ~CommandObjectThreadJump() override
+ ~CommandObjectThreadJump() override = default;
+
+ Options *
+ GetOptions() override
{
+ return &m_options;
}
protected:
-
bool DoExecute (Args& args, CommandReturnObject &result) override
{
RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext();
@@ -1953,44 +1930,43 @@ protected:
CommandOptions m_options;
};
+
OptionDefinition
CommandObjectThreadJump::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
+ { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
"Specifies the source file to jump to."},
- { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum,
+ { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum,
"Specifies the line number to jump to."},
- { LLDB_OPT_SET_2, true, "by", 'b', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOffset,
+ { LLDB_OPT_SET_2, true, "by", 'b', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOffset,
"Jumps by a relative line offset from the current line."},
- { LLDB_OPT_SET_3, true, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression,
+ { LLDB_OPT_SET_3, true, "address", 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddressOrExpression,
"Jumps to a specific address."},
{ LLDB_OPT_SET_1|
LLDB_OPT_SET_2|
- LLDB_OPT_SET_3, false, "force",'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,"Allows the PC to leave the current function."},
+ LLDB_OPT_SET_3, false, "force",'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,"Allows the PC to leave the current function."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
// Next are the subcommands of CommandObjectMultiwordThreadPlan
//-------------------------------------------------------------------------
-
//-------------------------------------------------------------------------
// CommandObjectThreadPlanList
//-------------------------------------------------------------------------
+
class CommandObjectThreadPlanList : public CommandObjectIterateOverThreads
{
public:
-
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options(interpreter)
{
@@ -1998,9 +1974,7 @@ public:
OptionParsingStarting ();
}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -2011,19 +1985,14 @@ public:
switch (short_option)
{
case 'i':
- {
m_internal = true;
- }
- break;
+ break;
case 'v':
- {
m_verbose = true;
- }
- break;
+ break;
default:
error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
break;
-
}
return error;
}
@@ -2050,24 +2019,18 @@ public:
bool m_internal;
};
- CommandObjectThreadPlanList (CommandInterpreter &interpreter) :
- CommandObjectIterateOverThreads (interpreter,
- "thread plan list",
- "Show thread plans for one or more threads. If no threads are specified, show the "
- "currently selected thread. Use the thread-index \"all\" to see all threads.",
- NULL,
- eCommandRequiresProcess |
- eCommandRequiresThread |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused ),
- m_options(interpreter)
+ CommandObjectThreadPlanList(CommandInterpreter &interpreter)
+ : CommandObjectIterateOverThreads(
+ interpreter, "thread plan list",
+ "Show thread plans for one or more threads. If no threads are specified, show the "
+ "current thread. Use the thread-index \"all\" to see all threads.",
+ nullptr, eCommandRequiresProcess | eCommandRequiresThread | eCommandTryTargetAPILock |
+ eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
+ m_options(interpreter)
{
}
- ~CommandObjectThreadPlanList () override
- {
- }
+ ~CommandObjectThreadPlanList() override = default;
Options *
GetOptions () override
@@ -2077,42 +2040,48 @@ public:
protected:
bool
- HandleOneThread (Thread &thread, CommandReturnObject &result) override
+ HandleOneThread (lldb::tid_t tid, CommandReturnObject &result) override
{
+ ThreadSP thread_sp = m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
+ if (!thread_sp)
+ {
+ result.AppendErrorWithFormat ("thread no longer exists: 0x%" PRIx64 "\n", tid);
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+
+ Thread *thread = thread_sp.get();
+
Stream &strm = result.GetOutputStream();
DescriptionLevel desc_level = eDescriptionLevelFull;
if (m_options.m_verbose)
desc_level = eDescriptionLevelVerbose;
- thread.DumpThreadPlans (&strm, desc_level, m_options.m_internal, true);
+ thread->DumpThreadPlans (&strm, desc_level, m_options.m_internal, true);
return true;
}
+
CommandOptions m_options;
};
OptionDefinition
CommandObjectThreadPlanList::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display more information about the thread plans"},
-{ LLDB_OPT_SET_1, false, "internal", 'i', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Display internal as well as user thread plans"},
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display more information about the thread plans"},
+{ LLDB_OPT_SET_1, false, "internal", 'i', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display internal as well as user thread plans"},
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
class CommandObjectThreadPlanDiscard : public CommandObjectParsed
{
public:
- CommandObjectThreadPlanDiscard (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "thread plan discard",
- "Discards thread plans up to and including the plan passed as the command argument."
- "Only user visible plans can be discarded, use the index from \"thread plan list\""
- " without the \"-i\" argument.",
- NULL,
- eCommandRequiresProcess |
- eCommandRequiresThread |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused )
+ CommandObjectThreadPlanDiscard(CommandInterpreter &interpreter)
+ : CommandObjectParsed(
+ interpreter, "thread plan discard",
+ "Discards thread plans up to and including the specified index (see 'thread plan list'.) "
+ "Only user visible plans can be discarded.",
+ nullptr, eCommandRequiresProcess | eCommandRequiresThread | eCommandTryTargetAPILock |
+ eCommandProcessMustBeLaunched | eCommandProcessMustBePaused)
{
CommandArgumentEntry arg;
CommandArgumentData plan_index_arg;
@@ -2128,7 +2097,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectThreadPlanDiscard () override {}
+ ~CommandObjectThreadPlanDiscard() override = default;
bool
DoExecute (Args& args, CommandReturnObject &result) override
@@ -2181,30 +2150,25 @@ public:
class CommandObjectMultiwordThreadPlan : public CommandObjectMultiword
{
public:
- CommandObjectMultiwordThreadPlan(CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "plan",
- "A set of subcommands for accessing the thread plans controlling execution control on one or more threads.",
- "thread plan <subcommand> [<subcommand objects]")
+ CommandObjectMultiwordThreadPlan(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "plan", "Commands for managing thread plans that control execution.",
+ "thread plan <subcommand> [<subcommand objects]")
{
LoadSubCommand ("list", CommandObjectSP (new CommandObjectThreadPlanList (interpreter)));
LoadSubCommand ("discard", CommandObjectSP (new CommandObjectThreadPlanDiscard (interpreter)));
}
- ~CommandObjectMultiwordThreadPlan () override {}
-
-
+ ~CommandObjectMultiwordThreadPlan() override = default;
};
//-------------------------------------------------------------------------
// CommandObjectMultiwordThread
//-------------------------------------------------------------------------
-CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "thread",
- "A set of commands for operating on one or more threads within a running process.",
- "thread <subcommand> [<subcommand-options>]")
+CommandObjectMultiwordThread::CommandObjectMultiwordThread(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "thread",
+ "Commands for operating on one or more threads in the current process.",
+ "thread <subcommand> [<subcommand-options>]")
{
LoadSubCommand ("backtrace", CommandObjectSP (new CommandObjectThreadBacktrace (interpreter)));
LoadSubCommand ("continue", CommandObjectSP (new CommandObjectThreadContinue (interpreter)));
@@ -2214,59 +2178,47 @@ CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter &
LoadSubCommand ("select", CommandObjectSP (new CommandObjectThreadSelect (interpreter)));
LoadSubCommand ("until", CommandObjectSP (new CommandObjectThreadUntil (interpreter)));
LoadSubCommand ("info", CommandObjectSP (new CommandObjectThreadInfo (interpreter)));
- LoadSubCommand ("step-in", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope (
- interpreter,
- "thread step-in",
- "Source level single step in specified thread (current thread, if none specified).",
- NULL,
- eStepTypeInto,
- eStepScopeSource)));
-
- LoadSubCommand ("step-out", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope (
- interpreter,
- "thread step-out",
- "Finish executing the function of the currently selected frame and return to its call site in specified thread (current thread, if none specified).",
- NULL,
- eStepTypeOut,
- eStepScopeSource)));
-
- LoadSubCommand ("step-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope (
- interpreter,
- "thread step-over",
- "Source level single step in specified thread (current thread, if none specified), stepping over calls.",
- NULL,
- eStepTypeOver,
- eStepScopeSource)));
-
- LoadSubCommand ("step-inst", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope (
- interpreter,
- "thread step-inst",
- "Single step one instruction in specified thread (current thread, if none specified).",
- NULL,
- eStepTypeTrace,
- eStepScopeInstruction)));
-
- LoadSubCommand ("step-inst-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope (
- interpreter,
- "thread step-inst-over",
- "Single step one instruction in specified thread (current thread, if none specified), stepping over calls.",
- NULL,
- eStepTypeTraceOver,
- eStepScopeInstruction)));
+ LoadSubCommand("step-in",
+ CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
+ interpreter, "thread step-in",
+ "Source level single step, stepping into calls. Defaults to current thread unless specified.",
+ nullptr, eStepTypeInto, eStepScopeSource)));
+
+ LoadSubCommand("step-out",
+ CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
+ interpreter, "thread step-out", "Finish executing the current stack frame and stop after "
+ "returning. Defaults to current thread unless specified.",
+ nullptr, eStepTypeOut, eStepScopeSource)));
+
+ LoadSubCommand("step-over",
+ CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
+ interpreter, "thread step-over",
+ "Source level single step, stepping over calls. Defaults to current thread unless specified.",
+ nullptr, eStepTypeOver, eStepScopeSource)));
+
+ LoadSubCommand(
+ "step-inst",
+ CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
+ interpreter, "thread step-inst",
+ "Instruction level single step, stepping into calls. Defaults to current thread unless specified.",
+ nullptr, eStepTypeTrace, eStepScopeInstruction)));
+
+ LoadSubCommand(
+ "step-inst-over",
+ CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
+ interpreter, "thread step-inst-over",
+ "Instruction level single step, stepping over calls. Defaults to current thread unless specified.",
+ nullptr, eStepTypeTraceOver, eStepScopeInstruction)));
LoadSubCommand ("step-scripted", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope (
interpreter,
"thread step-scripted",
"Step as instructed by the script class passed in the -C option.",
- NULL,
+ nullptr,
eStepTypeScripted,
eStepScopeSource)));
LoadSubCommand ("plan", CommandObjectSP (new CommandObjectMultiwordThreadPlan(interpreter)));
}
-CommandObjectMultiwordThread::~CommandObjectMultiwordThread ()
-{
-}
-
-
+CommandObjectMultiwordThread::~CommandObjectMultiwordThread() = default;
diff --git a/source/Commands/CommandObjectType.cpp b/source/Commands/CommandObjectType.cpp
index 2b803e7eb0d3f..6f1199de69ded 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;
diff --git a/source/Commands/CommandObjectVersion.cpp b/source/Commands/CommandObjectVersion.cpp
index 70e101c223304..06962f8648adb 100644
--- a/source/Commands/CommandObjectVersion.cpp
+++ b/source/Commands/CommandObjectVersion.cpp
@@ -24,8 +24,8 @@ using namespace lldb_private;
// CommandObjectVersion
//-------------------------------------------------------------------------
-CommandObjectVersion::CommandObjectVersion (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter, "version", "Show version of LLDB debugger.", "version")
+CommandObjectVersion::CommandObjectVersion(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "version", "Show the LLDB debugger version.", "version")
{
}
diff --git a/source/Commands/CommandObjectWatchpoint.cpp b/source/Commands/CommandObjectWatchpoint.cpp
index a97f5ade64603..977b6bb374373 100644
--- a/source/Commands/CommandObjectWatchpoint.cpp
+++ b/source/Commands/CommandObjectWatchpoint.cpp
@@ -12,7 +12,11 @@
// C Includes
// C++ Includes
+#include <vector>
+
// Other libraries and framework includes
+#include "llvm/ADT/StringRef.h"
+
// Project includes
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Breakpoint/WatchpointList.h"
@@ -28,10 +32,6 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
-#include "llvm/ADT/StringRef.h"
-
-#include <vector>
-
using namespace lldb;
using namespace lldb_private;
@@ -47,7 +47,7 @@ AddWatchpointDescription(Stream *s, Watchpoint *wp, lldb::DescriptionLevel level
static bool
CheckTargetForWatchpointOperations(Target *target, CommandReturnObject &result)
{
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("Invalid target. No existing target or watchpoints.");
result.SetStatus (eReturnStatusFailed);
@@ -87,7 +87,7 @@ CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(Target *target, Args &args
// Pre-condition: args.GetArgumentCount() > 0.
if (args.GetArgumentCount() == 0)
{
- if (target == NULL)
+ if (target == nullptr)
return false;
WatchpointSP watch_sp = target->GetLastCreatedWatchpoint();
if (watch_sp)
@@ -166,10 +166,10 @@ class CommandObjectWatchpointList : public CommandObjectParsed
{
public:
CommandObjectWatchpointList (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "watchpoint list",
- "List all watchpoints at configurable levels of detail.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "watchpoint list",
+ "List all watchpoints at configurable levels of detail.",
+ nullptr),
m_options(interpreter)
{
CommandArgumentEntry arg;
@@ -178,7 +178,7 @@ public:
m_arguments.push_back(arg);
}
- ~CommandObjectWatchpointList () override {}
+ ~CommandObjectWatchpointList() override = default;
Options *
GetOptions () override
@@ -189,14 +189,13 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options(interpreter),
m_level(lldb::eDescriptionLevelBrief) // Watchpoint List defaults to brief descriptions
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -235,7 +234,6 @@ public:
return g_option_table;
}
-
// Options table: Required for subclasses of Options.
static OptionDefinition g_option_table[];
@@ -250,7 +248,7 @@ protected:
DoExecute (Args& command, CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("Invalid target. No current target or watchpoints.");
result.SetStatus (eReturnStatusSuccessFinishNoResult);
@@ -267,8 +265,9 @@ protected:
}
const WatchpointList &watchpoints = target->GetWatchpointList();
- Mutex::Locker locker;
- target->GetWatchpointList().GetListMutex(locker);
+
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetWatchpointList().GetListMutex(lock);
size_t num_watchpoints = watchpoints.GetSize();
@@ -324,19 +323,20 @@ private:
// CommandObjectWatchpointList::Options
//-------------------------------------------------------------------------
#pragma mark List::CommandOptions
+
OptionDefinition
CommandObjectWatchpointList::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "brief", 'b', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_1, false, "brief", 'b', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Give a brief description of the watchpoint (no location info)."},
- { LLDB_OPT_SET_2, false, "full", 'f', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_2, false, "full", 'f', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Give a full description of the watchpoint and its locations."},
- { LLDB_OPT_SET_3, false, "verbose", 'v', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone,
+ { LLDB_OPT_SET_3, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Explain everything we know about the watchpoint (for debugging debugger bugs)." },
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -348,10 +348,10 @@ class CommandObjectWatchpointEnable : public CommandObjectParsed
{
public:
CommandObjectWatchpointEnable (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "enable",
- "Enable the specified disabled watchpoint(s). If no watchpoints are specified, enable all of them.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "enable",
+ "Enable the specified disabled watchpoint(s). If no watchpoints are specified, enable all of them.",
+ nullptr)
{
CommandArgumentEntry arg;
CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
@@ -359,7 +359,7 @@ public:
m_arguments.push_back(arg);
}
- ~CommandObjectWatchpointEnable () override {}
+ ~CommandObjectWatchpointEnable() override = default;
protected:
bool
@@ -370,8 +370,8 @@ protected:
if (!CheckTargetForWatchpointOperations(target, result))
return false;
- Mutex::Locker locker;
- target->GetWatchpointList().GetListMutex(locker);
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetWatchpointList().GetListMutex(lock);
const WatchpointList &watchpoints = target->GetWatchpointList();
@@ -413,8 +413,6 @@ protected:
return result.Succeeded();
}
-
-private:
};
//-------------------------------------------------------------------------
@@ -426,10 +424,10 @@ class CommandObjectWatchpointDisable : public CommandObjectParsed
{
public:
CommandObjectWatchpointDisable (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "watchpoint disable",
- "Disable the specified watchpoint(s) without removing it/them. If no watchpoints are specified, disable them all.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "watchpoint disable",
+ "Disable the specified watchpoint(s) without removing it/them. If no watchpoints are specified, disable them all.",
+ nullptr)
{
CommandArgumentEntry arg;
CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
@@ -437,8 +435,7 @@ public:
m_arguments.push_back(arg);
}
-
- ~CommandObjectWatchpointDisable () override {}
+ ~CommandObjectWatchpointDisable() override = default;
protected:
bool
@@ -448,8 +445,8 @@ protected:
if (!CheckTargetForWatchpointOperations(target, result))
return false;
- Mutex::Locker locker;
- target->GetWatchpointList().GetListMutex(locker);
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetWatchpointList().GetListMutex(lock);
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
@@ -497,7 +494,6 @@ protected:
return result.Succeeded();
}
-
};
//-------------------------------------------------------------------------
@@ -512,7 +508,7 @@ public:
CommandObjectParsed(interpreter,
"watchpoint delete",
"Delete the specified watchpoint(s). If no watchpoints are specified, delete them all.",
- NULL)
+ nullptr)
{
CommandArgumentEntry arg;
CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
@@ -520,7 +516,7 @@ public:
m_arguments.push_back(arg);
}
- ~CommandObjectWatchpointDelete () override {}
+ ~CommandObjectWatchpointDelete() override = default;
protected:
bool
@@ -530,9 +526,9 @@ protected:
if (!CheckTargetForWatchpointOperations(target, result))
return false;
- Mutex::Locker locker;
- target->GetWatchpointList().GetListMutex(locker);
-
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetWatchpointList().GetListMutex(lock);
+
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
@@ -579,7 +575,6 @@ protected:
return result.Succeeded();
}
-
};
//-------------------------------------------------------------------------
@@ -590,10 +585,10 @@ class CommandObjectWatchpointIgnore : public CommandObjectParsed
{
public:
CommandObjectWatchpointIgnore (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "watchpoint ignore",
- "Set ignore count on the specified watchpoint(s). If no watchpoints are specified, set them all.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "watchpoint ignore",
+ "Set ignore count on the specified watchpoint(s). If no watchpoints are specified, set them all.",
+ nullptr),
m_options (interpreter)
{
CommandArgumentEntry arg;
@@ -602,7 +597,7 @@ public:
m_arguments.push_back(arg);
}
- ~CommandObjectWatchpointIgnore () override {}
+ ~CommandObjectWatchpointIgnore() override = default;
Options *
GetOptions () override
@@ -613,14 +608,13 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_ignore_count (0)
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -631,12 +625,10 @@ public:
switch (short_option)
{
case 'i':
- {
m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_ignore_count == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
- }
- break;
+ break;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
break;
@@ -657,7 +649,6 @@ public:
return g_option_table;
}
-
// Options table: Required for subclasses of Options.
static OptionDefinition g_option_table[];
@@ -676,9 +667,9 @@ protected:
if (!CheckTargetForWatchpointOperations(target, result))
return false;
- Mutex::Locker locker;
- target->GetWatchpointList().GetListMutex(locker);
-
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetWatchpointList().GetListMutex(lock);
+
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
@@ -724,14 +715,14 @@ private:
};
#pragma mark Ignore::CommandOptions
+
OptionDefinition
CommandObjectWatchpointIgnore::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, true, "ignore-count", 'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount, "Set the number of times this watchpoint is skipped before stopping." },
- { 0, false, NULL, 0 , 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, true, "ignore-count", 'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount, "Set the number of times this watchpoint is skipped before stopping." },
+ { 0, false, nullptr, 0 , 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
//-------------------------------------------------------------------------
// CommandObjectWatchpointModify
//-------------------------------------------------------------------------
@@ -740,14 +731,13 @@ CommandObjectWatchpointIgnore::CommandOptions::g_option_table[] =
class CommandObjectWatchpointModify : public CommandObjectParsed
{
public:
-
CommandObjectWatchpointModify (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "watchpoint modify",
- "Modify the options on a watchpoint or set of watchpoints in the executable. "
- "If no watchpoint is specified, act on the last created watchpoint. "
- "Passing an empty argument clears the modification.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "watchpoint modify",
+ "Modify the options on a watchpoint or set of watchpoints in the executable. "
+ "If no watchpoint is specified, act on the last created watchpoint. "
+ "Passing an empty argument clears the modification.",
+ nullptr),
m_options (interpreter)
{
CommandArgumentEntry arg;
@@ -756,7 +746,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectWatchpointModify () override {}
+ ~CommandObjectWatchpointModify() override = default;
Options *
GetOptions () override
@@ -767,7 +757,6 @@ public:
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_condition (),
@@ -775,7 +764,7 @@ public:
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -786,7 +775,7 @@ public:
switch (short_option)
{
case 'c':
- if (option_arg != NULL)
+ if (option_arg != nullptr)
m_condition.assign (option_arg);
else
m_condition.clear();
@@ -831,9 +820,9 @@ protected:
if (!CheckTargetForWatchpointOperations(target, result))
return false;
- Mutex::Locker locker;
- target->GetWatchpointList().GetListMutex(locker);
-
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetWatchpointList().GetListMutex(lock);
+
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
@@ -885,11 +874,12 @@ private:
};
#pragma mark Modify::CommandOptions
+
OptionDefinition
CommandObjectWatchpointModify::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_ALL, false, "condition", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeExpression, "The watchpoint stops only if this condition expression evaluates to true."},
-{ 0, false, NULL, 0 , 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_ALL, false, "condition", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeExpression, "The watchpoint stops only if this condition expression evaluates to true."},
+{ 0, false, nullptr, 0 , 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -900,24 +890,23 @@ CommandObjectWatchpointModify::CommandOptions::g_option_table[] =
class CommandObjectWatchpointSetVariable : public CommandObjectParsed
{
public:
-
CommandObjectWatchpointSetVariable (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "watchpoint set variable",
- "Set a watchpoint on a variable. "
- "Use the '-w' option to specify the type of watchpoint and "
- "the '-x' option to specify the byte size to watch for. "
- "If no '-w' option is specified, it defaults to write. "
- "If no '-x' option is specified, it defaults to the variable's "
- "byte size. "
- "Note that there are limited hardware resources for watchpoints. "
- "If watchpoint setting fails, consider disable/delete existing ones "
- "to free up resources.",
- NULL,
- eCommandRequiresFrame |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused ),
+ CommandObjectParsed(interpreter,
+ "watchpoint set variable",
+ "Set a watchpoint on a variable. "
+ "Use the '-w' option to specify the type of watchpoint and "
+ "the '-s' option to specify the byte size to watch for. "
+ "If no '-w' option is specified, it defaults to write. "
+ "If no '-s' option is specified, it defaults to the variable's "
+ "byte size. "
+ "Note that there are limited hardware resources for watchpoints. "
+ "If watchpoint setting fails, consider disable/delete existing ones "
+ "to free up resources.",
+ nullptr,
+ eCommandRequiresFrame |
+ eCommandTryTargetAPILock |
+ eCommandProcessMustBeLaunched |
+ eCommandProcessMustBePaused ),
m_option_group (interpreter),
m_option_watchpoint ()
{
@@ -944,12 +933,12 @@ corresponding to the byte size of the data type."
// Push the data for the only argument into the m_arguments vector.
m_arguments.push_back (arg);
- // Absorb the '-w' and '-x' options into our option group.
+ // Absorb the '-w' and '-s' options into our option group.
m_option_group.Append (&m_option_watchpoint, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Finalize();
}
- ~CommandObjectWatchpointSetVariable () override {}
+ ~CommandObjectWatchpointSetVariable() override = default;
Options *
GetOptions () override
@@ -1055,7 +1044,7 @@ protected:
}
else
{
- const char *error_cstr = error.AsCString(NULL);
+ const char *error_cstr = error.AsCString(nullptr);
if (error_cstr)
result.GetErrorStream().Printf("error: %s\n", error_cstr);
else
@@ -1089,7 +1078,7 @@ protected:
{
result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%" PRIx64 ", size=%" PRIu64 ", variable expression='%s').\n",
addr, (uint64_t)size, command.GetArgumentAtIndex(0));
- if (error.AsCString(NULL))
+ if (error.AsCString(nullptr))
result.AppendError(error.AsCString());
result.SetStatus(eReturnStatusFailed);
}
@@ -1110,24 +1099,23 @@ private:
class CommandObjectWatchpointSetExpression : public CommandObjectRaw
{
public:
-
CommandObjectWatchpointSetExpression (CommandInterpreter &interpreter) :
- CommandObjectRaw (interpreter,
- "watchpoint set expression",
- "Set a watchpoint on an address by supplying an expression. "
- "Use the '-w' option to specify the type of watchpoint and "
- "the '-x' option to specify the byte size to watch for. "
- "If no '-w' option is specified, it defaults to write. "
- "If no '-x' option is specified, it defaults to the target's "
- "pointer byte size. "
- "Note that there are limited hardware resources for watchpoints. "
- "If watchpoint setting fails, consider disable/delete existing ones "
- "to free up resources.",
- NULL,
- eCommandRequiresFrame |
- eCommandTryTargetAPILock |
- eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused ),
+ CommandObjectRaw(interpreter,
+ "watchpoint set expression",
+ "Set a watchpoint on an address by supplying an expression. "
+ "Use the '-w' option to specify the type of watchpoint and "
+ "the '-s' option to specify the byte size to watch for. "
+ "If no '-w' option is specified, it defaults to write. "
+ "If no '-s' option is specified, it defaults to the target's "
+ "pointer byte size. "
+ "Note that there are limited hardware resources for watchpoints. "
+ "If watchpoint setting fails, consider disable/delete existing ones "
+ "to free up resources.",
+ nullptr,
+ eCommandRequiresFrame |
+ eCommandTryTargetAPILock |
+ eCommandProcessMustBeLaunched |
+ eCommandProcessMustBePaused ),
m_option_group (interpreter),
m_option_watchpoint ()
{
@@ -1135,7 +1123,7 @@ public:
R"(
Examples:
-(lldb) watchpoint set expression -w write -x 1 -- foo + 32
+(lldb) watchpoint set expression -w write -s 1 -- foo + 32
Watches write access for the 1-byte region pointed to by the address 'foo + 32')"
);
@@ -1153,13 +1141,12 @@ Examples:
// Push the data for the only argument into the m_arguments vector.
m_arguments.push_back (arg);
- // Absorb the '-w' and '-x' options into our option group.
+ // Absorb the '-w' and '-s' options into our option group.
m_option_group.Append (&m_option_watchpoint, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Finalize();
}
-
- ~CommandObjectWatchpointSetExpression () override {}
+ ~CommandObjectWatchpointSetExpression() override = default;
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
bool
@@ -1181,11 +1168,11 @@ protected:
StackFrame *frame = m_exe_ctx.GetFramePtr();
Args command(raw_command);
- const char *expr = NULL;
+ const char *expr = nullptr;
if (raw_command[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;
while (s && s[0])
{
@@ -1220,7 +1207,7 @@ protected:
}
}
- if (expr == NULL)
+ if (expr == nullptr)
expr = raw_command;
// If no argument is present, issue an error message. There's no way to set a watchpoint.
@@ -1300,7 +1287,7 @@ protected:
{
result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%" PRIx64 ", size=%" PRIu64 ").\n",
addr, (uint64_t)size);
- if (error.AsCString(NULL))
+ if (error.AsCString(nullptr))
result.AppendError(error.AsCString());
result.SetStatus(eReturnStatusFailed);
}
@@ -1321,21 +1308,16 @@ private:
class CommandObjectWatchpointSet : public CommandObjectMultiword
{
public:
-
- CommandObjectWatchpointSet (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "watchpoint set",
- "A set of commands for setting a watchpoint.",
- "watchpoint set <subcommand> [<subcommand-options>]")
+ CommandObjectWatchpointSet(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "watchpoint set", "Commands for setting a watchpoint.",
+ "watchpoint set <subcommand> [<subcommand-options>]")
{
LoadSubCommand ("variable", CommandObjectSP (new CommandObjectWatchpointSetVariable (interpreter)));
LoadSubCommand ("expression", CommandObjectSP (new CommandObjectWatchpointSetExpression (interpreter)));
}
-
- ~CommandObjectWatchpointSet () override {}
-
+ ~CommandObjectWatchpointSet() override = default;
};
//-------------------------------------------------------------------------
@@ -1343,11 +1325,9 @@ public:
//-------------------------------------------------------------------------
#pragma mark MultiwordWatchpoint
-CommandObjectMultiwordWatchpoint::CommandObjectMultiwordWatchpoint(CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "watchpoint",
- "A set of commands for operating on watchpoints.",
- "watchpoint <command> [<command-options>]")
+CommandObjectMultiwordWatchpoint::CommandObjectMultiwordWatchpoint(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "watchpoint", "Commands for operating on watchpoints.",
+ "watchpoint <subcommand> [<command-options>]")
{
CommandObjectSP list_command_object (new CommandObjectWatchpointList (interpreter));
CommandObjectSP enable_command_object (new CommandObjectWatchpointEnable (interpreter));
@@ -1377,7 +1357,4 @@ CommandObjectMultiwordWatchpoint::CommandObjectMultiwordWatchpoint(CommandInterp
LoadSubCommand ("set", set_command_object);
}
-CommandObjectMultiwordWatchpoint::~CommandObjectMultiwordWatchpoint()
-{
-}
-
+CommandObjectMultiwordWatchpoint::~CommandObjectMultiwordWatchpoint() = default;
diff --git a/source/Commands/CommandObjectWatchpointCommand.cpp b/source/Commands/CommandObjectWatchpointCommand.cpp
index 2fa849f97674f..0ae1850b5e28a 100644
--- a/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -9,11 +9,12 @@
// C Includes
// C++ Includes
+#include <vector>
-
+// Other libraries and framework includes
+// Project includes
#include "CommandObjectWatchpointCommand.h"
#include "CommandObjectWatchpoint.h"
-
#include "lldb/Core/IOHandler.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -23,8 +24,6 @@
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/State.h"
-#include <vector>
-
using namespace lldb;
using namespace lldb_private;
@@ -32,20 +31,17 @@ using namespace lldb_private;
// CommandObjectWatchpointCommandAdd
//-------------------------------------------------------------------------
-
class CommandObjectWatchpointCommandAdd :
public CommandObjectParsed,
public IOHandlerDelegateMultiline
{
public:
-
- CommandObjectWatchpointCommandAdd (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "add",
- "Add a set of commands to a watchpoint, to be executed whenever the watchpoint is hit.",
- NULL),
- IOHandlerDelegateMultiline("DONE", IOHandlerDelegate::Completion::LLDBCommand),
- m_options (interpreter)
+ CommandObjectWatchpointCommandAdd(CommandInterpreter &interpreter)
+ : CommandObjectParsed(
+ interpreter, "add",
+ "Add a set of LLDB commands to a watchpoint, to be executed whenever the watchpoint is hit.", nullptr),
+ IOHandlerDelegateMultiline("DONE", IOHandlerDelegate::Completion::LLDBCommand),
+ m_options(interpreter)
{
SetHelpLong (
R"(
@@ -169,7 +165,7 @@ are no syntax errors may indicate that a function was declared but never called.
m_arguments.push_back (arg);
}
- ~CommandObjectWatchpointCommandAdd () override {}
+ ~CommandObjectWatchpointCommandAdd() override = default;
Options *
GetOptions () override
@@ -187,8 +183,7 @@ are no syntax errors may indicate that a function was declared but never called.
output_sp->Flush();
}
}
-
-
+
void
IOHandlerInputComplete (IOHandler &io_handler, std::string &line) override
{
@@ -199,7 +194,7 @@ are no syntax errors may indicate that a function was declared but never called.
if (wp_options)
{
std::unique_ptr<WatchpointOptions::CommandData> data_ap(new WatchpointOptions::CommandData());
- if (data_ap.get())
+ if (data_ap)
{
data_ap->user_source.SplitIntoLines(line);
BatonSP baton_sp (new WatchpointOptions::CommandBaton (data_ap.release()));
@@ -234,8 +229,6 @@ are no syntax errors may indicate that a function was declared but never called.
BatonSP baton_sp (new WatchpointOptions::CommandBaton (data_ap.release()));
wp_options->SetCallback (WatchpointOptionsCallbackFunction, baton_sp);
-
- return;
}
static bool
@@ -244,10 +237,9 @@ are no syntax errors may indicate that a function was declared but never called.
lldb::user_id_t watch_id)
{
bool ret_value = true;
- if (baton == NULL)
+ if (baton == nullptr)
return true;
-
-
+
WatchpointOptions::CommandData *data = (WatchpointOptions::CommandData *) baton;
StringList &commands = data->user_source;
@@ -288,7 +280,6 @@ are no syntax errors may indicate that a function was declared but never called.
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_use_commands (false),
@@ -300,7 +291,7 @@ are no syntax errors may indicate that a function was declared but never called.
{
}
- ~CommandOptions () override {}
+ ~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -321,14 +312,8 @@ are no syntax errors may indicate that a function was declared but never called.
eScriptLanguageNone,
error);
- if (m_script_language == eScriptLanguagePython || m_script_language == eScriptLanguageDefault)
- {
- m_use_script_language = true;
- }
- else
- {
- m_use_script_language = false;
- }
+ m_use_script_language =
+ (m_script_language == eScriptLanguagePython || m_script_language == eScriptLanguageDefault);
break;
case 'e':
@@ -341,11 +326,9 @@ are no syntax errors may indicate that a function was declared but never called.
break;
case 'F':
- {
- m_use_one_liner = false;
- m_use_script_language = true;
- m_function_name.assign(option_arg);
- }
+ m_use_one_liner = false;
+ m_use_script_language = true;
+ m_function_name.assign(option_arg);
break;
default:
@@ -353,6 +336,7 @@ are no syntax errors may indicate that a function was declared but never called.
}
return error;
}
+
void
OptionParsingStarting () override
{
@@ -395,7 +379,7 @@ protected:
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("There is not a current executable; there are no watchpoints to which to add commands");
result.SetStatus (eReturnStatusFailed);
@@ -412,7 +396,7 @@ protected:
return false;
}
- if (m_options.m_use_script_language == false && m_options.m_function_name.size())
+ if (!m_options.m_use_script_language && !m_options.m_function_name.empty())
{
result.AppendError ("need to enable scripting to have a function run as a watchpoint command");
result.SetStatus (eReturnStatusFailed);
@@ -436,11 +420,11 @@ protected:
{
Watchpoint *wp = target->GetWatchpointList().FindByID (cur_wp_id).get();
// Sanity check wp first.
- if (wp == NULL) continue;
+ if (wp == nullptr) continue;
WatchpointOptions *wp_options = wp->GetOptions();
// Skip this watchpoint if wp_options is not good.
- if (wp_options == NULL) continue;
+ if (wp_options == nullptr) continue;
// If we are using script language, get the script interpreter
// in order to set or collect command callback. Otherwise, call
@@ -456,7 +440,7 @@ protected:
// Special handling for using a Python function by name
// instead of extending the watchpoint callback data structures, we just automatize
// what the user would do manually: make their watchpoint command be a function call
- else if (m_options.m_function_name.size())
+ else if (!m_options.m_function_name.empty())
{
std::string oneliner(m_options.m_function_name);
oneliner += "(frame, wp, internal_dict)";
@@ -489,7 +473,6 @@ private:
CommandOptions m_options;
};
-
// FIXME: "script-type" needs to have its contents determined dynamically, so somebody can add a new scripting
// language to lldb and have it pickable here without having to change this enumeration by hand and rebuild lldb proper.
@@ -499,25 +482,25 @@ g_script_option_enumeration[4] =
{ eScriptLanguageNone, "command", "Commands are in the lldb command interpreter language"},
{ eScriptLanguagePython, "python", "Commands are in the Python language."},
{ eSortOrderByName, "default-script", "Commands are in the default scripting language."},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
OptionDefinition
CommandObjectWatchpointCommandAdd::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOneLiner,
+ { LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOneLiner,
"Specify a one-line watchpoint command inline. Be sure to surround it with quotes." },
- { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean,
+ { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
"Specify whether watchpoint command execution should terminate on error." },
- { LLDB_OPT_SET_ALL, false, "script-type", 's', OptionParser::eRequiredArgument, NULL, g_script_option_enumeration, 0, eArgTypeNone,
+ { LLDB_OPT_SET_ALL, false, "script-type", 's', OptionParser::eRequiredArgument, nullptr, g_script_option_enumeration, 0, eArgTypeNone,
"Specify the language for the commands - if none is specified, the lldb command interpreter will be used."},
- { LLDB_OPT_SET_2, false, "python-function", 'F', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonFunction,
+ { LLDB_OPT_SET_2, false, "python-function", 'F', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePythonFunction,
"Give the name of a Python function to run as command for this watchpoint. Be sure to give a module name if appropriate."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
//-------------------------------------------------------------------------
@@ -528,10 +511,10 @@ class CommandObjectWatchpointCommandDelete : public CommandObjectParsed
{
public:
CommandObjectWatchpointCommandDelete (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "delete",
- "Delete the set of commands from a watchpoint.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "delete",
+ "Delete the set of commands from a watchpoint.",
+ nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData wp_id_arg;
@@ -547,8 +530,7 @@ public:
m_arguments.push_back (arg);
}
-
- ~CommandObjectWatchpointCommandDelete () override {}
+ ~CommandObjectWatchpointCommandDelete() override = default;
protected:
bool
@@ -556,7 +538,7 @@ protected:
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("There is not a current executable; there are no watchpoints from which to delete commands");
result.SetStatus (eReturnStatusFailed);
@@ -619,10 +601,10 @@ class CommandObjectWatchpointCommandList : public CommandObjectParsed
{
public:
CommandObjectWatchpointCommandList (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "list",
- "List the script or set of commands to be executed when the watchpoint is hit.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "list",
+ "List the script or set of commands to be executed when the watchpoint is hit.",
+ nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData wp_id_arg;
@@ -638,7 +620,7 @@ public:
m_arguments.push_back (arg);
}
- ~CommandObjectWatchpointCommandList () override {}
+ ~CommandObjectWatchpointCommandList() override = default;
protected:
bool
@@ -646,7 +628,7 @@ protected:
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("There is not a current executable; there are no watchpoints for which to list commands");
result.SetStatus (eReturnStatusFailed);
@@ -725,11 +707,10 @@ protected:
// CommandObjectWatchpointCommand
//-------------------------------------------------------------------------
-CommandObjectWatchpointCommand::CommandObjectWatchpointCommand (CommandInterpreter &interpreter) :
- CommandObjectMultiword (interpreter,
- "command",
- "A set of commands for adding, removing and examining bits of code to be executed when the watchpoint is hit (watchpoint 'commmands').",
- "command <sub-command> [<sub-command-options>] <watchpoint-id>")
+CommandObjectWatchpointCommand::CommandObjectWatchpointCommand(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "command", "Commands for adding, removing and examining LLDB commands "
+ "executed when the watchpoint is hit (watchpoint 'commmands').",
+ "command <sub-command> [<sub-command-options>] <watchpoint-id>")
{
CommandObjectSP add_command_object (new CommandObjectWatchpointCommandAdd (interpreter));
CommandObjectSP delete_command_object (new CommandObjectWatchpointCommandDelete (interpreter));
@@ -744,8 +725,4 @@ CommandObjectWatchpointCommand::CommandObjectWatchpointCommand (CommandInterpret
LoadSubCommand ("list", list_command_object);
}
-CommandObjectWatchpointCommand::~CommandObjectWatchpointCommand ()
-{
-}
-
-
+CommandObjectWatchpointCommand::~CommandObjectWatchpointCommand() = default;
diff --git a/source/Commands/Makefile b/source/Commands/Makefile
deleted file mode 100644
index 1a66485a0c219..0000000000000
--- a/source/Commands/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-##===- source/Commands/Makefile ----------------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LLDB_LEVEL := ../..
-LIBRARYNAME := lldbCommands
-BUILD_ARCHIVE = 1
-
-include $(LLDB_LEVEL)/Makefile
-
-EXTRA_OPTIONS += -Wno-four-char-constants \ No newline at end of file