aboutsummaryrefslogtreecommitdiffstats
path: root/source/Commands/CommandObjectBreakpointCommand.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Commands/CommandObjectBreakpointCommand.cpp')
-rw-r--r--source/Commands/CommandObjectBreakpointCommand.cpp115
1 files changed, 45 insertions, 70 deletions
diff --git a/source/Commands/CommandObjectBreakpointCommand.cpp b/source/Commands/CommandObjectBreakpointCommand.cpp
index 3f9d83cd86a8..a6bcd1d8dc32 100644
--- a/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -26,33 +26,33 @@
using namespace lldb;
using namespace lldb_private;
-// CommandObjectBreakpointCommandAdd
-
// FIXME: "script-type" needs to have its contents determined dynamically, so
-// somebody can add a new scripting
-// language to lldb and have it pickable here without having to change this
-// enumeration by hand and rebuild lldb proper.
-
+// somebody can add a new scripting language to lldb and have it pickable here
+// without having to change this enumeration by hand and rebuild lldb proper.
static constexpr OptionEnumValueElement g_script_option_enumeration[] = {
- {eScriptLanguageNone, "command",
- "Commands are in the lldb command interpreter language"},
- {eScriptLanguagePython, "python", "Commands are in the Python language."},
- {eSortOrderByName, "default-script",
- "Commands are in the default scripting language."} };
+ {
+ eScriptLanguageNone,
+ "command",
+ "Commands are in the lldb command interpreter language",
+ },
+ {
+ eScriptLanguagePython,
+ "python",
+ "Commands are in the Python language.",
+ },
+ {
+ eSortOrderByName,
+ "default-script",
+ "Commands are in the default scripting language.",
+ },
+};
static constexpr OptionEnumValues ScriptOptionEnum() {
return OptionEnumValues(g_script_option_enumeration);
}
-static constexpr OptionDefinition g_breakpoint_add_options[] = {
- // clang-format off
- { 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." },
- { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Specify whether breakpoint command execution should terminate on error." },
- { 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." },
- { 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." },
- { 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." },
- // clang-format on
-};
+#define LLDB_OPTIONS_breakpoint_command_add
+#include "CommandOptions.inc"
class CommandObjectBreakpointCommandAdd : public CommandObjectParsed,
public IOHandlerDelegateMultiline {
@@ -221,7 +221,7 @@ are no syntax errors may indicate that a function was declared but never called.
Options *GetOptions() override { return &m_options; }
void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
- StreamFileSP output_sp(io_handler.GetOutputStreamFile());
+ StreamFileSP output_sp(io_handler.GetOutputStreamFileSP());
if (output_sp && interactive) {
output_sp->PutCString(g_reader_instructions);
output_sp->Flush();
@@ -238,7 +238,7 @@ are no syntax errors may indicate that a function was declared but never called.
if (!bp_options)
continue;
- auto cmd_data = llvm::make_unique<BreakpointOptions::CommandData>();
+ auto cmd_data = std::make_unique<BreakpointOptions::CommandData>();
cmd_data->user_source.SplitIntoLines(line.c_str(), line.size());
bp_options->SetCommandDataCallback(cmd_data);
}
@@ -260,7 +260,7 @@ are no syntax errors may indicate that a function was declared but never called.
SetBreakpointCommandCallback(std::vector<BreakpointOptions *> &bp_options_vec,
const char *oneliner) {
for (auto bp_options : bp_options_vec) {
- auto cmd_data = llvm::make_unique<BreakpointOptions::CommandData>();
+ auto cmd_data = std::make_unique<BreakpointOptions::CommandData>();
cmd_data->user_source.AppendString(oneliner);
cmd_data->stop_on_error = m_options.m_stop_on_error;
@@ -291,7 +291,8 @@ are no syntax errors may indicate that a function was declared but never called.
case 's':
m_script_language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum(
- option_arg, g_breakpoint_add_options[option_idx].enum_values,
+ option_arg,
+ g_breakpoint_command_add_options[option_idx].enum_values,
eScriptLanguageNone, error);
if (m_script_language == eScriptLanguagePython ||
@@ -323,7 +324,7 @@ are no syntax errors may indicate that a function was declared but never called.
break;
default:
- break;
+ llvm_unreachable("Unimplemented option");
}
return error;
}
@@ -341,7 +342,7 @@ are no syntax errors may indicate that a function was declared but never called.
}
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
- return llvm::makeArrayRef(g_breakpoint_add_options);
+ return llvm::makeArrayRef(g_breakpoint_command_add_options);
}
// Instance variables to hold the values for command options.
@@ -360,16 +361,9 @@ are no syntax errors may indicate that a function was declared but never called.
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
+ Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
- if (target == nullptr) {
- result.AppendError("There is not a current executable; there are no "
- "breakpoints to which to add commands");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
- const BreakpointList &breakpoints = target->GetBreakpointList();
+ const BreakpointList &breakpoints = target.GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
if (num_breakpoints == 0) {
@@ -388,7 +382,7 @@ protected:
BreakpointIDList valid_bp_ids;
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
- command, target, result, &valid_bp_ids,
+ command, &target, result, &valid_bp_ids,
BreakpointName::Permissions::PermissionKinds::listPerm);
m_bp_options_vec.clear();
@@ -400,7 +394,7 @@ protected:
BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
Breakpoint *bp =
- target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
+ target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
BreakpointOptions *bp_options = nullptr;
if (cur_bp_id.GetLocationID() == LLDB_INVALID_BREAK_ID) {
// This breakpoint does not have an associated location.
@@ -469,11 +463,8 @@ const char *CommandObjectBreakpointCommandAdd::g_reader_instructions =
// CommandObjectBreakpointCommandDelete
-static constexpr OptionDefinition g_breakpoint_delete_options[] = {
- // clang-format off
- { 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." },
- // clang-format on
-};
+#define LLDB_OPTIONS_breakpoint_command_delete
+#include "CommandOptions.inc"
class CommandObjectBreakpointCommandDelete : public CommandObjectParsed {
public:
@@ -518,9 +509,7 @@ public:
break;
default:
- error.SetErrorStringWithFormat("unrecognized option '%c'",
- short_option);
- break;
+ llvm_unreachable("Unimplemented option");
}
return error;
@@ -531,7 +520,7 @@ public:
}
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
- return llvm::makeArrayRef(g_breakpoint_delete_options);
+ return llvm::makeArrayRef(g_breakpoint_command_delete_options);
}
// Instance variables to hold the values for command options.
@@ -540,16 +529,9 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
-
- if (target == nullptr) {
- result.AppendError("There is not a current executable; there are no "
- "breakpoints from which to delete commands");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
- const BreakpointList &breakpoints = target->GetBreakpointList();
+ const BreakpointList &breakpoints = target.GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
if (num_breakpoints == 0) {
@@ -567,7 +549,7 @@ protected:
BreakpointIDList valid_bp_ids;
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
- command, target, result, &valid_bp_ids,
+ command, &target, result, &valid_bp_ids,
BreakpointName::Permissions::PermissionKinds::listPerm);
if (result.Succeeded()) {
@@ -576,7 +558,7 @@ protected:
BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
Breakpoint *bp =
- target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
+ target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
BreakpointLocationSP bp_loc_sp(
bp->FindLocationByID(cur_bp_id.GetLocationID()));
@@ -607,10 +589,10 @@ private:
class CommandObjectBreakpointCommandList : public CommandObjectParsed {
public:
CommandObjectBreakpointCommandList(CommandInterpreter &interpreter)
- : CommandObjectParsed(interpreter, "list", "List the script or set of "
- "commands to be executed when "
- "the breakpoint is hit.",
- nullptr) {
+ : CommandObjectParsed(interpreter, "list",
+ "List the script or set of commands to be "
+ "executed when the breakpoint is hit.",
+ nullptr, eCommandRequiresTarget) {
CommandArgumentEntry arg;
CommandArgumentData bp_id_arg;
@@ -630,14 +612,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = GetDebugger().GetSelectedTarget().get();
-
- if (target == nullptr) {
- result.AppendError("There is not a current executable; there are no "
- "breakpoints for which to list commands");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ Target *target = &GetSelectedTarget();
const BreakpointList &breakpoints = target->GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@@ -657,7 +632,7 @@ protected:
BreakpointIDList valid_bp_ids;
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
- command, target, result, &valid_bp_ids,
+ command, target, result, &valid_bp_ids,
BreakpointName::Permissions::PermissionKinds::listPerm);
if (result.Succeeded()) {