diff options
Diffstat (limited to 'source/Commands/CommandObjectBreakpointCommand.cpp')
-rw-r--r-- | source/Commands/CommandObjectBreakpointCommand.cpp | 124 |
1 files changed, 53 insertions, 71 deletions
diff --git a/source/Commands/CommandObjectBreakpointCommand.cpp b/source/Commands/CommandObjectBreakpointCommand.cpp index 7b58bf9185bc..57572c8ef144 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; |