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" 2230fdc8d8SChris Lattner #include "lldb/Interpreter/CommandInterpreter.h" 2330fdc8d8SChris Lattner #include "lldb/Interpreter/CommandReturnObject.h" 2430fdc8d8SChris Lattner #include "lldb/Target/Target.h" 2530fdc8d8SChris Lattner #include "lldb/Target/Thread.h" 2630fdc8d8SChris Lattner 274e4fbe82SZachary Turner #include "llvm/ADT/STLExtras.h" 284e4fbe82SZachary Turner 2930fdc8d8SChris Lattner using namespace lldb; 3030fdc8d8SChris Lattner using namespace lldb_private; 3130fdc8d8SChris Lattner 3230fdc8d8SChris Lattner //------------------------------------------------------------------------- 3330fdc8d8SChris Lattner // CommandObjectBreakpointCommandAdd 3430fdc8d8SChris Lattner //------------------------------------------------------------------------- 3530fdc8d8SChris Lattner 36b9c1b51eSKate Stone class CommandObjectBreakpointCommandAdd : public CommandObjectParsed, 37b9c1b51eSKate Stone public IOHandlerDelegateMultiline { 385a988416SJim Ingham public: 397428a18cSKate Stone CommandObjectBreakpointCommandAdd(CommandInterpreter &interpreter) 407428a18cSKate Stone : CommandObjectParsed(interpreter, "add", 41b9c1b51eSKate Stone "Add LLDB commands to a breakpoint, to be executed " 42b9c1b51eSKate Stone "whenever the breakpoint is hit." 43b9c1b51eSKate Stone " If no breakpoint is specified, adds the " 44b9c1b51eSKate Stone "commands to the last created breakpoint.", 45c8ecc2a9SEugene Zelenko nullptr), 46b9c1b51eSKate Stone IOHandlerDelegateMultiline("DONE", 47b9c1b51eSKate Stone IOHandlerDelegate::Completion::LLDBCommand), 48b9c1b51eSKate Stone m_options() { 4930fdc8d8SChris Lattner SetHelpLong( 50ea671fbdSKate Stone R"( 51ea671fbdSKate Stone General information about entering breakpoint commands 52ea671fbdSKate Stone ------------------------------------------------------ 53ea671fbdSKate Stone 54b9c1b51eSKate Stone )" 55b9c1b51eSKate Stone "This command will prompt for commands to be executed when the specified \ 56ea671fbdSKate Stone breakpoint is hit. Each command is typed on its own line following the '> ' \ 57b9c1b51eSKate Stone prompt until 'DONE' is entered." 58b9c1b51eSKate Stone R"( 59ea671fbdSKate Stone 60b9c1b51eSKate Stone )" 61b9c1b51eSKate Stone "Syntactic errors may not be detected when initially entered, and many \ 62ea671fbdSKate Stone malformed commands can silently fail when executed. If your breakpoint commands \ 63b9c1b51eSKate Stone do not appear to be executing, double-check the command syntax." 64b9c1b51eSKate Stone R"( 65ea671fbdSKate Stone 66b9c1b51eSKate Stone )" 67b9c1b51eSKate Stone "Note: You may enter any debugger command exactly as you would at the debugger \ 68ea671fbdSKate Stone prompt. There is no limit to the number of commands supplied, but do NOT enter \ 69b9c1b51eSKate Stone more than one command per line." 70b9c1b51eSKate Stone R"( 71ea671fbdSKate Stone 72ea671fbdSKate Stone Special information about PYTHON breakpoint commands 73ea671fbdSKate Stone ---------------------------------------------------- 74ea671fbdSKate Stone 75b9c1b51eSKate Stone )" 76b9c1b51eSKate Stone "You may enter either one or more lines of Python, including function \ 77ea671fbdSKate Stone definitions or calls to functions that will have been imported by the time \ 78ea671fbdSKate Stone the code executes. Single line breakpoint commands will be interpreted 'as is' \ 79ea671fbdSKate Stone when the breakpoint is hit. Multiple lines of Python will be wrapped in a \ 80b9c1b51eSKate Stone generated function, and a call to the function will be attached to the breakpoint." 81b9c1b51eSKate Stone R"( 82ea671fbdSKate Stone 83ea671fbdSKate Stone This auto-generated function is passed in three arguments: 84ea671fbdSKate Stone 85ea671fbdSKate Stone frame: an lldb.SBFrame object for the frame which hit breakpoint. 86ea671fbdSKate Stone 87ea671fbdSKate Stone bp_loc: an lldb.SBBreakpointLocation object that represents the breakpoint location that was hit. 88ea671fbdSKate Stone 89ea671fbdSKate Stone dict: the python session dictionary hit. 90ea671fbdSKate Stone 91b9c1b51eSKate Stone )" 92b9c1b51eSKate Stone "When specifying a python function with the --python-function option, you need \ 93b9c1b51eSKate Stone to supply the function name prepended by the module name:" 94b9c1b51eSKate Stone R"( 95ea671fbdSKate Stone 96ea671fbdSKate Stone --python-function myutils.breakpoint_callback 97ea671fbdSKate Stone 98ea671fbdSKate Stone The function itself must have the following prototype: 99ea671fbdSKate Stone 100ea671fbdSKate Stone def breakpoint_callback(frame, bp_loc, dict): 101ea671fbdSKate Stone # Your code goes here 102ea671fbdSKate Stone 103b9c1b51eSKate Stone )" 104b9c1b51eSKate Stone "The arguments are the same as the arguments passed to generated functions as \ 105ea671fbdSKate Stone described above. Note that the global variable 'lldb.frame' will NOT be updated when \ 106ea671fbdSKate Stone this function is called, so be sure to use the 'frame' argument. The 'frame' argument \ 107ea671fbdSKate Stone can get you to the thread via frame.GetThread(), the thread can get you to the \ 108ea671fbdSKate Stone process via thread.GetProcess(), and the process can get you back to the target \ 109b9c1b51eSKate Stone via process.GetTarget()." 110b9c1b51eSKate Stone R"( 111ea671fbdSKate Stone 112b9c1b51eSKate Stone )" 113b9c1b51eSKate Stone "Important Note: As Python code gets collected into functions, access to global \ 114ea671fbdSKate Stone variables requires explicit scoping using the 'global' keyword. Be sure to use correct \ 115b9c1b51eSKate Stone Python syntax, including indentation, when entering Python breakpoint commands." 116b9c1b51eSKate Stone R"( 117ea671fbdSKate Stone 118ea671fbdSKate Stone Example Python one-line breakpoint command: 119ea671fbdSKate Stone 120ea671fbdSKate Stone (lldb) breakpoint command add -s python 1 121ea671fbdSKate Stone Enter your Python command(s). Type 'DONE' to end. 122ea671fbdSKate Stone > print "Hit this breakpoint!" 123ea671fbdSKate Stone > DONE 124ea671fbdSKate Stone 125ea671fbdSKate Stone As a convenience, this also works for a short Python one-liner: 126ea671fbdSKate Stone 127ea671fbdSKate Stone (lldb) breakpoint command add -s python 1 -o 'import time; print time.asctime()' 128ea671fbdSKate Stone (lldb) run 129ea671fbdSKate Stone Launching '.../a.out' (x86_64) 130ea671fbdSKate Stone (lldb) Fri Sep 10 12:17:45 2010 131ea671fbdSKate Stone Process 21778 Stopped 132ea671fbdSKate Stone * thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread 133ea671fbdSKate Stone 36 134ea671fbdSKate Stone 37 int c(int val) 135ea671fbdSKate Stone 38 { 136ea671fbdSKate Stone 39 -> return val + 3; 137ea671fbdSKate Stone 40 } 138ea671fbdSKate Stone 41 139ea671fbdSKate Stone 42 int main (int argc, char const *argv[]) 140ea671fbdSKate Stone 141ea671fbdSKate Stone Example multiple line Python breakpoint command: 142ea671fbdSKate Stone 143ea671fbdSKate Stone (lldb) breakpoint command add -s p 1 144ea671fbdSKate Stone Enter your Python command(s). Type 'DONE' to end. 145ea671fbdSKate Stone > global bp_count 146ea671fbdSKate Stone > bp_count = bp_count + 1 147ea671fbdSKate Stone > print "Hit this breakpoint " + repr(bp_count) + " times!" 148ea671fbdSKate Stone > DONE 149ea671fbdSKate Stone 150ea671fbdSKate Stone Example multiple line Python breakpoint command, using function definition: 151ea671fbdSKate Stone 152ea671fbdSKate Stone (lldb) breakpoint command add -s python 1 153ea671fbdSKate Stone Enter your Python command(s). Type 'DONE' to end. 154ea671fbdSKate Stone > def breakpoint_output (bp_no): 155ea671fbdSKate Stone > out_string = "Hit breakpoint number " + repr (bp_no) 156ea671fbdSKate Stone > print out_string 157ea671fbdSKate Stone > return True 158ea671fbdSKate Stone > breakpoint_output (1) 159ea671fbdSKate Stone > DONE 160ea671fbdSKate Stone 161b9c1b51eSKate Stone )" 162b9c1b51eSKate Stone "In this case, since there is a reference to a global variable, \ 163ea671fbdSKate Stone 'bp_count', you will also need to make sure 'bp_count' exists and is \ 164b9c1b51eSKate Stone initialized:" 165b9c1b51eSKate Stone R"( 166ea671fbdSKate Stone 167ea671fbdSKate Stone (lldb) script 168ea671fbdSKate Stone >>> bp_count = 0 169ea671fbdSKate Stone >>> quit() 170ea671fbdSKate Stone 171b9c1b51eSKate Stone )" 172b9c1b51eSKate Stone "Your Python code, however organized, can optionally return a value. \ 173ea671fbdSKate Stone If the returned value is False, that tells LLDB not to stop at the breakpoint \ 174ea671fbdSKate Stone to which the code is associated. Returning anything other than False, or even \ 175ea671fbdSKate Stone returning None, or even omitting a return statement entirely, will cause \ 176b9c1b51eSKate Stone LLDB to stop." 177b9c1b51eSKate Stone R"( 178ea671fbdSKate Stone 179b9c1b51eSKate Stone )" 180b9c1b51eSKate Stone "Final Note: A warning that no breakpoint command was generated when there \ 181b9c1b51eSKate Stone are no syntax errors may indicate that a function was declared but never called."); 182405fe67fSCaroline Tice 183405fe67fSCaroline Tice CommandArgumentEntry arg; 184405fe67fSCaroline Tice CommandArgumentData bp_id_arg; 185405fe67fSCaroline Tice 186405fe67fSCaroline Tice // Define the first (and only) variant of this arg. 187405fe67fSCaroline Tice bp_id_arg.arg_type = eArgTypeBreakpointID; 1881bb0750bSJim Ingham bp_id_arg.arg_repetition = eArgRepeatOptional; 189405fe67fSCaroline Tice 190b9c1b51eSKate Stone // There is only one variant this argument could be; put it into the 191b9c1b51eSKate Stone // argument entry. 192405fe67fSCaroline Tice arg.push_back(bp_id_arg); 193405fe67fSCaroline Tice 194405fe67fSCaroline Tice // Push the data for the first argument into the m_arguments vector. 195405fe67fSCaroline Tice m_arguments.push_back(arg); 19630fdc8d8SChris Lattner } 19730fdc8d8SChris Lattner 198c8ecc2a9SEugene Zelenko ~CommandObjectBreakpointCommandAdd() override = default; 1995a988416SJim Ingham 200b9c1b51eSKate Stone Options *GetOptions() override { return &m_options; } 2015a988416SJim Ingham 202b9c1b51eSKate Stone void IOHandlerActivated(IOHandler &io_handler) override { 20344d93782SGreg Clayton StreamFileSP output_sp(io_handler.GetOutputStreamFile()); 204b9c1b51eSKate Stone if (output_sp) { 20544d93782SGreg Clayton output_sp->PutCString(g_reader_instructions); 20644d93782SGreg Clayton output_sp->Flush(); 20744d93782SGreg Clayton } 20844d93782SGreg Clayton } 20944d93782SGreg Clayton 210b9c1b51eSKate Stone void IOHandlerInputComplete(IOHandler &io_handler, 211b9c1b51eSKate Stone std::string &line) override { 21244d93782SGreg Clayton io_handler.SetIsDone(true); 21344d93782SGreg Clayton 214b9c1b51eSKate Stone std::vector<BreakpointOptions *> *bp_options_vec = 215b9c1b51eSKate Stone (std::vector<BreakpointOptions *> *)io_handler.GetUserData(); 216b9c1b51eSKate Stone for (BreakpointOptions *bp_options : *bp_options_vec) { 217b5796cb4SJim Ingham if (!bp_options) 218b5796cb4SJim Ingham continue; 219b5796cb4SJim Ingham 2204e4fbe82SZachary Turner auto cmd_data = llvm::make_unique<BreakpointOptions::CommandData>(); 221e14dc268SJim Ingham cmd_data->user_source.SplitIntoLines(line.c_str(), line.size()); 222*92d1960eSJim Ingham bp_options->SetCommandDataCallback(cmd_data); 22344d93782SGreg Clayton } 22444d93782SGreg Clayton } 22544d93782SGreg Clayton 226b9c1b51eSKate Stone void CollectDataForBreakpointCommandCallback( 227b9c1b51eSKate Stone std::vector<BreakpointOptions *> &bp_options_vec, 228b9c1b51eSKate Stone CommandReturnObject &result) { 229b9c1b51eSKate Stone m_interpreter.GetLLDBCommandsFromIOHandler( 230b9c1b51eSKate Stone "> ", // Prompt 23144d93782SGreg Clayton *this, // IOHandlerDelegate 23244d93782SGreg Clayton true, // Run IOHandler in async mode 233b9c1b51eSKate Stone &bp_options_vec); // Baton for the "io_handler" that will be passed back 234b9c1b51eSKate Stone // into our IOHandlerDelegate functions 2355a988416SJim Ingham } 2365a988416SJim Ingham 2375a988416SJim Ingham /// Set a one-liner as the callback for the breakpoint. 2385a988416SJim Ingham void 239b5796cb4SJim Ingham SetBreakpointCommandCallback(std::vector<BreakpointOptions *> &bp_options_vec, 240b9c1b51eSKate Stone const char *oneliner) { 241b9c1b51eSKate Stone for (auto bp_options : bp_options_vec) { 2424e4fbe82SZachary Turner auto cmd_data = llvm::make_unique<BreakpointOptions::CommandData>(); 2435a988416SJim Ingham 244b9c1b51eSKate Stone // It's necessary to set both user_source and script_source to the 245b9c1b51eSKate Stone // oneliner. 246b9c1b51eSKate Stone // The former is used to generate callback description (as in breakpoint 247b9c1b51eSKate Stone // command list) 248b9c1b51eSKate Stone // while the latter is used for Python to interpret during the actual 249b9c1b51eSKate Stone // callback. 250e14dc268SJim Ingham cmd_data->user_source.AppendString(oneliner); 251e14dc268SJim Ingham cmd_data->script_source.assign(oneliner); 252e14dc268SJim Ingham cmd_data->stop_on_error = m_options.m_stop_on_error; 2535a988416SJim Ingham 254*92d1960eSJim Ingham bp_options->SetCommandDataCallback(cmd_data); 255b5796cb4SJim Ingham } 2565a988416SJim Ingham } 2575a988416SJim Ingham 258b9c1b51eSKate Stone class CommandOptions : public Options { 2595a988416SJim Ingham public: 260b9c1b51eSKate Stone CommandOptions() 261b9c1b51eSKate Stone : Options(), m_use_commands(false), m_use_script_language(false), 262b9c1b51eSKate Stone m_script_language(eScriptLanguageNone), m_use_one_liner(false), 263b9c1b51eSKate Stone m_one_liner(), m_function_name() {} 26430fdc8d8SChris Lattner 265c8ecc2a9SEugene Zelenko ~CommandOptions() override = default; 2665a988416SJim Ingham 267b9c1b51eSKate Stone Error SetOptionValue(uint32_t option_idx, const char *option_arg, 268b9c1b51eSKate Stone ExecutionContext *execution_context) override { 2695a988416SJim Ingham Error error; 2703bcdfc0eSGreg Clayton const int short_option = m_getopt_table[option_idx].val; 271ecbb0bb1SZachary Turner auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg); 2725a988416SJim Ingham 273b9c1b51eSKate Stone switch (short_option) { 2745a988416SJim Ingham case 'o': 2755a988416SJim Ingham m_use_one_liner = true; 2765a988416SJim Ingham m_one_liner = option_arg; 2775a988416SJim Ingham break; 2785a988416SJim Ingham 2795a988416SJim Ingham case 's': 280b9c1b51eSKate Stone m_script_language = (lldb::ScriptLanguage)Args::StringToOptionEnum( 281b9c1b51eSKate Stone option_arg, g_option_table[option_idx].enum_values, 282b9c1b51eSKate Stone eScriptLanguageNone, error); 2835a988416SJim Ingham 284b9c1b51eSKate Stone if (m_script_language == eScriptLanguagePython || 285b9c1b51eSKate Stone m_script_language == eScriptLanguageDefault) { 2865a988416SJim Ingham m_use_script_language = true; 287b9c1b51eSKate Stone } else { 2885a988416SJim Ingham m_use_script_language = false; 2895a988416SJim Ingham } 2905a988416SJim Ingham break; 2915a988416SJim Ingham 292b9c1b51eSKate Stone case 'e': { 2935a988416SJim Ingham bool success = false; 294ecbb0bb1SZachary Turner m_stop_on_error = Args::StringToBoolean(option_strref, false, &success); 2955a988416SJim Ingham if (!success) 296b9c1b51eSKate Stone error.SetErrorStringWithFormat( 297b9c1b51eSKate Stone "invalid value for stop-on-error: \"%s\"", option_arg); 298b9c1b51eSKate Stone } break; 2995a988416SJim Ingham 3005a988416SJim Ingham case 'F': 3015a988416SJim Ingham m_use_one_liner = false; 3025a988416SJim Ingham m_use_script_language = true; 3035a988416SJim Ingham m_function_name.assign(option_arg); 3045a988416SJim Ingham break; 3055a988416SJim Ingham 30633df7cd3SJim Ingham case 'D': 30733df7cd3SJim Ingham m_use_dummy = true; 30833df7cd3SJim Ingham break; 30933df7cd3SJim Ingham 3105a988416SJim Ingham default: 3115a988416SJim Ingham break; 3125a988416SJim Ingham } 3135a988416SJim Ingham return error; 3145a988416SJim Ingham } 315c8ecc2a9SEugene Zelenko 316b9c1b51eSKate Stone void OptionParsingStarting(ExecutionContext *execution_context) override { 3175a988416SJim Ingham m_use_commands = true; 3185a988416SJim Ingham m_use_script_language = false; 3195a988416SJim Ingham m_script_language = eScriptLanguageNone; 3205a988416SJim Ingham 3215a988416SJim Ingham m_use_one_liner = false; 3225a988416SJim Ingham m_stop_on_error = true; 3235a988416SJim Ingham m_one_liner.clear(); 3245a988416SJim Ingham m_function_name.clear(); 32533df7cd3SJim Ingham m_use_dummy = false; 3265a988416SJim Ingham } 3275a988416SJim Ingham 328b9c1b51eSKate Stone const OptionDefinition *GetDefinitions() override { return g_option_table; } 3295a988416SJim Ingham 3305a988416SJim Ingham // Options table: Required for subclasses of Options. 3315a988416SJim Ingham 3325a988416SJim Ingham static OptionDefinition g_option_table[]; 3335a988416SJim Ingham 3345a988416SJim Ingham // Instance variables to hold the values for command options. 3355a988416SJim Ingham 3365a988416SJim Ingham bool m_use_commands; 3375a988416SJim Ingham bool m_use_script_language; 3385a988416SJim Ingham lldb::ScriptLanguage m_script_language; 3395a988416SJim Ingham 3405a988416SJim Ingham // Instance variables to hold the values for one_liner options. 3415a988416SJim Ingham bool m_use_one_liner; 3425a988416SJim Ingham std::string m_one_liner; 3435a988416SJim Ingham bool m_stop_on_error; 3445a988416SJim Ingham std::string m_function_name; 34533df7cd3SJim Ingham bool m_use_dummy; 3465a988416SJim Ingham }; 3475a988416SJim Ingham 3485a988416SJim Ingham protected: 349b9c1b51eSKate Stone bool DoExecute(Args &command, CommandReturnObject &result) override { 35033df7cd3SJim Ingham Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); 35130fdc8d8SChris Lattner 352b9c1b51eSKate Stone if (target == nullptr) { 353b9c1b51eSKate Stone result.AppendError("There is not a current executable; there are no " 354b9c1b51eSKate Stone "breakpoints to which to add commands"); 35530fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 35630fdc8d8SChris Lattner return false; 35730fdc8d8SChris Lattner } 35830fdc8d8SChris Lattner 35930fdc8d8SChris Lattner const BreakpointList &breakpoints = target->GetBreakpointList(); 36030fdc8d8SChris Lattner size_t num_breakpoints = breakpoints.GetSize(); 36130fdc8d8SChris Lattner 362b9c1b51eSKate Stone if (num_breakpoints == 0) { 36330fdc8d8SChris Lattner result.AppendError("No breakpoints exist to have commands added"); 36430fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 36530fdc8d8SChris Lattner return false; 36630fdc8d8SChris Lattner } 36730fdc8d8SChris Lattner 368b9c1b51eSKate Stone if (!m_options.m_use_script_language && 369b9c1b51eSKate Stone !m_options.m_function_name.empty()) { 370b9c1b51eSKate Stone result.AppendError("need to enable scripting to have a function run as a " 371b9c1b51eSKate Stone "breakpoint command"); 3728d4a8010SEnrico Granata result.SetStatus(eReturnStatusFailed); 3738d4a8010SEnrico Granata return false; 3748d4a8010SEnrico Granata } 3758d4a8010SEnrico Granata 37630fdc8d8SChris Lattner BreakpointIDList valid_bp_ids; 377b9c1b51eSKate Stone CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs( 378b9c1b51eSKate Stone command, target, result, &valid_bp_ids); 37930fdc8d8SChris Lattner 380b5796cb4SJim Ingham m_bp_options_vec.clear(); 381b5796cb4SJim Ingham 382b9c1b51eSKate Stone if (result.Succeeded()) { 383c982c768SGreg Clayton const size_t count = valid_bp_ids.GetSize(); 384d9916eaeSJim Ingham 385b9c1b51eSKate Stone for (size_t i = 0; i < count; ++i) { 38630fdc8d8SChris Lattner BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i); 387b9c1b51eSKate Stone if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) { 388b9c1b51eSKate Stone Breakpoint *bp = 389b9c1b51eSKate Stone target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); 390c8ecc2a9SEugene Zelenko BreakpointOptions *bp_options = nullptr; 391b9c1b51eSKate Stone if (cur_bp_id.GetLocationID() == LLDB_INVALID_BREAK_ID) { 39239d7d4f0SJohnny Chen // This breakpoint does not have an associated location. 39339d7d4f0SJohnny Chen bp_options = bp->GetOptions(); 394b9c1b51eSKate Stone } else { 395b9c1b51eSKate Stone BreakpointLocationSP bp_loc_sp( 396b9c1b51eSKate Stone bp->FindLocationByID(cur_bp_id.GetLocationID())); 39739d7d4f0SJohnny Chen // This breakpoint does have an associated location. 39839d7d4f0SJohnny Chen // Get its breakpoint options. 39930fdc8d8SChris Lattner if (bp_loc_sp) 40039d7d4f0SJohnny Chen bp_options = bp_loc_sp->GetLocationOptions(); 40139d7d4f0SJohnny Chen } 402b5796cb4SJim Ingham if (bp_options) 403b5796cb4SJim Ingham m_bp_options_vec.push_back(bp_options); 404b5796cb4SJim Ingham } 405b5796cb4SJim Ingham } 40639d7d4f0SJohnny Chen 40739d7d4f0SJohnny Chen // If we are using script language, get the script interpreter 40839d7d4f0SJohnny Chen // in order to set or collect command callback. Otherwise, call 40939d7d4f0SJohnny Chen // the methods associated with this object. 410b9c1b51eSKate Stone if (m_options.m_use_script_language) { 411b5796cb4SJim Ingham ScriptInterpreter *script_interp = m_interpreter.GetScriptInterpreter(); 41239d7d4f0SJohnny Chen // Special handling for one-liner specified inline. 413b9c1b51eSKate Stone if (m_options.m_use_one_liner) { 414b9c1b51eSKate Stone script_interp->SetBreakpointCommandCallback( 415b9c1b51eSKate Stone m_bp_options_vec, m_options.m_one_liner.c_str()); 416b9c1b51eSKate Stone } else if (!m_options.m_function_name.empty()) { 417b9c1b51eSKate Stone script_interp->SetBreakpointCommandCallbackFunction( 418b9c1b51eSKate Stone m_bp_options_vec, m_options.m_function_name.c_str()); 419b9c1b51eSKate Stone } else { 420b9c1b51eSKate Stone script_interp->CollectDataForBreakpointCommandCallback( 421b9c1b51eSKate Stone m_bp_options_vec, result); 4228d4a8010SEnrico Granata } 423b9c1b51eSKate Stone } else { 42439d7d4f0SJohnny Chen // Special handling for one-liner specified inline. 42539d7d4f0SJohnny Chen if (m_options.m_use_one_liner) 426b5796cb4SJim Ingham SetBreakpointCommandCallback(m_bp_options_vec, 42739d7d4f0SJohnny Chen m_options.m_one_liner.c_str()); 42839d7d4f0SJohnny Chen else 429b9c1b51eSKate Stone CollectDataForBreakpointCommandCallback(m_bp_options_vec, result); 43030fdc8d8SChris Lattner } 43130fdc8d8SChris Lattner } 43230fdc8d8SChris Lattner 43330fdc8d8SChris Lattner return result.Succeeded(); 43430fdc8d8SChris Lattner } 43530fdc8d8SChris Lattner 4365a988416SJim Ingham private: 4375a988416SJim Ingham CommandOptions m_options; 438b9c1b51eSKate Stone std::vector<BreakpointOptions *> m_bp_options_vec; // This stores the 439b9c1b51eSKate Stone // breakpoint options that 440b9c1b51eSKate Stone // we are currently 441b5796cb4SJim Ingham // collecting commands for. In the CollectData... calls we need 442b5796cb4SJim Ingham // to hand this off to the IOHandler, which may run asynchronously. 443b5796cb4SJim Ingham // So we have to have some way to keep it alive, and not leak it. 444b5796cb4SJim Ingham // Making it an ivar of the command object, which never goes away 445b5796cb4SJim Ingham // achieves this. Note that if we were able to run 446b5796cb4SJim Ingham // the same command concurrently in one interpreter we'd have to 447b5796cb4SJim Ingham // make this "per invocation". But there are many more reasons 448b5796cb4SJim Ingham // why it is not in general safe to do that in lldb at present, 449b5796cb4SJim Ingham // so it isn't worthwhile to come up with a more complex mechanism 450b5796cb4SJim Ingham // to address this particular weakness right now. 4515a988416SJim Ingham static const char *g_reader_instructions; 4525a988416SJim Ingham }; 4535a988416SJim Ingham 454b9c1b51eSKate Stone const char *CommandObjectBreakpointCommandAdd::g_reader_instructions = 455b9c1b51eSKate Stone "Enter your debugger command(s). Type 'DONE' to end.\n"; 4565a988416SJim Ingham 457b9c1b51eSKate Stone // FIXME: "script-type" needs to have its contents determined dynamically, so 458b9c1b51eSKate Stone // somebody can add a new scripting 459b9c1b51eSKate Stone // language to lldb and have it pickable here without having to change this 460b9c1b51eSKate Stone // enumeration by hand and rebuild lldb proper. 4615a988416SJim Ingham 462b9c1b51eSKate Stone static OptionEnumValueElement g_script_option_enumeration[4] = { 463b9c1b51eSKate Stone {eScriptLanguageNone, "command", 464b9c1b51eSKate Stone "Commands are in the lldb command interpreter language"}, 4655a988416SJim Ingham {eScriptLanguagePython, "python", "Commands are in the Python language."}, 466b9c1b51eSKate Stone {eSortOrderByName, "default-script", 467b9c1b51eSKate Stone "Commands are in the default scripting language."}, 468b9c1b51eSKate Stone {0, nullptr, nullptr}}; 46930fdc8d8SChris Lattner 4705a988416SJim Ingham OptionDefinition 471b9c1b51eSKate Stone CommandObjectBreakpointCommandAdd::CommandOptions::g_option_table[] = { 472ac9c3a62SKate Stone // clang-format off 473ac9c3a62SKate Stone {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." }, 474ac9c3a62SKate Stone {LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Specify whether breakpoint command execution should terminate on error." }, 475ac9c3a62SKate Stone {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."}, 476ac9c3a62SKate Stone {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."}, 477ac9c3a62SKate Stone {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."}, 478c8ecc2a9SEugene Zelenko {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr} 479ac9c3a62SKate Stone // clang-format on 4805a988416SJim Ingham }; 48130fdc8d8SChris Lattner 48230fdc8d8SChris Lattner //------------------------------------------------------------------------- 48393e0f19fSCaroline Tice // CommandObjectBreakpointCommandDelete 48430fdc8d8SChris Lattner //------------------------------------------------------------------------- 48530fdc8d8SChris Lattner 486b9c1b51eSKate Stone class CommandObjectBreakpointCommandDelete : public CommandObjectParsed { 4875a988416SJim Ingham public: 488b9c1b51eSKate Stone CommandObjectBreakpointCommandDelete(CommandInterpreter &interpreter) 489b9c1b51eSKate Stone : CommandObjectParsed(interpreter, "delete", 49093e0f19fSCaroline Tice "Delete the set of commands from a breakpoint.", 491c8ecc2a9SEugene Zelenko nullptr), 492b9c1b51eSKate Stone m_options() { 493405fe67fSCaroline Tice CommandArgumentEntry arg; 494405fe67fSCaroline Tice CommandArgumentData bp_id_arg; 495405fe67fSCaroline Tice 496405fe67fSCaroline Tice // Define the first (and only) variant of this arg. 497405fe67fSCaroline Tice bp_id_arg.arg_type = eArgTypeBreakpointID; 498405fe67fSCaroline Tice bp_id_arg.arg_repetition = eArgRepeatPlain; 499405fe67fSCaroline Tice 500b9c1b51eSKate Stone // There is only one variant this argument could be; put it into the 501b9c1b51eSKate Stone // argument entry. 502405fe67fSCaroline Tice arg.push_back(bp_id_arg); 503405fe67fSCaroline Tice 504405fe67fSCaroline Tice // Push the data for the first argument into the m_arguments vector. 505405fe67fSCaroline Tice m_arguments.push_back(arg); 50630fdc8d8SChris Lattner } 50730fdc8d8SChris Lattner 508c8ecc2a9SEugene Zelenko ~CommandObjectBreakpointCommandDelete() override = default; 5095a988416SJim Ingham 510b9c1b51eSKate Stone Options *GetOptions() override { return &m_options; } 51133df7cd3SJim Ingham 512b9c1b51eSKate Stone class CommandOptions : public Options { 51333df7cd3SJim Ingham public: 514b9c1b51eSKate Stone CommandOptions() : Options(), m_use_dummy(false) {} 51533df7cd3SJim Ingham 516c8ecc2a9SEugene Zelenko ~CommandOptions() override = default; 51733df7cd3SJim Ingham 518b9c1b51eSKate Stone Error SetOptionValue(uint32_t option_idx, const char *option_arg, 519b9c1b51eSKate Stone ExecutionContext *execution_context) override { 52033df7cd3SJim Ingham Error error; 52133df7cd3SJim Ingham const int short_option = m_getopt_table[option_idx].val; 52233df7cd3SJim Ingham 523b9c1b51eSKate Stone switch (short_option) { 52433df7cd3SJim Ingham case 'D': 52533df7cd3SJim Ingham m_use_dummy = true; 52633df7cd3SJim Ingham break; 52733df7cd3SJim Ingham 52833df7cd3SJim Ingham default: 529b9c1b51eSKate Stone error.SetErrorStringWithFormat("unrecognized option '%c'", 530b9c1b51eSKate Stone short_option); 53133df7cd3SJim Ingham break; 53233df7cd3SJim Ingham } 53333df7cd3SJim Ingham 53433df7cd3SJim Ingham return error; 53533df7cd3SJim Ingham } 53633df7cd3SJim Ingham 537b9c1b51eSKate Stone void OptionParsingStarting(ExecutionContext *execution_context) override { 53833df7cd3SJim Ingham m_use_dummy = false; 53933df7cd3SJim Ingham } 54033df7cd3SJim Ingham 541b9c1b51eSKate Stone const OptionDefinition *GetDefinitions() override { return g_option_table; } 54233df7cd3SJim Ingham 54333df7cd3SJim Ingham // Options table: Required for subclasses of Options. 54433df7cd3SJim Ingham 54533df7cd3SJim Ingham static OptionDefinition g_option_table[]; 54633df7cd3SJim Ingham 54733df7cd3SJim Ingham // Instance variables to hold the values for command options. 54833df7cd3SJim Ingham bool m_use_dummy; 54933df7cd3SJim Ingham }; 55033df7cd3SJim Ingham 5515a988416SJim Ingham protected: 552b9c1b51eSKate Stone bool DoExecute(Args &command, CommandReturnObject &result) override { 55333df7cd3SJim Ingham Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); 55430fdc8d8SChris Lattner 555b9c1b51eSKate Stone if (target == nullptr) { 556b9c1b51eSKate Stone result.AppendError("There is not a current executable; there are no " 557b9c1b51eSKate Stone "breakpoints from which to delete commands"); 55830fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 55930fdc8d8SChris Lattner return false; 56030fdc8d8SChris Lattner } 56130fdc8d8SChris Lattner 56230fdc8d8SChris Lattner const BreakpointList &breakpoints = target->GetBreakpointList(); 56330fdc8d8SChris Lattner size_t num_breakpoints = breakpoints.GetSize(); 56430fdc8d8SChris Lattner 565b9c1b51eSKate Stone if (num_breakpoints == 0) { 56693e0f19fSCaroline Tice result.AppendError("No breakpoints exist to have commands deleted"); 56730fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 56830fdc8d8SChris Lattner return false; 56930fdc8d8SChris Lattner } 57030fdc8d8SChris Lattner 571b9c1b51eSKate Stone if (command.GetArgumentCount() == 0) { 572b9c1b51eSKate Stone result.AppendError( 573b9c1b51eSKate Stone "No breakpoint specified from which to delete the commands"); 57430fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 57530fdc8d8SChris Lattner return false; 57630fdc8d8SChris Lattner } 57730fdc8d8SChris Lattner 57830fdc8d8SChris Lattner BreakpointIDList valid_bp_ids; 579b9c1b51eSKate Stone CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs( 580b9c1b51eSKate Stone command, target, result, &valid_bp_ids); 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 61433df7cd3SJim Ingham OptionDefinition 615b9c1b51eSKate Stone CommandObjectBreakpointCommandDelete::CommandOptions::g_option_table[] = { 616ac9c3a62SKate Stone // clang-format off 617ac9c3a62SKate Stone {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."}, 618c8ecc2a9SEugene Zelenko {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr} 619ac9c3a62SKate Stone // clang-format on 62033df7cd3SJim Ingham }; 62133df7cd3SJim Ingham 62230fdc8d8SChris Lattner //------------------------------------------------------------------------- 62330fdc8d8SChris Lattner // CommandObjectBreakpointCommandList 62430fdc8d8SChris Lattner //------------------------------------------------------------------------- 62530fdc8d8SChris Lattner 626b9c1b51eSKate Stone class CommandObjectBreakpointCommandList : public CommandObjectParsed { 6275a988416SJim Ingham public: 628b9c1b51eSKate Stone CommandObjectBreakpointCommandList(CommandInterpreter &interpreter) 629b9c1b51eSKate Stone : CommandObjectParsed(interpreter, "list", "List the script or set of " 630b9c1b51eSKate Stone "commands to be executed when " 631b9c1b51eSKate Stone "the breakpoint is hit.", 632b9c1b51eSKate Stone nullptr) { 633405fe67fSCaroline Tice CommandArgumentEntry arg; 634405fe67fSCaroline Tice CommandArgumentData bp_id_arg; 635405fe67fSCaroline Tice 636405fe67fSCaroline Tice // Define the first (and only) variant of this arg. 637405fe67fSCaroline Tice bp_id_arg.arg_type = eArgTypeBreakpointID; 638405fe67fSCaroline Tice bp_id_arg.arg_repetition = eArgRepeatPlain; 639405fe67fSCaroline Tice 640b9c1b51eSKate Stone // There is only one variant this argument could be; put it into the 641b9c1b51eSKate Stone // argument entry. 642405fe67fSCaroline Tice arg.push_back(bp_id_arg); 643405fe67fSCaroline Tice 644405fe67fSCaroline Tice // Push the data for the first argument into the m_arguments vector. 645405fe67fSCaroline Tice m_arguments.push_back(arg); 64630fdc8d8SChris Lattner } 64730fdc8d8SChris Lattner 648c8ecc2a9SEugene Zelenko ~CommandObjectBreakpointCommandList() override = default; 64930fdc8d8SChris Lattner 6505a988416SJim Ingham protected: 651b9c1b51eSKate Stone bool DoExecute(Args &command, CommandReturnObject &result) override { 652a7015092SGreg Clayton Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); 65330fdc8d8SChris Lattner 654b9c1b51eSKate Stone if (target == nullptr) { 655b9c1b51eSKate Stone result.AppendError("There is not a current executable; there are no " 656b9c1b51eSKate Stone "breakpoints for which to list commands"); 65730fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 65830fdc8d8SChris Lattner return false; 65930fdc8d8SChris Lattner } 66030fdc8d8SChris Lattner 66130fdc8d8SChris Lattner const BreakpointList &breakpoints = target->GetBreakpointList(); 66230fdc8d8SChris Lattner size_t num_breakpoints = breakpoints.GetSize(); 66330fdc8d8SChris Lattner 664b9c1b51eSKate Stone if (num_breakpoints == 0) { 66530fdc8d8SChris Lattner result.AppendError("No breakpoints exist for which to list commands"); 66630fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 66730fdc8d8SChris Lattner return false; 66830fdc8d8SChris Lattner } 66930fdc8d8SChris Lattner 670b9c1b51eSKate Stone if (command.GetArgumentCount() == 0) { 671b9c1b51eSKate Stone result.AppendError( 672b9c1b51eSKate Stone "No breakpoint specified for which to list the commands"); 67330fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 67430fdc8d8SChris Lattner return false; 67530fdc8d8SChris Lattner } 67630fdc8d8SChris Lattner 67730fdc8d8SChris Lattner BreakpointIDList valid_bp_ids; 678b9c1b51eSKate Stone CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs( 679b9c1b51eSKate Stone command, target, result, &valid_bp_ids); 68030fdc8d8SChris Lattner 681b9c1b51eSKate Stone if (result.Succeeded()) { 682c982c768SGreg Clayton const size_t count = valid_bp_ids.GetSize(); 683b9c1b51eSKate Stone for (size_t i = 0; i < count; ++i) { 68430fdc8d8SChris Lattner BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i); 685b9c1b51eSKate Stone if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) { 686b9c1b51eSKate Stone Breakpoint *bp = 687b9c1b51eSKate Stone target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); 68830fdc8d8SChris Lattner 689b9c1b51eSKate Stone if (bp) { 690c8ecc2a9SEugene Zelenko const BreakpointOptions *bp_options = nullptr; 691b9c1b51eSKate Stone if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) { 692b9c1b51eSKate Stone BreakpointLocationSP bp_loc_sp( 693b9c1b51eSKate Stone bp->FindLocationByID(cur_bp_id.GetLocationID())); 69430fdc8d8SChris Lattner if (bp_loc_sp) 69505407f6bSJim Ingham bp_options = bp_loc_sp->GetOptionsNoCreate(); 696b9c1b51eSKate Stone else { 69730fdc8d8SChris Lattner result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n", 69830fdc8d8SChris Lattner cur_bp_id.GetBreakpointID(), 69930fdc8d8SChris Lattner cur_bp_id.GetLocationID()); 70030fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 70130fdc8d8SChris Lattner return false; 70230fdc8d8SChris Lattner } 703b9c1b51eSKate Stone } else { 70430fdc8d8SChris Lattner bp_options = bp->GetOptions(); 70530fdc8d8SChris Lattner } 70630fdc8d8SChris Lattner 707b9c1b51eSKate Stone if (bp_options) { 70830fdc8d8SChris Lattner StreamString id_str; 709e16c50a1SJim Ingham BreakpointID::GetCanonicalReference(&id_str, 710e16c50a1SJim Ingham cur_bp_id.GetBreakpointID(), 711e16c50a1SJim Ingham cur_bp_id.GetLocationID()); 7121b54c88cSJim Ingham const Baton *baton = bp_options->GetBaton(); 713b9c1b51eSKate Stone if (baton) { 714b9c1b51eSKate Stone result.GetOutputStream().Printf("Breakpoint %s:\n", 715b9c1b51eSKate Stone id_str.GetData()); 71630fdc8d8SChris Lattner result.GetOutputStream().IndentMore(); 717b9c1b51eSKate Stone baton->GetDescription(&result.GetOutputStream(), 718b9c1b51eSKate Stone eDescriptionLevelFull); 71930fdc8d8SChris Lattner result.GetOutputStream().IndentLess(); 720b9c1b51eSKate Stone } else { 721b9c1b51eSKate Stone result.AppendMessageWithFormat( 722b9c1b51eSKate Stone "Breakpoint %s does not have an associated command.\n", 723e16c50a1SJim Ingham id_str.GetData()); 72430fdc8d8SChris Lattner } 72530fdc8d8SChris Lattner } 72630fdc8d8SChris Lattner result.SetStatus(eReturnStatusSuccessFinishResult); 727b9c1b51eSKate Stone } else { 728b9c1b51eSKate Stone result.AppendErrorWithFormat("Invalid breakpoint ID: %u.\n", 729b9c1b51eSKate Stone cur_bp_id.GetBreakpointID()); 73030fdc8d8SChris Lattner result.SetStatus(eReturnStatusFailed); 73130fdc8d8SChris Lattner } 73230fdc8d8SChris Lattner } 73330fdc8d8SChris Lattner } 73430fdc8d8SChris Lattner } 73530fdc8d8SChris Lattner 73630fdc8d8SChris Lattner return result.Succeeded(); 73730fdc8d8SChris Lattner } 7385a988416SJim Ingham }; 73930fdc8d8SChris Lattner 74030fdc8d8SChris Lattner //------------------------------------------------------------------------- 74130fdc8d8SChris Lattner // CommandObjectBreakpointCommand 74230fdc8d8SChris Lattner //------------------------------------------------------------------------- 74330fdc8d8SChris Lattner 744b9c1b51eSKate Stone CommandObjectBreakpointCommand::CommandObjectBreakpointCommand( 745b9c1b51eSKate Stone CommandInterpreter &interpreter) 7467428a18cSKate Stone : CommandObjectMultiword( 747b9c1b51eSKate Stone interpreter, "command", "Commands for adding, removing and listing " 748b9c1b51eSKate Stone "LLDB commands executed when a breakpoint is " 749b9c1b51eSKate Stone "hit.", 750b9c1b51eSKate Stone "command <sub-command> [<sub-command-options>] <breakpoint-id>") { 751b9c1b51eSKate Stone CommandObjectSP add_command_object( 752b9c1b51eSKate Stone new CommandObjectBreakpointCommandAdd(interpreter)); 753b9c1b51eSKate Stone CommandObjectSP delete_command_object( 754b9c1b51eSKate Stone new CommandObjectBreakpointCommandDelete(interpreter)); 755b9c1b51eSKate Stone CommandObjectSP list_command_object( 756b9c1b51eSKate Stone new CommandObjectBreakpointCommandList(interpreter)); 75730fdc8d8SChris Lattner 75830fdc8d8SChris Lattner add_command_object->SetCommandName("breakpoint command add"); 75993e0f19fSCaroline Tice delete_command_object->SetCommandName("breakpoint command delete"); 76030fdc8d8SChris Lattner list_command_object->SetCommandName("breakpoint command list"); 76130fdc8d8SChris Lattner 76223f59509SGreg Clayton LoadSubCommand("add", add_command_object); 76323f59509SGreg Clayton LoadSubCommand("delete", delete_command_object); 76423f59509SGreg Clayton LoadSubCommand("list", list_command_object); 76530fdc8d8SChris Lattner } 76630fdc8d8SChris Lattner 767c8ecc2a9SEugene Zelenko CommandObjectBreakpointCommand::~CommandObjectBreakpointCommand() = default; 768