15ffd83dbSDimitry Andric //===-- CommandObjectBreakpointCommand.cpp --------------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric
90b57cec5SDimitry Andric #include "CommandObjectBreakpointCommand.h"
100b57cec5SDimitry Andric #include "CommandObjectBreakpoint.h"
110b57cec5SDimitry Andric #include "lldb/Breakpoint/Breakpoint.h"
120b57cec5SDimitry Andric #include "lldb/Breakpoint/BreakpointIDList.h"
130b57cec5SDimitry Andric #include "lldb/Breakpoint/BreakpointLocation.h"
140b57cec5SDimitry Andric #include "lldb/Core/IOHandler.h"
150b57cec5SDimitry Andric #include "lldb/Host/OptionParser.h"
160b57cec5SDimitry Andric #include "lldb/Interpreter/CommandInterpreter.h"
170b57cec5SDimitry Andric #include "lldb/Interpreter/CommandReturnObject.h"
180b57cec5SDimitry Andric #include "lldb/Interpreter/OptionArgParser.h"
19480093f4SDimitry Andric #include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
200b57cec5SDimitry Andric #include "lldb/Target/Target.h"
210b57cec5SDimitry Andric
220b57cec5SDimitry Andric using namespace lldb;
230b57cec5SDimitry Andric using namespace lldb_private;
240b57cec5SDimitry Andric
250b57cec5SDimitry Andric // FIXME: "script-type" needs to have its contents determined dynamically, so
269dba64beSDimitry Andric // somebody can add a new scripting language to lldb and have it pickable here
279dba64beSDimitry Andric // without having to change this enumeration by hand and rebuild lldb proper.
280b57cec5SDimitry Andric static constexpr OptionEnumValueElement g_script_option_enumeration[] = {
299dba64beSDimitry Andric {
309dba64beSDimitry Andric eScriptLanguageNone,
319dba64beSDimitry Andric "command",
329dba64beSDimitry Andric "Commands are in the lldb command interpreter language",
339dba64beSDimitry Andric },
349dba64beSDimitry Andric {
359dba64beSDimitry Andric eScriptLanguagePython,
369dba64beSDimitry Andric "python",
379dba64beSDimitry Andric "Commands are in the Python language.",
389dba64beSDimitry Andric },
399dba64beSDimitry Andric {
40480093f4SDimitry Andric eScriptLanguageLua,
41480093f4SDimitry Andric "lua",
42480093f4SDimitry Andric "Commands are in the Lua language.",
43480093f4SDimitry Andric },
44480093f4SDimitry Andric {
45480093f4SDimitry Andric eScriptLanguageDefault,
469dba64beSDimitry Andric "default-script",
479dba64beSDimitry Andric "Commands are in the default scripting language.",
489dba64beSDimitry Andric },
499dba64beSDimitry Andric };
500b57cec5SDimitry Andric
ScriptOptionEnum()510b57cec5SDimitry Andric static constexpr OptionEnumValues ScriptOptionEnum() {
520b57cec5SDimitry Andric return OptionEnumValues(g_script_option_enumeration);
530b57cec5SDimitry Andric }
540b57cec5SDimitry Andric
559dba64beSDimitry Andric #define LLDB_OPTIONS_breakpoint_command_add
569dba64beSDimitry Andric #include "CommandOptions.inc"
570b57cec5SDimitry Andric
580b57cec5SDimitry Andric class CommandObjectBreakpointCommandAdd : public CommandObjectParsed,
590b57cec5SDimitry Andric public IOHandlerDelegateMultiline {
600b57cec5SDimitry Andric public:
CommandObjectBreakpointCommandAdd(CommandInterpreter & interpreter)610b57cec5SDimitry Andric CommandObjectBreakpointCommandAdd(CommandInterpreter &interpreter)
620b57cec5SDimitry Andric : CommandObjectParsed(interpreter, "add",
630b57cec5SDimitry Andric "Add LLDB commands to a breakpoint, to be executed "
640b57cec5SDimitry Andric "whenever the breakpoint is hit. "
65*5f7ddb14SDimitry Andric "The commands added to the breakpoint replace any "
66*5f7ddb14SDimitry Andric "commands previously added to it."
670b57cec5SDimitry Andric " If no breakpoint is specified, adds the "
680b57cec5SDimitry Andric "commands to the last created breakpoint.",
690b57cec5SDimitry Andric nullptr),
700b57cec5SDimitry Andric IOHandlerDelegateMultiline("DONE",
710b57cec5SDimitry Andric IOHandlerDelegate::Completion::LLDBCommand),
72480093f4SDimitry Andric m_options(), m_func_options("breakpoint command", false, 'F') {
730b57cec5SDimitry Andric SetHelpLong(
740b57cec5SDimitry Andric R"(
750b57cec5SDimitry Andric General information about entering breakpoint commands
760b57cec5SDimitry Andric ------------------------------------------------------
770b57cec5SDimitry Andric
780b57cec5SDimitry Andric )"
790b57cec5SDimitry Andric "This command will prompt for commands to be executed when the specified \
800b57cec5SDimitry Andric breakpoint is hit. Each command is typed on its own line following the '> ' \
810b57cec5SDimitry Andric prompt until 'DONE' is entered."
820b57cec5SDimitry Andric R"(
830b57cec5SDimitry Andric
840b57cec5SDimitry Andric )"
850b57cec5SDimitry Andric "Syntactic errors may not be detected when initially entered, and many \
860b57cec5SDimitry Andric malformed commands can silently fail when executed. If your breakpoint commands \
870b57cec5SDimitry Andric do not appear to be executing, double-check the command syntax."
880b57cec5SDimitry Andric R"(
890b57cec5SDimitry Andric
900b57cec5SDimitry Andric )"
910b57cec5SDimitry Andric "Note: You may enter any debugger command exactly as you would at the debugger \
920b57cec5SDimitry Andric prompt. There is no limit to the number of commands supplied, but do NOT enter \
930b57cec5SDimitry Andric more than one command per line."
940b57cec5SDimitry Andric R"(
950b57cec5SDimitry Andric
960b57cec5SDimitry Andric Special information about PYTHON breakpoint commands
970b57cec5SDimitry Andric ----------------------------------------------------
980b57cec5SDimitry Andric
990b57cec5SDimitry Andric )"
1000b57cec5SDimitry Andric "You may enter either one or more lines of Python, including function \
1010b57cec5SDimitry Andric definitions or calls to functions that will have been imported by the time \
1020b57cec5SDimitry Andric the code executes. Single line breakpoint commands will be interpreted 'as is' \
1030b57cec5SDimitry Andric when the breakpoint is hit. Multiple lines of Python will be wrapped in a \
1040b57cec5SDimitry Andric generated function, and a call to the function will be attached to the breakpoint."
1050b57cec5SDimitry Andric R"(
1060b57cec5SDimitry Andric
1070b57cec5SDimitry Andric This auto-generated function is passed in three arguments:
1080b57cec5SDimitry Andric
1090b57cec5SDimitry Andric frame: an lldb.SBFrame object for the frame which hit breakpoint.
1100b57cec5SDimitry Andric
1110b57cec5SDimitry Andric bp_loc: an lldb.SBBreakpointLocation object that represents the breakpoint location that was hit.
1120b57cec5SDimitry Andric
1130b57cec5SDimitry Andric dict: the python session dictionary hit.
1140b57cec5SDimitry Andric
1150b57cec5SDimitry Andric )"
1160b57cec5SDimitry Andric "When specifying a python function with the --python-function option, you need \
1170b57cec5SDimitry Andric to supply the function name prepended by the module name:"
1180b57cec5SDimitry Andric R"(
1190b57cec5SDimitry Andric
1200b57cec5SDimitry Andric --python-function myutils.breakpoint_callback
1210b57cec5SDimitry Andric
122*5f7ddb14SDimitry Andric The function itself must have either of the following prototypes:
1230b57cec5SDimitry Andric
124*5f7ddb14SDimitry Andric def breakpoint_callback(frame, bp_loc, internal_dict):
125*5f7ddb14SDimitry Andric # Your code goes here
126*5f7ddb14SDimitry Andric
127*5f7ddb14SDimitry Andric or:
128*5f7ddb14SDimitry Andric
129*5f7ddb14SDimitry Andric def breakpoint_callback(frame, bp_loc, extra_args, internal_dict):
1300b57cec5SDimitry Andric # Your code goes here
1310b57cec5SDimitry Andric
1320b57cec5SDimitry Andric )"
1330b57cec5SDimitry Andric "The arguments are the same as the arguments passed to generated functions as \
134*5f7ddb14SDimitry Andric described above. In the second form, any -k and -v pairs provided to the command will \
135*5f7ddb14SDimitry Andric be packaged into a SBDictionary in an SBStructuredData and passed as the extra_args parameter. \
136*5f7ddb14SDimitry Andric \n\n\
137*5f7ddb14SDimitry Andric Note that the global variable 'lldb.frame' will NOT be updated when \
1380b57cec5SDimitry Andric this function is called, so be sure to use the 'frame' argument. The 'frame' argument \
1390b57cec5SDimitry Andric can get you to the thread via frame.GetThread(), the thread can get you to the \
1400b57cec5SDimitry Andric process via thread.GetProcess(), and the process can get you back to the target \
1410b57cec5SDimitry Andric via process.GetTarget()."
1420b57cec5SDimitry Andric R"(
1430b57cec5SDimitry Andric
1440b57cec5SDimitry Andric )"
1450b57cec5SDimitry Andric "Important Note: As Python code gets collected into functions, access to global \
1460b57cec5SDimitry Andric variables requires explicit scoping using the 'global' keyword. Be sure to use correct \
1470b57cec5SDimitry Andric Python syntax, including indentation, when entering Python breakpoint commands."
1480b57cec5SDimitry Andric R"(
1490b57cec5SDimitry Andric
1500b57cec5SDimitry Andric Example Python one-line breakpoint command:
1510b57cec5SDimitry Andric
1520b57cec5SDimitry Andric (lldb) breakpoint command add -s python 1
1530b57cec5SDimitry Andric Enter your Python command(s). Type 'DONE' to end.
154af732203SDimitry Andric def function (frame, bp_loc, internal_dict):
155af732203SDimitry Andric """frame: the lldb.SBFrame for the location at which you stopped
156af732203SDimitry Andric bp_loc: an lldb.SBBreakpointLocation for the breakpoint location information
157af732203SDimitry Andric internal_dict: an LLDB support object not to be used"""
158af732203SDimitry Andric print("Hit this breakpoint!")
159af732203SDimitry Andric DONE
1600b57cec5SDimitry Andric
1610b57cec5SDimitry Andric As a convenience, this also works for a short Python one-liner:
1620b57cec5SDimitry Andric
163af732203SDimitry Andric (lldb) breakpoint command add -s python 1 -o 'import time; print(time.asctime())'
1640b57cec5SDimitry Andric (lldb) run
1650b57cec5SDimitry Andric Launching '.../a.out' (x86_64)
1660b57cec5SDimitry Andric (lldb) Fri Sep 10 12:17:45 2010
1670b57cec5SDimitry Andric Process 21778 Stopped
1680b57cec5SDimitry Andric * thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread
1690b57cec5SDimitry Andric 36
1700b57cec5SDimitry Andric 37 int c(int val)
1710b57cec5SDimitry Andric 38 {
1720b57cec5SDimitry Andric 39 -> return val + 3;
1730b57cec5SDimitry Andric 40 }
1740b57cec5SDimitry Andric 41
1750b57cec5SDimitry Andric 42 int main (int argc, char const *argv[])
1760b57cec5SDimitry Andric
1770b57cec5SDimitry Andric Example multiple line Python breakpoint command:
1780b57cec5SDimitry Andric
1790b57cec5SDimitry Andric (lldb) breakpoint command add -s p 1
1800b57cec5SDimitry Andric Enter your Python command(s). Type 'DONE' to end.
181af732203SDimitry Andric def function (frame, bp_loc, internal_dict):
182af732203SDimitry Andric """frame: the lldb.SBFrame for the location at which you stopped
183af732203SDimitry Andric bp_loc: an lldb.SBBreakpointLocation for the breakpoint location information
184af732203SDimitry Andric internal_dict: an LLDB support object not to be used"""
185af732203SDimitry Andric global bp_count
186af732203SDimitry Andric bp_count = bp_count + 1
187af732203SDimitry Andric print("Hit this breakpoint " + repr(bp_count) + " times!")
188af732203SDimitry Andric DONE
1890b57cec5SDimitry Andric
1900b57cec5SDimitry Andric )"
1910b57cec5SDimitry Andric "In this case, since there is a reference to a global variable, \
1920b57cec5SDimitry Andric 'bp_count', you will also need to make sure 'bp_count' exists and is \
1930b57cec5SDimitry Andric initialized:"
1940b57cec5SDimitry Andric R"(
1950b57cec5SDimitry Andric
1960b57cec5SDimitry Andric (lldb) script
1970b57cec5SDimitry Andric >>> bp_count = 0
1980b57cec5SDimitry Andric >>> quit()
1990b57cec5SDimitry Andric
2000b57cec5SDimitry Andric )"
2010b57cec5SDimitry Andric "Your Python code, however organized, can optionally return a value. \
2020b57cec5SDimitry Andric If the returned value is False, that tells LLDB not to stop at the breakpoint \
2030b57cec5SDimitry Andric to which the code is associated. Returning anything other than False, or even \
2040b57cec5SDimitry Andric returning None, or even omitting a return statement entirely, will cause \
2050b57cec5SDimitry Andric LLDB to stop."
2060b57cec5SDimitry Andric R"(
2070b57cec5SDimitry Andric
2080b57cec5SDimitry Andric )"
2090b57cec5SDimitry Andric "Final Note: A warning that no breakpoint command was generated when there \
2100b57cec5SDimitry Andric are no syntax errors may indicate that a function was declared but never called.");
2110b57cec5SDimitry Andric
212480093f4SDimitry Andric m_all_options.Append(&m_options);
213480093f4SDimitry Andric m_all_options.Append(&m_func_options, LLDB_OPT_SET_2 | LLDB_OPT_SET_3,
214480093f4SDimitry Andric LLDB_OPT_SET_2);
215480093f4SDimitry Andric m_all_options.Finalize();
216480093f4SDimitry Andric
2170b57cec5SDimitry Andric CommandArgumentEntry arg;
2180b57cec5SDimitry Andric CommandArgumentData bp_id_arg;
2190b57cec5SDimitry Andric
2200b57cec5SDimitry Andric // Define the first (and only) variant of this arg.
2210b57cec5SDimitry Andric bp_id_arg.arg_type = eArgTypeBreakpointID;
2220b57cec5SDimitry Andric bp_id_arg.arg_repetition = eArgRepeatOptional;
2230b57cec5SDimitry Andric
2240b57cec5SDimitry Andric // There is only one variant this argument could be; put it into the
2250b57cec5SDimitry Andric // argument entry.
2260b57cec5SDimitry Andric arg.push_back(bp_id_arg);
2270b57cec5SDimitry Andric
2280b57cec5SDimitry Andric // Push the data for the first argument into the m_arguments vector.
2290b57cec5SDimitry Andric m_arguments.push_back(arg);
2300b57cec5SDimitry Andric }
2310b57cec5SDimitry Andric
2320b57cec5SDimitry Andric ~CommandObjectBreakpointCommandAdd() override = default;
2330b57cec5SDimitry Andric
GetOptions()234480093f4SDimitry Andric Options *GetOptions() override { return &m_all_options; }
2350b57cec5SDimitry Andric
IOHandlerActivated(IOHandler & io_handler,bool interactive)2360b57cec5SDimitry Andric void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
2379dba64beSDimitry Andric StreamFileSP output_sp(io_handler.GetOutputStreamFileSP());
2380b57cec5SDimitry Andric if (output_sp && interactive) {
2390b57cec5SDimitry Andric output_sp->PutCString(g_reader_instructions);
2400b57cec5SDimitry Andric output_sp->Flush();
2410b57cec5SDimitry Andric }
2420b57cec5SDimitry Andric }
2430b57cec5SDimitry Andric
IOHandlerInputComplete(IOHandler & io_handler,std::string & line)2440b57cec5SDimitry Andric void IOHandlerInputComplete(IOHandler &io_handler,
2450b57cec5SDimitry Andric std::string &line) override {
2460b57cec5SDimitry Andric io_handler.SetIsDone(true);
2470b57cec5SDimitry Andric
248*5f7ddb14SDimitry Andric std::vector<std::reference_wrapper<BreakpointOptions>> *bp_options_vec =
249*5f7ddb14SDimitry Andric (std::vector<std::reference_wrapper<BreakpointOptions>> *)
250*5f7ddb14SDimitry Andric io_handler.GetUserData();
251*5f7ddb14SDimitry Andric for (BreakpointOptions &bp_options : *bp_options_vec) {
2529dba64beSDimitry Andric auto cmd_data = std::make_unique<BreakpointOptions::CommandData>();
2530b57cec5SDimitry Andric cmd_data->user_source.SplitIntoLines(line.c_str(), line.size());
254*5f7ddb14SDimitry Andric bp_options.SetCommandDataCallback(cmd_data);
2550b57cec5SDimitry Andric }
2560b57cec5SDimitry Andric }
2570b57cec5SDimitry Andric
CollectDataForBreakpointCommandCallback(std::vector<std::reference_wrapper<BreakpointOptions>> & bp_options_vec,CommandReturnObject & result)2580b57cec5SDimitry Andric void CollectDataForBreakpointCommandCallback(
259*5f7ddb14SDimitry Andric std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
2600b57cec5SDimitry Andric CommandReturnObject &result) {
2610b57cec5SDimitry Andric m_interpreter.GetLLDBCommandsFromIOHandler(
2620b57cec5SDimitry Andric "> ", // Prompt
2630b57cec5SDimitry Andric *this, // IOHandlerDelegate
2640b57cec5SDimitry Andric &bp_options_vec); // Baton for the "io_handler" that will be passed back
2650b57cec5SDimitry Andric // into our IOHandlerDelegate functions
2660b57cec5SDimitry Andric }
2670b57cec5SDimitry Andric
2680b57cec5SDimitry Andric /// Set a one-liner as the callback for the breakpoint.
SetBreakpointCommandCallback(std::vector<std::reference_wrapper<BreakpointOptions>> & bp_options_vec,const char * oneliner)269*5f7ddb14SDimitry Andric void SetBreakpointCommandCallback(
270*5f7ddb14SDimitry Andric std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
2710b57cec5SDimitry Andric const char *oneliner) {
272*5f7ddb14SDimitry Andric for (BreakpointOptions &bp_options : bp_options_vec) {
2739dba64beSDimitry Andric auto cmd_data = std::make_unique<BreakpointOptions::CommandData>();
2740b57cec5SDimitry Andric
2750b57cec5SDimitry Andric cmd_data->user_source.AppendString(oneliner);
2760b57cec5SDimitry Andric cmd_data->stop_on_error = m_options.m_stop_on_error;
2770b57cec5SDimitry Andric
278*5f7ddb14SDimitry Andric bp_options.SetCommandDataCallback(cmd_data);
2790b57cec5SDimitry Andric }
2800b57cec5SDimitry Andric }
2810b57cec5SDimitry Andric
282480093f4SDimitry Andric class CommandOptions : public OptionGroup {
2830b57cec5SDimitry Andric public:
CommandOptions()284*5f7ddb14SDimitry Andric CommandOptions() : OptionGroup(), m_one_liner() {}
2850b57cec5SDimitry Andric
2860b57cec5SDimitry Andric ~CommandOptions() override = default;
2870b57cec5SDimitry Andric
SetOptionValue(uint32_t option_idx,llvm::StringRef option_arg,ExecutionContext * execution_context)2880b57cec5SDimitry Andric Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2890b57cec5SDimitry Andric ExecutionContext *execution_context) override {
2900b57cec5SDimitry Andric Status error;
291480093f4SDimitry Andric const int short_option =
292480093f4SDimitry Andric g_breakpoint_command_add_options[option_idx].short_option;
2930b57cec5SDimitry Andric
2940b57cec5SDimitry Andric switch (short_option) {
2950b57cec5SDimitry Andric case 'o':
2960b57cec5SDimitry Andric m_use_one_liner = true;
2975ffd83dbSDimitry Andric m_one_liner = std::string(option_arg);
2980b57cec5SDimitry Andric break;
2990b57cec5SDimitry Andric
3000b57cec5SDimitry Andric case 's':
3010b57cec5SDimitry Andric m_script_language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum(
3029dba64beSDimitry Andric option_arg,
3039dba64beSDimitry Andric g_breakpoint_command_add_options[option_idx].enum_values,
3040b57cec5SDimitry Andric eScriptLanguageNone, error);
305480093f4SDimitry Andric switch (m_script_language) {
306480093f4SDimitry Andric case eScriptLanguagePython:
307480093f4SDimitry Andric case eScriptLanguageLua:
3080b57cec5SDimitry Andric m_use_script_language = true;
309480093f4SDimitry Andric break;
310480093f4SDimitry Andric case eScriptLanguageNone:
311480093f4SDimitry Andric case eScriptLanguageUnknown:
3120b57cec5SDimitry Andric m_use_script_language = false;
313480093f4SDimitry Andric break;
3140b57cec5SDimitry Andric }
3150b57cec5SDimitry Andric break;
3160b57cec5SDimitry Andric
3170b57cec5SDimitry Andric case 'e': {
3180b57cec5SDimitry Andric bool success = false;
3190b57cec5SDimitry Andric m_stop_on_error =
3200b57cec5SDimitry Andric OptionArgParser::ToBoolean(option_arg, false, &success);
3210b57cec5SDimitry Andric if (!success)
3220b57cec5SDimitry Andric error.SetErrorStringWithFormat(
3230b57cec5SDimitry Andric "invalid value for stop-on-error: \"%s\"",
3240b57cec5SDimitry Andric option_arg.str().c_str());
3250b57cec5SDimitry Andric } break;
3260b57cec5SDimitry Andric
3270b57cec5SDimitry Andric case 'D':
3280b57cec5SDimitry Andric m_use_dummy = true;
3290b57cec5SDimitry Andric break;
3300b57cec5SDimitry Andric
3310b57cec5SDimitry Andric default:
3329dba64beSDimitry Andric llvm_unreachable("Unimplemented option");
3330b57cec5SDimitry Andric }
3340b57cec5SDimitry Andric return error;
3350b57cec5SDimitry Andric }
3360b57cec5SDimitry Andric
OptionParsingStarting(ExecutionContext * execution_context)3370b57cec5SDimitry Andric void OptionParsingStarting(ExecutionContext *execution_context) override {
3380b57cec5SDimitry Andric m_use_commands = true;
3390b57cec5SDimitry Andric m_use_script_language = false;
3400b57cec5SDimitry Andric m_script_language = eScriptLanguageNone;
3410b57cec5SDimitry Andric
3420b57cec5SDimitry Andric m_use_one_liner = false;
3430b57cec5SDimitry Andric m_stop_on_error = true;
3440b57cec5SDimitry Andric m_one_liner.clear();
3450b57cec5SDimitry Andric m_use_dummy = false;
3460b57cec5SDimitry Andric }
3470b57cec5SDimitry Andric
GetDefinitions()3480b57cec5SDimitry Andric llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
3499dba64beSDimitry Andric return llvm::makeArrayRef(g_breakpoint_command_add_options);
3500b57cec5SDimitry Andric }
3510b57cec5SDimitry Andric
3520b57cec5SDimitry Andric // Instance variables to hold the values for command options.
3530b57cec5SDimitry Andric
354*5f7ddb14SDimitry Andric bool m_use_commands = false;
355*5f7ddb14SDimitry Andric bool m_use_script_language = false;
356*5f7ddb14SDimitry Andric lldb::ScriptLanguage m_script_language = eScriptLanguageNone;
3570b57cec5SDimitry Andric
3580b57cec5SDimitry Andric // Instance variables to hold the values for one_liner options.
359*5f7ddb14SDimitry Andric bool m_use_one_liner = false;
3600b57cec5SDimitry Andric std::string m_one_liner;
3610b57cec5SDimitry Andric bool m_stop_on_error;
3620b57cec5SDimitry Andric bool m_use_dummy;
3630b57cec5SDimitry Andric };
3640b57cec5SDimitry Andric
3650b57cec5SDimitry Andric protected:
DoExecute(Args & command,CommandReturnObject & result)3660b57cec5SDimitry Andric bool DoExecute(Args &command, CommandReturnObject &result) override {
3679dba64beSDimitry Andric Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
3680b57cec5SDimitry Andric
3699dba64beSDimitry Andric const BreakpointList &breakpoints = target.GetBreakpointList();
3700b57cec5SDimitry Andric size_t num_breakpoints = breakpoints.GetSize();
3710b57cec5SDimitry Andric
3720b57cec5SDimitry Andric if (num_breakpoints == 0) {
3730b57cec5SDimitry Andric result.AppendError("No breakpoints exist to have commands added");
3740b57cec5SDimitry Andric return false;
3750b57cec5SDimitry Andric }
3760b57cec5SDimitry Andric
377480093f4SDimitry Andric if (!m_func_options.GetName().empty()) {
378480093f4SDimitry Andric m_options.m_use_one_liner = false;
379480093f4SDimitry Andric if (!m_options.m_use_script_language) {
380480093f4SDimitry Andric m_options.m_script_language = GetDebugger().GetScriptLanguage();
381480093f4SDimitry Andric m_options.m_use_script_language = true;
382480093f4SDimitry Andric }
3830b57cec5SDimitry Andric }
3840b57cec5SDimitry Andric
3850b57cec5SDimitry Andric BreakpointIDList valid_bp_ids;
3860b57cec5SDimitry Andric CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
3879dba64beSDimitry Andric command, &target, result, &valid_bp_ids,
3880b57cec5SDimitry Andric BreakpointName::Permissions::PermissionKinds::listPerm);
3890b57cec5SDimitry Andric
3900b57cec5SDimitry Andric m_bp_options_vec.clear();
3910b57cec5SDimitry Andric
3920b57cec5SDimitry Andric if (result.Succeeded()) {
3930b57cec5SDimitry Andric const size_t count = valid_bp_ids.GetSize();
3940b57cec5SDimitry Andric
3950b57cec5SDimitry Andric for (size_t i = 0; i < count; ++i) {
3960b57cec5SDimitry Andric BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
3970b57cec5SDimitry Andric if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
3980b57cec5SDimitry Andric Breakpoint *bp =
3999dba64beSDimitry Andric target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
4000b57cec5SDimitry Andric if (cur_bp_id.GetLocationID() == LLDB_INVALID_BREAK_ID) {
4010b57cec5SDimitry Andric // This breakpoint does not have an associated location.
402*5f7ddb14SDimitry Andric m_bp_options_vec.push_back(bp->GetOptions());
4030b57cec5SDimitry Andric } else {
4040b57cec5SDimitry Andric BreakpointLocationSP bp_loc_sp(
4050b57cec5SDimitry Andric bp->FindLocationByID(cur_bp_id.GetLocationID()));
4060b57cec5SDimitry Andric // This breakpoint does have an associated location. Get its
4070b57cec5SDimitry Andric // breakpoint options.
4080b57cec5SDimitry Andric if (bp_loc_sp)
409*5f7ddb14SDimitry Andric m_bp_options_vec.push_back(bp_loc_sp->GetLocationOptions());
4100b57cec5SDimitry Andric }
4110b57cec5SDimitry Andric }
4120b57cec5SDimitry Andric }
4130b57cec5SDimitry Andric
4140b57cec5SDimitry Andric // If we are using script language, get the script interpreter in order
4150b57cec5SDimitry Andric // to set or collect command callback. Otherwise, call the methods
4160b57cec5SDimitry Andric // associated with this object.
4170b57cec5SDimitry Andric if (m_options.m_use_script_language) {
418af732203SDimitry Andric Status error;
419480093f4SDimitry Andric ScriptInterpreter *script_interp = GetDebugger().GetScriptInterpreter(
420480093f4SDimitry Andric /*can_create=*/true, m_options.m_script_language);
4210b57cec5SDimitry Andric // Special handling for one-liner specified inline.
4220b57cec5SDimitry Andric if (m_options.m_use_one_liner) {
423af732203SDimitry Andric error = script_interp->SetBreakpointCommandCallback(
4240b57cec5SDimitry Andric m_bp_options_vec, m_options.m_one_liner.c_str());
425480093f4SDimitry Andric } else if (!m_func_options.GetName().empty()) {
426af732203SDimitry Andric error = script_interp->SetBreakpointCommandCallbackFunction(
427480093f4SDimitry Andric m_bp_options_vec, m_func_options.GetName().c_str(),
428480093f4SDimitry Andric m_func_options.GetStructuredData());
4290b57cec5SDimitry Andric } else {
4300b57cec5SDimitry Andric script_interp->CollectDataForBreakpointCommandCallback(
4310b57cec5SDimitry Andric m_bp_options_vec, result);
4320b57cec5SDimitry Andric }
433af732203SDimitry Andric if (!error.Success())
434af732203SDimitry Andric result.SetError(error);
4350b57cec5SDimitry Andric } else {
4360b57cec5SDimitry Andric // Special handling for one-liner specified inline.
4370b57cec5SDimitry Andric if (m_options.m_use_one_liner)
4380b57cec5SDimitry Andric SetBreakpointCommandCallback(m_bp_options_vec,
4390b57cec5SDimitry Andric m_options.m_one_liner.c_str());
4400b57cec5SDimitry Andric else
4410b57cec5SDimitry Andric CollectDataForBreakpointCommandCallback(m_bp_options_vec, result);
4420b57cec5SDimitry Andric }
4430b57cec5SDimitry Andric }
4440b57cec5SDimitry Andric
4450b57cec5SDimitry Andric return result.Succeeded();
4460b57cec5SDimitry Andric }
4470b57cec5SDimitry Andric
4480b57cec5SDimitry Andric private:
4490b57cec5SDimitry Andric CommandOptions m_options;
450480093f4SDimitry Andric OptionGroupPythonClassWithDict m_func_options;
451480093f4SDimitry Andric OptionGroupOptions m_all_options;
452480093f4SDimitry Andric
453*5f7ddb14SDimitry Andric std::vector<std::reference_wrapper<BreakpointOptions>>
454*5f7ddb14SDimitry Andric m_bp_options_vec; // This stores the
4550b57cec5SDimitry Andric // breakpoint options that
4560b57cec5SDimitry Andric // we are currently
4570b57cec5SDimitry Andric // collecting commands for. In the CollectData... calls we need to hand this
4580b57cec5SDimitry Andric // off to the IOHandler, which may run asynchronously. So we have to have
4590b57cec5SDimitry Andric // some way to keep it alive, and not leak it. Making it an ivar of the
4600b57cec5SDimitry Andric // command object, which never goes away achieves this. Note that if we were
4610b57cec5SDimitry Andric // able to run the same command concurrently in one interpreter we'd have to
4620b57cec5SDimitry Andric // make this "per invocation". But there are many more reasons why it is not
4630b57cec5SDimitry Andric // in general safe to do that in lldb at present, so it isn't worthwhile to
4640b57cec5SDimitry Andric // come up with a more complex mechanism to address this particular weakness
4650b57cec5SDimitry Andric // right now.
4660b57cec5SDimitry Andric static const char *g_reader_instructions;
4670b57cec5SDimitry Andric };
4680b57cec5SDimitry Andric
4690b57cec5SDimitry Andric const char *CommandObjectBreakpointCommandAdd::g_reader_instructions =
4700b57cec5SDimitry Andric "Enter your debugger command(s). Type 'DONE' to end.\n";
4710b57cec5SDimitry Andric
4720b57cec5SDimitry Andric // CommandObjectBreakpointCommandDelete
4730b57cec5SDimitry Andric
4749dba64beSDimitry Andric #define LLDB_OPTIONS_breakpoint_command_delete
4759dba64beSDimitry Andric #include "CommandOptions.inc"
4760b57cec5SDimitry Andric
4770b57cec5SDimitry Andric class CommandObjectBreakpointCommandDelete : public CommandObjectParsed {
4780b57cec5SDimitry Andric public:
CommandObjectBreakpointCommandDelete(CommandInterpreter & interpreter)4790b57cec5SDimitry Andric CommandObjectBreakpointCommandDelete(CommandInterpreter &interpreter)
4800b57cec5SDimitry Andric : CommandObjectParsed(interpreter, "delete",
4810b57cec5SDimitry Andric "Delete the set of commands from a breakpoint.",
4820b57cec5SDimitry Andric nullptr),
4830b57cec5SDimitry Andric m_options() {
4840b57cec5SDimitry Andric CommandArgumentEntry arg;
4850b57cec5SDimitry Andric CommandArgumentData bp_id_arg;
4860b57cec5SDimitry Andric
4870b57cec5SDimitry Andric // Define the first (and only) variant of this arg.
4880b57cec5SDimitry Andric bp_id_arg.arg_type = eArgTypeBreakpointID;
4890b57cec5SDimitry Andric bp_id_arg.arg_repetition = eArgRepeatPlain;
4900b57cec5SDimitry Andric
4910b57cec5SDimitry Andric // There is only one variant this argument could be; put it into the
4920b57cec5SDimitry Andric // argument entry.
4930b57cec5SDimitry Andric arg.push_back(bp_id_arg);
4940b57cec5SDimitry Andric
4950b57cec5SDimitry Andric // Push the data for the first argument into the m_arguments vector.
4960b57cec5SDimitry Andric m_arguments.push_back(arg);
4970b57cec5SDimitry Andric }
4980b57cec5SDimitry Andric
4990b57cec5SDimitry Andric ~CommandObjectBreakpointCommandDelete() override = default;
5000b57cec5SDimitry Andric
GetOptions()5010b57cec5SDimitry Andric Options *GetOptions() override { return &m_options; }
5020b57cec5SDimitry Andric
5030b57cec5SDimitry Andric class CommandOptions : public Options {
5040b57cec5SDimitry Andric public:
CommandOptions()505*5f7ddb14SDimitry Andric CommandOptions() : Options() {}
5060b57cec5SDimitry Andric
5070b57cec5SDimitry Andric ~CommandOptions() override = default;
5080b57cec5SDimitry Andric
SetOptionValue(uint32_t option_idx,llvm::StringRef option_arg,ExecutionContext * execution_context)5090b57cec5SDimitry Andric Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
5100b57cec5SDimitry Andric ExecutionContext *execution_context) override {
5110b57cec5SDimitry Andric Status error;
5120b57cec5SDimitry Andric const int short_option = m_getopt_table[option_idx].val;
5130b57cec5SDimitry Andric
5140b57cec5SDimitry Andric switch (short_option) {
5150b57cec5SDimitry Andric case 'D':
5160b57cec5SDimitry Andric m_use_dummy = true;
5170b57cec5SDimitry Andric break;
5180b57cec5SDimitry Andric
5190b57cec5SDimitry Andric default:
5209dba64beSDimitry Andric llvm_unreachable("Unimplemented option");
5210b57cec5SDimitry Andric }
5220b57cec5SDimitry Andric
5230b57cec5SDimitry Andric return error;
5240b57cec5SDimitry Andric }
5250b57cec5SDimitry Andric
OptionParsingStarting(ExecutionContext * execution_context)5260b57cec5SDimitry Andric void OptionParsingStarting(ExecutionContext *execution_context) override {
5270b57cec5SDimitry Andric m_use_dummy = false;
5280b57cec5SDimitry Andric }
5290b57cec5SDimitry Andric
GetDefinitions()5300b57cec5SDimitry Andric llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
5319dba64beSDimitry Andric return llvm::makeArrayRef(g_breakpoint_command_delete_options);
5320b57cec5SDimitry Andric }
5330b57cec5SDimitry Andric
5340b57cec5SDimitry Andric // Instance variables to hold the values for command options.
535*5f7ddb14SDimitry Andric bool m_use_dummy = false;
5360b57cec5SDimitry Andric };
5370b57cec5SDimitry Andric
5380b57cec5SDimitry Andric protected:
DoExecute(Args & command,CommandReturnObject & result)5390b57cec5SDimitry Andric bool DoExecute(Args &command, CommandReturnObject &result) override {
5409dba64beSDimitry Andric Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
5410b57cec5SDimitry Andric
5429dba64beSDimitry Andric const BreakpointList &breakpoints = target.GetBreakpointList();
5430b57cec5SDimitry Andric size_t num_breakpoints = breakpoints.GetSize();
5440b57cec5SDimitry Andric
5450b57cec5SDimitry Andric if (num_breakpoints == 0) {
5460b57cec5SDimitry Andric result.AppendError("No breakpoints exist to have commands deleted");
5470b57cec5SDimitry Andric return false;
5480b57cec5SDimitry Andric }
5490b57cec5SDimitry Andric
5500b57cec5SDimitry Andric if (command.empty()) {
5510b57cec5SDimitry Andric result.AppendError(
5520b57cec5SDimitry Andric "No breakpoint specified from which to delete the commands");
5530b57cec5SDimitry Andric return false;
5540b57cec5SDimitry Andric }
5550b57cec5SDimitry Andric
5560b57cec5SDimitry Andric BreakpointIDList valid_bp_ids;
5570b57cec5SDimitry Andric CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
5589dba64beSDimitry Andric command, &target, result, &valid_bp_ids,
5590b57cec5SDimitry Andric BreakpointName::Permissions::PermissionKinds::listPerm);
5600b57cec5SDimitry Andric
5610b57cec5SDimitry Andric if (result.Succeeded()) {
5620b57cec5SDimitry Andric const size_t count = valid_bp_ids.GetSize();
5630b57cec5SDimitry Andric for (size_t i = 0; i < count; ++i) {
5640b57cec5SDimitry Andric BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
5650b57cec5SDimitry Andric if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
5660b57cec5SDimitry Andric Breakpoint *bp =
5679dba64beSDimitry Andric target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
5680b57cec5SDimitry Andric if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
5690b57cec5SDimitry Andric BreakpointLocationSP bp_loc_sp(
5700b57cec5SDimitry Andric bp->FindLocationByID(cur_bp_id.GetLocationID()));
5710b57cec5SDimitry Andric if (bp_loc_sp)
5720b57cec5SDimitry Andric bp_loc_sp->ClearCallback();
5730b57cec5SDimitry Andric else {
5740b57cec5SDimitry Andric result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n",
5750b57cec5SDimitry Andric cur_bp_id.GetBreakpointID(),
5760b57cec5SDimitry Andric cur_bp_id.GetLocationID());
5770b57cec5SDimitry Andric return false;
5780b57cec5SDimitry Andric }
5790b57cec5SDimitry Andric } else {
5800b57cec5SDimitry Andric bp->ClearCallback();
5810b57cec5SDimitry Andric }
5820b57cec5SDimitry Andric }
5830b57cec5SDimitry Andric }
5840b57cec5SDimitry Andric }
5850b57cec5SDimitry Andric return result.Succeeded();
5860b57cec5SDimitry Andric }
5870b57cec5SDimitry Andric
5880b57cec5SDimitry Andric private:
5890b57cec5SDimitry Andric CommandOptions m_options;
5900b57cec5SDimitry Andric };
5910b57cec5SDimitry Andric
5920b57cec5SDimitry Andric // CommandObjectBreakpointCommandList
5930b57cec5SDimitry Andric
5940b57cec5SDimitry Andric class CommandObjectBreakpointCommandList : public CommandObjectParsed {
5950b57cec5SDimitry Andric public:
CommandObjectBreakpointCommandList(CommandInterpreter & interpreter)5960b57cec5SDimitry Andric CommandObjectBreakpointCommandList(CommandInterpreter &interpreter)
5979dba64beSDimitry Andric : CommandObjectParsed(interpreter, "list",
5989dba64beSDimitry Andric "List the script or set of commands to be "
5999dba64beSDimitry Andric "executed when the breakpoint is hit.",
6009dba64beSDimitry Andric nullptr, eCommandRequiresTarget) {
6010b57cec5SDimitry Andric CommandArgumentEntry arg;
6020b57cec5SDimitry Andric CommandArgumentData bp_id_arg;
6030b57cec5SDimitry Andric
6040b57cec5SDimitry Andric // Define the first (and only) variant of this arg.
6050b57cec5SDimitry Andric bp_id_arg.arg_type = eArgTypeBreakpointID;
6060b57cec5SDimitry Andric bp_id_arg.arg_repetition = eArgRepeatPlain;
6070b57cec5SDimitry Andric
6080b57cec5SDimitry Andric // There is only one variant this argument could be; put it into the
6090b57cec5SDimitry Andric // argument entry.
6100b57cec5SDimitry Andric arg.push_back(bp_id_arg);
6110b57cec5SDimitry Andric
6120b57cec5SDimitry Andric // Push the data for the first argument into the m_arguments vector.
6130b57cec5SDimitry Andric m_arguments.push_back(arg);
6140b57cec5SDimitry Andric }
6150b57cec5SDimitry Andric
6160b57cec5SDimitry Andric ~CommandObjectBreakpointCommandList() override = default;
6170b57cec5SDimitry Andric
6180b57cec5SDimitry Andric protected:
DoExecute(Args & command,CommandReturnObject & result)6190b57cec5SDimitry Andric bool DoExecute(Args &command, CommandReturnObject &result) override {
6209dba64beSDimitry Andric Target *target = &GetSelectedTarget();
6210b57cec5SDimitry Andric
6220b57cec5SDimitry Andric const BreakpointList &breakpoints = target->GetBreakpointList();
6230b57cec5SDimitry Andric size_t num_breakpoints = breakpoints.GetSize();
6240b57cec5SDimitry Andric
6250b57cec5SDimitry Andric if (num_breakpoints == 0) {
6260b57cec5SDimitry Andric result.AppendError("No breakpoints exist for which to list commands");
6270b57cec5SDimitry Andric return false;
6280b57cec5SDimitry Andric }
6290b57cec5SDimitry Andric
6300b57cec5SDimitry Andric if (command.empty()) {
6310b57cec5SDimitry Andric result.AppendError(
6320b57cec5SDimitry Andric "No breakpoint specified for which to list the commands");
6330b57cec5SDimitry Andric return false;
6340b57cec5SDimitry Andric }
6350b57cec5SDimitry Andric
6360b57cec5SDimitry Andric BreakpointIDList valid_bp_ids;
6370b57cec5SDimitry Andric CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
6380b57cec5SDimitry Andric command, target, result, &valid_bp_ids,
6390b57cec5SDimitry Andric BreakpointName::Permissions::PermissionKinds::listPerm);
6400b57cec5SDimitry Andric
6410b57cec5SDimitry Andric if (result.Succeeded()) {
6420b57cec5SDimitry Andric const size_t count = valid_bp_ids.GetSize();
6430b57cec5SDimitry Andric for (size_t i = 0; i < count; ++i) {
6440b57cec5SDimitry Andric BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
6450b57cec5SDimitry Andric if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
6460b57cec5SDimitry Andric Breakpoint *bp =
6470b57cec5SDimitry Andric target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
6480b57cec5SDimitry Andric
6490b57cec5SDimitry Andric if (bp) {
6500b57cec5SDimitry Andric BreakpointLocationSP bp_loc_sp;
6510b57cec5SDimitry Andric if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
6520b57cec5SDimitry Andric bp_loc_sp = bp->FindLocationByID(cur_bp_id.GetLocationID());
653480093f4SDimitry Andric if (!bp_loc_sp) {
6540b57cec5SDimitry Andric result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n",
6550b57cec5SDimitry Andric cur_bp_id.GetBreakpointID(),
6560b57cec5SDimitry Andric cur_bp_id.GetLocationID());
6570b57cec5SDimitry Andric return false;
6580b57cec5SDimitry Andric }
6590b57cec5SDimitry Andric }
6600b57cec5SDimitry Andric
6610b57cec5SDimitry Andric StreamString id_str;
6620b57cec5SDimitry Andric BreakpointID::GetCanonicalReference(&id_str,
6630b57cec5SDimitry Andric cur_bp_id.GetBreakpointID(),
6640b57cec5SDimitry Andric cur_bp_id.GetLocationID());
6650b57cec5SDimitry Andric const Baton *baton = nullptr;
6660b57cec5SDimitry Andric if (bp_loc_sp)
667480093f4SDimitry Andric baton =
668480093f4SDimitry Andric bp_loc_sp
6690b57cec5SDimitry Andric ->GetOptionsSpecifyingKind(BreakpointOptions::eCallback)
670*5f7ddb14SDimitry Andric .GetBaton();
6710b57cec5SDimitry Andric else
672*5f7ddb14SDimitry Andric baton = bp->GetOptions().GetBaton();
6730b57cec5SDimitry Andric
6740b57cec5SDimitry Andric if (baton) {
6750b57cec5SDimitry Andric result.GetOutputStream().Printf("Breakpoint %s:\n",
6760b57cec5SDimitry Andric id_str.GetData());
677480093f4SDimitry Andric baton->GetDescription(result.GetOutputStream().AsRawOstream(),
678480093f4SDimitry Andric eDescriptionLevelFull,
679480093f4SDimitry Andric result.GetOutputStream().GetIndentLevel() +
680480093f4SDimitry Andric 2);
6810b57cec5SDimitry Andric } else {
6820b57cec5SDimitry Andric result.AppendMessageWithFormat(
6830b57cec5SDimitry Andric "Breakpoint %s does not have an associated command.\n",
6840b57cec5SDimitry Andric id_str.GetData());
6850b57cec5SDimitry Andric }
6860b57cec5SDimitry Andric }
6870b57cec5SDimitry Andric result.SetStatus(eReturnStatusSuccessFinishResult);
6880b57cec5SDimitry Andric } else {
6890b57cec5SDimitry Andric result.AppendErrorWithFormat("Invalid breakpoint ID: %u.\n",
6900b57cec5SDimitry Andric cur_bp_id.GetBreakpointID());
6910b57cec5SDimitry Andric }
6920b57cec5SDimitry Andric }
6930b57cec5SDimitry Andric }
6940b57cec5SDimitry Andric
6950b57cec5SDimitry Andric return result.Succeeded();
6960b57cec5SDimitry Andric }
6970b57cec5SDimitry Andric };
6980b57cec5SDimitry Andric
6990b57cec5SDimitry Andric // CommandObjectBreakpointCommand
7000b57cec5SDimitry Andric
CommandObjectBreakpointCommand(CommandInterpreter & interpreter)7010b57cec5SDimitry Andric CommandObjectBreakpointCommand::CommandObjectBreakpointCommand(
7020b57cec5SDimitry Andric CommandInterpreter &interpreter)
7030b57cec5SDimitry Andric : CommandObjectMultiword(
704480093f4SDimitry Andric interpreter, "command",
705480093f4SDimitry Andric "Commands for adding, removing and listing "
7060b57cec5SDimitry Andric "LLDB commands executed when a breakpoint is "
7070b57cec5SDimitry Andric "hit.",
7080b57cec5SDimitry Andric "command <sub-command> [<sub-command-options>] <breakpoint-id>") {
7090b57cec5SDimitry Andric CommandObjectSP add_command_object(
7100b57cec5SDimitry Andric new CommandObjectBreakpointCommandAdd(interpreter));
7110b57cec5SDimitry Andric CommandObjectSP delete_command_object(
7120b57cec5SDimitry Andric new CommandObjectBreakpointCommandDelete(interpreter));
7130b57cec5SDimitry Andric CommandObjectSP list_command_object(
7140b57cec5SDimitry Andric new CommandObjectBreakpointCommandList(interpreter));
7150b57cec5SDimitry Andric
7160b57cec5SDimitry Andric add_command_object->SetCommandName("breakpoint command add");
7170b57cec5SDimitry Andric delete_command_object->SetCommandName("breakpoint command delete");
7180b57cec5SDimitry Andric list_command_object->SetCommandName("breakpoint command list");
7190b57cec5SDimitry Andric
7200b57cec5SDimitry Andric LoadSubCommand("add", add_command_object);
7210b57cec5SDimitry Andric LoadSubCommand("delete", delete_command_object);
7220b57cec5SDimitry Andric LoadSubCommand("list", list_command_object);
7230b57cec5SDimitry Andric }
7240b57cec5SDimitry Andric
7250b57cec5SDimitry Andric CommandObjectBreakpointCommand::~CommandObjectBreakpointCommand() = default;
726