Fix Clang-tidy modernize-use-nullptr and modernize-use-default warnings in some files in source/Commands; other minor fixes.

llvm-svn: 261716
This commit is contained in:
Eugene Zelenko 2016-02-24 02:05:55 +00:00
parent ee7023f79a
commit 3f18ea0e38
3 changed files with 290 additions and 326 deletions

View File

@ -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
@ -33,7 +34,7 @@ public:
CommandObjectRaw(interpreter,
"settings set",
"Set or change the value of a single debugger setting variable.",
NULL),
nullptr),
m_options (interpreter)
{
CommandArgumentEntry arg1;
@ -82,8 +83,7 @@ insert-before or insert-after."
}
~CommandObjectSettingsSet () override {}
~CommandObjectSettingsSet() override = default;
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
bool
@ -98,14 +98,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 +159,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)
@ -177,7 +176,7 @@ insert-before or insert-after."
completion_str.c_str(),
match_start_point,
max_return_elements,
NULL,
nullptr,
word_complete,
matches);
}
@ -231,7 +230,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,7 +245,7 @@ protected:
Error error;
if (m_options.m_global)
{
error = m_interpreter.GetDebugger().SetPropertyValue (NULL,
error = m_interpreter.GetDebugger().SetPropertyValue(nullptr,
eVarSetOperationAssign,
var_name,
var_value_cstr);
@ -280,6 +279,7 @@ protected:
return result.Succeeded();
}
private:
CommandOptions m_options;
};
@ -287,11 +287,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
//-------------------------------------------------------------------------
@ -303,7 +302,7 @@ public:
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)
nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentData var_name_arg;
@ -319,8 +318,7 @@ public:
m_arguments.push_back (arg1);
}
~CommandObjectSettingsShow () override {}
~CommandObjectSettingsShow() override = default;
int
HandleArgumentCompletion (Args &input,
@ -339,7 +337,7 @@ public:
completion_str.c_str(),
match_start_point,
max_return_elements,
NULL,
nullptr,
word_complete,
matches);
return matches.GetSize();
@ -390,7 +388,7 @@ public:
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)
nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData var_name_arg;
@ -411,7 +409,7 @@ public:
m_arguments.push_back (arg);
}
~CommandObjectSettingsList () override {}
~CommandObjectSettingsList() override = default;
int
HandleArgumentCompletion (Args &input,
@ -430,7 +428,7 @@ public:
completion_str.c_str(),
match_start_point,
max_return_elements,
NULL,
nullptr,
word_complete,
matches);
return matches.GetSize();
@ -485,7 +483,7 @@ public:
CommandObjectRaw(interpreter,
"settings remove",
"Remove the specified element from an array or dictionary settings variable.",
NULL)
nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@ -517,7 +515,7 @@ public:
m_arguments.push_back (arg2);
}
~CommandObjectSettingsRemove () override {}
~CommandObjectSettingsRemove() override = default;
int
HandleArgumentCompletion (Args &input,
@ -538,7 +536,7 @@ public:
completion_str.c_str(),
match_start_point,
max_return_elements,
NULL,
nullptr,
word_complete,
matches);
@ -566,7 +564,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);
@ -604,7 +602,7 @@ public:
CommandObjectRaw(interpreter,
"settings replace",
"Replace the specified element from an internal debugger settings array or dictionary variable with the specified new value.",
NULL)
nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@ -646,8 +644,7 @@ public:
m_arguments.push_back (arg3);
}
~CommandObjectSettingsReplace () override {}
~CommandObjectSettingsReplace() override = default;
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
bool
@ -672,7 +669,7 @@ public:
completion_str.c_str(),
match_start_point,
max_return_elements,
NULL,
nullptr,
word_complete,
matches);
@ -687,14 +684,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();
@ -731,7 +727,7 @@ public:
CommandObjectRaw(interpreter,
"settings insert-before",
"Insert value(s) into an internal debugger settings array variable, immediately before the specified element.",
NULL)
nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@ -767,7 +763,7 @@ public:
m_arguments.push_back (arg3);
}
~CommandObjectSettingsInsertBefore () override {}
~CommandObjectSettingsInsertBefore() override = default;
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
bool
@ -792,7 +788,7 @@ public:
completion_str.c_str(),
match_start_point,
max_return_elements,
NULL,
nullptr,
word_complete,
matches);
@ -816,7 +812,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);
@ -854,7 +850,7 @@ public:
CommandObjectRaw(interpreter,
"settings insert-after",
"Insert value(s) into an internal debugger settings array variable, immediately after the specified element.",
NULL)
nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@ -890,7 +886,7 @@ public:
m_arguments.push_back (arg3);
}
~CommandObjectSettingsInsertAfter () override {}
~CommandObjectSettingsInsertAfter() override = default;
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
bool
@ -915,7 +911,7 @@ public:
completion_str.c_str(),
match_start_point,
max_return_elements,
NULL,
nullptr,
word_complete,
matches);
@ -939,7 +935,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);
@ -977,7 +973,7 @@ public:
CommandObjectRaw(interpreter,
"settings append",
"Append a new value to the end of an internal debugger settings array, dictionary or string variable.",
NULL)
nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@ -1003,7 +999,7 @@ public:
m_arguments.push_back (arg2);
}
~CommandObjectSettingsAppend () override {}
~CommandObjectSettingsAppend() override = default;
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
bool
@ -1028,7 +1024,7 @@ public:
completion_str.c_str(),
match_start_point,
max_return_elements,
NULL,
nullptr,
word_complete,
matches);
@ -1051,7 +1047,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);
@ -1092,7 +1088,7 @@ public:
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)
nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData var_name_arg;
@ -1108,7 +1104,7 @@ public:
m_arguments.push_back (arg);
}
~CommandObjectSettingsClear () override {}
~CommandObjectSettingsClear() override = default;
int
HandleArgumentCompletion (Args &input,
@ -1129,7 +1125,7 @@ public:
completion_str.c_str(),
match_start_point,
max_return_elements,
NULL,
nullptr,
word_complete,
matches);
@ -1151,7 +1147,7 @@ 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);
@ -1161,7 +1157,7 @@ protected:
Error error(m_interpreter.GetDebugger().SetPropertyValue(&m_exe_ctx,
eVarSetOperationClear,
var_name,
NULL));
nullptr));
if (error.Fail())
{
result.AppendError (error.AsCString());
@ -1194,6 +1190,4 @@ CommandObjectMultiwordSettings::CommandObjectMultiwordSettings (CommandInterpret
LoadSubCommand ("clear", CommandObjectSP (new CommandObjectSettingsClear (interpreter)));
}
CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings ()
{
}
CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings() = default;

View File

@ -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,18 @@ class CommandObjectSourceInfo : public CommandObjectParsed
};
public:
CommandObjectSourceInfo (CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "source info", "Display source line information (as specified) based "
CommandObjectSourceInfo (CommandInterpreter &interpreter) :
CommandObjectParsed(interpreter,
"source info",
"Display source line information (as specified) based "
"on the current executable's debug info.",
NULL, eCommandRequiresTarget),
nullptr,
eCommandRequiresTarget),
m_options(interpreter)
{
}
~CommandObjectSourceInfo () override {}
~CommandObjectSourceInfo() override = default;
Options *
GetOptions () override
@ -150,7 +152,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 +173,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 +241,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 +391,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 +400,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 +574,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 +614,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 +632,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 +700,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 +727,6 @@ OptionDefinition CommandObjectSourceInfo::CommandOptions::g_option_table[] = {
class CommandObjectSourceList : public CommandObjectParsed
{
class CommandOptions : public Options
{
public:
@ -736,9 +735,7 @@ class CommandObjectSourceList : public CommandObjectParsed
{
}
~CommandOptions () override
{
}
~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@ -810,6 +807,7 @@ class CommandObjectSourceList : public CommandObjectParsed
{
return g_option_table;
}
static OptionDefinition g_option_table[];
// Instance variables to hold the values for command options.
@ -829,16 +827,13 @@ public:
CommandObjectParsed(interpreter,
"source list",
"Display source code (as specified) based on the current executable's debug info.",
NULL,
nullptr,
eCommandRequiresTarget),
m_options (interpreter)
{
}
~CommandObjectSourceList () override
{
}
~CommandObjectSourceList() override = default;
Options *
GetOptions () override
@ -875,7 +870,6 @@ public:
}
protected:
struct SourceInfo
{
ConstString function;
@ -950,7 +944,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);
@ -1231,7 +1225,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);
@ -1339,7 +1333,6 @@ protected:
{
result.SetStatus (eReturnStatusSuccessFinishResult);
}
}
}
else
@ -1350,7 +1343,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 +1382,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 +1454,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
@ -1499,7 +1492,4 @@ CommandObjectMultiwordSource::CommandObjectMultiwordSource (CommandInterpreter &
LoadSubCommand ("list", CommandObjectSP (new CommandObjectSourceList (interpreter)));
}
CommandObjectMultiwordSource::~CommandObjectMultiwordSource ()
{
}
CommandObjectMultiwordSource::~CommandObjectMultiwordSource() = default;

