aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r--lldb/source/Commands/CommandCompletions.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectBreakpoint.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp63
-rw-r--r--lldb/source/Commands/Options.td10
4 files changed, 61 insertions, 20 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index b2fc893..c60d303 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -777,13 +777,11 @@ void CommandCompletions::StopHookIDs(CommandInterpreter &interpreter,
if (!target_sp)
return;
- const size_t num = target_sp->GetNumStopHooks();
- for (size_t idx = 0; idx < num; ++idx) {
+ for (auto &stophook_sp : target_sp->GetStopHooks()) {
StreamString strm;
// The value 11 is an offset to make the completion description looks
// neater.
strm.SetIndentLevel(11);
- const Target::StopHookSP stophook_sp = target_sp->GetStopHookAtIndex(idx);
stophook_sp->GetDescription(strm, lldb::eDescriptionLevelInitial);
request.TryCompleteCurrentArg(std::to_string(stophook_sp->GetID()),
strm.GetString());
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index de0a7e7..5a55126 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -1114,9 +1114,7 @@ public:
CommandObjectBreakpointList(CommandInterpreter &interpreter)
: CommandObjectParsed(
interpreter, "breakpoint list",
- "List some or all breakpoints at configurable levels of detail.",
- nullptr) {
- CommandArgumentData bp_id_arg;
+ "List some or all breakpoints at configurable levels of detail.") {
// Define the first (and only) variant of this arg.
AddSimpleArgumentList(eArgTypeBreakpointID, eArgRepeatOptional);
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index c59d028..8de6521 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -5223,33 +5223,72 @@ private:
#pragma mark CommandObjectTargetStopHookList
// CommandObjectTargetStopHookList
+#define LLDB_OPTIONS_target_stop_hook_list
+#include "CommandOptions.inc"
class CommandObjectTargetStopHookList : public CommandObjectParsed {
public:
CommandObjectTargetStopHookList(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "target stop-hook list",
- "List all stop-hooks.", "target stop-hook list") {}
+ "List all stop-hooks.") {}
~CommandObjectTargetStopHookList() override = default;
+ Options *GetOptions() override { return &m_options; }
+
+ class CommandOptions : public Options {
+ public:
+ CommandOptions() = default;
+ ~CommandOptions() override = default;
+
+ Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ ExecutionContext *execution_context) override {
+ Status error;
+ const int short_option = m_getopt_table[option_idx].val;
+
+ switch (short_option) {
+ case 'i':
+ m_internal = true;
+ break;
+ default:
+ llvm_unreachable("Unimplemented option");
+ }
+
+ return error;
+ }
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override {
+ m_internal = false;
+ }
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return llvm::ArrayRef(g_target_stop_hook_list_options);
+ }
+
+ // Instance variables to hold the values for command options.
+ bool m_internal = false;
+ };
+
protected:
void DoExecute(Args &command, CommandReturnObject &result) override {
Target &target = GetTarget();
- size_t num_hooks = target.GetNumStopHooks();
- if (num_hooks == 0) {
- result.GetOutputStream().PutCString("No stop hooks.\n");
- } else {
- for (size_t i = 0; i < num_hooks; i++) {
- Target::StopHookSP this_hook = target.GetStopHookAtIndex(i);
- if (i > 0)
- result.GetOutputStream().PutCString("\n");
- this_hook->GetDescription(result.GetOutputStream(),
- eDescriptionLevelFull);
- }
+ bool printed_hook = false;
+ for (auto &hook : target.GetStopHooks(m_options.m_internal)) {
+ if (printed_hook)
+ result.GetOutputStream().PutCString("\n");
+ hook->GetDescription(result.GetOutputStream(), eDescriptionLevelFull);
+ printed_hook = true;
}
+
+ if (!printed_hook)
+ result.GetOutputStream().PutCString("No stop hooks.\n");
+
result.SetStatus(eReturnStatusSuccessFinishResult);
}
+
+private:
+ CommandOptions m_options;
};
#pragma mark CommandObjectMultiwordTargetStopHooks
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index a9f054e..ed06131 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -77,7 +77,7 @@ let Command = "breakpoint list" in {
// 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.
def blist_internal : Option<"internal", "i">,
- Desc<"Show debugger ${i}nternal breakpoints">;
+ Desc<"Show debugger ${i}nternal breakpoints.">;
def blist_brief : Option<"brief", "b">,
Group<1>,
Desc<"Give a ${b}rief description of the breakpoint (no "
@@ -1686,7 +1686,7 @@ let Command = "target modules lookup" in {
"match, if a best match is available.">;
}
-let Command = "target stop hook add" in {
+let Command = "target stop_hook add" in {
def target_stop_hook_add_one_liner
: Option<"one-liner", "o">,
GroupRange<1, 3>,
@@ -1762,6 +1762,12 @@ let Command = "target stop hook add" in {
"Defaults to true.">;
}
+let Command = "target stop_hook list" in {
+ def target_stop_hook_list_internal
+ : Option<"internal", "i">,
+ Desc<"Show debugger ${i}nternal stop hooks.">;
+}
+
let Command = "thread backtrace" in {
def thread_backtrace_count : Option<"count", "c">,
Group<1>,