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" 213eb2b44dSZachary Turner #include "lldb/Host/OptionParser.h" 2230fdc8d8SChris Lattner #include "lldb/Interpreter/CommandInterpreter.h" 2330fdc8d8SChris Lattner #include "lldb/Interpreter/CommandReturnObject.h" 2447cbf4a0SPavel Labath #include "lldb/Interpreter/OptionArgParser.h" 2530fdc8d8SChris Lattner #include "lldb/Target/Target.h" 2630fdc8d8SChris Lattner #include "lldb/Target/Thread.h" 27d821c997SPavel Labath #include "lldb/Utility/State.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 43*8fe53c49STatyana Krasnukha static constexpr OptionEnumValueElement g_script_option_enumeration[] = { 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", 48*8fe53c49STatyana Krasnukha "Commands are in the default scripting language."} }; 491f0f5b5bSZachary Turner 50*8fe53c49STatyana Krasnukha static constexpr OptionEnumValues ScriptOptionEnum() { 51*8fe53c49STatyana Krasnukha return OptionEnumValues(g_script_option_enumeration); 52*8fe53c49STatyana Krasnukha } 53*8fe53c49STatyana Krasnukha 54*8fe53c49STatyana Krasnukha static constexpr OptionDefinition g_breakpoint_add_options[] = { 551f0f5b5bSZachary Turner // clang-format off 56*8fe53c49STatyana Krasnukha { LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOneLiner, "Specify a one-line breakpoint command inline. Be sure to surround it with quotes." }, 57*8fe53c49STatyana Krasnukha { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Specify whether breakpoint command execution should terminate on error." }, 58*8fe53c49STatyana Krasnukha { LLDB_OPT_SET_ALL, false, "script-type", 's', OptionParser::eRequiredArgument, nullptr, ScriptOptionEnum(), 0, eArgTypeNone, "Specify the language for the commands - if none is specified, the lldb command interpreter will be used." }, 59*8fe53c49STatyana Krasnukha { LLDB_OPT_SET_2, false, "python-function", 'F', OptionParser::eRequiredArgument, 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." }, 60*8fe53c49STatyana Krasnukha { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Sets Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets." }, 611f0f5b5bSZachary Turner // clang-format on 621f0f5b5bSZachary Turner }; 631f0f5b5bSZachary Turner 64b9c1b51eSKate Stone class CommandObjectBreakpointCommandAdd : public CommandObjectParsed, 65b9c1b51eSKate Stone public IOHandlerDelegateMultiline { 665a988416SJim Ingham public: 677428a18cSKate Stone CommandObjectBreakpointCommandAdd(CommandInterpreter &interpreter) 687428a18cSKate Stone : CommandObjectParsed(interpreter, "add", 69b9c1b51eSKate Stone "Add LLDB commands to a breakpoint, to be executed " 70b9c1b51eSKate Stone "whenever the breakpoint is hit." 71b9c1b51eSKate Stone " If no breakpoint is specified, adds the " 72b9c1b51eSKate Stone "commands to the last created breakpoint.", 73c8ecc2a9SEugene Zelenko nullptr), 74b9c1b51eSKate Stone IOHandlerDelegateMultiline("DONE", 75b9c1b51eSKate Stone IOHandlerDelegate::Completion::LLDBCommand), 76b9c1b51eSKate Stone m_options() { 7730fdc8d8SChris Lattner SetHelpLong( 78ea671fbdSKate Stone R"( 79ea671fbdSKate Stone General information about entering breakpoint commands 80ea671fbdSKate Stone ------------------------------------------------------ 81ea671fbdSKate Stone 82b9c1b51eSKate Stone )" 83b9c1b51eSKate Stone "This command will prompt for commands to be executed when the specified \ 84ea671fbdSKate Stone breakpoint is hit. Each command is typed on its own line following the '> ' \ 85b9c1b51eSKate Stone prompt until 'DONE' is entered." 86b9c1b51eSKate Stone R"( 87ea671fbdSKate Stone 88b9c1b51eSKate Stone )" 89b9c1b51eSKate Stone "Syntactic errors may not be detected when initially entered, and many \ 90ea671fbdSKate Stone malformed commands can silently fail when executed. If your breakpoint commands \ 91b9c1b51eSKate Stone do not appear to be executing, double-check the command syntax." 92b9c1b51eSKate Stone R"( 93ea671fbdSKate Stone 94b9c1b51eSKate Stone )" 95b9c1b51eSKate Stone "Note: You may enter any debugger command exactly as you would at the debugger \ 96ea671fbdSKate Stone prompt. There is no limit to the number of commands supplied, but do NOT enter \ 97b9c1b51eSKate Stone more than one command per line." 98b9c1b51eSKate Stone R"( 99ea671fbdSKate Stone 100ea671fbdSKate Stone Special information about PYTHON breakpoint commands 101ea671fbdSKate Stone ---------------------------------------------------- 102ea671fbdSKate Stone 103b9c1b51eSKate Stone )" 104b9c1b51eSKate Stone "You may enter either one or more lines of Python, including function \ 105ea671fbdSKate Stone definitions or calls to functions that will have been imported by the time \ 106ea671fbdSKate Stone the code executes. Single line breakpoint commands will be interpreted 'as is' \ 107ea671fbdSKate Stone when the breakpoint is hit. Multiple lines of Python will be wrapped in a \ 108b9c1b51eSKate Stone generated function, and a call to the function will be attached to the breakpoint." 109b9c1b51eSKate Stone R"( 110ea671fbdSKate Stone 111ea671fbdSKate Stone This auto-generated function is passed in three arguments: 112ea671fbdSKate Stone 113ea671fbdSKate Stone frame: an lldb.SBFrame object for the frame which hit breakpoint. 114ea671fbdSKate Stone 115ea671fbdSKate Stone bp_loc: an lldb.SBBreakpointLocation object that represents the breakpoint location that was hit. 116ea671fbdSKate Stone 117ea671fbdSKate Stone dict: the python session dictionary hit. 118ea671fbdSKate Stone 119b9c1b51eSKate Stone )" 120b9c1b51eSKate Stone "When specifying a python function with the --python-function option, you need \ 121b9c1b51eSKate Stone to supply the function name prepended by the module name:" 122b9c1b51eSKate Stone R"( 123ea671fbdSKate Stone 124ea671fbdSKate Stone --python-function myutils.breakpoint_callback 125ea671fbdSKate Stone 126ea671fbdSKate Stone The function itself must have the following prototype: 127ea671fbdSKate Stone 128ea671fbdSKate Stone def breakpoint_callback(frame, bp_loc, dict): 129ea671fbdSKate Stone # Your code goes here 130ea671fbdSKate Stone 131b9c1b51eSKate Stone )" 132b9c1b51eSKate Stone "The arguments are the same as the arguments passed to generated functions as \ 133ea671fbdSKate Stone described above. Note that the global variable 'lldb.frame' will NOT be updated when \ 134ea671fbdSKate Stone this function is called, so be sure to use the 'frame' argument. The 'frame' argument \ 135ea671fbdSKate Stone can get you to the thread via frame.GetThread(), the thread can get you to the \ 136ea671fbdSKate Stone process via thread.GetProcess(), and the process can get you back to the target \ 137b9c1b51eSKate Stone via process.GetTarget()." 138b9c1b51eSKate Stone R"( 139ea671fbdSKate Stone 140b9c1b51eSKate Stone )" 141b9c1b51eSKate Stone "Important Note: As Python code gets collected into functions, access to global \ 142ea671fbdSKate Stone variables requires explicit scoping using the 'global' keyword. Be sure to use correct \ 143b9c1b51eSKate Stone Python syntax, including indentation, when entering Python breakpoint commands." 144b9c1b51eSKate Stone R"( 145ea671fbdSKate Stone 146ea671fbdSKate Stone Example Python one-line breakpoint command: 147ea671fbdSKate Stone 148ea671fbdSKate Stone (lldb) breakpoint command add -s python 1 149ea671fbdSKate Stone Enter your Python command(s). Type 'DONE' to end. 150ea671fbdSKate Stone > print "Hit this breakpoint!" 151ea671fbdSKate Stone > DONE 152ea671fbdSKate Stone 153ea671fbdSKate Stone As a convenience, this also works for a short Python one-liner: 154ea671fbdSKate Stone 155ea671fbdSKate Stone (lldb) breakpoint command add -s python 1 -o 'import time; print time.asctime()' 156ea671fbdSKate Stone (lldb) run 157ea671fbdSKate Stone Launching '.../a.out' (x86_64) 158ea671fbdSKate Stone (lldb) Fri Sep 10 12:17:45 2010 159ea671fbdSKate Stone Process 21778 Stopped 160ea671fbdSKate Stone * thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread 161ea671fbdSKate Stone 36 162ea671fbdSKate Stone 37 int c(int val) 163ea671fbdSKate Stone 38 { 164ea671fbdSKate Stone 39 -> return val + 3; 165ea671fbdSKate Stone 40 } 166ea671fbdSKate Stone 41 167ea671fbdSKate Stone 42 int main (int argc, char const *argv[]) 168ea671fbdSKate Stone 169ea671fbdSKate Stone Example multiple line Python breakpoint command: 170ea671fbdSKate Stone 171ea671fbdSKate Stone (lldb) breakpoint command add -s p 1 172ea671fbdSKate Stone Enter your Python command(s). Type 'DONE' to end. 173ea671fbdSKate Stone > global bp_count 174ea671fbdSKate Stone > bp_count = bp_count + 1 175ea671fbdSKate Stone > print "Hit this breakpoint " + repr(bp_count) + " times!" 176ea671fbdSKate Stone > DONE 177ea671fbdSKate Stone 178ea671fbdSKate Stone Example multiple line Python breakpoint command, using function definition: 179ea671fbdSKate Stone 180ea671fbdSKate Stone (lldb) breakpoint command add -s python 1 181ea671fbdSKate Stone Enter your Python command(s). Type 'DONE' to end. 182ea671fbdSKate Stone > def breakpoint_output (bp_no): 183ea671fbdSKate Stone > out_string = "Hit breakpoint number " + repr (bp_no) 184ea671fbdSKate Stone > print out_string 185ea671fbdSKate Stone > return True 186ea671fbdSKate Stone > breakpoint_output (1) 187ea671fbdSKate Stone > DONE 188ea671fbdSKate Stone 189b9c1b51eSKate Stone )" 190b9c1b51eSKate Stone "In this case, since there is a reference to a global variable, \ 191ea671fbdSKate Stone 'bp_count', you will also need to make sure 'bp_count' exists and is \ 192b9c1b51eSKate Stone initialized:" 193b9c1b51eSKate Stone R"( 194ea671fbdSKate Stone 195ea671fbdSKate Stone (lldb) script 196ea671fbdSKate Stone >>> bp_count = 0 197ea671fbdSKate Stone >>> quit() 198ea671fbdSKate Stone 199b9c1b51eSKate Stone )" 200b9c1b51eSKate Stone "Your Python code, however organized, can optionally return a value. \ 201ea671fbdSKate Stone If the returned value is False, that tells LLDB not to stop at the breakpoint \ 202ea671fbdSKate Stone to which the code is associated. Returning anything other than False, or even \ 203ea671fbdSKate Stone returning None, or even omitting a return statement entirely, will cause \ 204b9c1b51eSKate Stone LLDB to stop." 205b9c1b51eSKate Stone R"( 206ea671fbdSKate Stone 207b9c1b51eSKate Stone )" 208b9c1b51eSKate Stone "Final Note: A warning that no breakpoint command was generated when there \ 209b9c1b51eSKate Stone are no syntax errors may indicate that a function was declared but never called."); 210405fe67fSCaroline Tice 211405fe67fSCaroline Tice CommandArgumentEntry arg; 212405fe67fSCaroline Tice CommandArgumentData bp_id_arg; 213405fe67fSCaroline Tice 214405fe67fSCaroline Tice // Define the first (and only) variant of this arg. 215405fe67fSCaroline Tice bp_id_arg.arg_type = eArgTypeBreakpointID; 2161bb0750bSJim Ingham bp_id_arg.arg_repetition = eArgRepeatOptional; 217405fe67fSCaroline Tice 218b9c1b51eSKate Stone // There is only one variant this argument could be; put it into the 219b9c1b51eSKate Stone // argument entry. 220405fe67fSCaroline Tice arg.push_back(bp_id_arg); 221405fe67fSCaroline Tice 222405fe67fSCaroline Tice // Push the data for the first argument into the m_arguments vector. 223405fe67fSCaroline Tice m_arguments.push_back(arg); 22430fdc8d8SChris Lattner } 22530fdc8d8SChris Lattner 226c8ecc2a9SEugene Zelenko ~CommandObjectBreakpointCommandAdd() override = default; 2275a988416SJim Ingham 228b9c1b51eSKate Stone Options *GetOptions() override { return &m_options; } 2295a988416SJim Ingham 230b9c1b51eSKate Stone void IOHandlerActivated(IOHandler &io_handler) override { 23144d93782SGreg Clayton StreamFileSP output_sp(io_handler.GetOutputStreamFile()); 232b9c1b51eSKate Stone if (output_sp) { 23344d93782SGreg Clayton output_sp->PutCString(g_reader_instructions); 23444d93782SGreg Clayton output_sp->Flush(); 23544d93782SGreg Clayton } 23644d93782SGreg Clayton } 23744d93782SGreg Clayton 238b9c1b51eSKate Stone void IOHandlerInputComplete(IOHandler &io_handler, 239b9c1b51eSKate Stone std::string &line) override { 24044d93782SGreg Clayton io_handler.SetIsDone(true); 24144d93782SGreg Clayton 242b9c1b51eSKate Stone std::vector<BreakpointOptions *> *bp_options_vec = 243b9c1b51eSKate Stone (std::vector<BreakpointOptions *> *)io_handler.GetUserData(); 244b9c1b51eSKate Stone for (BreakpointOptions *bp_options : *bp_options_vec) { 245b5796cb4SJim Ingham if (!bp_options) 246b5796cb4SJim Ingham continue; 247b5796cb4SJim Ingham 2484e4fbe82SZachary Turner auto cmd_data = llvm::make_unique<BreakpointOptions::CommandData>(); 249e14dc268SJim Ingham cmd_data->user_source.SplitIntoLines(line.c_str(), line.size()); 25092d1960eSJim Ingham bp_options->SetCommandDataCallback(cmd_data); 25144d93782SGreg Clayton } 25244d93782SGreg Clayton } 25344d93782SGreg Clayton 254b9c1b51eSKate Stone void CollectDataForBreakpointCommandCallback( 255b9c1b51eSKate Stone std::vector<BreakpointOptions *> &bp_options_vec, 256b9c1b51eSKate Stone CommandReturnObject &result) { 257b9c1b51eSKate Stone m_interpreter.GetLLDBCommandsFromIOHandler( 258b9c1b51eSKate Stone "> ", // Prompt 25944d93782SGreg Clayton *this, // IOHandlerDelegate 26044d93782SGreg Clayton true, // Run IOHandler in async mode 261b9c1b51eSKate Stone &bp_options_vec); // Baton for the "io_handler" that will be passed back 262b9c1b51eSKate Stone // into our IOHandlerDelegate functions 2635a988416SJim Ingham } 2645a988416SJim Ingham 2655a988416SJim Ingham /// Set a one-liner as the callback for the breakpoint. 2665a988416SJim Ingham void 267b5796cb4SJim Ingham SetBreakpointCommandCallback(std::vector<BreakpointOptions *> &bp_options_vec, 268b9c1b51eSKate Stone const char *oneliner) { 269b9c1b51eSKate Stone for (auto bp_options : bp_options_vec) { 2704e4fbe82SZachary Turner auto cmd_data = llvm::make_unique<BreakpointOptions::CommandData>(); 2715a988416SJim Ingham 272e14dc268SJim Ingham cmd_data->user_source.AppendString(oneliner); 273e14dc268SJim Ingham cmd_data->stop_on_error = m_options.m_stop_on_error; 2745a988416SJim Ingham 27592d1960eSJim Ingham bp_options->SetCommandDataCallback(cmd_data); 276b5796cb4SJim Ingham } 2775a988416SJim Ingham } 2785a988416SJim Ingham 279b9c1b51eSKate Stone class CommandOptions : public Options { 2805a988416SJim Ingham public: 281b9c1b51eSKate Stone CommandOptions() 282b9c1b51eSKate Stone : Options(), m_use_commands(false), m_use_script_language(false), 283b9c1b51eSKate Stone m_script_language(eScriptLanguageNone), m_use_one_liner(false), 284b9c1b51eSKate Stone m_one_liner(), m_function_name() {} 28530fdc8d8SChris Lattner 286c8ecc2a9SEugene Zelenko ~CommandOptions() override = default; 2875a988416SJim Ingham 28897206d57SZachary Turner Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, 289b9c1b51eSKate Stone ExecutionContext *execution_context) override { 29097206d57SZachary Turner Status error; 2913bcdfc0eSGreg Clayton const int short_option = m_getopt_table[option_idx].val; 2925a988416SJim Ingham 293b9c1b51eSKate Stone switch (short_option) { 2945a988416SJim Ingham case 'o': 2955a988416SJim Ingham m_use_one_liner = true; 2965a988416SJim Ingham m_one_liner = option_arg; 2975a988416SJim Ingham break; 2985a988416SJim Ingham 2995a988416SJim Ingham case 's': 30047cbf4a0SPavel Labath m_script_language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum( 301fe11483bSZachary Turner option_arg, g_breakpoint_add_options[option_idx].enum_values, 302b9c1b51eSKate Stone eScriptLanguageNone, error); 3035a988416SJim Ingham 304b9c1b51eSKate Stone if (m_script_language == eScriptLanguagePython || 305b9c1b51eSKate Stone m_script_language == eScriptLanguageDefault) { 3065a988416SJim Ingham m_use_script_language = true; 307b9c1b51eSKate Stone } else { 3085a988416SJim Ingham m_use_script_language = false; 3095a988416SJim Ingham } 3105a988416SJim Ingham break; 3115a988416SJim Ingham 312b9c1b51eSKate Stone case 'e': { 3135a988416SJim Ingham bool success = false; 31447cbf4a0SPavel Labath m_stop_on_error = 31547cbf4a0SPavel Labath OptionArgParser::ToBoolean(option_arg, false, &success); 3165a988416SJim Ingham if (!success) 317b9c1b51eSKate Stone error.SetErrorStringWithFormat( 318fe11483bSZachary Turner "invalid value for stop-on-error: \"%s\"", 319fe11483bSZachary Turner option_arg.str().c_str()); 320b9c1b51eSKate Stone } break; 3215a988416SJim Ingham 3225a988416SJim Ingham case 'F': 3235a988416SJim Ingham m_use_one_liner = false; 3245a988416SJim Ingham m_use_script_language = true; 3255a988416SJim Ingham m_function_name.assign(option_arg); 3265a988416SJim Ingham break; 3275a988416SJim Ingham 32833df7cd3SJim Ingham case 'D': 32933df7cd3SJim Ingham m_use_dummy = true; 33033df7cd3SJim Ingham break; 33133df7cd3SJim Ingham 3325a988416SJim Ingham default: 3335a988416SJim Ingham break; 3345a988416SJim Ingham } 3355a988416SJim Ingham return error; 3365a988416SJim Ingham } 337c8ecc2a9SEugene Zelenko 338b9c1b51eSKate Stone void OptionParsingStarting(ExecutionContext *execution_context) override { 3395a988416SJim Ingham m_use_commands = true; 3405a988416SJim Ingham m_use_script_language = false; 3415a988416SJim Ingham m_script_language = eScriptLanguageNone; 3425a988416SJim Ingham 3435a988416SJim Ingham m_use_one_liner = false; 3445a988416SJim Ingham m_stop_on_error = true; 3455a988416SJim Ingham m_one_liner.clear(); 3465a988416SJim Ingham m_function_name.clear(); 34733df7cd3SJim Ingham m_use_dummy = false; 3485a988416SJim Ingham } 3495a988416SJim Ingham 3501f0f5b5bSZachary Turner llvm::ArrayRef<OptionDefinition> GetDefinitions() override { 35170602439SZachary Turner return llvm::makeArrayRef(g_breakpoint_add_options); 3521f0f5b5bSZachary Turner } 3535a988416SJim Ingham 3545a988416SJim Ingham // Instance variables to hold the values for command options. 3555a988416SJim Ingham 3565a988416SJim Ingham bool m_use_commands; 3575a988416SJim Ingham bool m_use_script_language; 3585a988416SJim Ingham lldb::ScriptLanguage m_script_language; 3595a988416SJim Ingham 3605a988416SJim Ingham // Instance variables to hold the values for one_liner options. 3615a988416SJim Ingham bool m_use_one_liner; 3625a988416SJim Ingham std::string m_one_liner; 3635a988416SJim Ingham bool m_stop_on_error; 3645a988416SJim Ingham std::string m_function_name; 36533df7cd3SJim Ingham bool m_use_dummy; 3665a988416SJim Ingham }; 3675a988416SJim Ingham 3685a988416SJim Ingham protected: 369b9c1b51eSKate Stone bool DoExecute(Args &command, CommandReturnObject &result) override { 37033df7cd3SJim Ingham Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); 37130fdc8d8SChris Lattner 372b9c1b51eSKate Stone if (target == nullptr) { 373b9c1b51eSKate Stone result.AppendError("There is not a current executable; there are no " 374b9c1b51eSKate Stone "breakpoints to which to add commands"); 37530fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 37630fdc8d8SChris Lattner return false; 37730fdc8d8SChris Lattner } 37830fdc8d8SChris Lattner 37930fdc8d8SChris Lattner const BreakpointList &breakpoints = target->GetBreakpointList(); 38030fdc8d8SChris Lattner size_t num_breakpoints = breakpoints.GetSize(); 38130fdc8d8SChris Lattner 382b9c1b51eSKate Stone if (num_breakpoints == 0) { 38330fdc8d8SChris Lattner result.AppendError("No breakpoints exist to have commands added"); 38430fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 38530fdc8d8SChris Lattner return false; 38630fdc8d8SChris Lattner } 38730fdc8d8SChris Lattner 388b9c1b51eSKate Stone if (!m_options.m_use_script_language && 389b9c1b51eSKate Stone !m_options.m_function_name.empty()) { 390b9c1b51eSKate Stone result.AppendError("need to enable scripting to have a function run as a " 391b9c1b51eSKate Stone "breakpoint command"); 3928d4a8010SEnrico Granata result.SetStatus(eReturnStatusFailed); 3938d4a8010SEnrico Granata return false; 3948d4a8010SEnrico Granata } 3958d4a8010SEnrico Granata 39630fdc8d8SChris Lattner BreakpointIDList valid_bp_ids; 397b9c1b51eSKate Stone CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs( 398b842f2ecSJim Ingham command, target, result, &valid_bp_ids, 399b842f2ecSJim Ingham BreakpointName::Permissions::PermissionKinds::listPerm); 40030fdc8d8SChris Lattner 401b5796cb4SJim Ingham m_bp_options_vec.clear(); 402b5796cb4SJim Ingham 403b9c1b51eSKate Stone if (result.Succeeded()) { 404c982c768SGreg Clayton const size_t count = valid_bp_ids.GetSize(); 405d9916eaeSJim Ingham 406b9c1b51eSKate Stone for (size_t i = 0; i < count; ++i) { 40730fdc8d8SChris Lattner BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i); 408b9c1b51eSKate Stone if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) { 409b9c1b51eSKate Stone Breakpoint *bp = 410b9c1b51eSKate Stone target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); 411c8ecc2a9SEugene Zelenko BreakpointOptions *bp_options = nullptr; 412b9c1b51eSKate Stone if (cur_bp_id.GetLocationID() == LLDB_INVALID_BREAK_ID) { 41339d7d4f0SJohnny Chen // This breakpoint does not have an associated location. 41439d7d4f0SJohnny Chen bp_options = bp->GetOptions(); 415b9c1b51eSKate Stone } else { 416b9c1b51eSKate Stone BreakpointLocationSP bp_loc_sp( 417b9c1b51eSKate Stone bp->FindLocationByID(cur_bp_id.GetLocationID())); 41805097246SAdrian Prantl // This breakpoint does have an associated location. Get its 41905097246SAdrian Prantl // breakpoint options. 42030fdc8d8SChris Lattner if (bp_loc_sp) 42139d7d4f0SJohnny Chen bp_options = bp_loc_sp->GetLocationOptions(); 42239d7d4f0SJohnny Chen } 423b5796cb4SJim Ingham if (bp_options) 424b5796cb4SJim Ingham m_bp_options_vec.push_back(bp_options); 425b5796cb4SJim Ingham } 426b5796cb4SJim Ingham } 42739d7d4f0SJohnny Chen 42805097246SAdrian Prantl // If we are using script language, get the script interpreter in order 42905097246SAdrian Prantl // to set or collect command callback. Otherwise, call the methods 43005097246SAdrian Prantl // associated with this object. 431b9c1b51eSKate Stone if (m_options.m_use_script_language) { 432b5796cb4SJim Ingham ScriptInterpreter *script_interp = m_interpreter.GetScriptInterpreter(); 43339d7d4f0SJohnny Chen // Special handling for one-liner specified inline. 434b9c1b51eSKate Stone if (m_options.m_use_one_liner) { 435b9c1b51eSKate Stone script_interp->SetBreakpointCommandCallback( 436b9c1b51eSKate Stone m_bp_options_vec, m_options.m_one_liner.c_str()); 437b9c1b51eSKate Stone } else if (!m_options.m_function_name.empty()) { 438b9c1b51eSKate Stone script_interp->SetBreakpointCommandCallbackFunction( 439b9c1b51eSKate Stone m_bp_options_vec, m_options.m_function_name.c_str()); 440b9c1b51eSKate Stone } else { 441b9c1b51eSKate Stone script_interp->CollectDataForBreakpointCommandCallback( 442b9c1b51eSKate Stone m_bp_options_vec, result); 4438d4a8010SEnrico Granata } 444b9c1b51eSKate Stone } else { 44539d7d4f0SJohnny Chen // Special handling for one-liner specified inline. 44639d7d4f0SJohnny Chen if (m_options.m_use_one_liner) 447b5796cb4SJim Ingham SetBreakpointCommandCallback(m_bp_options_vec, 44839d7d4f0SJohnny Chen m_options.m_one_liner.c_str()); 44939d7d4f0SJohnny Chen else 450b9c1b51eSKate Stone CollectDataForBreakpointCommandCallback(m_bp_options_vec, result); 45130fdc8d8SChris Lattner } 45230fdc8d8SChris Lattner } 45330fdc8d8SChris Lattner 45430fdc8d8SChris Lattner return result.Succeeded(); 45530fdc8d8SChris Lattner } 45630fdc8d8SChris Lattner 4575a988416SJim Ingham private: 4585a988416SJim Ingham CommandOptions m_options; 459b9c1b51eSKate Stone std::vector<BreakpointOptions *> m_bp_options_vec; // This stores the 460b9c1b51eSKate Stone // breakpoint options that 461b9c1b51eSKate Stone // we are currently 46205097246SAdrian Prantl // collecting commands for. In the CollectData... calls we need to hand this 46305097246SAdrian Prantl // off to the IOHandler, which may run asynchronously. So we have to have 46405097246SAdrian Prantl // some way to keep it alive, and not leak it. Making it an ivar of the 46505097246SAdrian Prantl // command object, which never goes away achieves this. Note that if we were 46605097246SAdrian Prantl // able to run the same command concurrently in one interpreter we'd have to 46705097246SAdrian Prantl // make this "per invocation". But there are many more reasons why it is not 46805097246SAdrian Prantl // in general safe to do that in lldb at present, so it isn't worthwhile to 46905097246SAdrian Prantl // come up with a more complex mechanism to address this particular weakness 47005097246SAdrian Prantl // right now. 4715a988416SJim Ingham static const char *g_reader_instructions; 4725a988416SJim Ingham }; 4735a988416SJim Ingham 474b9c1b51eSKate Stone const char *CommandObjectBreakpointCommandAdd::g_reader_instructions = 475b9c1b51eSKate Stone "Enter your debugger command(s). Type 'DONE' to end.\n"; 4765a988416SJim Ingham 47730fdc8d8SChris Lattner //------------------------------------------------------------------------- 47893e0f19fSCaroline Tice // CommandObjectBreakpointCommandDelete 47930fdc8d8SChris Lattner //------------------------------------------------------------------------- 48030fdc8d8SChris Lattner 481*8fe53c49STatyana Krasnukha static constexpr OptionDefinition g_breakpoint_delete_options[] = { 4821f0f5b5bSZachary Turner // clang-format off 483*8fe53c49STatyana Krasnukha { LLDB_OPT_SET_1, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Delete commands from Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets." }, 4841f0f5b5bSZachary Turner // clang-format on 4851f0f5b5bSZachary Turner }; 4861f0f5b5bSZachary Turner 487b9c1b51eSKate Stone class CommandObjectBreakpointCommandDelete : public CommandObjectParsed { 4885a988416SJim Ingham public: 489b9c1b51eSKate Stone CommandObjectBreakpointCommandDelete(CommandInterpreter &interpreter) 490b9c1b51eSKate Stone : CommandObjectParsed(interpreter, "delete", 49193e0f19fSCaroline Tice "Delete the set of commands from a breakpoint.", 492c8ecc2a9SEugene Zelenko nullptr), 493b9c1b51eSKate Stone m_options() { 494405fe67fSCaroline Tice CommandArgumentEntry arg; 495405fe67fSCaroline Tice CommandArgumentData bp_id_arg; 496405fe67fSCaroline Tice 497405fe67fSCaroline Tice // Define the first (and only) variant of this arg. 498405fe67fSCaroline Tice bp_id_arg.arg_type = eArgTypeBreakpointID; 499405fe67fSCaroline Tice bp_id_arg.arg_repetition = eArgRepeatPlain; 500405fe67fSCaroline Tice 501b9c1b51eSKate Stone // There is only one variant this argument could be; put it into the 502b9c1b51eSKate Stone // argument entry. 503405fe67fSCaroline Tice arg.push_back(bp_id_arg); 504405fe67fSCaroline Tice 505405fe67fSCaroline Tice // Push the data for the first argument into the m_arguments vector. 506405fe67fSCaroline Tice m_arguments.push_back(arg); 50730fdc8d8SChris Lattner } 50830fdc8d8SChris Lattner 509c8ecc2a9SEugene Zelenko ~CommandObjectBreakpointCommandDelete() override = default; 5105a988416SJim Ingham 511b9c1b51eSKate Stone Options *GetOptions() override { return &m_options; } 51233df7cd3SJim Ingham 513b9c1b51eSKate Stone class CommandOptions : public Options { 51433df7cd3SJim Ingham public: 515b9c1b51eSKate Stone CommandOptions() : Options(), m_use_dummy(false) {} 51633df7cd3SJim Ingham 517c8ecc2a9SEugene Zelenko ~CommandOptions() override = default; 51833df7cd3SJim Ingham 51997206d57SZachary Turner Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, 520b9c1b51eSKate Stone ExecutionContext *execution_context) override { 52197206d57SZachary Turner Status error; 52233df7cd3SJim Ingham const int short_option = m_getopt_table[option_idx].val; 52333df7cd3SJim Ingham 524b9c1b51eSKate Stone switch (short_option) { 52533df7cd3SJim Ingham case 'D': 52633df7cd3SJim Ingham m_use_dummy = true; 52733df7cd3SJim Ingham break; 52833df7cd3SJim Ingham 52933df7cd3SJim Ingham default: 530b9c1b51eSKate Stone error.SetErrorStringWithFormat("unrecognized option '%c'", 531b9c1b51eSKate Stone short_option); 53233df7cd3SJim Ingham break; 53333df7cd3SJim Ingham } 53433df7cd3SJim Ingham 53533df7cd3SJim Ingham return error; 53633df7cd3SJim Ingham } 53733df7cd3SJim Ingham 538b9c1b51eSKate Stone void OptionParsingStarting(ExecutionContext *execution_context) override { 53933df7cd3SJim Ingham m_use_dummy = false; 54033df7cd3SJim Ingham } 54133df7cd3SJim Ingham 5421f0f5b5bSZachary Turner llvm::ArrayRef<OptionDefinition> GetDefinitions() override { 54370602439SZachary Turner return llvm::makeArrayRef(g_breakpoint_delete_options); 5441f0f5b5bSZachary Turner } 54533df7cd3SJim Ingham 54633df7cd3SJim Ingham // Instance variables to hold the values for command options. 54733df7cd3SJim Ingham bool m_use_dummy; 54833df7cd3SJim Ingham }; 54933df7cd3SJim Ingham 5505a988416SJim Ingham protected: 551b9c1b51eSKate Stone bool DoExecute(Args &command, CommandReturnObject &result) override { 55233df7cd3SJim Ingham Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); 55330fdc8d8SChris Lattner 554b9c1b51eSKate Stone if (target == nullptr) { 555b9c1b51eSKate Stone result.AppendError("There is not a current executable; there are no " 556b9c1b51eSKate Stone "breakpoints from which to delete commands"); 55730fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 55830fdc8d8SChris Lattner return false; 55930fdc8d8SChris Lattner } 56030fdc8d8SChris Lattner 56130fdc8d8SChris Lattner const BreakpointList &breakpoints = target->GetBreakpointList(); 56230fdc8d8SChris Lattner size_t num_breakpoints = breakpoints.GetSize(); 56330fdc8d8SChris Lattner 564b9c1b51eSKate Stone if (num_breakpoints == 0) { 56593e0f19fSCaroline Tice result.AppendError("No breakpoints exist to have commands deleted"); 56630fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 56730fdc8d8SChris Lattner return false; 56830fdc8d8SChris Lattner } 56930fdc8d8SChris Lattner 57011eb9c64SZachary Turner if (command.empty()) { 571b9c1b51eSKate Stone result.AppendError( 572b9c1b51eSKate Stone "No breakpoint specified from which to delete the commands"); 57330fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 57430fdc8d8SChris Lattner return false; 57530fdc8d8SChris Lattner } 57630fdc8d8SChris Lattner 57730fdc8d8SChris Lattner BreakpointIDList valid_bp_ids; 578b9c1b51eSKate Stone CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs( 579b842f2ecSJim Ingham command, target, result, &valid_bp_ids, 580b842f2ecSJim Ingham BreakpointName::Permissions::PermissionKinds::listPerm); 58130fdc8d8SChris Lattner 582b9c1b51eSKate Stone if (result.Succeeded()) { 583c982c768SGreg Clayton const size_t count = valid_bp_ids.GetSize(); 584b9c1b51eSKate Stone for (size_t i = 0; i < count; ++i) { 58530fdc8d8SChris Lattner BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i); 586b9c1b51eSKate Stone if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) { 587b9c1b51eSKate Stone Breakpoint *bp = 588b9c1b51eSKate Stone target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); 589b9c1b51eSKate Stone if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) { 590b9c1b51eSKate Stone BreakpointLocationSP bp_loc_sp( 591b9c1b51eSKate Stone bp->FindLocationByID(cur_bp_id.GetLocationID())); 59230fdc8d8SChris Lattner if (bp_loc_sp) 59330fdc8d8SChris Lattner bp_loc_sp->ClearCallback(); 594b9c1b51eSKate Stone else { 59530fdc8d8SChris Lattner result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n", 59630fdc8d8SChris Lattner cur_bp_id.GetBreakpointID(), 59730fdc8d8SChris Lattner cur_bp_id.GetLocationID()); 59830fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 59930fdc8d8SChris Lattner return false; 60030fdc8d8SChris Lattner } 601b9c1b51eSKate Stone } else { 60230fdc8d8SChris Lattner bp->ClearCallback(); 60330fdc8d8SChris Lattner } 60430fdc8d8SChris Lattner } 60530fdc8d8SChris Lattner } 60630fdc8d8SChris Lattner } 60730fdc8d8SChris Lattner return result.Succeeded(); 60830fdc8d8SChris Lattner } 609c8ecc2a9SEugene Zelenko 61033df7cd3SJim Ingham private: 61133df7cd3SJim Ingham CommandOptions m_options; 6125a988416SJim Ingham }; 61330fdc8d8SChris Lattner 61430fdc8d8SChris Lattner //------------------------------------------------------------------------- 61530fdc8d8SChris Lattner // CommandObjectBreakpointCommandList 61630fdc8d8SChris Lattner //------------------------------------------------------------------------- 61730fdc8d8SChris Lattner 618b9c1b51eSKate Stone class CommandObjectBreakpointCommandList : public CommandObjectParsed { 6195a988416SJim Ingham public: 620b9c1b51eSKate Stone CommandObjectBreakpointCommandList(CommandInterpreter &interpreter) 621b9c1b51eSKate Stone : CommandObjectParsed(interpreter, "list", "List the script or set of " 622b9c1b51eSKate Stone "commands to be executed when " 623b9c1b51eSKate Stone "the breakpoint is hit.", 624b9c1b51eSKate Stone nullptr) { 625405fe67fSCaroline Tice CommandArgumentEntry arg; 626405fe67fSCaroline Tice CommandArgumentData bp_id_arg; 627405fe67fSCaroline Tice 628405fe67fSCaroline Tice // Define the first (and only) variant of this arg. 629405fe67fSCaroline Tice bp_id_arg.arg_type = eArgTypeBreakpointID; 630405fe67fSCaroline Tice bp_id_arg.arg_repetition = eArgRepeatPlain; 631405fe67fSCaroline Tice 632b9c1b51eSKate Stone // There is only one variant this argument could be; put it into the 633b9c1b51eSKate Stone // argument entry. 634405fe67fSCaroline Tice arg.push_back(bp_id_arg); 635405fe67fSCaroline Tice 636405fe67fSCaroline Tice // Push the data for the first argument into the m_arguments vector. 637405fe67fSCaroline Tice m_arguments.push_back(arg); 63830fdc8d8SChris Lattner } 63930fdc8d8SChris Lattner 640c8ecc2a9SEugene Zelenko ~CommandObjectBreakpointCommandList() override = default; 64130fdc8d8SChris Lattner 6425a988416SJim Ingham protected: 643b9c1b51eSKate Stone bool DoExecute(Args &command, CommandReturnObject &result) override { 644a7015092SGreg Clayton Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); 64530fdc8d8SChris Lattner 646b9c1b51eSKate Stone if (target == nullptr) { 647b9c1b51eSKate Stone result.AppendError("There is not a current executable; there are no " 648b9c1b51eSKate Stone "breakpoints for which to list commands"); 64930fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 65030fdc8d8SChris Lattner return false; 65130fdc8d8SChris Lattner } 65230fdc8d8SChris Lattner 65330fdc8d8SChris Lattner const BreakpointList &breakpoints = target->GetBreakpointList(); 65430fdc8d8SChris Lattner size_t num_breakpoints = breakpoints.GetSize(); 65530fdc8d8SChris Lattner 656b9c1b51eSKate Stone if (num_breakpoints == 0) { 65730fdc8d8SChris Lattner result.AppendError("No breakpoints exist for which to list commands"); 65830fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 65930fdc8d8SChris Lattner return false; 66030fdc8d8SChris Lattner } 66130fdc8d8SChris Lattner 66211eb9c64SZachary Turner if (command.empty()) { 663b9c1b51eSKate Stone result.AppendError( 664b9c1b51eSKate Stone "No breakpoint specified for which to list the commands"); 66530fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 66630fdc8d8SChris Lattner return false; 66730fdc8d8SChris Lattner } 66830fdc8d8SChris Lattner 66930fdc8d8SChris Lattner BreakpointIDList valid_bp_ids; 670b9c1b51eSKate Stone CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs( 671b842f2ecSJim Ingham command, target, result, &valid_bp_ids, 672b842f2ecSJim Ingham BreakpointName::Permissions::PermissionKinds::listPerm); 67330fdc8d8SChris Lattner 674b9c1b51eSKate Stone if (result.Succeeded()) { 675c982c768SGreg Clayton const size_t count = valid_bp_ids.GetSize(); 676b9c1b51eSKate Stone for (size_t i = 0; i < count; ++i) { 67730fdc8d8SChris Lattner BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i); 678b9c1b51eSKate Stone if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) { 679b9c1b51eSKate Stone Breakpoint *bp = 680b9c1b51eSKate Stone target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); 68130fdc8d8SChris Lattner 682b9c1b51eSKate Stone if (bp) { 683af26b22cSJim Ingham BreakpointLocationSP bp_loc_sp; 684b9c1b51eSKate Stone if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) { 685af26b22cSJim Ingham bp_loc_sp = bp->FindLocationByID(cur_bp_id.GetLocationID()); 686af26b22cSJim Ingham if (!bp_loc_sp) 687af26b22cSJim Ingham { 68830fdc8d8SChris Lattner result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n", 68930fdc8d8SChris Lattner cur_bp_id.GetBreakpointID(), 69030fdc8d8SChris Lattner cur_bp_id.GetLocationID()); 69130fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 69230fdc8d8SChris Lattner return false; 69330fdc8d8SChris Lattner } 69430fdc8d8SChris Lattner } 69530fdc8d8SChris Lattner 69630fdc8d8SChris Lattner StreamString id_str; 697e16c50a1SJim Ingham BreakpointID::GetCanonicalReference(&id_str, 698e16c50a1SJim Ingham cur_bp_id.GetBreakpointID(), 699e16c50a1SJim Ingham cur_bp_id.GetLocationID()); 700af26b22cSJim Ingham const Baton *baton = nullptr; 701af26b22cSJim Ingham if (bp_loc_sp) 702af26b22cSJim Ingham baton = bp_loc_sp 703af26b22cSJim Ingham ->GetOptionsSpecifyingKind(BreakpointOptions::eCallback) 704af26b22cSJim Ingham ->GetBaton(); 705af26b22cSJim Ingham else 706af26b22cSJim Ingham baton = bp->GetOptions()->GetBaton(); 707af26b22cSJim Ingham 708b9c1b51eSKate Stone if (baton) { 709b9c1b51eSKate Stone result.GetOutputStream().Printf("Breakpoint %s:\n", 710b9c1b51eSKate Stone id_str.GetData()); 71130fdc8d8SChris Lattner result.GetOutputStream().IndentMore(); 712b9c1b51eSKate Stone baton->GetDescription(&result.GetOutputStream(), 713b9c1b51eSKate Stone eDescriptionLevelFull); 71430fdc8d8SChris Lattner result.GetOutputStream().IndentLess(); 715b9c1b51eSKate Stone } else { 716b9c1b51eSKate Stone result.AppendMessageWithFormat( 717b9c1b51eSKate Stone "Breakpoint %s does not have an associated command.\n", 718e16c50a1SJim Ingham id_str.GetData()); 71930fdc8d8SChris Lattner } 72030fdc8d8SChris Lattner } 72130fdc8d8SChris Lattner result.SetStatus(eReturnStatusSuccessFinishResult); 722b9c1b51eSKate Stone } else { 723b9c1b51eSKate Stone result.AppendErrorWithFormat("Invalid breakpoint ID: %u.\n", 724b9c1b51eSKate Stone cur_bp_id.GetBreakpointID()); 72530fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 72630fdc8d8SChris Lattner } 72730fdc8d8SChris Lattner } 72830fdc8d8SChris Lattner } 72930fdc8d8SChris Lattner 73030fdc8d8SChris Lattner return result.Succeeded(); 73130fdc8d8SChris Lattner } 7325a988416SJim Ingham }; 73330fdc8d8SChris Lattner 73430fdc8d8SChris Lattner //------------------------------------------------------------------------- 73530fdc8d8SChris Lattner // CommandObjectBreakpointCommand 73630fdc8d8SChris Lattner //------------------------------------------------------------------------- 73730fdc8d8SChris Lattner 738b9c1b51eSKate Stone CommandObjectBreakpointCommand::CommandObjectBreakpointCommand( 739b9c1b51eSKate Stone CommandInterpreter &interpreter) 7407428a18cSKate Stone : CommandObjectMultiword( 741b9c1b51eSKate Stone interpreter, "command", "Commands for adding, removing and listing " 742b9c1b51eSKate Stone "LLDB commands executed when a breakpoint is " 743b9c1b51eSKate Stone "hit.", 744b9c1b51eSKate Stone "command <sub-command> [<sub-command-options>] <breakpoint-id>") { 745b9c1b51eSKate Stone CommandObjectSP add_command_object( 746b9c1b51eSKate Stone new CommandObjectBreakpointCommandAdd(interpreter)); 747b9c1b51eSKate Stone CommandObjectSP delete_command_object( 748b9c1b51eSKate Stone new CommandObjectBreakpointCommandDelete(interpreter)); 749b9c1b51eSKate Stone CommandObjectSP list_command_object( 750b9c1b51eSKate Stone new CommandObjectBreakpointCommandList(interpreter)); 75130fdc8d8SChris Lattner 75230fdc8d8SChris Lattner add_command_object->SetCommandName("breakpoint command add"); 75393e0f19fSCaroline Tice delete_command_object->SetCommandName("breakpoint command delete"); 75430fdc8d8SChris Lattner list_command_object->SetCommandName("breakpoint command list"); 75530fdc8d8SChris Lattner 75623f59509SGreg Clayton LoadSubCommand("add", add_command_object); 75723f59509SGreg Clayton LoadSubCommand("delete", delete_command_object); 75823f59509SGreg Clayton LoadSubCommand("list", list_command_object); 75930fdc8d8SChris Lattner } 76030fdc8d8SChris Lattner 761c8ecc2a9SEugene Zelenko CommandObjectBreakpointCommand::~CommandObjectBreakpointCommand() = default; 762