130fdc8d8SChris Lattner //===-- CommandObjectBreakpointCommand.cpp ----------------------*- C++ -*-===// 230fdc8d8SChris Lattner // 330fdc8d8SChris Lattner // The LLVM Compiler Infrastructure 430fdc8d8SChris Lattner // 530fdc8d8SChris Lattner // This file is distributed under the University of Illinois Open Source 630fdc8d8SChris Lattner // License. See LICENSE.TXT for details. 730fdc8d8SChris Lattner // 830fdc8d8SChris Lattner //===----------------------------------------------------------------------===// 930fdc8d8SChris Lattner 1030fdc8d8SChris Lattner // C Includes 1130fdc8d8SChris Lattner // C++ Includes 12c8ecc2a9SEugene Zelenko // Other libraries and framework includes 13c8ecc2a9SEugene Zelenko // Project includes 1430fdc8d8SChris Lattner #include "CommandObjectBreakpointCommand.h" 1530fdc8d8SChris Lattner #include "CommandObjectBreakpoint.h" 16b9c1b51eSKate Stone #include "lldb/Breakpoint/Breakpoint.h" 17b9c1b51eSKate Stone #include "lldb/Breakpoint/BreakpointIDList.h" 18b9c1b51eSKate Stone #include "lldb/Breakpoint/BreakpointLocation.h" 19b9c1b51eSKate Stone #include "lldb/Breakpoint/StoppointCallbackContext.h" 2044d93782SGreg Clayton #include "lldb/Core/IOHandler.h" 21b9c1b51eSKate Stone #include "lldb/Core/State.h" 223eb2b44dSZachary Turner #include "lldb/Host/OptionParser.h" 2330fdc8d8SChris Lattner #include "lldb/Interpreter/CommandInterpreter.h" 2430fdc8d8SChris Lattner #include "lldb/Interpreter/CommandReturnObject.h" 25*47cbf4a0SPavel Labath #include "lldb/Interpreter/OptionArgParser.h" 2630fdc8d8SChris Lattner #include "lldb/Target/Target.h" 2730fdc8d8SChris Lattner #include "lldb/Target/Thread.h" 2830fdc8d8SChris Lattner 294e4fbe82SZachary Turner #include "llvm/ADT/STLExtras.h" 304e4fbe82SZachary Turner 3130fdc8d8SChris Lattner using namespace lldb; 3230fdc8d8SChris Lattner using namespace lldb_private; 3330fdc8d8SChris Lattner 3430fdc8d8SChris Lattner //------------------------------------------------------------------------- 3530fdc8d8SChris Lattner // CommandObjectBreakpointCommandAdd 3630fdc8d8SChris Lattner //------------------------------------------------------------------------- 3730fdc8d8SChris Lattner 381f0f5b5bSZachary Turner // FIXME: "script-type" needs to have its contents determined dynamically, so 391f0f5b5bSZachary Turner // somebody can add a new scripting 401f0f5b5bSZachary Turner // language to lldb and have it pickable here without having to change this 411f0f5b5bSZachary Turner // enumeration by hand and rebuild lldb proper. 421f0f5b5bSZachary Turner 431f0f5b5bSZachary Turner static OptionEnumValueElement g_script_option_enumeration[4] = { 441f0f5b5bSZachary Turner {eScriptLanguageNone, "command", 451f0f5b5bSZachary Turner "Commands are in the lldb command interpreter language"}, 461f0f5b5bSZachary Turner {eScriptLanguagePython, "python", "Commands are in the Python language."}, 471f0f5b5bSZachary Turner {eSortOrderByName, "default-script", 481f0f5b5bSZachary Turner "Commands are in the default scripting language."}, 491f0f5b5bSZachary Turner {0, nullptr, nullptr}}; 501f0f5b5bSZachary Turner 511f0f5b5bSZachary Turner static OptionDefinition g_breakpoint_add_options[] = { 521f0f5b5bSZachary Turner // clang-format off 531f0f5b5bSZachary Turner { 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." }, 541f0f5b5bSZachary Turner { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Specify whether breakpoint command execution should terminate on error." }, 551f0f5b5bSZachary Turner { 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." }, 561f0f5b5bSZachary Turner { 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." }, 571f0f5b5bSZachary Turner { 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." }, 581f0f5b5bSZachary Turner // clang-format on 591f0f5b5bSZachary Turner }; 601f0f5b5bSZachary Turner 61b9c1b51eSKate Stone class CommandObjectBreakpointCommandAdd : public CommandObjectParsed, 62b9c1b51eSKate Stone public IOHandlerDelegateMultiline { 635a988416SJim Ingham public: 647428a18cSKate Stone CommandObjectBreakpointCommandAdd(CommandInterpreter &interpreter) 657428a18cSKate Stone : CommandObjectParsed(interpreter, "add", 66b9c1b51eSKate Stone "Add LLDB commands to a breakpoint, to be executed " 67b9c1b51eSKate Stone "whenever the breakpoint is hit." 68b9c1b51eSKate Stone " If no breakpoint is specified, adds the " 69b9c1b51eSKate Stone "commands to the last created breakpoint.", 70c8ecc2a9SEugene Zelenko nullptr), 71b9c1b51eSKate Stone IOHandlerDelegateMultiline("DONE", 72b9c1b51eSKate Stone IOHandlerDelegate::Completion::LLDBCommand), 73b9c1b51eSKate Stone m_options() { 7430fdc8d8SChris Lattner SetHelpLong( 75ea671fbdSKate Stone R"( 76ea671fbdSKate Stone General information about entering breakpoint commands 77ea671fbdSKate Stone ------------------------------------------------------ 78ea671fbdSKate Stone 79b9c1b51eSKate Stone )" 80b9c1b51eSKate Stone "This command will prompt for commands to be executed when the specified \ 81ea671fbdSKate Stone breakpoint is hit. Each command is typed on its own line following the '> ' \ 82b9c1b51eSKate Stone prompt until 'DONE' is entered." 83b9c1b51eSKate Stone R"( 84ea671fbdSKate Stone 85b9c1b51eSKate Stone )" 86b9c1b51eSKate Stone "Syntactic errors may not be detected when initially entered, and many \ 87ea671fbdSKate Stone malformed commands can silently fail when executed. If your breakpoint commands \ 88b9c1b51eSKate Stone do not appear to be executing, double-check the command syntax." 89b9c1b51eSKate Stone R"( 90ea671fbdSKate Stone 91b9c1b51eSKate Stone )" 92b9c1b51eSKate Stone "Note: You may enter any debugger command exactly as you would at the debugger \ 93ea671fbdSKate Stone prompt. There is no limit to the number of commands supplied, but do NOT enter \ 94b9c1b51eSKate Stone more than one command per line." 95b9c1b51eSKate Stone R"( 96ea671fbdSKate Stone 97ea671fbdSKate Stone Special information about PYTHON breakpoint commands 98ea671fbdSKate Stone ---------------------------------------------------- 99ea671fbdSKate Stone 100b9c1b51eSKate Stone )" 101b9c1b51eSKate Stone "You may enter either one or more lines of Python, including function \ 102ea671fbdSKate Stone definitions or calls to functions that will have been imported by the time \ 103ea671fbdSKate Stone the code executes. Single line breakpoint commands will be interpreted 'as is' \ 104ea671fbdSKate Stone when the breakpoint is hit. Multiple lines of Python will be wrapped in a \ 105b9c1b51eSKate Stone generated function, and a call to the function will be attached to the breakpoint." 106b9c1b51eSKate Stone R"( 107ea671fbdSKate Stone 108ea671fbdSKate Stone This auto-generated function is passed in three arguments: 109ea671fbdSKate Stone 110ea671fbdSKate Stone frame: an lldb.SBFrame object for the frame which hit breakpoint. 111ea671fbdSKate Stone 112ea671fbdSKate Stone bp_loc: an lldb.SBBreakpointLocation object that represents the breakpoint location that was hit. 113ea671fbdSKate Stone 114ea671fbdSKate Stone dict: the python session dictionary hit. 115ea671fbdSKate Stone 116b9c1b51eSKate Stone )" 117b9c1b51eSKate Stone "When specifying a python function with the --python-function option, you need \ 118b9c1b51eSKate Stone to supply the function name prepended by the module name:" 119b9c1b51eSKate Stone R"( 120ea671fbdSKate Stone 121ea671fbdSKate Stone --python-function myutils.breakpoint_callback 122ea671fbdSKate Stone 123ea671fbdSKate Stone The function itself must have the following prototype: 124ea671fbdSKate Stone 125ea671fbdSKate Stone def breakpoint_callback(frame, bp_loc, dict): 126ea671fbdSKate Stone # Your code goes here 127ea671fbdSKate Stone 128b9c1b51eSKate Stone )" 129b9c1b51eSKate Stone "The arguments are the same as the arguments passed to generated functions as \ 130ea671fbdSKate Stone described above. Note that the global variable 'lldb.frame' will NOT be updated when \ 131ea671fbdSKate Stone this function is called, so be sure to use the 'frame' argument. The 'frame' argument \ 132ea671fbdSKate Stone can get you to the thread via frame.GetThread(), the thread can get you to the \ 133ea671fbdSKate Stone process via thread.GetProcess(), and the process can get you back to the target \ 134b9c1b51eSKate Stone via process.GetTarget()." 135b9c1b51eSKate Stone R"( 136ea671fbdSKate Stone 137b9c1b51eSKate Stone )" 138b9c1b51eSKate Stone "Important Note: As Python code gets collected into functions, access to global \ 139ea671fbdSKate Stone variables requires explicit scoping using the 'global' keyword. Be sure to use correct \ 140b9c1b51eSKate Stone Python syntax, including indentation, when entering Python breakpoint commands." 141b9c1b51eSKate Stone R"( 142ea671fbdSKate Stone 143ea671fbdSKate Stone Example Python one-line breakpoint command: 144ea671fbdSKate Stone 145ea671fbdSKate Stone (lldb) breakpoint command add -s python 1 146ea671fbdSKate Stone Enter your Python command(s). Type 'DONE' to end. 147ea671fbdSKate Stone > print "Hit this breakpoint!" 148ea671fbdSKate Stone > DONE 149ea671fbdSKate Stone 150ea671fbdSKate Stone As a convenience, this also works for a short Python one-liner: 151ea671fbdSKate Stone 152ea671fbdSKate Stone (lldb) breakpoint command add -s python 1 -o 'import time; print time.asctime()' 153ea671fbdSKate Stone (lldb) run 154ea671fbdSKate Stone Launching '.../a.out' (x86_64) 155ea671fbdSKate Stone (lldb) Fri Sep 10 12:17:45 2010 156ea671fbdSKate Stone Process 21778 Stopped 157ea671fbdSKate Stone * thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread 158ea671fbdSKate Stone 36 159ea671fbdSKate Stone 37 int c(int val) 160ea671fbdSKate Stone 38 { 161ea671fbdSKate Stone 39 -> return val + 3; 162ea671fbdSKate Stone 40 } 163ea671fbdSKate Stone 41 164ea671fbdSKate Stone 42 int main (int argc, char const *argv[]) 165ea671fbdSKate Stone 166ea671fbdSKate Stone Example multiple line Python breakpoint command: 167ea671fbdSKate Stone 168ea671fbdSKate Stone (lldb) breakpoint command add -s p 1 169ea671fbdSKate Stone Enter your Python command(s). Type 'DONE' to end. 170ea671fbdSKate Stone > global bp_count 171ea671fbdSKate Stone > bp_count = bp_count + 1 172ea671fbdSKate Stone > print "Hit this breakpoint " + repr(bp_count) + " times!" 173ea671fbdSKate Stone > DONE 174ea671fbdSKate Stone 175ea671fbdSKate Stone Example multiple line Python breakpoint command, using function definition: 176ea671fbdSKate Stone 177ea671fbdSKate Stone (lldb) breakpoint command add -s python 1 178ea671fbdSKate Stone Enter your Python command(s). Type 'DONE' to end. 179ea671fbdSKate Stone > def breakpoint_output (bp_no): 180ea671fbdSKate Stone > out_string = "Hit breakpoint number " + repr (bp_no) 181ea671fbdSKate Stone > print out_string 182ea671fbdSKate Stone > return True 183ea671fbdSKate Stone > breakpoint_output (1) 184ea671fbdSKate Stone > DONE 185ea671fbdSKate Stone 186b9c1b51eSKate Stone )" 187b9c1b51eSKate Stone "In this case, since there is a reference to a global variable, \ 188ea671fbdSKate Stone 'bp_count', you will also need to make sure 'bp_count' exists and is \ 189b9c1b51eSKate Stone initialized:" 190b9c1b51eSKate Stone R"( 191ea671fbdSKate Stone 192ea671fbdSKate Stone (lldb) script 193ea671fbdSKate Stone >>> bp_count = 0 194ea671fbdSKate Stone >>> quit() 195ea671fbdSKate Stone 196b9c1b51eSKate Stone )" 197b9c1b51eSKate Stone "Your Python code, however organized, can optionally return a value. \ 198ea671fbdSKate Stone If the returned value is False, that tells LLDB not to stop at the breakpoint \ 199ea671fbdSKate Stone to which the code is associated. Returning anything other than False, or even \ 200ea671fbdSKate Stone returning None, or even omitting a return statement entirely, will cause \ 201b9c1b51eSKate Stone LLDB to stop." 202b9c1b51eSKate Stone R"( 203ea671fbdSKate Stone 204b9c1b51eSKate Stone )" 205b9c1b51eSKate Stone "Final Note: A warning that no breakpoint command was generated when there \ 206b9c1b51eSKate Stone are no syntax errors may indicate that a function was declared but never called."); 207405fe67fSCaroline Tice 208405fe67fSCaroline Tice CommandArgumentEntry arg; 209405fe67fSCaroline Tice CommandArgumentData bp_id_arg; 210405fe67fSCaroline Tice 211405fe67fSCaroline Tice // Define the first (and only) variant of this arg. 212405fe67fSCaroline Tice bp_id_arg.arg_type = eArgTypeBreakpointID; 2131bb0750bSJim Ingham bp_id_arg.arg_repetition = eArgRepeatOptional; 214405fe67fSCaroline Tice 215b9c1b51eSKate Stone // There is only one variant this argument could be; put it into the 216b9c1b51eSKate Stone // argument entry. 217405fe67fSCaroline Tice arg.push_back(bp_id_arg); 218405fe67fSCaroline Tice 219405fe67fSCaroline Tice // Push the data for the first argument into the m_arguments vector. 220405fe67fSCaroline Tice m_arguments.push_back(arg); 22130fdc8d8SChris Lattner } 22230fdc8d8SChris Lattner 223c8ecc2a9SEugene Zelenko ~CommandObjectBreakpointCommandAdd() override = default; 2245a988416SJim Ingham 225b9c1b51eSKate Stone Options *GetOptions() override { return &m_options; } 2265a988416SJim Ingham 227b9c1b51eSKate Stone void IOHandlerActivated(IOHandler &io_handler) override { 22844d93782SGreg Clayton StreamFileSP output_sp(io_handler.GetOutputStreamFile()); 229b9c1b51eSKate Stone if (output_sp) { 23044d93782SGreg Clayton output_sp->PutCString(g_reader_instructions); 23144d93782SGreg Clayton output_sp->Flush(); 23244d93782SGreg Clayton } 23344d93782SGreg Clayton } 23444d93782SGreg Clayton 235b9c1b51eSKate Stone void IOHandlerInputComplete(IOHandler &io_handler, 236b9c1b51eSKate Stone std::string &line) override { 23744d93782SGreg Clayton io_handler.SetIsDone(true); 23844d93782SGreg Clayton 239b9c1b51eSKate Stone std::vector<BreakpointOptions *> *bp_options_vec = 240b9c1b51eSKate Stone (std::vector<BreakpointOptions *> *)io_handler.GetUserData(); 241b9c1b51eSKate Stone for (BreakpointOptions *bp_options : *bp_options_vec) { 242b5796cb4SJim Ingham if (!bp_options) 243b5796cb4SJim Ingham continue; 244b5796cb4SJim Ingham 2454e4fbe82SZachary Turner auto cmd_data = llvm::make_unique<BreakpointOptions::CommandData>(); 246e14dc268SJim Ingham cmd_data->user_source.SplitIntoLines(line.c_str(), line.size()); 24792d1960eSJim Ingham bp_options->SetCommandDataCallback(cmd_data); 24844d93782SGreg Clayton } 24944d93782SGreg Clayton } 25044d93782SGreg Clayton 251b9c1b51eSKate Stone void CollectDataForBreakpointCommandCallback( 252b9c1b51eSKate Stone std::vector<BreakpointOptions *> &bp_options_vec, 253b9c1b51eSKate Stone CommandReturnObject &result) { 254b9c1b51eSKate Stone m_interpreter.GetLLDBCommandsFromIOHandler( 255b9c1b51eSKate Stone "> ", // Prompt 25644d93782SGreg Clayton *this, // IOHandlerDelegate 25744d93782SGreg Clayton true, // Run IOHandler in async mode 258b9c1b51eSKate Stone &bp_options_vec); // Baton for the "io_handler" that will be passed back 259b9c1b51eSKate Stone // into our IOHandlerDelegate functions 2605a988416SJim Ingham } 2615a988416SJim Ingham 2625a988416SJim Ingham /// Set a one-liner as the callback for the breakpoint. 2635a988416SJim Ingham void 264b5796cb4SJim Ingham SetBreakpointCommandCallback(std::vector<BreakpointOptions *> &bp_options_vec, 265b9c1b51eSKate Stone const char *oneliner) { 266b9c1b51eSKate Stone for (auto bp_options : bp_options_vec) { 2674e4fbe82SZachary Turner auto cmd_data = llvm::make_unique<BreakpointOptions::CommandData>(); 2685a988416SJim Ingham 269e14dc268SJim Ingham cmd_data->user_source.AppendString(oneliner); 270e14dc268SJim Ingham cmd_data->stop_on_error = m_options.m_stop_on_error; 2715a988416SJim Ingham 27292d1960eSJim Ingham bp_options->SetCommandDataCallback(cmd_data); 273b5796cb4SJim Ingham } 2745a988416SJim Ingham } 2755a988416SJim Ingham 276b9c1b51eSKate Stone class CommandOptions : public Options { 2775a988416SJim Ingham public: 278b9c1b51eSKate Stone CommandOptions() 279b9c1b51eSKate Stone : Options(), m_use_commands(false), m_use_script_language(false), 280b9c1b51eSKate Stone m_script_language(eScriptLanguageNone), m_use_one_liner(false), 281b9c1b51eSKate Stone m_one_liner(), m_function_name() {} 28230fdc8d8SChris Lattner 283c8ecc2a9SEugene Zelenko ~CommandOptions() override = default; 2845a988416SJim Ingham 28597206d57SZachary Turner Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, 286b9c1b51eSKate Stone ExecutionContext *execution_context) override { 28797206d57SZachary Turner Status error; 2883bcdfc0eSGreg Clayton const int short_option = m_getopt_table[option_idx].val; 2895a988416SJim Ingham 290b9c1b51eSKate Stone switch (short_option) { 2915a988416SJim Ingham case 'o': 2925a988416SJim Ingham m_use_one_liner = true; 2935a988416SJim Ingham m_one_liner = option_arg; 2945a988416SJim Ingham break; 2955a988416SJim Ingham 2965a988416SJim Ingham case 's': 297*47cbf4a0SPavel Labath m_script_language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum( 298fe11483bSZachary Turner option_arg, g_breakpoint_add_options[option_idx].enum_values, 299b9c1b51eSKate Stone eScriptLanguageNone, error); 3005a988416SJim Ingham 301b9c1b51eSKate Stone if (m_script_language == eScriptLanguagePython || 302b9c1b51eSKate Stone m_script_language == eScriptLanguageDefault) { 3035a988416SJim Ingham m_use_script_language = true; 304b9c1b51eSKate Stone } else { 3055a988416SJim Ingham m_use_script_language = false; 3065a988416SJim Ingham } 3075a988416SJim Ingham break; 3085a988416SJim Ingham 309b9c1b51eSKate Stone case 'e': { 3105a988416SJim Ingham bool success = false; 311*47cbf4a0SPavel Labath m_stop_on_error = 312*47cbf4a0SPavel Labath OptionArgParser::ToBoolean(option_arg, false, &success); 3135a988416SJim Ingham if (!success) 314b9c1b51eSKate Stone error.SetErrorStringWithFormat( 315fe11483bSZachary Turner "invalid value for stop-on-error: \"%s\"", 316fe11483bSZachary Turner option_arg.str().c_str()); 317b9c1b51eSKate Stone } break; 3185a988416SJim Ingham 3195a988416SJim Ingham case 'F': 3205a988416SJim Ingham m_use_one_liner = false; 3215a988416SJim Ingham m_use_script_language = true; 3225a988416SJim Ingham m_function_name.assign(option_arg); 3235a988416SJim Ingham break; 3245a988416SJim Ingham 32533df7cd3SJim Ingham case 'D': 32633df7cd3SJim Ingham m_use_dummy = true; 32733df7cd3SJim Ingham break; 32833df7cd3SJim Ingham 3295a988416SJim Ingham default: 3305a988416SJim Ingham break; 3315a988416SJim Ingham } 3325a988416SJim Ingham return error; 3335a988416SJim Ingham } 334c8ecc2a9SEugene Zelenko 335b9c1b51eSKate Stone void OptionParsingStarting(ExecutionContext *execution_context) override { 3365a988416SJim Ingham m_use_commands = true; 3375a988416SJim Ingham m_use_script_language = false; 3385a988416SJim Ingham m_script_language = eScriptLanguageNone; 3395a988416SJim Ingham 3405a988416SJim Ingham m_use_one_liner = false; 3415a988416SJim Ingham m_stop_on_error = true; 3425a988416SJim Ingham m_one_liner.clear(); 3435a988416SJim Ingham m_function_name.clear(); 34433df7cd3SJim Ingham m_use_dummy = false; 3455a988416SJim Ingham } 3465a988416SJim Ingham 3471f0f5b5bSZachary Turner llvm::ArrayRef<OptionDefinition> GetDefinitions() override { 34870602439SZachary Turner return llvm::makeArrayRef(g_breakpoint_add_options); 3491f0f5b5bSZachary Turner } 3505a988416SJim Ingham 3515a988416SJim Ingham // Instance variables to hold the values for command options. 3525a988416SJim Ingham 3535a988416SJim Ingham bool m_use_commands; 3545a988416SJim Ingham bool m_use_script_language; 3555a988416SJim Ingham lldb::ScriptLanguage m_script_language; 3565a988416SJim Ingham 3575a988416SJim Ingham // Instance variables to hold the values for one_liner options. 3585a988416SJim Ingham bool m_use_one_liner; 3595a988416SJim Ingham std::string m_one_liner; 3605a988416SJim Ingham bool m_stop_on_error; 3615a988416SJim Ingham std::string m_function_name; 36233df7cd3SJim Ingham bool m_use_dummy; 3635a988416SJim Ingham }; 3645a988416SJim Ingham 3655a988416SJim Ingham protected: 366b9c1b51eSKate Stone bool DoExecute(Args &command, CommandReturnObject &result) override { 36733df7cd3SJim Ingham Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); 36830fdc8d8SChris Lattner 369b9c1b51eSKate Stone if (target == nullptr) { 370b9c1b51eSKate Stone result.AppendError("There is not a current executable; there are no " 371b9c1b51eSKate Stone "breakpoints to which to add commands"); 37230fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 37330fdc8d8SChris Lattner return false; 37430fdc8d8SChris Lattner } 37530fdc8d8SChris Lattner 37630fdc8d8SChris Lattner const BreakpointList &breakpoints = target->GetBreakpointList(); 37730fdc8d8SChris Lattner size_t num_breakpoints = breakpoints.GetSize(); 37830fdc8d8SChris Lattner 379b9c1b51eSKate Stone if (num_breakpoints == 0) { 38030fdc8d8SChris Lattner result.AppendError("No breakpoints exist to have commands added"); 38130fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 38230fdc8d8SChris Lattner return false; 38330fdc8d8SChris Lattner } 38430fdc8d8SChris Lattner 385b9c1b51eSKate Stone if (!m_options.m_use_script_language && 386b9c1b51eSKate Stone !m_options.m_function_name.empty()) { 387b9c1b51eSKate Stone result.AppendError("need to enable scripting to have a function run as a " 388b9c1b51eSKate Stone "breakpoint command"); 3898d4a8010SEnrico Granata result.SetStatus(eReturnStatusFailed); 3908d4a8010SEnrico Granata return false; 3918d4a8010SEnrico Granata } 3928d4a8010SEnrico Granata 39330fdc8d8SChris Lattner BreakpointIDList valid_bp_ids; 394b9c1b51eSKate Stone CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs( 395b842f2ecSJim Ingham command, target, result, &valid_bp_ids, 396b842f2ecSJim Ingham BreakpointName::Permissions::PermissionKinds::listPerm); 39730fdc8d8SChris Lattner 398b5796cb4SJim Ingham m_bp_options_vec.clear(); 399b5796cb4SJim Ingham 400b9c1b51eSKate Stone if (result.Succeeded()) { 401c982c768SGreg Clayton const size_t count = valid_bp_ids.GetSize(); 402d9916eaeSJim Ingham 403b9c1b51eSKate Stone for (size_t i = 0; i < count; ++i) { 40430fdc8d8SChris Lattner BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i); 405b9c1b51eSKate Stone if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) { 406b9c1b51eSKate Stone Breakpoint *bp = 407b9c1b51eSKate Stone target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); 408c8ecc2a9SEugene Zelenko BreakpointOptions *bp_options = nullptr; 409b9c1b51eSKate Stone if (cur_bp_id.GetLocationID() == LLDB_INVALID_BREAK_ID) { 41039d7d4f0SJohnny Chen // This breakpoint does not have an associated location. 41139d7d4f0SJohnny Chen bp_options = bp->GetOptions(); 412b9c1b51eSKate Stone } else { 413b9c1b51eSKate Stone BreakpointLocationSP bp_loc_sp( 414b9c1b51eSKate Stone bp->FindLocationByID(cur_bp_id.GetLocationID())); 41539d7d4f0SJohnny Chen // This breakpoint does have an associated location. 41639d7d4f0SJohnny Chen // Get its breakpoint options. 41730fdc8d8SChris Lattner if (bp_loc_sp) 41839d7d4f0SJohnny Chen bp_options = bp_loc_sp->GetLocationOptions(); 41939d7d4f0SJohnny Chen } 420b5796cb4SJim Ingham if (bp_options) 421b5796cb4SJim Ingham m_bp_options_vec.push_back(bp_options); 422b5796cb4SJim Ingham } 423b5796cb4SJim Ingham } 42439d7d4f0SJohnny Chen 42539d7d4f0SJohnny Chen // If we are using script language, get the script interpreter 42639d7d4f0SJohnny Chen // in order to set or collect command callback. Otherwise, call 42739d7d4f0SJohnny Chen // the methods associated with this object. 428b9c1b51eSKate Stone if (m_options.m_use_script_language) { 429b5796cb4SJim Ingham ScriptInterpreter *script_interp = m_interpreter.GetScriptInterpreter(); 43039d7d4f0SJohnny Chen // Special handling for one-liner specified inline. 431b9c1b51eSKate Stone if (m_options.m_use_one_liner) { 432b9c1b51eSKate Stone script_interp->SetBreakpointCommandCallback( 433b9c1b51eSKate Stone m_bp_options_vec, m_options.m_one_liner.c_str()); 434b9c1b51eSKate Stone } else if (!m_options.m_function_name.empty()) { 435b9c1b51eSKate Stone script_interp->SetBreakpointCommandCallbackFunction( 436b9c1b51eSKate Stone m_bp_options_vec, m_options.m_function_name.c_str()); 437b9c1b51eSKate Stone } else { 438b9c1b51eSKate Stone script_interp->CollectDataForBreakpointCommandCallback( 439b9c1b51eSKate Stone m_bp_options_vec, result); 4408d4a8010SEnrico Granata } 441b9c1b51eSKate Stone } else { 44239d7d4f0SJohnny Chen // Special handling for one-liner specified inline. 44339d7d4f0SJohnny Chen if (m_options.m_use_one_liner) 444b5796cb4SJim Ingham SetBreakpointCommandCallback(m_bp_options_vec, 44539d7d4f0SJohnny Chen m_options.m_one_liner.c_str()); 44639d7d4f0SJohnny Chen else 447b9c1b51eSKate Stone CollectDataForBreakpointCommandCallback(m_bp_options_vec, result); 44830fdc8d8SChris Lattner } 44930fdc8d8SChris Lattner } 45030fdc8d8SChris Lattner 45130fdc8d8SChris Lattner return result.Succeeded(); 45230fdc8d8SChris Lattner } 45330fdc8d8SChris Lattner 4545a988416SJim Ingham private: 4555a988416SJim Ingham CommandOptions m_options; 456b9c1b51eSKate Stone std::vector<BreakpointOptions *> m_bp_options_vec; // This stores the 457b9c1b51eSKate Stone // breakpoint options that 458b9c1b51eSKate Stone // we are currently 459b5796cb4SJim Ingham // collecting commands for. In the CollectData... calls we need 460b5796cb4SJim Ingham // to hand this off to the IOHandler, which may run asynchronously. 461b5796cb4SJim Ingham // So we have to have some way to keep it alive, and not leak it. 462b5796cb4SJim Ingham // Making it an ivar of the command object, which never goes away 463b5796cb4SJim Ingham // achieves this. Note that if we were able to run 464b5796cb4SJim Ingham // the same command concurrently in one interpreter we'd have to 465b5796cb4SJim Ingham // make this "per invocation". But there are many more reasons 466b5796cb4SJim Ingham // why it is not in general safe to do that in lldb at present, 467b5796cb4SJim Ingham // so it isn't worthwhile to come up with a more complex mechanism 468b5796cb4SJim Ingham // to address this particular weakness right now. 4695a988416SJim Ingham static const char *g_reader_instructions; 4705a988416SJim Ingham }; 4715a988416SJim Ingham 472b9c1b51eSKate Stone const char *CommandObjectBreakpointCommandAdd::g_reader_instructions = 473b9c1b51eSKate Stone "Enter your debugger command(s). Type 'DONE' to end.\n"; 4745a988416SJim Ingham 47530fdc8d8SChris Lattner //------------------------------------------------------------------------- 47693e0f19fSCaroline Tice // CommandObjectBreakpointCommandDelete 47730fdc8d8SChris Lattner //------------------------------------------------------------------------- 47830fdc8d8SChris Lattner 4791f0f5b5bSZachary Turner static OptionDefinition g_breakpoint_delete_options[] = { 4801f0f5b5bSZachary Turner // clang-format off 4811f0f5b5bSZachary Turner { 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." }, 4821f0f5b5bSZachary Turner // clang-format on 4831f0f5b5bSZachary Turner }; 4841f0f5b5bSZachary Turner 485b9c1b51eSKate Stone class CommandObjectBreakpointCommandDelete : public CommandObjectParsed { 4865a988416SJim Ingham public: 487b9c1b51eSKate Stone CommandObjectBreakpointCommandDelete(CommandInterpreter &interpreter) 488b9c1b51eSKate Stone : CommandObjectParsed(interpreter, "delete", 48993e0f19fSCaroline Tice "Delete the set of commands from a breakpoint.", 490c8ecc2a9SEugene Zelenko nullptr), 491b9c1b51eSKate Stone m_options() { 492405fe67fSCaroline Tice CommandArgumentEntry arg; 493405fe67fSCaroline Tice CommandArgumentData bp_id_arg; 494405fe67fSCaroline Tice 495405fe67fSCaroline Tice // Define the first (and only) variant of this arg. 496405fe67fSCaroline Tice bp_id_arg.arg_type = eArgTypeBreakpointID; 497405fe67fSCaroline Tice bp_id_arg.arg_repetition = eArgRepeatPlain; 498405fe67fSCaroline Tice 499b9c1b51eSKate Stone // There is only one variant this argument could be; put it into the 500b9c1b51eSKate Stone // argument entry. 501405fe67fSCaroline Tice arg.push_back(bp_id_arg); 502405fe67fSCaroline Tice 503405fe67fSCaroline Tice // Push the data for the first argument into the m_arguments vector. 504405fe67fSCaroline Tice m_arguments.push_back(arg); 50530fdc8d8SChris Lattner } 50630fdc8d8SChris Lattner 507c8ecc2a9SEugene Zelenko ~CommandObjectBreakpointCommandDelete() override = default; 5085a988416SJim Ingham 509b9c1b51eSKate Stone Options *GetOptions() override { return &m_options; } 51033df7cd3SJim Ingham 511b9c1b51eSKate Stone class CommandOptions : public Options { 51233df7cd3SJim Ingham public: 513b9c1b51eSKate Stone CommandOptions() : Options(), m_use_dummy(false) {} 51433df7cd3SJim Ingham 515c8ecc2a9SEugene Zelenko ~CommandOptions() override = default; 51633df7cd3SJim Ingham 51797206d57SZachary Turner Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, 518b9c1b51eSKate Stone ExecutionContext *execution_context) override { 51997206d57SZachary Turner Status error; 52033df7cd3SJim Ingham const int short_option = m_getopt_table[option_idx].val; 52133df7cd3SJim Ingham 522b9c1b51eSKate Stone switch (short_option) { 52333df7cd3SJim Ingham case 'D': 52433df7cd3SJim Ingham m_use_dummy = true; 52533df7cd3SJim Ingham break; 52633df7cd3SJim Ingham 52733df7cd3SJim Ingham default: 528b9c1b51eSKate Stone error.SetErrorStringWithFormat("unrecognized option '%c'", 529b9c1b51eSKate Stone short_option); 53033df7cd3SJim Ingham break; 53133df7cd3SJim Ingham } 53233df7cd3SJim Ingham 53333df7cd3SJim Ingham return error; 53433df7cd3SJim Ingham } 53533df7cd3SJim Ingham 536b9c1b51eSKate Stone void OptionParsingStarting(ExecutionContext *execution_context) override { 53733df7cd3SJim Ingham m_use_dummy = false; 53833df7cd3SJim Ingham } 53933df7cd3SJim Ingham 5401f0f5b5bSZachary Turner llvm::ArrayRef<OptionDefinition> GetDefinitions() override { 54170602439SZachary Turner return llvm::makeArrayRef(g_breakpoint_delete_options); 5421f0f5b5bSZachary Turner } 54333df7cd3SJim Ingham 54433df7cd3SJim Ingham // Instance variables to hold the values for command options. 54533df7cd3SJim Ingham bool m_use_dummy; 54633df7cd3SJim Ingham }; 54733df7cd3SJim Ingham 5485a988416SJim Ingham protected: 549b9c1b51eSKate Stone bool DoExecute(Args &command, CommandReturnObject &result) override { 55033df7cd3SJim Ingham Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); 55130fdc8d8SChris Lattner 552b9c1b51eSKate Stone if (target == nullptr) { 553b9c1b51eSKate Stone result.AppendError("There is not a current executable; there are no " 554b9c1b51eSKate Stone "breakpoints from which to delete commands"); 55530fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 55630fdc8d8SChris Lattner return false; 55730fdc8d8SChris Lattner } 55830fdc8d8SChris Lattner 55930fdc8d8SChris Lattner const BreakpointList &breakpoints = target->GetBreakpointList(); 56030fdc8d8SChris Lattner size_t num_breakpoints = breakpoints.GetSize(); 56130fdc8d8SChris Lattner 562b9c1b51eSKate Stone if (num_breakpoints == 0) { 56393e0f19fSCaroline Tice result.AppendError("No breakpoints exist to have commands deleted"); 56430fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 56530fdc8d8SChris Lattner return false; 56630fdc8d8SChris Lattner } 56730fdc8d8SChris Lattner 56811eb9c64SZachary Turner if (command.empty()) { 569b9c1b51eSKate Stone result.AppendError( 570b9c1b51eSKate Stone "No breakpoint specified from which to delete the commands"); 57130fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 57230fdc8d8SChris Lattner return false; 57330fdc8d8SChris Lattner } 57430fdc8d8SChris Lattner 57530fdc8d8SChris Lattner BreakpointIDList valid_bp_ids; 576b9c1b51eSKate Stone CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs( 577b842f2ecSJim Ingham command, target, result, &valid_bp_ids, 578b842f2ecSJim Ingham BreakpointName::Permissions::PermissionKinds::listPerm); 57930fdc8d8SChris Lattner 580b9c1b51eSKate Stone if (result.Succeeded()) { 581c982c768SGreg Clayton const size_t count = valid_bp_ids.GetSize(); 582b9c1b51eSKate Stone for (size_t i = 0; i < count; ++i) { 58330fdc8d8SChris Lattner BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i); 584b9c1b51eSKate Stone if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) { 585b9c1b51eSKate Stone Breakpoint *bp = 586b9c1b51eSKate Stone target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); 587b9c1b51eSKate Stone if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) { 588b9c1b51eSKate Stone BreakpointLocationSP bp_loc_sp( 589b9c1b51eSKate Stone bp->FindLocationByID(cur_bp_id.GetLocationID())); 59030fdc8d8SChris Lattner if (bp_loc_sp) 59130fdc8d8SChris Lattner bp_loc_sp->ClearCallback(); 592b9c1b51eSKate Stone else { 59330fdc8d8SChris Lattner result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n", 59430fdc8d8SChris Lattner cur_bp_id.GetBreakpointID(), 59530fdc8d8SChris Lattner cur_bp_id.GetLocationID()); 59630fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 59730fdc8d8SChris Lattner return false; 59830fdc8d8SChris Lattner } 599b9c1b51eSKate Stone } else { 60030fdc8d8SChris Lattner bp->ClearCallback(); 60130fdc8d8SChris Lattner } 60230fdc8d8SChris Lattner } 60330fdc8d8SChris Lattner } 60430fdc8d8SChris Lattner } 60530fdc8d8SChris Lattner return result.Succeeded(); 60630fdc8d8SChris Lattner } 607c8ecc2a9SEugene Zelenko 60833df7cd3SJim Ingham private: 60933df7cd3SJim Ingham CommandOptions m_options; 6105a988416SJim Ingham }; 61130fdc8d8SChris Lattner 61230fdc8d8SChris Lattner //------------------------------------------------------------------------- 61330fdc8d8SChris Lattner // CommandObjectBreakpointCommandList 61430fdc8d8SChris Lattner //------------------------------------------------------------------------- 61530fdc8d8SChris Lattner 616b9c1b51eSKate Stone class CommandObjectBreakpointCommandList : public CommandObjectParsed { 6175a988416SJim Ingham public: 618b9c1b51eSKate Stone CommandObjectBreakpointCommandList(CommandInterpreter &interpreter) 619b9c1b51eSKate Stone : CommandObjectParsed(interpreter, "list", "List the script or set of " 620b9c1b51eSKate Stone "commands to be executed when " 621b9c1b51eSKate Stone "the breakpoint is hit.", 622b9c1b51eSKate Stone nullptr) { 623405fe67fSCaroline Tice CommandArgumentEntry arg; 624405fe67fSCaroline Tice CommandArgumentData bp_id_arg; 625405fe67fSCaroline Tice 626405fe67fSCaroline Tice // Define the first (and only) variant of this arg. 627405fe67fSCaroline Tice bp_id_arg.arg_type = eArgTypeBreakpointID; 628405fe67fSCaroline Tice bp_id_arg.arg_repetition = eArgRepeatPlain; 629405fe67fSCaroline Tice 630b9c1b51eSKate Stone // There is only one variant this argument could be; put it into the 631b9c1b51eSKate Stone // argument entry. 632405fe67fSCaroline Tice arg.push_back(bp_id_arg); 633405fe67fSCaroline Tice 634405fe67fSCaroline Tice // Push the data for the first argument into the m_arguments vector. 635405fe67fSCaroline Tice m_arguments.push_back(arg); 63630fdc8d8SChris Lattner } 63730fdc8d8SChris Lattner 638c8ecc2a9SEugene Zelenko ~CommandObjectBreakpointCommandList() override = default; 63930fdc8d8SChris Lattner 6405a988416SJim Ingham protected: 641b9c1b51eSKate Stone bool DoExecute(Args &command, CommandReturnObject &result) override { 642a7015092SGreg Clayton Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); 64330fdc8d8SChris Lattner 644b9c1b51eSKate Stone if (target == nullptr) { 645b9c1b51eSKate Stone result.AppendError("There is not a current executable; there are no " 646b9c1b51eSKate Stone "breakpoints for which to list commands"); 64730fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 64830fdc8d8SChris Lattner return false; 64930fdc8d8SChris Lattner } 65030fdc8d8SChris Lattner 65130fdc8d8SChris Lattner const BreakpointList &breakpoints = target->GetBreakpointList(); 65230fdc8d8SChris Lattner size_t num_breakpoints = breakpoints.GetSize(); 65330fdc8d8SChris Lattner 654b9c1b51eSKate Stone if (num_breakpoints == 0) { 65530fdc8d8SChris Lattner result.AppendError("No breakpoints exist for which to list commands"); 65630fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 65730fdc8d8SChris Lattner return false; 65830fdc8d8SChris Lattner } 65930fdc8d8SChris Lattner 66011eb9c64SZachary Turner if (command.empty()) { 661b9c1b51eSKate Stone result.AppendError( 662b9c1b51eSKate Stone "No breakpoint specified for which to list the commands"); 66330fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 66430fdc8d8SChris Lattner return false; 66530fdc8d8SChris Lattner } 66630fdc8d8SChris Lattner 66730fdc8d8SChris Lattner BreakpointIDList valid_bp_ids; 668b9c1b51eSKate Stone CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs( 669b842f2ecSJim Ingham command, target, result, &valid_bp_ids, 670b842f2ecSJim Ingham BreakpointName::Permissions::PermissionKinds::listPerm); 67130fdc8d8SChris Lattner 672b9c1b51eSKate Stone if (result.Succeeded()) { 673c982c768SGreg Clayton const size_t count = valid_bp_ids.GetSize(); 674b9c1b51eSKate Stone for (size_t i = 0; i < count; ++i) { 67530fdc8d8SChris Lattner BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i); 676b9c1b51eSKate Stone if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) { 677b9c1b51eSKate Stone Breakpoint *bp = 678b9c1b51eSKate Stone target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); 67930fdc8d8SChris Lattner 680b9c1b51eSKate Stone if (bp) { 681af26b22cSJim Ingham BreakpointLocationSP bp_loc_sp; 682b9c1b51eSKate Stone if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) { 683af26b22cSJim Ingham bp_loc_sp = bp->FindLocationByID(cur_bp_id.GetLocationID()); 684af26b22cSJim Ingham if (!bp_loc_sp) 685af26b22cSJim Ingham { 68630fdc8d8SChris Lattner result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n", 68730fdc8d8SChris Lattner cur_bp_id.GetBreakpointID(), 68830fdc8d8SChris Lattner cur_bp_id.GetLocationID()); 68930fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 69030fdc8d8SChris Lattner return false; 69130fdc8d8SChris Lattner } 69230fdc8d8SChris Lattner } 69330fdc8d8SChris Lattner 69430fdc8d8SChris Lattner StreamString id_str; 695e16c50a1SJim Ingham BreakpointID::GetCanonicalReference(&id_str, 696e16c50a1SJim Ingham cur_bp_id.GetBreakpointID(), 697e16c50a1SJim Ingham cur_bp_id.GetLocationID()); 698af26b22cSJim Ingham const Baton *baton = nullptr; 699af26b22cSJim Ingham if (bp_loc_sp) 700af26b22cSJim Ingham baton = bp_loc_sp 701af26b22cSJim Ingham ->GetOptionsSpecifyingKind(BreakpointOptions::eCallback) 702af26b22cSJim Ingham ->GetBaton(); 703af26b22cSJim Ingham else 704af26b22cSJim Ingham baton = bp->GetOptions()->GetBaton(); 705af26b22cSJim Ingham 706b9c1b51eSKate Stone if (baton) { 707b9c1b51eSKate Stone result.GetOutputStream().Printf("Breakpoint %s:\n", 708b9c1b51eSKate Stone id_str.GetData()); 70930fdc8d8SChris Lattner result.GetOutputStream().IndentMore(); 710b9c1b51eSKate Stone baton->GetDescription(&result.GetOutputStream(), 711b9c1b51eSKate Stone eDescriptionLevelFull); 71230fdc8d8SChris Lattner result.GetOutputStream().IndentLess(); 713b9c1b51eSKate Stone } else { 714b9c1b51eSKate Stone result.AppendMessageWithFormat( 715b9c1b51eSKate Stone "Breakpoint %s does not have an associated command.\n", 716e16c50a1SJim Ingham id_str.GetData()); 71730fdc8d8SChris Lattner } 71830fdc8d8SChris Lattner } 71930fdc8d8SChris Lattner result.SetStatus(eReturnStatusSuccessFinishResult); 720b9c1b51eSKate Stone } else { 721b9c1b51eSKate Stone result.AppendErrorWithFormat("Invalid breakpoint ID: %u.\n", 722b9c1b51eSKate Stone cur_bp_id.GetBreakpointID()); 72330fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 72430fdc8d8SChris Lattner } 72530fdc8d8SChris Lattner } 72630fdc8d8SChris Lattner } 72730fdc8d8SChris Lattner 72830fdc8d8SChris Lattner return result.Succeeded(); 72930fdc8d8SChris Lattner } 7305a988416SJim Ingham }; 73130fdc8d8SChris Lattner 73230fdc8d8SChris Lattner //------------------------------------------------------------------------- 73330fdc8d8SChris Lattner // CommandObjectBreakpointCommand 73430fdc8d8SChris Lattner //------------------------------------------------------------------------- 73530fdc8d8SChris Lattner 736b9c1b51eSKate Stone CommandObjectBreakpointCommand::CommandObjectBreakpointCommand( 737b9c1b51eSKate Stone CommandInterpreter &interpreter) 7387428a18cSKate Stone : CommandObjectMultiword( 739b9c1b51eSKate Stone interpreter, "command", "Commands for adding, removing and listing " 740b9c1b51eSKate Stone "LLDB commands executed when a breakpoint is " 741b9c1b51eSKate Stone "hit.", 742b9c1b51eSKate Stone "command <sub-command> [<sub-command-options>] <breakpoint-id>") { 743b9c1b51eSKate Stone CommandObjectSP add_command_object( 744b9c1b51eSKate Stone new CommandObjectBreakpointCommandAdd(interpreter)); 745b9c1b51eSKate Stone CommandObjectSP delete_command_object( 746b9c1b51eSKate Stone new CommandObjectBreakpointCommandDelete(interpreter)); 747b9c1b51eSKate Stone CommandObjectSP list_command_object( 748b9c1b51eSKate Stone new CommandObjectBreakpointCommandList(interpreter)); 74930fdc8d8SChris Lattner 75030fdc8d8SChris Lattner add_command_object->SetCommandName("breakpoint command add"); 75193e0f19fSCaroline Tice delete_command_object->SetCommandName("breakpoint command delete"); 75230fdc8d8SChris Lattner list_command_object->SetCommandName("breakpoint command list"); 75330fdc8d8SChris Lattner 75423f59509SGreg Clayton LoadSubCommand("add", add_command_object); 75523f59509SGreg Clayton LoadSubCommand("delete", delete_command_object); 75623f59509SGreg Clayton LoadSubCommand("list", list_command_object); 75730fdc8d8SChris Lattner } 75830fdc8d8SChris Lattner 759c8ecc2a9SEugene Zelenko CommandObjectBreakpointCommand::~CommandObjectBreakpointCommand() = default; 760