View File

@ -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)
@ -169,7 +169,7 @@ public:
CommandObjectParsed(interpreter,
"watchpoint list",
"List all watchpoints at configurable levels of detail.",
NULL),
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);
@ -324,19 +322,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 }
};
//-------------------------------------------------------------------------
@ -351,7 +350,7 @@ public:
CommandObjectParsed(interpreter,
"enable",
"Enable the specified disabled watchpoint(s). If no watchpoints are specified, enable all of them.",
NULL)
nullptr)
{
CommandArgumentEntry arg;
CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
@ -359,7 +358,7 @@ public:
m_arguments.push_back(arg);
}
~CommandObjectWatchpointEnable () override {}
~CommandObjectWatchpointEnable() override = default;
protected:
bool
@ -413,8 +412,6 @@ protected:
return result.Succeeded();
}
private:
};
//-------------------------------------------------------------------------
@ -429,7 +426,7 @@ public:
CommandObjectParsed(interpreter,
"watchpoint disable",
"Disable the specified watchpoint(s) without removing it/them. If no watchpoints are specified, disable them all.",
NULL)
nullptr)
{
CommandArgumentEntry arg;
CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange);
@ -437,8 +434,7 @@ public:
m_arguments.push_back(arg);
}
~CommandObjectWatchpointDisable () override {}
~CommandObjectWatchpointDisable() override = default;
protected:
bool
@ -497,7 +493,6 @@ protected:
return result.Succeeded();
}
};
//-------------------------------------------------------------------------
@ -512,7 +507,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 +515,7 @@ public:
m_arguments.push_back(arg);
}
~CommandObjectWatchpointDelete () override {}
~CommandObjectWatchpointDelete() override = default;
protected:
bool
@ -579,7 +574,6 @@ protected:
return result.Succeeded();
}
};
//-------------------------------------------------------------------------
@ -593,7 +587,7 @@ public:
CommandObjectParsed(interpreter,
"watchpoint ignore",
"Set ignore count on the specified watchpoint(s). If no watchpoints are specified, set them all.",
NULL),
nullptr),
m_options (interpreter)
{
CommandArgumentEntry arg;
@ -602,7 +596,7 @@ public:
m_arguments.push_back(arg);
}
~CommandObjectWatchpointIgnore () override {}
~CommandObjectWatchpointIgnore() override = default;
Options *
GetOptions () override
@ -613,14 +607,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,11 +624,9 @@ 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;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
@ -657,7 +648,6 @@ public:
return g_option_table;
}
// Options table: Required for subclasses of Options.
static OptionDefinition g_option_table[];
@ -724,14 +714,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 +730,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),
nullptr),
m_options (interpreter)
{
CommandArgumentEntry arg;
@ -756,7 +745,7 @@ public:
m_arguments.push_back (arg);
}
~CommandObjectWatchpointModify () override {}
~CommandObjectWatchpointModify() override = default;
Options *
GetOptions () override
@ -767,7 +756,6 @@ public:
class CommandOptions : public Options
{
public:
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
m_condition (),
@ -775,7 +763,7 @@ public:
{
}
~CommandOptions () override {}
~CommandOptions() override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@ -786,7 +774,7 @@ public:
switch (short_option)
{
case 'c':
if (option_arg != NULL)
if (option_arg != nullptr)
m_condition.assign (option_arg);
else
m_condition.clear();
@ -885,11 +873,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,7 +889,6 @@ CommandObjectWatchpointModify::CommandOptions::g_option_table[] =
class CommandObjectWatchpointSetVariable : public CommandObjectParsed
{
public:
CommandObjectWatchpointSetVariable (CommandInterpreter &interpreter) :
CommandObjectParsed(interpreter,
"watchpoint set variable",
@ -913,7 +901,7 @@ public:
"Note that there are limited hardware resources for watchpoints. "
"If watchpoint setting fails, consider disable/delete existing ones "
"to free up resources.",
NULL,
nullptr,
eCommandRequiresFrame |
eCommandTryTargetAPILock |
eCommandProcessMustBeLaunched |
@ -949,7 +937,7 @@ corresponding to the byte size of the data type."
m_option_group.Finalize();
}
~CommandObjectWatchpointSetVariable () override {}
~CommandObjectWatchpointSetVariable() override = default;
Options *
GetOptions () override
@ -1055,7 +1043,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 +1077,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,7 +1098,6 @@ private:
class CommandObjectWatchpointSetExpression : public CommandObjectRaw
{
public:
CommandObjectWatchpointSetExpression (CommandInterpreter &interpreter) :
CommandObjectRaw(interpreter,
"watchpoint set expression",
@ -1123,7 +1110,7 @@ public:
"Note that there are limited hardware resources for watchpoints. "
"If watchpoint setting fails, consider disable/delete existing ones "
"to free up resources.",
NULL,
nullptr,
eCommandRequiresFrame |
eCommandTryTargetAPILock |
eCommandProcessMustBeLaunched |
@ -1158,8 +1145,7 @@ Examples:
m_option_group.Finalize();
}
~CommandObjectWatchpointSetExpression () override {}
~CommandObjectWatchpointSetExpression() override = default;
// Overrides base class's behavior where WantsCompletion = !WantsRawCommandString.
bool
@ -1181,11 +1167,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 +1206,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 +1286,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,7 +1307,6 @@ private:
class CommandObjectWatchpointSet : public CommandObjectMultiword
{
public:
CommandObjectWatchpointSet (CommandInterpreter &interpreter) :
CommandObjectMultiword (interpreter,
"watchpoint set",
@ -1333,9 +1318,7 @@ public:
LoadSubCommand ("expression", CommandObjectSP (new CommandObjectWatchpointSetExpression (interpreter)));
}
~CommandObjectWatchpointSet () override {}
~CommandObjectWatchpointSet() override = default;
};
//-------------------------------------------------------------------------
@ -1377,7 +1360,4 @@ CommandObjectMultiwordWatchpoint::CommandObjectMultiwordWatchpoint(CommandInterp
LoadSubCommand ("set", set_command_object);
}
CommandObjectMultiwordWatchpoint::~CommandObjectMultiwordWatchpoint()
{
}
CommandObjectMultiwordWatchpoint::~CommandObjectMultiwordWatchpoint() = default;