diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index 890d77028a99..b2c47431a43f 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/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 @@ -30,10 +31,10 @@ class CommandObjectSettingsSet : public CommandObjectRaw { public: CommandObjectSettingsSet (CommandInterpreter &interpreter) : - CommandObjectRaw (interpreter, - "settings set", - "Set or change the value of a single debugger setting variable.", - NULL), + CommandObjectRaw(interpreter, + "settings set", + "Set or change the value of a single debugger setting variable.", + 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(argc); ++setting_var_idx) @@ -172,14 +171,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 +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,10 +245,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 +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 //------------------------------------------------------------------------- @@ -300,10 +299,10 @@ 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) + 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.", + 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, @@ -334,14 +332,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 +352,7 @@ protected: const size_t argc = args.GetArgumentCount (); if (argc > 0) { - for (size_t i=0; iGetSupportFiles(); 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. @@ -826,19 +824,16 @@ class CommandObjectSourceList : public CommandObjectParsed public: CommandObjectSourceList(CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "source list", - "Display source code (as specified) based on the current executable's debug info.", - NULL, - eCommandRequiresTarget), + CommandObjectParsed(interpreter, + "source list", + "Display source code (as specified) based on the current executable's debug info.", + nullptr, + eCommandRequiresTarget), m_options (interpreter) { } - ~CommandObjectSourceList () override - { - } - + ~CommandObjectSourceList() override = default; Options * GetOptions () override @@ -853,7 +848,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 +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); @@ -1194,7 +1188,7 @@ protected: // in all modules const ModuleList &module_list = target->GetImages(); const size_t num_modules = module_list.GetSize(); - for (size_t i=0; iResolveFileAddress(m_options.address, so_addr)) @@ -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); @@ -1248,7 +1242,7 @@ protected: } } uint32_t num_matches = sc_list.GetSize(); - for (uint32_t i=0; i 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; diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index a97f5ade6460..17f446232165 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -12,7 +12,11 @@ // C Includes // C++ Includes +#include + // 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 - 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); @@ -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 } }; //------------------------------------------------------------------------- @@ -348,10 +347,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 +358,7 @@ public: m_arguments.push_back(arg); } - ~CommandObjectWatchpointEnable () override {} + ~CommandObjectWatchpointEnable() override = default; protected: bool @@ -413,8 +412,6 @@ protected: return result.Succeeded(); } - -private: }; //------------------------------------------------------------------------- @@ -426,10 +423,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 +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(); } - }; //------------------------------------------------------------------------- @@ -590,10 +584,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 +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,12 +624,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 +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), + 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 +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,24 +889,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 '-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.", + nullptr, + eCommandRequiresFrame | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_option_group (interpreter), m_option_watchpoint () { @@ -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,24 +1098,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 '-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.", + nullptr, + eCommandRequiresFrame | + eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused ), m_option_group (interpreter), m_option_watchpoint () { @@ -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;