15ffd83dbSDimitry Andric //===-- CommandObjectBreakpointCommand.cpp --------------------------------===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #include "CommandObjectBreakpointCommand.h" 10*0b57cec5SDimitry Andric #include "CommandObjectBreakpoint.h" 11*0b57cec5SDimitry Andric #include "lldb/Breakpoint/Breakpoint.h" 12*0b57cec5SDimitry Andric #include "lldb/Breakpoint/BreakpointIDList.h" 13*0b57cec5SDimitry Andric #include "lldb/Breakpoint/BreakpointLocation.h" 14*0b57cec5SDimitry Andric #include "lldb/Core/IOHandler.h" 15*0b57cec5SDimitry Andric #include "lldb/Host/OptionParser.h" 16*0b57cec5SDimitry Andric #include "lldb/Interpreter/CommandInterpreter.h" 17*0b57cec5SDimitry Andric #include "lldb/Interpreter/CommandReturnObject.h" 18*0b57cec5SDimitry Andric #include "lldb/Interpreter/OptionArgParser.h" 19480093f4SDimitry Andric #include "lldb/Interpreter/OptionGroupPythonClassWithDict.h" 20*0b57cec5SDimitry Andric #include "lldb/Target/Target.h" 21*0b57cec5SDimitry Andric 22*0b57cec5SDimitry Andric using namespace lldb; 23*0b57cec5SDimitry Andric using namespace lldb_private; 24*0b57cec5SDimitry Andric 25*0b57cec5SDimitry Andric // FIXME: "script-type" needs to have its contents determined dynamically, so 269dba64beSDimitry Andric // somebody can add a new scripting language to lldb and have it pickable here 279dba64beSDimitry Andric // without having to change this enumeration by hand and rebuild lldb proper. 28*0b57cec5SDimitry Andric static constexpr OptionEnumValueElement g_script_option_enumeration[] = { 299dba64beSDimitry Andric { 309dba64beSDimitry Andric eScriptLanguageNone, 319dba64beSDimitry Andric "command", 329dba64beSDimitry Andric "Commands are in the lldb command interpreter language", 339dba64beSDimitry Andric }, 349dba64beSDimitry Andric { 359dba64beSDimitry Andric eScriptLanguagePython, 369dba64beSDimitry Andric "python", 379dba64beSDimitry Andric "Commands are in the Python language.", 389dba64beSDimitry Andric }, 399dba64beSDimitry Andric { 40480093f4SDimitry Andric eScriptLanguageLua, 41480093f4SDimitry Andric "lua", 42480093f4SDimitry Andric "Commands are in the Lua language.", 43480093f4SDimitry Andric }, 44480093f4SDimitry Andric { 45480093f4SDimitry Andric eScriptLanguageDefault, 469dba64beSDimitry Andric "default-script", 479dba64beSDimitry Andric "Commands are in the default scripting language.", 489dba64beSDimitry Andric }, 499dba64beSDimitry Andric }; 50*0b57cec5SDimitry Andric 51*0b57cec5SDimitry Andric static constexpr OptionEnumValues ScriptOptionEnum() { 52*0b57cec5SDimitry Andric return OptionEnumValues(g_script_option_enumeration); 53*0b57cec5SDimitry Andric } 54*0b57cec5SDimitry Andric 559dba64beSDimitry Andric #define LLDB_OPTIONS_breakpoint_command_add 569dba64beSDimitry Andric #include "CommandOptions.inc" 57*0b57cec5SDimitry Andric 58*0b57cec5SDimitry Andric class CommandObjectBreakpointCommandAdd : public CommandObjectParsed, 59*0b57cec5SDimitry Andric public IOHandlerDelegateMultiline { 60*0b57cec5SDimitry Andric public: 61*0b57cec5SDimitry Andric CommandObjectBreakpointCommandAdd(CommandInterpreter &interpreter) 62*0b57cec5SDimitry Andric : CommandObjectParsed(interpreter, "add", 63*0b57cec5SDimitry Andric "Add LLDB commands to a breakpoint, to be executed " 64*0b57cec5SDimitry Andric "whenever the breakpoint is hit." 65*0b57cec5SDimitry Andric " If no breakpoint is specified, adds the " 66*0b57cec5SDimitry Andric "commands to the last created breakpoint.", 67*0b57cec5SDimitry Andric nullptr), 68*0b57cec5SDimitry Andric IOHandlerDelegateMultiline("DONE", 69*0b57cec5SDimitry Andric IOHandlerDelegate::Completion::LLDBCommand), 70480093f4SDimitry Andric m_options(), m_func_options("breakpoint command", false, 'F') { 71*0b57cec5SDimitry Andric SetHelpLong( 72*0b57cec5SDimitry Andric R"( 73*0b57cec5SDimitry Andric General information about entering breakpoint commands 74*0b57cec5SDimitry Andric ------------------------------------------------------ 75*0b57cec5SDimitry Andric 76*0b57cec5SDimitry Andric )" 77*0b57cec5SDimitry Andric "This command will prompt for commands to be executed when the specified \ 78*0b57cec5SDimitry Andric breakpoint is hit. Each command is typed on its own line following the '> ' \ 79*0b57cec5SDimitry Andric prompt until 'DONE' is entered." 80*0b57cec5SDimitry Andric R"( 81*0b57cec5SDimitry Andric 82*0b57cec5SDimitry Andric )" 83*0b57cec5SDimitry Andric "Syntactic errors may not be detected when initially entered, and many \ 84*0b57cec5SDimitry Andric malformed commands can silently fail when executed. If your breakpoint commands \ 85*0b57cec5SDimitry Andric do not appear to be executing, double-check the command syntax." 86*0b57cec5SDimitry Andric R"( 87*0b57cec5SDimitry Andric 88*0b57cec5SDimitry Andric )" 89*0b57cec5SDimitry Andric "Note: You may enter any debugger command exactly as you would at the debugger \ 90*0b57cec5SDimitry Andric prompt. There is no limit to the number of commands supplied, but do NOT enter \ 91*0b57cec5SDimitry Andric more than one command per line." 92*0b57cec5SDimitry Andric R"( 93*0b57cec5SDimitry Andric 94*0b57cec5SDimitry Andric Special information about PYTHON breakpoint commands 95*0b57cec5SDimitry Andric ---------------------------------------------------- 96*0b57cec5SDimitry Andric 97*0b57cec5SDimitry Andric )" 98*0b57cec5SDimitry Andric "You may enter either one or more lines of Python, including function \ 99*0b57cec5SDimitry Andric definitions or calls to functions that will have been imported by the time \ 100*0b57cec5SDimitry Andric the code executes. Single line breakpoint commands will be interpreted 'as is' \ 101*0b57cec5SDimitry Andric when the breakpoint is hit. Multiple lines of Python will be wrapped in a \ 102*0b57cec5SDimitry Andric generated function, and a call to the function will be attached to the breakpoint." 103*0b57cec5SDimitry Andric R"( 104*0b57cec5SDimitry Andric 105*0b57cec5SDimitry Andric This auto-generated function is passed in three arguments: 106*0b57cec5SDimitry Andric 107*0b57cec5SDimitry Andric frame: an lldb.SBFrame object for the frame which hit breakpoint. 108*0b57cec5SDimitry Andric 109*0b57cec5SDimitry Andric bp_loc: an lldb.SBBreakpointLocation object that represents the breakpoint location that was hit. 110*0b57cec5SDimitry Andric 111*0b57cec5SDimitry Andric dict: the python session dictionary hit. 112*0b57cec5SDimitry Andric 113*0b57cec5SDimitry Andric )" 114*0b57cec5SDimitry Andric "When specifying a python function with the --python-function option, you need \ 115*0b57cec5SDimitry Andric to supply the function name prepended by the module name:" 116*0b57cec5SDimitry Andric R"( 117*0b57cec5SDimitry Andric 118*0b57cec5SDimitry Andric --python-function myutils.breakpoint_callback 119*0b57cec5SDimitry Andric 120*0b57cec5SDimitry Andric The function itself must have the following prototype: 121*0b57cec5SDimitry Andric 122*0b57cec5SDimitry Andric def breakpoint_callback(frame, bp_loc, dict): 123*0b57cec5SDimitry Andric # Your code goes here 124*0b57cec5SDimitry Andric 125*0b57cec5SDimitry Andric )" 126*0b57cec5SDimitry Andric "The arguments are the same as the arguments passed to generated functions as \ 127*0b57cec5SDimitry Andric described above. Note that the global variable 'lldb.frame' will NOT be updated when \ 128*0b57cec5SDimitry Andric this function is called, so be sure to use the 'frame' argument. The 'frame' argument \ 129*0b57cec5SDimitry Andric can get you to the thread via frame.GetThread(), the thread can get you to the \ 130*0b57cec5SDimitry Andric process via thread.GetProcess(), and the process can get you back to the target \ 131*0b57cec5SDimitry Andric via process.GetTarget()." 132*0b57cec5SDimitry Andric R"( 133*0b57cec5SDimitry Andric 134*0b57cec5SDimitry Andric )" 135*0b57cec5SDimitry Andric "Important Note: As Python code gets collected into functions, access to global \ 136*0b57cec5SDimitry Andric variables requires explicit scoping using the 'global' keyword. Be sure to use correct \ 137*0b57cec5SDimitry Andric Python syntax, including indentation, when entering Python breakpoint commands." 138*0b57cec5SDimitry Andric R"( 139*0b57cec5SDimitry Andric 140*0b57cec5SDimitry Andric Example Python one-line breakpoint command: 141*0b57cec5SDimitry Andric 142*0b57cec5SDimitry Andric (lldb) breakpoint command add -s python 1 143*0b57cec5SDimitry Andric Enter your Python command(s). Type 'DONE' to end. 144*0b57cec5SDimitry Andric > print "Hit this breakpoint!" 145*0b57cec5SDimitry Andric > DONE 146*0b57cec5SDimitry Andric 147*0b57cec5SDimitry Andric As a convenience, this also works for a short Python one-liner: 148*0b57cec5SDimitry Andric 149*0b57cec5SDimitry Andric (lldb) breakpoint command add -s python 1 -o 'import time; print time.asctime()' 150*0b57cec5SDimitry Andric (lldb) run 151*0b57cec5SDimitry Andric Launching '.../a.out' (x86_64) 152*0b57cec5SDimitry Andric (lldb) Fri Sep 10 12:17:45 2010 153*0b57cec5SDimitry Andric Process 21778 Stopped 154*0b57cec5SDimitry Andric * thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread 155*0b57cec5SDimitry Andric 36 156*0b57cec5SDimitry Andric 37 int c(int val) 157*0b57cec5SDimitry Andric 38 { 158*0b57cec5SDimitry Andric 39 -> return val + 3; 159*0b57cec5SDimitry Andric 40 } 160*0b57cec5SDimitry Andric 41 161*0b57cec5SDimitry Andric 42 int main (int argc, char const *argv[]) 162*0b57cec5SDimitry Andric 163*0b57cec5SDimitry Andric Example multiple line Python breakpoint command: 164*0b57cec5SDimitry Andric 165*0b57cec5SDimitry Andric (lldb) breakpoint command add -s p 1 166*0b57cec5SDimitry Andric Enter your Python command(s). Type 'DONE' to end. 167*0b57cec5SDimitry Andric > global bp_count 168*0b57cec5SDimitry Andric > bp_count = bp_count + 1 169*0b57cec5SDimitry Andric > print "Hit this breakpoint " + repr(bp_count) + " times!" 170*0b57cec5SDimitry Andric > DONE 171*0b57cec5SDimitry Andric 172*0b57cec5SDimitry Andric Example multiple line Python breakpoint command, using function definition: 173*0b57cec5SDimitry Andric 174*0b57cec5SDimitry Andric (lldb) breakpoint command add -s python 1 175*0b57cec5SDimitry Andric Enter your Python command(s). Type 'DONE' to end. 176*0b57cec5SDimitry Andric > def breakpoint_output (bp_no): 177*0b57cec5SDimitry Andric > out_string = "Hit breakpoint number " + repr (bp_no) 178*0b57cec5SDimitry Andric > print out_string 179*0b57cec5SDimitry Andric > return True 180*0b57cec5SDimitry Andric > breakpoint_output (1) 181*0b57cec5SDimitry Andric > DONE 182*0b57cec5SDimitry Andric 183*0b57cec5SDimitry Andric )" 184*0b57cec5SDimitry Andric "In this case, since there is a reference to a global variable, \ 185*0b57cec5SDimitry Andric 'bp_count', you will also need to make sure 'bp_count' exists and is \ 186*0b57cec5SDimitry Andric initialized:" 187*0b57cec5SDimitry Andric R"( 188*0b57cec5SDimitry Andric 189*0b57cec5SDimitry Andric (lldb) script 190*0b57cec5SDimitry Andric >>> bp_count = 0 191*0b57cec5SDimitry Andric >>> quit() 192*0b57cec5SDimitry Andric 193*0b57cec5SDimitry Andric )" 194*0b57cec5SDimitry Andric "Your Python code, however organized, can optionally return a value. \ 195*0b57cec5SDimitry Andric If the returned value is False, that tells LLDB not to stop at the breakpoint \ 196*0b57cec5SDimitry Andric to which the code is associated. Returning anything other than False, or even \ 197*0b57cec5SDimitry Andric returning None, or even omitting a return statement entirely, will cause \ 198*0b57cec5SDimitry Andric LLDB to stop." 199*0b57cec5SDimitry Andric R"( 200*0b57cec5SDimitry Andric 201*0b57cec5SDimitry Andric )" 202*0b57cec5SDimitry Andric "Final Note: A warning that no breakpoint command was generated when there \ 203*0b57cec5SDimitry Andric are no syntax errors may indicate that a function was declared but never called."); 204*0b57cec5SDimitry Andric 205480093f4SDimitry Andric m_all_options.Append(&m_options); 206480093f4SDimitry Andric m_all_options.Append(&m_func_options, LLDB_OPT_SET_2 | LLDB_OPT_SET_3, 207480093f4SDimitry Andric LLDB_OPT_SET_2); 208480093f4SDimitry Andric m_all_options.Finalize(); 209480093f4SDimitry Andric 210*0b57cec5SDimitry Andric CommandArgumentEntry arg; 211*0b57cec5SDimitry Andric CommandArgumentData bp_id_arg; 212*0b57cec5SDimitry Andric 213*0b57cec5SDimitry Andric // Define the first (and only) variant of this arg. 214*0b57cec5SDimitry Andric bp_id_arg.arg_type = eArgTypeBreakpointID; 215*0b57cec5SDimitry Andric bp_id_arg.arg_repetition = eArgRepeatOptional; 216*0b57cec5SDimitry Andric 217*0b57cec5SDimitry Andric // There is only one variant this argument could be; put it into the 218*0b57cec5SDimitry Andric // argument entry. 219*0b57cec5SDimitry Andric arg.push_back(bp_id_arg); 220*0b57cec5SDimitry Andric 221*0b57cec5SDimitry Andric // Push the data for the first argument into the m_arguments vector. 222*0b57cec5SDimitry Andric m_arguments.push_back(arg); 223*0b57cec5SDimitry Andric } 224*0b57cec5SDimitry Andric 225*0b57cec5SDimitry Andric ~CommandObjectBreakpointCommandAdd() override = default; 226*0b57cec5SDimitry Andric 227480093f4SDimitry Andric Options *GetOptions() override { return &m_all_options; } 228*0b57cec5SDimitry Andric 229*0b57cec5SDimitry Andric void IOHandlerActivated(IOHandler &io_handler, bool interactive) override { 2309dba64beSDimitry Andric StreamFileSP output_sp(io_handler.GetOutputStreamFileSP()); 231*0b57cec5SDimitry Andric if (output_sp && interactive) { 232*0b57cec5SDimitry Andric output_sp->PutCString(g_reader_instructions); 233*0b57cec5SDimitry Andric output_sp->Flush(); 234*0b57cec5SDimitry Andric } 235*0b57cec5SDimitry Andric } 236*0b57cec5SDimitry Andric 237*0b57cec5SDimitry Andric void IOHandlerInputComplete(IOHandler &io_handler, 238*0b57cec5SDimitry Andric std::string &line) override { 239*0b57cec5SDimitry Andric io_handler.SetIsDone(true); 240*0b57cec5SDimitry Andric 241*0b57cec5SDimitry Andric std::vector<BreakpointOptions *> *bp_options_vec = 242*0b57cec5SDimitry Andric (std::vector<BreakpointOptions *> *)io_handler.GetUserData(); 243*0b57cec5SDimitry Andric for (BreakpointOptions *bp_options : *bp_options_vec) { 244*0b57cec5SDimitry Andric if (!bp_options) 245*0b57cec5SDimitry Andric continue; 246*0b57cec5SDimitry Andric 2479dba64beSDimitry Andric auto cmd_data = std::make_unique<BreakpointOptions::CommandData>(); 248*0b57cec5SDimitry Andric cmd_data->user_source.SplitIntoLines(line.c_str(), line.size()); 249*0b57cec5SDimitry Andric bp_options->SetCommandDataCallback(cmd_data); 250*0b57cec5SDimitry Andric } 251*0b57cec5SDimitry Andric } 252*0b57cec5SDimitry Andric 253*0b57cec5SDimitry Andric void CollectDataForBreakpointCommandCallback( 254*0b57cec5SDimitry Andric std::vector<BreakpointOptions *> &bp_options_vec, 255*0b57cec5SDimitry Andric CommandReturnObject &result) { 256*0b57cec5SDimitry Andric m_interpreter.GetLLDBCommandsFromIOHandler( 257*0b57cec5SDimitry Andric "> ", // Prompt 258*0b57cec5SDimitry Andric *this, // IOHandlerDelegate 259*0b57cec5SDimitry Andric &bp_options_vec); // Baton for the "io_handler" that will be passed back 260*0b57cec5SDimitry Andric // into our IOHandlerDelegate functions 261*0b57cec5SDimitry Andric } 262*0b57cec5SDimitry Andric 263*0b57cec5SDimitry Andric /// Set a one-liner as the callback for the breakpoint. 264*0b57cec5SDimitry Andric void 265*0b57cec5SDimitry Andric SetBreakpointCommandCallback(std::vector<BreakpointOptions *> &bp_options_vec, 266*0b57cec5SDimitry Andric const char *oneliner) { 267*0b57cec5SDimitry Andric for (auto bp_options : bp_options_vec) { 2689dba64beSDimitry Andric auto cmd_data = std::make_unique<BreakpointOptions::CommandData>(); 269*0b57cec5SDimitry Andric 270*0b57cec5SDimitry Andric cmd_data->user_source.AppendString(oneliner); 271*0b57cec5SDimitry Andric cmd_data->stop_on_error = m_options.m_stop_on_error; 272*0b57cec5SDimitry Andric 273*0b57cec5SDimitry Andric bp_options->SetCommandDataCallback(cmd_data); 274*0b57cec5SDimitry Andric } 275*0b57cec5SDimitry Andric } 276*0b57cec5SDimitry Andric 277480093f4SDimitry Andric class CommandOptions : public OptionGroup { 278*0b57cec5SDimitry Andric public: 279*0b57cec5SDimitry Andric CommandOptions() 280480093f4SDimitry Andric : OptionGroup(), m_use_commands(false), m_use_script_language(false), 281*0b57cec5SDimitry Andric m_script_language(eScriptLanguageNone), m_use_one_liner(false), 282480093f4SDimitry Andric m_one_liner() {} 283*0b57cec5SDimitry Andric 284*0b57cec5SDimitry Andric ~CommandOptions() override = default; 285*0b57cec5SDimitry Andric 286*0b57cec5SDimitry Andric Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, 287*0b57cec5SDimitry Andric ExecutionContext *execution_context) override { 288*0b57cec5SDimitry Andric Status error; 289480093f4SDimitry Andric const int short_option = 290480093f4SDimitry Andric g_breakpoint_command_add_options[option_idx].short_option; 291*0b57cec5SDimitry Andric 292*0b57cec5SDimitry Andric switch (short_option) { 293*0b57cec5SDimitry Andric case 'o': 294*0b57cec5SDimitry Andric m_use_one_liner = true; 2955ffd83dbSDimitry Andric m_one_liner = std::string(option_arg); 296*0b57cec5SDimitry Andric break; 297*0b57cec5SDimitry Andric 298*0b57cec5SDimitry Andric case 's': 299*0b57cec5SDimitry Andric m_script_language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum( 3009dba64beSDimitry Andric option_arg, 3019dba64beSDimitry Andric g_breakpoint_command_add_options[option_idx].enum_values, 302*0b57cec5SDimitry Andric eScriptLanguageNone, error); 303480093f4SDimitry Andric switch (m_script_language) { 304480093f4SDimitry Andric case eScriptLanguagePython: 305480093f4SDimitry Andric case eScriptLanguageLua: 306*0b57cec5SDimitry Andric m_use_script_language = true; 307480093f4SDimitry Andric break; 308480093f4SDimitry Andric case eScriptLanguageNone: 309480093f4SDimitry Andric case eScriptLanguageUnknown: 310*0b57cec5SDimitry Andric m_use_script_language = false; 311480093f4SDimitry Andric break; 312*0b57cec5SDimitry Andric } 313*0b57cec5SDimitry Andric break; 314*0b57cec5SDimitry Andric 315*0b57cec5SDimitry Andric case 'e': { 316*0b57cec5SDimitry Andric bool success = false; 317*0b57cec5SDimitry Andric m_stop_on_error = 318*0b57cec5SDimitry Andric OptionArgParser::ToBoolean(option_arg, false, &success); 319*0b57cec5SDimitry Andric if (!success) 320*0b57cec5SDimitry Andric error.SetErrorStringWithFormat( 321*0b57cec5SDimitry Andric "invalid value for stop-on-error: \"%s\"", 322*0b57cec5SDimitry Andric option_arg.str().c_str()); 323*0b57cec5SDimitry Andric } break; 324*0b57cec5SDimitry Andric 325*0b57cec5SDimitry Andric case 'D': 326*0b57cec5SDimitry Andric m_use_dummy = true; 327*0b57cec5SDimitry Andric break; 328*0b57cec5SDimitry Andric 329*0b57cec5SDimitry Andric default: 3309dba64beSDimitry Andric llvm_unreachable("Unimplemented option"); 331*0b57cec5SDimitry Andric } 332*0b57cec5SDimitry Andric return error; 333*0b57cec5SDimitry Andric } 334*0b57cec5SDimitry Andric 335*0b57cec5SDimitry Andric void OptionParsingStarting(ExecutionContext *execution_context) override { 336*0b57cec5SDimitry Andric m_use_commands = true; 337*0b57cec5SDimitry Andric m_use_script_language = false; 338*0b57cec5SDimitry Andric m_script_language = eScriptLanguageNone; 339*0b57cec5SDimitry Andric 340*0b57cec5SDimitry Andric m_use_one_liner = false; 341*0b57cec5SDimitry Andric m_stop_on_error = true; 342*0b57cec5SDimitry Andric m_one_liner.clear(); 343*0b57cec5SDimitry Andric m_use_dummy = false; 344*0b57cec5SDimitry Andric } 345*0b57cec5SDimitry Andric 346*0b57cec5SDimitry Andric llvm::ArrayRef<OptionDefinition> GetDefinitions() override { 3479dba64beSDimitry Andric return llvm::makeArrayRef(g_breakpoint_command_add_options); 348*0b57cec5SDimitry Andric } 349*0b57cec5SDimitry Andric 350*0b57cec5SDimitry Andric // Instance variables to hold the values for command options. 351*0b57cec5SDimitry Andric 352*0b57cec5SDimitry Andric bool m_use_commands; 353*0b57cec5SDimitry Andric bool m_use_script_language; 354*0b57cec5SDimitry Andric lldb::ScriptLanguage m_script_language; 355*0b57cec5SDimitry Andric 356*0b57cec5SDimitry Andric // Instance variables to hold the values for one_liner options. 357*0b57cec5SDimitry Andric bool m_use_one_liner; 358*0b57cec5SDimitry Andric std::string m_one_liner; 359*0b57cec5SDimitry Andric bool m_stop_on_error; 360*0b57cec5SDimitry Andric bool m_use_dummy; 361*0b57cec5SDimitry Andric }; 362*0b57cec5SDimitry Andric 363*0b57cec5SDimitry Andric protected: 364*0b57cec5SDimitry Andric bool DoExecute(Args &command, CommandReturnObject &result) override { 3659dba64beSDimitry Andric Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy); 366*0b57cec5SDimitry Andric 3679dba64beSDimitry Andric const BreakpointList &breakpoints = target.GetBreakpointList(); 368*0b57cec5SDimitry Andric size_t num_breakpoints = breakpoints.GetSize(); 369*0b57cec5SDimitry Andric 370*0b57cec5SDimitry Andric if (num_breakpoints == 0) { 371*0b57cec5SDimitry Andric result.AppendError("No breakpoints exist to have commands added"); 372*0b57cec5SDimitry Andric result.SetStatus(eReturnStatusFailed); 373*0b57cec5SDimitry Andric return false; 374*0b57cec5SDimitry Andric } 375*0b57cec5SDimitry Andric 376480093f4SDimitry Andric if (!m_func_options.GetName().empty()) { 377480093f4SDimitry Andric m_options.m_use_one_liner = false; 378480093f4SDimitry Andric if (!m_options.m_use_script_language) { 379480093f4SDimitry Andric m_options.m_script_language = GetDebugger().GetScriptLanguage(); 380480093f4SDimitry Andric m_options.m_use_script_language = true; 381480093f4SDimitry Andric } 382*0b57cec5SDimitry Andric } 383*0b57cec5SDimitry Andric 384*0b57cec5SDimitry Andric BreakpointIDList valid_bp_ids; 385*0b57cec5SDimitry Andric CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs( 3869dba64beSDimitry Andric command, &target, result, &valid_bp_ids, 387*0b57cec5SDimitry Andric BreakpointName::Permissions::PermissionKinds::listPerm); 388*0b57cec5SDimitry Andric 389*0b57cec5SDimitry Andric m_bp_options_vec.clear(); 390*0b57cec5SDimitry Andric 391*0b57cec5SDimitry Andric if (result.Succeeded()) { 392*0b57cec5SDimitry Andric const size_t count = valid_bp_ids.GetSize(); 393*0b57cec5SDimitry Andric 394*0b57cec5SDimitry Andric for (size_t i = 0; i < count; ++i) { 395*0b57cec5SDimitry Andric BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i); 396*0b57cec5SDimitry Andric if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) { 397*0b57cec5SDimitry Andric Breakpoint *bp = 3989dba64beSDimitry Andric target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); 399*0b57cec5SDimitry Andric BreakpointOptions *bp_options = nullptr; 400*0b57cec5SDimitry Andric if (cur_bp_id.GetLocationID() == LLDB_INVALID_BREAK_ID) { 401*0b57cec5SDimitry Andric // This breakpoint does not have an associated location. 402*0b57cec5SDimitry Andric bp_options = bp->GetOptions(); 403*0b57cec5SDimitry Andric } else { 404*0b57cec5SDimitry Andric BreakpointLocationSP bp_loc_sp( 405*0b57cec5SDimitry Andric bp->FindLocationByID(cur_bp_id.GetLocationID())); 406*0b57cec5SDimitry Andric // This breakpoint does have an associated location. Get its 407*0b57cec5SDimitry Andric // breakpoint options. 408*0b57cec5SDimitry Andric if (bp_loc_sp) 409*0b57cec5SDimitry Andric bp_options = bp_loc_sp->GetLocationOptions(); 410*0b57cec5SDimitry Andric } 411*0b57cec5SDimitry Andric if (bp_options) 412*0b57cec5SDimitry Andric m_bp_options_vec.push_back(bp_options); 413*0b57cec5SDimitry Andric } 414*0b57cec5SDimitry Andric } 415*0b57cec5SDimitry Andric 416*0b57cec5SDimitry Andric // If we are using script language, get the script interpreter in order 417*0b57cec5SDimitry Andric // to set or collect command callback. Otherwise, call the methods 418*0b57cec5SDimitry Andric // associated with this object. 419*0b57cec5SDimitry Andric if (m_options.m_use_script_language) { 420480093f4SDimitry Andric ScriptInterpreter *script_interp = GetDebugger().GetScriptInterpreter( 421480093f4SDimitry Andric /*can_create=*/true, m_options.m_script_language); 422*0b57cec5SDimitry Andric // Special handling for one-liner specified inline. 423*0b57cec5SDimitry Andric if (m_options.m_use_one_liner) { 424*0b57cec5SDimitry Andric script_interp->SetBreakpointCommandCallback( 425*0b57cec5SDimitry Andric m_bp_options_vec, m_options.m_one_liner.c_str()); 426480093f4SDimitry Andric } else if (!m_func_options.GetName().empty()) { 427480093f4SDimitry Andric Status error = script_interp->SetBreakpointCommandCallbackFunction( 428480093f4SDimitry Andric m_bp_options_vec, m_func_options.GetName().c_str(), 429480093f4SDimitry Andric m_func_options.GetStructuredData()); 430480093f4SDimitry Andric if (!error.Success()) 431480093f4SDimitry Andric result.SetError(error); 432*0b57cec5SDimitry Andric } else { 433*0b57cec5SDimitry Andric script_interp->CollectDataForBreakpointCommandCallback( 434*0b57cec5SDimitry Andric m_bp_options_vec, result); 435*0b57cec5SDimitry Andric } 436*0b57cec5SDimitry Andric } else { 437*0b57cec5SDimitry Andric // Special handling for one-liner specified inline. 438*0b57cec5SDimitry Andric if (m_options.m_use_one_liner) 439*0b57cec5SDimitry Andric SetBreakpointCommandCallback(m_bp_options_vec, 440*0b57cec5SDimitry Andric m_options.m_one_liner.c_str()); 441*0b57cec5SDimitry Andric else 442*0b57cec5SDimitry Andric CollectDataForBreakpointCommandCallback(m_bp_options_vec, result); 443*0b57cec5SDimitry Andric } 444*0b57cec5SDimitry Andric } 445*0b57cec5SDimitry Andric 446*0b57cec5SDimitry Andric return result.Succeeded(); 447*0b57cec5SDimitry Andric } 448*0b57cec5SDimitry Andric 449*0b57cec5SDimitry Andric private: 450*0b57cec5SDimitry Andric CommandOptions m_options; 451480093f4SDimitry Andric OptionGroupPythonClassWithDict m_func_options; 452480093f4SDimitry Andric OptionGroupOptions m_all_options; 453480093f4SDimitry Andric 454*0b57cec5SDimitry Andric std::vector<BreakpointOptions *> m_bp_options_vec; // This stores the 455*0b57cec5SDimitry Andric // breakpoint options that 456*0b57cec5SDimitry Andric // we are currently 457*0b57cec5SDimitry Andric // collecting commands for. In the CollectData... calls we need to hand this 458*0b57cec5SDimitry Andric // off to the IOHandler, which may run asynchronously. So we have to have 459*0b57cec5SDimitry Andric // some way to keep it alive, and not leak it. Making it an ivar of the 460*0b57cec5SDimitry Andric // command object, which never goes away achieves this. Note that if we were 461*0b57cec5SDimitry Andric // able to run the same command concurrently in one interpreter we'd have to 462*0b57cec5SDimitry Andric // make this "per invocation". But there are many more reasons why it is not 463*0b57cec5SDimitry Andric // in general safe to do that in lldb at present, so it isn't worthwhile to 464*0b57cec5SDimitry Andric // come up with a more complex mechanism to address this particular weakness 465*0b57cec5SDimitry Andric // right now. 466*0b57cec5SDimitry Andric static const char *g_reader_instructions; 467*0b57cec5SDimitry Andric }; 468*0b57cec5SDimitry Andric 469*0b57cec5SDimitry Andric const char *CommandObjectBreakpointCommandAdd::g_reader_instructions = 470*0b57cec5SDimitry Andric "Enter your debugger command(s). Type 'DONE' to end.\n"; 471*0b57cec5SDimitry Andric 472*0b57cec5SDimitry Andric // CommandObjectBreakpointCommandDelete 473*0b57cec5SDimitry Andric 4749dba64beSDimitry Andric #define LLDB_OPTIONS_breakpoint_command_delete 4759dba64beSDimitry Andric #include "CommandOptions.inc" 476*0b57cec5SDimitry Andric 477*0b57cec5SDimitry Andric class CommandObjectBreakpointCommandDelete : public CommandObjectParsed { 478*0b57cec5SDimitry Andric public: 479*0b57cec5SDimitry Andric CommandObjectBreakpointCommandDelete(CommandInterpreter &interpreter) 480*0b57cec5SDimitry Andric : CommandObjectParsed(interpreter, "delete", 481*0b57cec5SDimitry Andric "Delete the set of commands from a breakpoint.", 482*0b57cec5SDimitry Andric nullptr), 483*0b57cec5SDimitry Andric m_options() { 484*0b57cec5SDimitry Andric CommandArgumentEntry arg; 485*0b57cec5SDimitry Andric CommandArgumentData bp_id_arg; 486*0b57cec5SDimitry Andric 487*0b57cec5SDimitry Andric // Define the first (and only) variant of this arg. 488*0b57cec5SDimitry Andric bp_id_arg.arg_type = eArgTypeBreakpointID; 489*0b57cec5SDimitry Andric bp_id_arg.arg_repetition = eArgRepeatPlain; 490*0b57cec5SDimitry Andric 491*0b57cec5SDimitry Andric // There is only one variant this argument could be; put it into the 492*0b57cec5SDimitry Andric // argument entry. 493*0b57cec5SDimitry Andric arg.push_back(bp_id_arg); 494*0b57cec5SDimitry Andric 495*0b57cec5SDimitry Andric // Push the data for the first argument into the m_arguments vector. 496*0b57cec5SDimitry Andric m_arguments.push_back(arg); 497*0b57cec5SDimitry Andric } 498*0b57cec5SDimitry Andric 499*0b57cec5SDimitry Andric ~CommandObjectBreakpointCommandDelete() override = default; 500*0b57cec5SDimitry Andric 501*0b57cec5SDimitry Andric Options *GetOptions() override { return &m_options; } 502*0b57cec5SDimitry Andric 503*0b57cec5SDimitry Andric class CommandOptions : public Options { 504*0b57cec5SDimitry Andric public: 505*0b57cec5SDimitry Andric CommandOptions() : Options(), m_use_dummy(false) {} 506*0b57cec5SDimitry Andric 507*0b57cec5SDimitry Andric ~CommandOptions() override = default; 508*0b57cec5SDimitry Andric 509*0b57cec5SDimitry Andric Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, 510*0b57cec5SDimitry Andric ExecutionContext *execution_context) override { 511*0b57cec5SDimitry Andric Status error; 512*0b57cec5SDimitry Andric const int short_option = m_getopt_table[option_idx].val; 513*0b57cec5SDimitry Andric 514*0b57cec5SDimitry Andric switch (short_option) { 515*0b57cec5SDimitry Andric case 'D': 516*0b57cec5SDimitry Andric m_use_dummy = true; 517*0b57cec5SDimitry Andric break; 518*0b57cec5SDimitry Andric 519*0b57cec5SDimitry Andric default: 5209dba64beSDimitry Andric llvm_unreachable("Unimplemented option"); 521*0b57cec5SDimitry Andric } 522*0b57cec5SDimitry Andric 523*0b57cec5SDimitry Andric return error; 524*0b57cec5SDimitry Andric } 525*0b57cec5SDimitry Andric 526*0b57cec5SDimitry Andric void OptionParsingStarting(ExecutionContext *execution_context) override { 527*0b57cec5SDimitry Andric m_use_dummy = false; 528*0b57cec5SDimitry Andric } 529*0b57cec5SDimitry Andric 530*0b57cec5SDimitry Andric llvm::ArrayRef<OptionDefinition> GetDefinitions() override { 5319dba64beSDimitry Andric return llvm::makeArrayRef(g_breakpoint_command_delete_options); 532*0b57cec5SDimitry Andric } 533*0b57cec5SDimitry Andric 534*0b57cec5SDimitry Andric // Instance variables to hold the values for command options. 535*0b57cec5SDimitry Andric bool m_use_dummy; 536*0b57cec5SDimitry Andric }; 537*0b57cec5SDimitry Andric 538*0b57cec5SDimitry Andric protected: 539*0b57cec5SDimitry Andric bool DoExecute(Args &command, CommandReturnObject &result) override { 5409dba64beSDimitry Andric Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy); 541*0b57cec5SDimitry Andric 5429dba64beSDimitry Andric const BreakpointList &breakpoints = target.GetBreakpointList(); 543*0b57cec5SDimitry Andric size_t num_breakpoints = breakpoints.GetSize(); 544*0b57cec5SDimitry Andric 545*0b57cec5SDimitry Andric if (num_breakpoints == 0) { 546*0b57cec5SDimitry Andric result.AppendError("No breakpoints exist to have commands deleted"); 547*0b57cec5SDimitry Andric result.SetStatus(eReturnStatusFailed); 548*0b57cec5SDimitry Andric return false; 549*0b57cec5SDimitry Andric } 550*0b57cec5SDimitry Andric 551*0b57cec5SDimitry Andric if (command.empty()) { 552*0b57cec5SDimitry Andric result.AppendError( 553*0b57cec5SDimitry Andric "No breakpoint specified from which to delete the commands"); 554*0b57cec5SDimitry Andric result.SetStatus(eReturnStatusFailed); 555*0b57cec5SDimitry Andric return false; 556*0b57cec5SDimitry Andric } 557*0b57cec5SDimitry Andric 558*0b57cec5SDimitry Andric BreakpointIDList valid_bp_ids; 559*0b57cec5SDimitry Andric CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs( 5609dba64beSDimitry Andric command, &target, result, &valid_bp_ids, 561*0b57cec5SDimitry Andric BreakpointName::Permissions::PermissionKinds::listPerm); 562*0b57cec5SDimitry Andric 563*0b57cec5SDimitry Andric if (result.Succeeded()) { 564*0b57cec5SDimitry Andric const size_t count = valid_bp_ids.GetSize(); 565*0b57cec5SDimitry Andric for (size_t i = 0; i < count; ++i) { 566*0b57cec5SDimitry Andric BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i); 567*0b57cec5SDimitry Andric if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) { 568*0b57cec5SDimitry Andric Breakpoint *bp = 5699dba64beSDimitry Andric target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); 570*0b57cec5SDimitry Andric if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) { 571*0b57cec5SDimitry Andric BreakpointLocationSP bp_loc_sp( 572*0b57cec5SDimitry Andric bp->FindLocationByID(cur_bp_id.GetLocationID())); 573*0b57cec5SDimitry Andric if (bp_loc_sp) 574*0b57cec5SDimitry Andric bp_loc_sp->ClearCallback(); 575*0b57cec5SDimitry Andric else { 576*0b57cec5SDimitry Andric result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n", 577*0b57cec5SDimitry Andric cur_bp_id.GetBreakpointID(), 578*0b57cec5SDimitry Andric cur_bp_id.GetLocationID()); 579*0b57cec5SDimitry Andric result.SetStatus(eReturnStatusFailed); 580*0b57cec5SDimitry Andric return false; 581*0b57cec5SDimitry Andric } 582*0b57cec5SDimitry Andric } else { 583*0b57cec5SDimitry Andric bp->ClearCallback(); 584*0b57cec5SDimitry Andric } 585*0b57cec5SDimitry Andric } 586*0b57cec5SDimitry Andric } 587*0b57cec5SDimitry Andric } 588*0b57cec5SDimitry Andric return result.Succeeded(); 589*0b57cec5SDimitry Andric } 590*0b57cec5SDimitry Andric 591*0b57cec5SDimitry Andric private: 592*0b57cec5SDimitry Andric CommandOptions m_options; 593*0b57cec5SDimitry Andric }; 594*0b57cec5SDimitry Andric 595*0b57cec5SDimitry Andric // CommandObjectBreakpointCommandList 596*0b57cec5SDimitry Andric 597*0b57cec5SDimitry Andric class CommandObjectBreakpointCommandList : public CommandObjectParsed { 598*0b57cec5SDimitry Andric public: 599*0b57cec5SDimitry Andric CommandObjectBreakpointCommandList(CommandInterpreter &interpreter) 6009dba64beSDimitry Andric : CommandObjectParsed(interpreter, "list", 6019dba64beSDimitry Andric "List the script or set of commands to be " 6029dba64beSDimitry Andric "executed when the breakpoint is hit.", 6039dba64beSDimitry Andric nullptr, eCommandRequiresTarget) { 604*0b57cec5SDimitry Andric CommandArgumentEntry arg; 605*0b57cec5SDimitry Andric CommandArgumentData bp_id_arg; 606*0b57cec5SDimitry Andric 607*0b57cec5SDimitry Andric // Define the first (and only) variant of this arg. 608*0b57cec5SDimitry Andric bp_id_arg.arg_type = eArgTypeBreakpointID; 609*0b57cec5SDimitry Andric bp_id_arg.arg_repetition = eArgRepeatPlain; 610*0b57cec5SDimitry Andric 611*0b57cec5SDimitry Andric // There is only one variant this argument could be; put it into the 612*0b57cec5SDimitry Andric // argument entry. 613*0b57cec5SDimitry Andric arg.push_back(bp_id_arg); 614*0b57cec5SDimitry Andric 615*0b57cec5SDimitry Andric // Push the data for the first argument into the m_arguments vector. 616*0b57cec5SDimitry Andric m_arguments.push_back(arg); 617*0b57cec5SDimitry Andric } 618*0b57cec5SDimitry Andric 619*0b57cec5SDimitry Andric ~CommandObjectBreakpointCommandList() override = default; 620*0b57cec5SDimitry Andric 621*0b57cec5SDimitry Andric protected: 622*0b57cec5SDimitry Andric bool DoExecute(Args &command, CommandReturnObject &result) override { 6239dba64beSDimitry Andric Target *target = &GetSelectedTarget(); 624*0b57cec5SDimitry Andric 625*0b57cec5SDimitry Andric const BreakpointList &breakpoints = target->GetBreakpointList(); 626*0b57cec5SDimitry Andric size_t num_breakpoints = breakpoints.GetSize(); 627*0b57cec5SDimitry Andric 628*0b57cec5SDimitry Andric if (num_breakpoints == 0) { 629*0b57cec5SDimitry Andric result.AppendError("No breakpoints exist for which to list commands"); 630*0b57cec5SDimitry Andric result.SetStatus(eReturnStatusFailed); 631*0b57cec5SDimitry Andric return false; 632*0b57cec5SDimitry Andric } 633*0b57cec5SDimitry Andric 634*0b57cec5SDimitry Andric if (command.empty()) { 635*0b57cec5SDimitry Andric result.AppendError( 636*0b57cec5SDimitry Andric "No breakpoint specified for which to list the commands"); 637*0b57cec5SDimitry Andric result.SetStatus(eReturnStatusFailed); 638*0b57cec5SDimitry Andric return false; 639*0b57cec5SDimitry Andric } 640*0b57cec5SDimitry Andric 641*0b57cec5SDimitry Andric BreakpointIDList valid_bp_ids; 642*0b57cec5SDimitry Andric CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs( 643*0b57cec5SDimitry Andric command, target, result, &valid_bp_ids, 644*0b57cec5SDimitry Andric BreakpointName::Permissions::PermissionKinds::listPerm); 645*0b57cec5SDimitry Andric 646*0b57cec5SDimitry Andric if (result.Succeeded()) { 647*0b57cec5SDimitry Andric const size_t count = valid_bp_ids.GetSize(); 648*0b57cec5SDimitry Andric for (size_t i = 0; i < count; ++i) { 649*0b57cec5SDimitry Andric BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i); 650*0b57cec5SDimitry Andric if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) { 651*0b57cec5SDimitry Andric Breakpoint *bp = 652*0b57cec5SDimitry Andric target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); 653*0b57cec5SDimitry Andric 654*0b57cec5SDimitry Andric if (bp) { 655*0b57cec5SDimitry Andric BreakpointLocationSP bp_loc_sp; 656*0b57cec5SDimitry Andric if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) { 657*0b57cec5SDimitry Andric bp_loc_sp = bp->FindLocationByID(cur_bp_id.GetLocationID()); 658480093f4SDimitry Andric if (!bp_loc_sp) { 659*0b57cec5SDimitry Andric result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n", 660*0b57cec5SDimitry Andric cur_bp_id.GetBreakpointID(), 661*0b57cec5SDimitry Andric cur_bp_id.GetLocationID()); 662*0b57cec5SDimitry Andric result.SetStatus(eReturnStatusFailed); 663*0b57cec5SDimitry Andric return false; 664*0b57cec5SDimitry Andric } 665*0b57cec5SDimitry Andric } 666*0b57cec5SDimitry Andric 667*0b57cec5SDimitry Andric StreamString id_str; 668*0b57cec5SDimitry Andric BreakpointID::GetCanonicalReference(&id_str, 669*0b57cec5SDimitry Andric cur_bp_id.GetBreakpointID(), 670*0b57cec5SDimitry Andric cur_bp_id.GetLocationID()); 671*0b57cec5SDimitry Andric const Baton *baton = nullptr; 672*0b57cec5SDimitry Andric if (bp_loc_sp) 673480093f4SDimitry Andric baton = 674480093f4SDimitry Andric bp_loc_sp 675*0b57cec5SDimitry Andric ->GetOptionsSpecifyingKind(BreakpointOptions::eCallback) 676*0b57cec5SDimitry Andric ->GetBaton(); 677*0b57cec5SDimitry Andric else 678*0b57cec5SDimitry Andric baton = bp->GetOptions()->GetBaton(); 679*0b57cec5SDimitry Andric 680*0b57cec5SDimitry Andric if (baton) { 681*0b57cec5SDimitry Andric result.GetOutputStream().Printf("Breakpoint %s:\n", 682*0b57cec5SDimitry Andric id_str.GetData()); 683480093f4SDimitry Andric baton->GetDescription(result.GetOutputStream().AsRawOstream(), 684480093f4SDimitry Andric eDescriptionLevelFull, 685480093f4SDimitry Andric result.GetOutputStream().GetIndentLevel() + 686480093f4SDimitry Andric 2); 687*0b57cec5SDimitry Andric } else { 688*0b57cec5SDimitry Andric result.AppendMessageWithFormat( 689*0b57cec5SDimitry Andric "Breakpoint %s does not have an associated command.\n", 690*0b57cec5SDimitry Andric id_str.GetData()); 691*0b57cec5SDimitry Andric } 692*0b57cec5SDimitry Andric } 693*0b57cec5SDimitry Andric result.SetStatus(eReturnStatusSuccessFinishResult); 694*0b57cec5SDimitry Andric } else { 695*0b57cec5SDimitry Andric result.AppendErrorWithFormat("Invalid breakpoint ID: %u.\n", 696*0b57cec5SDimitry Andric cur_bp_id.GetBreakpointID()); 697*0b57cec5SDimitry Andric result.SetStatus(eReturnStatusFailed); 698*0b57cec5SDimitry Andric } 699*0b57cec5SDimitry Andric } 700*0b57cec5SDimitry Andric } 701*0b57cec5SDimitry Andric 702*0b57cec5SDimitry Andric return result.Succeeded(); 703*0b57cec5SDimitry Andric } 704*0b57cec5SDimitry Andric }; 705*0b57cec5SDimitry Andric 706*0b57cec5SDimitry Andric // CommandObjectBreakpointCommand 707*0b57cec5SDimitry Andric 708*0b57cec5SDimitry Andric CommandObjectBreakpointCommand::CommandObjectBreakpointCommand( 709*0b57cec5SDimitry Andric CommandInterpreter &interpreter) 710*0b57cec5SDimitry Andric : CommandObjectMultiword( 711480093f4SDimitry Andric interpreter, "command", 712480093f4SDimitry Andric "Commands for adding, removing and listing " 713*0b57cec5SDimitry Andric "LLDB commands executed when a breakpoint is " 714*0b57cec5SDimitry Andric "hit.", 715*0b57cec5SDimitry Andric "command <sub-command> [<sub-command-options>] <breakpoint-id>") { 716*0b57cec5SDimitry Andric CommandObjectSP add_command_object( 717*0b57cec5SDimitry Andric new CommandObjectBreakpointCommandAdd(interpreter)); 718*0b57cec5SDimitry Andric CommandObjectSP delete_command_object( 719*0b57cec5SDimitry Andric new CommandObjectBreakpointCommandDelete(interpreter)); 720*0b57cec5SDimitry Andric CommandObjectSP list_command_object( 721*0b57cec5SDimitry Andric new CommandObjectBreakpointCommandList(interpreter)); 722*0b57cec5SDimitry Andric 723*0b57cec5SDimitry Andric add_command_object->SetCommandName("breakpoint command add"); 724*0b57cec5SDimitry Andric delete_command_object->SetCommandName("breakpoint command delete"); 725*0b57cec5SDimitry Andric list_command_object->SetCommandName("breakpoint command list"); 726*0b57cec5SDimitry Andric 727*0b57cec5SDimitry Andric LoadSubCommand("add", add_command_object); 728*0b57cec5SDimitry Andric LoadSubCommand("delete", delete_command_object); 729*0b57cec5SDimitry Andric LoadSubCommand("list", list_command_object); 730*0b57cec5SDimitry Andric } 731*0b57cec5SDimitry Andric 732*0b57cec5SDimitry Andric CommandObjectBreakpointCommand::~CommandObjectBreakpointCommand() = default; 733