aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-06-13 19:31:46 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-06-13 19:37:19 +0000
commite8d8bef961a50d4dc22501cde4fb9fb0be1b2532 (patch)
tree94f04805f47bb7c59ae29690d8952b6074fff602 /contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp
parentbb130ff39747b94592cb26d71b7cb097b9a4ea6b (diff)
parentb60736ec1405bb0a8dd40989f67ef4c93da068ab (diff)
Diffstat (limited to 'contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp140
1 files changed, 130 insertions, 10 deletions
diff --git a/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp b/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp
index be7ef8a1b60b..0844c56cef2f 100644
--- a/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -17,6 +17,7 @@
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
#include "lldb/Interpreter/OptionValueBoolean.h"
+#include "lldb/Interpreter/OptionValueFileColonLine.h"
#include "lldb/Interpreter/OptionValueString.h"
#include "lldb/Interpreter/OptionValueUInt64.h"
#include "lldb/Interpreter/Options.h"
@@ -443,7 +444,22 @@ public:
case 'X':
m_source_regex_func_names.insert(std::string(option_arg));
break;
-
+
+ case 'y':
+ {
+ OptionValueFileColonLine value;
+ Status fcl_err = value.SetValueFromString(option_arg);
+ if (!fcl_err.Success()) {
+ error.SetErrorStringWithFormat(
+ "Invalid value for file:line specifier: %s",
+ fcl_err.AsCString());
+ } else {
+ m_filenames.AppendIfUnique(value.GetFileSpec());
+ m_line_num = value.GetLineNumber();
+ m_column = value.GetColumnNumber();
+ }
+ } break;
+
default:
llvm_unreachable("Unimplemented option");
}
@@ -1407,7 +1423,8 @@ public:
class CommandOptions : public Options {
public:
- CommandOptions() : Options(), m_use_dummy(false), m_force(false) {}
+ CommandOptions() : Options(), m_use_dummy(false), m_force(false),
+ m_delete_disabled(false) {}
~CommandOptions() override = default;
@@ -1424,6 +1441,10 @@ public:
case 'D':
m_use_dummy = true;
break;
+
+ case 'd':
+ m_delete_disabled = true;
+ break;
default:
llvm_unreachable("Unimplemented option");
@@ -1435,6 +1456,7 @@ public:
void OptionParsingStarting(ExecutionContext *execution_context) override {
m_use_dummy = false;
m_force = false;
+ m_delete_disabled = false;
}
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
@@ -1444,16 +1466,18 @@ public:
// Instance variables to hold the values for command options.
bool m_use_dummy;
bool m_force;
+ bool m_delete_disabled;
};
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
-
+ result.Clear();
+
std::unique_lock<std::recursive_mutex> lock;
target.GetBreakpointList().GetListMutex(lock);
- const BreakpointList &breakpoints = target.GetBreakpointList();
+ BreakpointList &breakpoints = target.GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@@ -1463,7 +1487,7 @@ protected:
return false;
}
- if (command.empty()) {
+ if (command.empty() && !m_options.m_delete_disabled) {
if (!m_options.m_force &&
!m_interpreter.Confirm(
"About to delete all breakpoints, do you want to do that?",
@@ -1479,10 +1503,34 @@ protected:
} else {
// Particular breakpoint selected; disable that breakpoint.
BreakpointIDList valid_bp_ids;
- CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
- command, &target, result, &valid_bp_ids,
- BreakpointName::Permissions::PermissionKinds::deletePerm);
-
+
+ if (m_options.m_delete_disabled) {
+ BreakpointIDList excluded_bp_ids;
+
+ if (!command.empty()) {
+ CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
+ command, &target, result, &excluded_bp_ids,
+ BreakpointName::Permissions::PermissionKinds::deletePerm);
+ }
+ for (auto breakpoint_sp : breakpoints.Breakpoints()) {
+ if (!breakpoint_sp->IsEnabled() && breakpoint_sp->AllowDelete()) {
+ BreakpointID bp_id(breakpoint_sp->GetID());
+ size_t pos = 0;
+ if (!excluded_bp_ids.FindBreakpointID(bp_id, &pos))
+ valid_bp_ids.AddBreakpointID(breakpoint_sp->GetID());
+ }
+ }
+ if (valid_bp_ids.GetSize() == 0) {
+ result.AppendError("No disabled breakpoints.");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ } else {
+ CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
+ command, &target, result, &valid_bp_ids,
+ BreakpointName::Permissions::PermissionKinds::deletePerm);
+ }
+
if (result.Succeeded()) {
int delete_count = 0;
int disable_count = 0;
@@ -2081,7 +2129,79 @@ public:
return llvm::makeArrayRef(g_breakpoint_read_options);
}
- // Instance variables to hold the values for command options.
+ void HandleOptionArgumentCompletion(
+ CompletionRequest &request, OptionElementVector &opt_element_vector,
+ int opt_element_index, CommandInterpreter &interpreter) override {
+ int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
+ int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index;
+
+ switch (GetDefinitions()[opt_defs_index].short_option) {
+ case 'f':
+ CommandCompletions::InvokeCommonCompletionCallbacks(
+ interpreter, CommandCompletions::eDiskFileCompletion, request,
+ nullptr);
+ break;
+
+ case 'N':
+ llvm::Optional<FileSpec> file_spec;
+ const llvm::StringRef dash_f("-f");
+ for (int arg_idx = 0; arg_idx < opt_arg_pos; arg_idx++) {
+ if (dash_f == request.GetParsedLine().GetArgumentAtIndex(arg_idx)) {
+ file_spec.emplace(
+ request.GetParsedLine().GetArgumentAtIndex(arg_idx + 1));
+ break;
+ }
+ }
+ if (!file_spec)
+ return;
+
+ FileSystem::Instance().Resolve(*file_spec);
+ Status error;
+ StructuredData::ObjectSP input_data_sp =
+ StructuredData::ParseJSONFromFile(*file_spec, error);
+ if (!error.Success())
+ return;
+
+ StructuredData::Array *bkpt_array = input_data_sp->GetAsArray();
+ if (!bkpt_array)
+ return;
+
+ const size_t num_bkpts = bkpt_array->GetSize();
+ for (size_t i = 0; i < num_bkpts; i++) {
+ StructuredData::ObjectSP bkpt_object_sp =
+ bkpt_array->GetItemAtIndex(i);
+ if (!bkpt_object_sp)
+ return;
+
+ StructuredData::Dictionary *bkpt_dict =
+ bkpt_object_sp->GetAsDictionary();
+ if (!bkpt_dict)
+ return;
+
+ StructuredData::ObjectSP bkpt_data_sp =
+ bkpt_dict->GetValueForKey(Breakpoint::GetSerializationKey());
+ if (!bkpt_data_sp)
+ return;
+
+ bkpt_dict = bkpt_data_sp->GetAsDictionary();
+ if (!bkpt_dict)
+ return;
+
+ StructuredData::Array *names_array;
+
+ if (!bkpt_dict->GetValueForKeyAsArray("Names", names_array))
+ return;
+
+ size_t num_names = names_array->GetSize();
+
+ for (size_t i = 0; i < num_names; i++) {
+ llvm::StringRef name;
+ if (names_array->GetItemAtIndexAsString(i, name))
+ request.TryCompleteCurrentArg(name);
+ }
+ }
+ }
+ }
std::string m_filename;
std::vector<std::string> m_names;