aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp578
1 files changed, 154 insertions, 424 deletions
diff --git a/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp b/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp
index c33f3834cb13..ad699975b507 100644
--- a/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -16,6 +16,7 @@
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
+#include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
#include "lldb/Interpreter/OptionValueBoolean.h"
#include "lldb/Interpreter/OptionValueString.h"
#include "lldb/Interpreter/OptionValueUInt64.h"
@@ -44,21 +45,9 @@ static void AddBreakpointDescription(Stream *s, Breakpoint *bp,
// Modifiable Breakpoint Options
#pragma mark Modify::CommandOptions
-static constexpr OptionDefinition g_breakpoint_modify_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "ignore-count", 'i', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." },
- { LLDB_OPT_SET_1, false, "one-shot", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "The breakpoint is deleted the first time it stop causes a stop." },
- { LLDB_OPT_SET_1, false, "thread-index", 'x', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose index matches this argument." },
- { LLDB_OPT_SET_1, false, "thread-id", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument." },
- { LLDB_OPT_SET_1, false, "thread-name", 'T', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument." },
- { LLDB_OPT_SET_1, false, "queue-name", 'q', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument." },
- { LLDB_OPT_SET_1, false, "condition", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true." },
- { LLDB_OPT_SET_1, false, "auto-continue",'G', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "The breakpoint will auto-continue after running its commands." },
- { LLDB_OPT_SET_2, false, "enable", 'e', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Enable the breakpoint." },
- { LLDB_OPT_SET_3, false, "disable", 'd', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Disable the breakpoint." },
- { LLDB_OPT_SET_4, false, "command", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCommand, "A command to run when the breakpoint is hit, can be provided more than once, the commands will get run in order left to right." },
- // clang-format on
-};
+#define LLDB_OPTIONS_breakpoint_modify
+#include "CommandOptions.inc"
+
class lldb_private::BreakpointOptionGroup : public OptionGroup
{
public:
@@ -153,9 +142,7 @@ public:
}
break;
default:
- error.SetErrorStringWithFormat("unrecognized option '%c'",
- short_option);
- break;
+ llvm_unreachable("Unimplemented option");
}
return error;
@@ -171,7 +158,7 @@ public:
{
if (!m_commands.empty())
{
- auto cmd_data = llvm::make_unique<BreakpointOptions::CommandData>();
+ auto cmd_data = std::make_unique<BreakpointOptions::CommandData>();
for (std::string &str : m_commands)
cmd_data->user_source.AppendString(str);
@@ -192,12 +179,9 @@ public:
BreakpointOptions m_bp_opts;
};
-static constexpr OptionDefinition g_breakpoint_dummy_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Act on Dummy breakpoints - i.e. breakpoints set before a file is provided, "
- "which prime new targets." },
- // clang-format on
-};
+
+#define LLDB_OPTIONS_breakpoint_dummy
+#include "CommandOptions.inc"
class BreakpointDummyOptionGroup : public OptionGroup
{
@@ -221,9 +205,7 @@ public:
m_use_dummy = true;
break;
default:
- error.SetErrorStringWithFormat("unrecognized option '%c'",
- short_option);
- break;
+ llvm_unreachable("Unimplemented option");
}
return error;
@@ -237,88 +219,8 @@ public:
};
-// If an additional option set beyond LLDB_OPTION_SET_10 is added, make sure to
-// update the numbers passed to LLDB_OPT_SET_FROM_TO(...) appropriately.
-#define LLDB_OPT_NOT_10 (LLDB_OPT_SET_FROM_TO(1, 11) & ~LLDB_OPT_SET_10)
-#define LLDB_OPT_SKIP_PROLOGUE (LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3, 8))
-#define LLDB_OPT_FILE (LLDB_OPT_SET_FROM_TO(1, 11) & ~LLDB_OPT_SET_2 & ~LLDB_OPT_SET_10)
-#define LLDB_OPT_OFFSET_APPLIES (LLDB_OPT_SET_FROM_TO(1, 8) & ~LLDB_OPT_SET_2)
-#define LLDB_OPT_MOVE_TO_NEAREST_CODE (LLDB_OPT_SET_1 | LLDB_OPT_SET_9)
-#define LLDB_OPT_EXPR_LANGUAGE (LLDB_OPT_SET_FROM_TO(3, 8))
-
-static constexpr OptionDefinition g_breakpoint_set_options[] = {
- // clang-format off
- { LLDB_OPT_NOT_10, false, "shlib", 's', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Set the breakpoint only in this shared library. Can repeat this option "
- "multiple times to specify multiple shared libraries." },
- { LLDB_OPT_SET_ALL, false, "hardware", 'H', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Require the breakpoint to use hardware breakpoints." },
- { LLDB_OPT_FILE, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "Specifies the source file in which to set this breakpoint. Note, by default "
- "lldb only looks for files that are #included if they use the standard include "
- "file extensions. To set breakpoints on .c/.cpp/.m/.mm files that are "
- "#included, set target.inline-breakpoint-strategy to \"always\"." },
- { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLineNum, "Specifies the line number on which to set this breakpoint." },
-
- // Comment out this option for the moment, as we don't actually use it, but
- // will in the future. This way users won't see it, but the infrastructure is
- // left in place.
- // { 0, false, "column", 'C', OptionParser::eRequiredArgument, nullptr, "<column>",
- // "Set the breakpoint by source location at this particular column."},
-
- { LLDB_OPT_SET_2, true, "address", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Set the breakpoint at the specified address. If the address maps uniquely to "
- "a particular binary, then the address will be converted to a \"file\" "
- "address, so that the breakpoint will track that binary+offset no matter where "
- "the binary eventually loads. Alternately, if you also specify the module - "
- "with the -s option - then the address will be treated as a file address in "
- "that module, and resolved accordingly. Again, this will allow lldb to track "
- "that offset on subsequent reloads. The module need not have been loaded at "
- "the time you specify this breakpoint, and will get resolved when the module "
- "is loaded." },
- { LLDB_OPT_SET_3, true, "name", 'n', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Set the breakpoint by function name. Can be repeated multiple times to make "
- "one breakpoint for multiple names" },
- { LLDB_OPT_SET_9, false, "source-regexp-function", 'X', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "When used with '-p' limits the source regex to source contained in the named "
- "functions. Can be repeated multiple times." },
- { LLDB_OPT_SET_4, true, "fullname", 'F', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSymbolCompletion, eArgTypeFullName, "Set the breakpoint by fully qualified function names. For C++ this means "
- "namespaces and all arguments, and for Objective-C this means a full function "
- "prototype with class and selector. Can be repeated multiple times to make "
- "one breakpoint for multiple names." },
- { LLDB_OPT_SET_5, true, "selector", 'S', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeSelector, "Set the breakpoint by ObjC selector name. Can be repeated multiple times to "
- "make one breakpoint for multiple Selectors." },
- { LLDB_OPT_SET_6, true, "method", 'M', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeMethod, "Set the breakpoint by C++ method names. Can be repeated multiple times to "
- "make one breakpoint for multiple methods." },
- { LLDB_OPT_SET_7, true, "func-regex", 'r', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeRegularExpression, "Set the breakpoint by function name, evaluating a regular-expression to find "
- "the function name(s)." },
- { LLDB_OPT_SET_8, true, "basename", 'b', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Set the breakpoint by function basename (C++ namespaces and arguments will be "
- "ignored). Can be repeated multiple times to make one breakpoint for multiple "
- "symbols." },
- { LLDB_OPT_SET_9, true, "source-pattern-regexp", 'p', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeRegularExpression, "Set the breakpoint by specifying a regular expression which is matched "
- "against the source text in a source file or files specified with the -f "
- "option. The -f option can be specified more than once. If no source files "
- "are specified, uses the current \"default source file\". If you want to "
- "match against all source files, pass the \"--all-files\" option." },
- { LLDB_OPT_SET_9, false, "all-files", 'A', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "All files are searched for source pattern matches." },
- { LLDB_OPT_SET_11, true, "python-class", 'P', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonClass, "The name of the class that implement a scripted breakpoint." },
- { LLDB_OPT_SET_11, false, "python-class-key", 'k', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNone, "The key for a key/value pair passed to the class that implements a scripted breakpoint. Can be specified more than once." },
- { LLDB_OPT_SET_11, false, "python-class-value", 'v', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNone, "The value for the previous key in the pair passed to the class that implements a scripted breakpoint. Can be specified more than once." },
- { LLDB_OPT_SET_10, true, "language-exception", 'E', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Set the breakpoint on exceptions thrown by the specified language (without "
- "options, on throw but not catch.)" },
- { LLDB_OPT_SET_10, false, "on-throw", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Set the breakpoint on exception throW." },
- { LLDB_OPT_SET_10, false, "on-catch", 'h', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Set the breakpoint on exception catcH." },
-
- // Don't add this option till it actually does something useful...
- // { LLDB_OPT_SET_10, false, "exception-typename", 'O', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeTypeName,
- // "The breakpoint will only stop if an exception Object of this type is thrown. Can be repeated multiple times to stop for multiple object types" },
-
- { LLDB_OPT_EXPR_LANGUAGE, false, "language", 'L', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Specifies the Language to use when interpreting the breakpoint's expression "
- "(note: currently only implemented for setting breakpoints on identifiers). "
- "If not set the target.language setting is used." },
- { LLDB_OPT_SKIP_PROLOGUE, false, "skip-prologue", 'K', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "sKip the prologue if the breakpoint is at the beginning of a function. "
- "If not set the target.skip-prologue setting is used." },
- { LLDB_OPT_SET_ALL, false, "breakpoint-name", 'N', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBreakpointName, "Adds this to the list of names for this breakpoint." },
- { LLDB_OPT_OFFSET_APPLIES, false, "address-slide", 'R', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddress, "Add the specified offset to whatever address(es) the breakpoint resolves to. "
- "At present this applies the offset directly as given, and doesn't try to align it to instruction boundaries." },
- { LLDB_OPT_MOVE_TO_NEAREST_CODE, false, "move-to-nearest-code", 'm', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Move breakpoints to nearest code. If not set the target.move-to-nearest-code "
- "setting is used." },
- // clang-format on
-};
+#define LLDB_OPTIONS_breakpoint_set
+#include "CommandOptions.inc"
// CommandObjectBreakpointSet
@@ -340,15 +242,18 @@ public:
interpreter, "breakpoint set",
"Sets a breakpoint or set of breakpoints in the executable.",
"breakpoint set <cmd-options>"),
- m_bp_opts(), m_options() {
- // We're picking up all the normal options, commands and disable.
- m_all_options.Append(&m_bp_opts,
- LLDB_OPT_SET_1 | LLDB_OPT_SET_3 | LLDB_OPT_SET_4,
- LLDB_OPT_SET_ALL);
- m_all_options.Append(&m_dummy_options, LLDB_OPT_SET_1, LLDB_OPT_SET_ALL);
- m_all_options.Append(&m_options);
- m_all_options.Finalize();
- }
+ m_bp_opts(), m_python_class_options("scripted breakpoint", 'P'),
+ m_options() {
+ // We're picking up all the normal options, commands and disable.
+ m_all_options.Append(&m_python_class_options, LLDB_OPT_SET_1,
+ LLDB_OPT_SET_11);
+ m_all_options.Append(&m_bp_opts,
+ LLDB_OPT_SET_1 | LLDB_OPT_SET_3 | LLDB_OPT_SET_4,
+ LLDB_OPT_SET_ALL);
+ m_all_options.Append(&m_dummy_options, LLDB_OPT_SET_1, LLDB_OPT_SET_ALL);
+ m_all_options.Append(&m_options);
+ m_all_options.Finalize();
+ }
~CommandObjectBreakpointSet() override = default;
@@ -451,14 +356,6 @@ public:
m_hardware = true;
break;
- case 'k': {
- if (m_current_key.empty())
- m_current_key.assign(option_arg);
- else
- error.SetErrorStringWithFormat("Key: %s missing value.",
- m_current_key.c_str());
-
- } break;
case 'K': {
bool success;
bool value;
@@ -540,10 +437,6 @@ public:
m_source_text_regexp.assign(option_arg);
break;
- case 'P':
- m_python_class.assign(option_arg);
- break;
-
case 'r':
m_func_regexp.assign(option_arg);
break;
@@ -557,16 +450,6 @@ public:
m_func_name_type_mask |= eFunctionNameTypeSelector;
break;
- case 'v': {
- if (!m_current_key.empty()) {
- m_extra_args_sp->AddStringItem(m_current_key, option_arg);
- m_current_key.clear();
- }
- else
- error.SetErrorStringWithFormat("Value \"%s\" missing matching key.",
- option_arg.str().c_str());
- } break;
-
case 'w': {
bool success;
m_throw_bp = OptionArgParser::ToBoolean(option_arg, true, &success);
@@ -581,9 +464,7 @@ public:
break;
default:
- error.SetErrorStringWithFormat("unrecognized option '%c'",
- short_option);
- break;
+ llvm_unreachable("Unimplemented option");
}
return error;
@@ -611,8 +492,6 @@ public:
m_exception_extra_args.Clear();
m_move_to_nearest_code = eLazyBoolCalculate;
m_source_regex_func_names.clear();
- m_python_class.clear();
- m_extra_args_sp = std::make_shared<StructuredData::Dictionary>();
m_current_key.clear();
}
@@ -644,21 +523,12 @@ public:
Args m_exception_extra_args;
LazyBool m_move_to_nearest_code;
std::unordered_set<std::string> m_source_regex_func_names;
- std::string m_python_class;
- StructuredData::DictionarySP m_extra_args_sp;
std::string m_current_key;
};
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = GetSelectedOrDummyTarget(m_dummy_options.m_use_dummy);
-
- if (target == nullptr) {
- result.AppendError("Invalid target. Must set target before setting "
- "breakpoints (see 'target create' command).");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ Target &target = GetSelectedOrDummyTarget(m_dummy_options.m_use_dummy);
// The following are the various types of breakpoints that could be set:
// 1). -f -l -p [-s -g] (setting breakpoint by source location)
@@ -673,7 +543,7 @@ protected:
BreakpointSetType break_type = eSetTypeInvalid;
- if (!m_options.m_python_class.empty())
+ if (!m_python_class_options.GetClassName().empty())
break_type = eSetTypeScripted;
else if (m_options.m_line_num != 0)
break_type = eSetTypeFileAndLine;
@@ -720,16 +590,11 @@ protected:
// Only check for inline functions if
LazyBool check_inlines = eLazyBoolCalculate;
- bp_sp = target->CreateBreakpoint(&(m_options.m_modules),
- file,
- m_options.m_line_num,
- m_options.m_column,
- m_options.m_offset_addr,
- check_inlines,
- m_options.m_skip_prologue,
- internal,
- m_options.m_hardware,
- m_options.m_move_to_nearest_code);
+ bp_sp = target.CreateBreakpoint(
+ &(m_options.m_modules), file, m_options.m_line_num,
+ m_options.m_column, m_options.m_offset_addr, check_inlines,
+ m_options.m_skip_prologue, internal, m_options.m_hardware,
+ m_options.m_move_to_nearest_code);
} break;
case eSetTypeAddress: // Breakpoint by address
@@ -741,12 +606,11 @@ protected:
if (num_modules_specified == 1) {
const FileSpec *file_spec =
m_options.m_modules.GetFileSpecPointerAtIndex(0);
- bp_sp = target->CreateAddressInModuleBreakpoint(m_options.m_load_addr,
- internal, file_spec,
- m_options.m_hardware);
+ bp_sp = target.CreateAddressInModuleBreakpoint(
+ m_options.m_load_addr, internal, file_spec, m_options.m_hardware);
} else if (num_modules_specified == 0) {
- bp_sp = target->CreateBreakpoint(m_options.m_load_addr, internal,
- m_options.m_hardware);
+ bp_sp = target.CreateBreakpoint(m_options.m_load_addr, internal,
+ m_options.m_hardware);
} else {
result.AppendError("Only one shared library can be specified for "
"address breakpoints.");
@@ -762,38 +626,29 @@ protected:
if (name_type_mask == 0)
name_type_mask = eFunctionNameTypeAuto;
- bp_sp = target->CreateBreakpoint(&(m_options.m_modules),
- &(m_options.m_filenames),
- m_options.m_func_names,
- name_type_mask,
- m_options.m_language,
- m_options.m_offset_addr,
- m_options.m_skip_prologue,
- internal,
- m_options.m_hardware);
+ bp_sp = target.CreateBreakpoint(
+ &(m_options.m_modules), &(m_options.m_filenames),
+ m_options.m_func_names, name_type_mask, m_options.m_language,
+ m_options.m_offset_addr, m_options.m_skip_prologue, internal,
+ m_options.m_hardware);
} break;
case eSetTypeFunctionRegexp: // Breakpoint by regular expression function
// name
{
RegularExpression regexp(m_options.m_func_regexp);
- if (!regexp.IsValid()) {
- char err_str[1024];
- regexp.GetErrorAsCString(err_str, sizeof(err_str));
+ if (llvm::Error err = regexp.GetError()) {
result.AppendErrorWithFormat(
"Function name regular expression could not be compiled: \"%s\"",
- err_str);
+ llvm::toString(std::move(err)).c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
- bp_sp = target->CreateFuncRegexBreakpoint(&(m_options.m_modules),
- &(m_options.m_filenames),
- regexp,
- m_options.m_language,
- m_options.m_skip_prologue,
- internal,
- m_options.m_hardware);
+ bp_sp = target.CreateFuncRegexBreakpoint(
+ &(m_options.m_modules), &(m_options.m_filenames), std::move(regexp),
+ m_options.m_language, m_options.m_skip_prologue, internal,
+ m_options.m_hardware);
}
break;
case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.
@@ -813,39 +668,29 @@ protected:
}
RegularExpression regexp(m_options.m_source_text_regexp);
- if (!regexp.IsValid()) {
- char err_str[1024];
- regexp.GetErrorAsCString(err_str, sizeof(err_str));
+ if (llvm::Error err = regexp.GetError()) {
result.AppendErrorWithFormat(
"Source text regular expression could not be compiled: \"%s\"",
- err_str);
+ llvm::toString(std::move(err)).c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
- bp_sp =
- target->CreateSourceRegexBreakpoint(&(m_options.m_modules),
- &(m_options.m_filenames),
- m_options
- .m_source_regex_func_names,
- regexp,
- internal,
- m_options.m_hardware,
- m_options.m_move_to_nearest_code);
+ bp_sp = target.CreateSourceRegexBreakpoint(
+ &(m_options.m_modules), &(m_options.m_filenames),
+ m_options.m_source_regex_func_names, std::move(regexp), internal,
+ m_options.m_hardware, m_options.m_move_to_nearest_code);
} break;
case eSetTypeException: {
Status precond_error;
- bp_sp = target->CreateExceptionBreakpoint(m_options.m_exception_language,
- m_options.m_catch_bp,
- m_options.m_throw_bp,
- internal,
- &m_options
- .m_exception_extra_args,
- &precond_error);
+ bp_sp = target.CreateExceptionBreakpoint(
+ m_options.m_exception_language, m_options.m_catch_bp,
+ m_options.m_throw_bp, internal, &m_options.m_exception_extra_args,
+ &precond_error);
if (precond_error.Fail()) {
result.AppendErrorWithFormat(
"Error setting extra exception arguments: %s",
precond_error.AsCString());
- target->RemoveBreakpointByID(bp_sp->GetID());
+ target.RemoveBreakpointByID(bp_sp->GetID());
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -853,18 +698,15 @@ protected:
case eSetTypeScripted: {
Status error;
- bp_sp = target->CreateScriptedBreakpoint(m_options.m_python_class,
- &(m_options.m_modules),
- &(m_options.m_filenames),
- false,
- m_options.m_hardware,
- m_options.m_extra_args_sp,
- &error);
+ bp_sp = target.CreateScriptedBreakpoint(
+ m_python_class_options.GetClassName().c_str(), &(m_options.m_modules),
+ &(m_options.m_filenames), false, m_options.m_hardware,
+ m_python_class_options.GetStructuredData(), &error);
if (error.Fail()) {
result.AppendErrorWithFormat(
"Error setting extra exception arguments: %s",
error.AsCString());
- target->RemoveBreakpointByID(bp_sp->GetID());
+ target.RemoveBreakpointByID(bp_sp->GetID());
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -880,11 +722,11 @@ protected:
if (!m_options.m_breakpoint_names.empty()) {
Status name_error;
for (auto name : m_options.m_breakpoint_names) {
- target->AddNameToBreakpoint(bp_sp, name.c_str(), name_error);
+ target.AddNameToBreakpoint(bp_sp, name.c_str(), name_error);
if (name_error.Fail()) {
result.AppendErrorWithFormat("Invalid breakpoint name: %s",
name.c_str());
- target->RemoveBreakpointByID(bp_sp->GetID());
+ target.RemoveBreakpointByID(bp_sp->GetID());
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -897,7 +739,7 @@ protected:
const bool show_locations = false;
bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
show_locations);
- if (target == GetDebugger().GetDummyTarget())
+ if (&target == &GetDummyTarget())
output_stream.Printf("Breakpoint set in dummy target, will get copied "
"into future targets.\n");
else {
@@ -919,12 +761,12 @@ protected:
}
private:
- bool GetDefaultFile(Target *target, FileSpec &file,
+ bool GetDefaultFile(Target &target, FileSpec &file,
CommandReturnObject &result) {
uint32_t default_line;
// First use the Source Manager's default file. Then use the current stack
// frame's file.
- if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line)) {
+ if (!target.GetSourceManager().GetDefaultFileAndLine(file, default_line)) {
StackFrame *cur_frame = m_exe_ctx.GetFramePtr();
if (cur_frame == nullptr) {
result.AppendError(
@@ -954,6 +796,7 @@ private:
BreakpointOptionGroup m_bp_opts;
BreakpointDummyOptionGroup m_dummy_options;
+ OptionGroupPythonClassWithDict m_python_class_options;
CommandOptions m_options;
OptionGroupOptions m_all_options;
};
@@ -993,20 +836,15 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = GetSelectedOrDummyTarget(m_dummy_opts.m_use_dummy);
- if (target == nullptr) {
- result.AppendError("Invalid target. No existing target or breakpoints.");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ Target &target = GetSelectedOrDummyTarget(m_dummy_opts.m_use_dummy);
std::unique_lock<std::recursive_mutex> lock;
- target->GetBreakpointList().GetListMutex(lock);
+ target.GetBreakpointList().GetListMutex(lock);
BreakpointIDList valid_bp_ids;
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
- command, target, result, &valid_bp_ids,
+ command, &target, result, &valid_bp_ids,
BreakpointName::Permissions::PermissionKinds::disablePerm);
if (result.Succeeded()) {
@@ -1016,7 +854,7 @@ protected:
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) {
BreakpointLocation *location =
bp->FindLocationByID(cur_bp_id.GetLocationID()).get();
@@ -1062,17 +900,12 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = GetSelectedOrDummyTarget();
- if (target == nullptr) {
- result.AppendError("Invalid target. No existing target or breakpoints.");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ Target &target = GetSelectedOrDummyTarget();
std::unique_lock<std::recursive_mutex> lock;
- target->GetBreakpointList().GetListMutex(lock);
+ target.GetBreakpointList().GetListMutex(lock);
- const BreakpointList &breakpoints = target->GetBreakpointList();
+ const BreakpointList &breakpoints = target.GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@@ -1084,7 +917,7 @@ protected:
if (command.empty()) {
// No breakpoint selected; enable all currently set breakpoints.
- target->EnableAllowedBreakpoints();
+ target.EnableAllowedBreakpoints();
result.AppendMessageWithFormat("All breakpoints enabled. (%" PRIu64
" breakpoints)\n",
(uint64_t)num_breakpoints);
@@ -1093,7 +926,7 @@ protected:
// Particular breakpoint selected; enable that breakpoint.
BreakpointIDList valid_bp_ids;
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
- command, target, result, &valid_bp_ids,
+ command, &target, result, &valid_bp_ids,
BreakpointName::Permissions::PermissionKinds::disablePerm);
if (result.Succeeded()) {
@@ -1105,7 +938,7 @@ protected:
if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
Breakpoint *breakpoint =
- target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
+ target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
BreakpointLocation *location =
breakpoint->FindLocationByID(cur_bp_id.GetLocationID()).get();
@@ -1175,17 +1008,11 @@ the second re-enables the first location.");
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = GetSelectedOrDummyTarget();
- if (target == nullptr) {
- result.AppendError("Invalid target. No existing target or breakpoints.");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
+ Target &target = GetSelectedOrDummyTarget();
std::unique_lock<std::recursive_mutex> lock;
- target->GetBreakpointList().GetListMutex(lock);
+ target.GetBreakpointList().GetListMutex(lock);
- const BreakpointList &breakpoints = target->GetBreakpointList();
+ const BreakpointList &breakpoints = target.GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
if (num_breakpoints == 0) {
@@ -1196,7 +1023,7 @@ protected:
if (command.empty()) {
// No breakpoint selected; disable all currently set breakpoints.
- target->DisableAllowedBreakpoints();
+ target.DisableAllowedBreakpoints();
result.AppendMessageWithFormat("All breakpoints disabled. (%" PRIu64
" breakpoints)\n",
(uint64_t)num_breakpoints);
@@ -1206,7 +1033,7 @@ protected:
BreakpointIDList valid_bp_ids;
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
- command, target, result, &valid_bp_ids,
+ command, &target, result, &valid_bp_ids,
BreakpointName::Permissions::PermissionKinds::disablePerm);
if (result.Succeeded()) {
@@ -1218,7 +1045,7 @@ protected:
if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
Breakpoint *breakpoint =
- target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
+ target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
BreakpointLocation *location =
breakpoint->FindLocationByID(cur_bp_id.GetLocationID()).get();
@@ -1245,12 +1072,8 @@ protected:
// CommandObjectBreakpointList
#pragma mark List::CommandOptions
-static constexpr OptionDefinition g_breakpoint_list_options[] = {
- // FIXME: We need to add an "internal" command, and then add this sort of
- // thing to it. But I need to see it for now, and don't want to wait.
#define LLDB_OPTIONS_breakpoint_list
#include "CommandOptions.inc"
-};
#pragma mark List
@@ -1311,9 +1134,7 @@ public:
m_internal = true;
break;
default:
- error.SetErrorStringWithFormat("unrecognized option '%c'",
- short_option);
- break;
+ llvm_unreachable("Unimplemented option");
}
return error;
@@ -1339,18 +1160,12 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
-
- if (target == nullptr) {
- result.AppendError("Invalid target. No current target or breakpoints.");
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- return true;
- }
+ Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
const BreakpointList &breakpoints =
- target->GetBreakpointList(m_options.m_internal);
+ target.GetBreakpointList(m_options.m_internal);
std::unique_lock<std::recursive_mutex> lock;
- target->GetBreakpointList(m_options.m_internal).GetListMutex(lock);
+ target.GetBreakpointList(m_options.m_internal).GetListMutex(lock);
size_t num_breakpoints = breakpoints.GetSize();
@@ -1376,14 +1191,14 @@ protected:
// Particular breakpoints selected; show info about that breakpoint.
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()) {
for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i) {
BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
Breakpoint *breakpoint =
- target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
+ target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
AddBreakpointDescription(&output_stream, breakpoint,
m_options.m_level);
}
@@ -1404,12 +1219,8 @@ private:
// CommandObjectBreakpointClear
#pragma mark Clear::CommandOptions
-static constexpr OptionDefinition g_breakpoint_clear_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "Specify the breakpoint by source location in this particular file." },
- { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLineNum, "Specify the breakpoint by source location at this particular line." }
- // clang-format on
-};
+#define LLDB_OPTIONS_breakpoint_clear
+#include "CommandOptions.inc"
#pragma mark Clear
@@ -1449,9 +1260,7 @@ public:
break;
default:
- error.SetErrorStringWithFormat("unrecognized option '%c'",
- short_option);
- break;
+ llvm_unreachable("Unimplemented option");
}
return error;
@@ -1474,12 +1283,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = GetSelectedOrDummyTarget();
- if (target == nullptr) {
- result.AppendError("Invalid target. No existing target or breakpoints.");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ Target &target = GetSelectedOrDummyTarget();
// The following are the various types of breakpoints that could be
// cleared:
@@ -1491,9 +1295,9 @@ protected:
break_type = eClearTypeFileAndLine;
std::unique_lock<std::recursive_mutex> lock;
- target->GetBreakpointList().GetListMutex(lock);
+ target.GetBreakpointList().GetListMutex(lock);
- BreakpointList &breakpoints = target->GetBreakpointList();
+ BreakpointList &breakpoints = target.GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
// Early return if there's no breakpoint at all.
@@ -1527,7 +1331,7 @@ protected:
if (loc_coll.GetSize() == 0) {
bp->GetDescription(&ss, lldb::eDescriptionLevelBrief);
ss.EOL();
- target->RemoveBreakpointByID(bp->GetID());
+ target.RemoveBreakpointByID(bp->GetID());
++num_cleared;
}
}
@@ -1557,12 +1361,8 @@ private:
};
// CommandObjectBreakpointDelete
-static constexpr OptionDefinition g_breakpoint_delete_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "force", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Delete all breakpoints without querying for confirmation." },
- { LLDB_OPT_SET_1, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Delete Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets." },
- // clang-format on
-};
+#define LLDB_OPTIONS_breakpoint_delete
+#include "CommandOptions.inc"
#pragma mark Delete
@@ -1607,9 +1407,7 @@ public:
break;
default:
- error.SetErrorStringWithFormat("unrecognized option '%c'",
- short_option);
- break;
+ llvm_unreachable("Unimplemented option");
}
return error;
@@ -1631,18 +1429,12 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
-
- if (target == nullptr) {
- result.AppendError("Invalid target. No existing target or breakpoints.");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
std::unique_lock<std::recursive_mutex> lock;
- target->GetBreakpointList().GetListMutex(lock);
+ target.GetBreakpointList().GetListMutex(lock);
- const BreakpointList &breakpoints = target->GetBreakpointList();
+ const BreakpointList &breakpoints = target.GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@@ -1659,7 +1451,7 @@ protected:
true)) {
result.AppendMessage("Operation cancelled...");
} else {
- target->RemoveAllowedBreakpoints();
+ target.RemoveAllowedBreakpoints();
result.AppendMessageWithFormat(
"All breakpoints removed. (%" PRIu64 " breakpoint%s)\n",
(uint64_t)num_breakpoints, num_breakpoints > 1 ? "s" : "");
@@ -1669,7 +1461,7 @@ protected:
// Particular breakpoint selected; disable that breakpoint.
BreakpointIDList valid_bp_ids;
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
- command, target, result, &valid_bp_ids,
+ command, &target, result, &valid_bp_ids,
BreakpointName::Permissions::PermissionKinds::deletePerm);
if (result.Succeeded()) {
@@ -1682,7 +1474,7 @@ protected:
if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
Breakpoint *breakpoint =
- target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
+ target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
BreakpointLocation *location =
breakpoint->FindLocationByID(cur_bp_id.GetLocationID()).get();
// It makes no sense to try to delete individual locations, so we
@@ -1692,7 +1484,7 @@ protected:
++disable_count;
}
} else {
- target->RemoveBreakpointByID(cur_bp_id.GetBreakpointID());
+ target.RemoveBreakpointByID(cur_bp_id.GetBreakpointID());
++delete_count;
}
}
@@ -1711,15 +1503,9 @@ private:
};
// CommandObjectBreakpointName
+#define LLDB_OPTIONS_breakpoint_name
+#include "CommandOptions.inc"
-static constexpr OptionDefinition g_breakpoint_name_options[] = {
- // clang-format off
- {LLDB_OPT_SET_1, false, "name", 'N', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBreakpointName, "Specifies a breakpoint name to use."},
- {LLDB_OPT_SET_2, false, "breakpoint-id", 'B', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBreakpointID, "Specify a breakpoint ID to use."},
- {LLDB_OPT_SET_3, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Operate on Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."},
- {LLDB_OPT_SET_4, false, "help-string", 'H', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNone, "A help string describing the purpose of this name."},
- // clang-format on
-};
class BreakpointNameOptionGroup : public OptionGroup {
public:
BreakpointNameOptionGroup()
@@ -1760,9 +1546,7 @@ public:
break;
default:
- error.SetErrorStringWithFormat("unrecognized short option '%c'",
- short_option);
- break;
+ llvm_unreachable("Unimplemented option");
}
return error;
}
@@ -1781,13 +1565,8 @@ public:
OptionValueString m_help_string;
};
-static constexpr OptionDefinition g_breakpoint_access_options[] = {
- // clang-format off
- {LLDB_OPT_SET_1, false, "allow-list", 'L', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Determines whether the breakpoint will show up in break list if not referred to explicitly."},
- {LLDB_OPT_SET_2, false, "allow-disable", 'A', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Determines whether the breakpoint can be disabled by name or when all breakpoints are disabled."},
- {LLDB_OPT_SET_3, false, "allow-delete", 'D', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Determines whether the breakpoint can be deleted by name or when all breakpoints are deleted."},
- // clang-format on
-};
+#define LLDB_OPTIONS_breakpoint_access
+#include "CommandOptions.inc"
class BreakpointAccessOptionGroup : public OptionGroup {
public:
@@ -1835,7 +1614,8 @@ public:
"invalid boolean value '%s' passed for -L option",
option_arg.str().c_str());
} break;
-
+ default:
+ llvm_unreachable("Unimplemented option");
}
return error;
@@ -1897,23 +1677,16 @@ protected:
result.SetStatus(eReturnStatusFailed);
return false;
}
-
- Target *target =
- GetSelectedOrDummyTarget(false);
- if (target == nullptr) {
- result.AppendError("Invalid target. No existing target or breakpoints.");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ Target &target = GetSelectedOrDummyTarget(false);
std::unique_lock<std::recursive_mutex> lock;
- target->GetBreakpointList().GetListMutex(lock);
+ target.GetBreakpointList().GetListMutex(lock);
// Make a pass through first to see that all the names are legal.
for (auto &entry : command.entries()) {
Status error;
- if (!BreakpointID::StringIsBreakpointName(entry.ref, error))
+ if (!BreakpointID::StringIsBreakpointName(entry.ref(), error))
{
result.AppendErrorWithFormat("Invalid breakpoint name: %s - %s",
entry.c_str(), error.AsCString());
@@ -1927,7 +1700,7 @@ protected:
if (m_bp_id.m_breakpoint.OptionWasSet())
{
lldb::break_id_t bp_id = m_bp_id.m_breakpoint.GetUInt64Value();
- bp_sp = target->GetBreakpointByID(bp_id);
+ bp_sp = target.GetBreakpointByID(bp_id);
if (!bp_sp)
{
result.AppendErrorWithFormatv("Could not find specified breakpoint {0}",
@@ -1940,18 +1713,17 @@ protected:
Status error;
for (auto &entry : command.entries()) {
ConstString name(entry.c_str());
- BreakpointName *bp_name = target->FindBreakpointName(name, true, error);
+ BreakpointName *bp_name = target.FindBreakpointName(name, true, error);
if (!bp_name)
continue;
if (m_bp_id.m_help_string.OptionWasSet())
bp_name->SetHelp(m_bp_id.m_help_string.GetStringValue().str().c_str());
if (bp_sp)
- target->ConfigureBreakpointName(*bp_name,
- *bp_sp->GetOptions(),
+ target.ConfigureBreakpointName(*bp_name, *bp_sp->GetOptions(),
m_access_options.GetPermissions());
else
- target->ConfigureBreakpointName(*bp_name,
+ target.ConfigureBreakpointName(*bp_name,
m_bp_opts.GetBreakpointOptions(),
m_access_options.GetPermissions());
}
@@ -1996,19 +1768,13 @@ protected:
return false;
}
- Target *target =
+ Target &target =
GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue());
- if (target == nullptr) {
- result.AppendError("Invalid target. No existing target or breakpoints.");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
std::unique_lock<std::recursive_mutex> lock;
- target->GetBreakpointList().GetListMutex(lock);
+ target.GetBreakpointList().GetListMutex(lock);
- const BreakpointList &breakpoints = target->GetBreakpointList();
+ const BreakpointList &breakpoints = target.GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
if (num_breakpoints == 0) {
@@ -2020,7 +1786,7 @@ protected:
// Particular breakpoint selected; disable that breakpoint.
BreakpointIDList valid_bp_ids;
CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs(
- command, target, result, &valid_bp_ids,
+ command, &target, result, &valid_bp_ids,
BreakpointName::Permissions::PermissionKinds::listPerm);
if (result.Succeeded()) {
@@ -2037,7 +1803,7 @@ protected:
lldb::break_id_t bp_id =
valid_bp_ids.GetBreakpointIDAtIndex(index).GetBreakpointID();
BreakpointSP bp_sp = breakpoints.FindBreakpointByID(bp_id);
- target->AddNameToBreakpoint(bp_sp, bp_name, error);
+ target.AddNameToBreakpoint(bp_sp, bp_name, error);
}
}
@@ -2081,19 +1847,13 @@ protected:
return false;
}
- Target *target =
+ Target &target =
GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue());
- if (target == nullptr) {
- result.AppendError("Invalid target. No existing target or breakpoints.");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
std::unique_lock<std::recursive_mutex> lock;
- target->GetBreakpointList().GetListMutex(lock);
+ target.GetBreakpointList().GetListMutex(lock);
- const BreakpointList &breakpoints = target->GetBreakpointList();
+ const BreakpointList &breakpoints = target.GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
if (num_breakpoints == 0) {
@@ -2105,7 +1865,7 @@ protected:
// Particular breakpoint selected; disable that breakpoint.
BreakpointIDList valid_bp_ids;
CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs(
- command, target, result, &valid_bp_ids,
+ command, &target, result, &valid_bp_ids,
BreakpointName::Permissions::PermissionKinds::deletePerm);
if (result.Succeeded()) {
@@ -2120,7 +1880,7 @@ protected:
lldb::break_id_t bp_id =
valid_bp_ids.GetBreakpointIDAtIndex(index).GetBreakpointID();
BreakpointSP bp_sp = breakpoints.FindBreakpointByID(bp_id);
- target->RemoveNameFromBreakpoint(bp_sp, bp_name);
+ target.RemoveNameFromBreakpoint(bp_sp, bp_name);
}
}
@@ -2151,19 +1911,12 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target =
+ Target &target =
GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue());
- if (target == nullptr) {
- result.AppendError("Invalid target. No existing target or breakpoints.");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
-
std::vector<std::string> name_list;
if (command.empty()) {
- target->GetBreakpointNames(name_list);
+ target.GetBreakpointNames(name_list);
} else {
for (const Args::ArgEntry &arg : command)
{
@@ -2178,9 +1931,8 @@ protected:
const char *name = name_str.c_str();
// First print out the options for the name:
Status error;
- BreakpointName *bp_name = target->FindBreakpointName(ConstString(name),
- false,
- error);
+ BreakpointName *bp_name =
+ target.FindBreakpointName(ConstString(name), false, error);
if (bp_name)
{
StreamString s;
@@ -2191,9 +1943,9 @@ protected:
}
std::unique_lock<std::recursive_mutex> lock;
- target->GetBreakpointList().GetListMutex(lock);
+ target.GetBreakpointList().GetListMutex(lock);
- BreakpointList &breakpoints = target->GetBreakpointList();
+ BreakpointList &breakpoints = target.GetBreakpointList();
bool any_set = false;
for (BreakpointSP bp_sp : breakpoints.Breakpoints()) {
if (bp_sp->MatchesName(name)) {
@@ -2246,12 +1998,8 @@ public:
// CommandObjectBreakpointRead
#pragma mark Read::CommandOptions
-static constexpr OptionDefinition g_breakpoint_read_options[] = {
- // clang-format off
- {LLDB_OPT_SET_ALL, true, "file", 'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eDiskFileCompletion, eArgTypeFilename, "The file from which to read the breakpoints." },
- {LLDB_OPT_SET_ALL, false, "breakpoint-name", 'N', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBreakpointName, "Only read in breakpoints with this name."},
- // clang-format on
-};
+#define LLDB_OPTIONS_breakpoint_read
+#include "CommandOptions.inc"
#pragma mark Read
@@ -2301,9 +2049,7 @@ public:
break;
}
default:
- error.SetErrorStringWithFormat("unrecognized option '%c'",
- short_option);
- break;
+ llvm_unreachable("Unimplemented option");
}
return error;
@@ -2326,21 +2072,16 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = GetSelectedOrDummyTarget();
- if (target == nullptr) {
- result.AppendError("Invalid target. No existing target or breakpoints.");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ Target &target = GetSelectedOrDummyTarget();
std::unique_lock<std::recursive_mutex> lock;
- target->GetBreakpointList().GetListMutex(lock);
+ target.GetBreakpointList().GetListMutex(lock);
FileSpec input_spec(m_options.m_filename);
FileSystem::Instance().Resolve(input_spec);
BreakpointIDList new_bps;
- Status error = target->CreateBreakpointsFromFile(
- input_spec, m_options.m_names, new_bps);
+ Status error = target.CreateBreakpointsFromFile(input_spec,
+ m_options.m_names, new_bps);
if (!error.Success()) {
result.AppendError(error.AsCString());
@@ -2358,7 +2099,7 @@ protected:
result.AppendMessage("New breakpoints:");
for (size_t i = 0; i < num_breakpoints; ++i) {
BreakpointID bp_id = new_bps.GetBreakpointIDAtIndex(i);
- Breakpoint *bp = target->GetBreakpointList()
+ Breakpoint *bp = target.GetBreakpointList()
.FindBreakpointByID(bp_id.GetBreakpointID())
.get();
if (bp)
@@ -2375,12 +2116,8 @@ private:
// CommandObjectBreakpointWrite
#pragma mark Write::CommandOptions
-static constexpr OptionDefinition g_breakpoint_write_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, true, "file", 'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eDiskFileCompletion, eArgTypeFilename, "The file into which to write the breakpoints." },
- { LLDB_OPT_SET_ALL, false, "append",'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Append to saved breakpoints file if it exists."},
- // clang-format on
-};
+#define LLDB_OPTIONS_breakpoint_write
+#include "CommandOptions.inc"
#pragma mark Write
class CommandObjectBreakpointWrite : public CommandObjectParsed {
@@ -2423,9 +2160,7 @@ public:
m_append = true;
break;
default:
- error.SetErrorStringWithFormat("unrecognized option '%c'",
- short_option);
- break;
+ llvm_unreachable("Unimplemented option");
}
return error;
@@ -2448,20 +2183,15 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = GetSelectedOrDummyTarget();
- if (target == nullptr) {
- result.AppendError("Invalid target. No existing target or breakpoints.");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ Target &target = GetSelectedOrDummyTarget();
std::unique_lock<std::recursive_mutex> lock;
- target->GetBreakpointList().GetListMutex(lock);
+ target.GetBreakpointList().GetListMutex(lock);
BreakpointIDList valid_bp_ids;
if (!command.empty()) {
CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs(
- command, target, result, &valid_bp_ids,
+ command, &target, result, &valid_bp_ids,
BreakpointName::Permissions::PermissionKinds::listPerm);
if (!result.Succeeded()) {
@@ -2471,8 +2201,8 @@ protected:
}
FileSpec file_spec(m_options.m_filename);
FileSystem::Instance().Resolve(file_spec);
- Status error = target->SerializeBreakpointsToFile(file_spec, valid_bp_ids,
- m_options.m_append);
+ Status error = target.SerializeBreakpointsToFile(file_spec, valid_bp_ids,
+ m_options.m_append);
if (!error.Success()) {
result.AppendErrorWithFormat("error serializing breakpoints: %s.",
error.AsCString());