diff options
author | Jim Ingham <jingham@apple.com> | 2021-07-28 16:59:55 -0700 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2021-08-06 15:29:55 -0700 |
commit | f362b05d0dcd176348f19a63f8b7f4d4c0498bba (patch) | |
tree | a20e4b407d63479f0076aa59a79abf7d2559757b /lldb/source/Commands | |
parent | 3229c971512404c512e041c3e88f22dbec2b650b (diff) | |
download | llvm-f362b05d0dcd176348f19a63f8b7f4d4c0498bba.zip llvm-f362b05d0dcd176348f19a63f8b7f4d4c0498bba.tar.gz llvm-f362b05d0dcd176348f19a63f8b7f4d4c0498bba.tar.bz2 |
Add a "current" token to the ThreadID option to break set/modify.
This provides a convenient way to limit a breakpoint
to the current thread when setting it from the command line w/o
having to figure out what the current thread is.
Differential Revision: https://reviews.llvm.org/D107015
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r-- | lldb/source/Commands/CommandObjectBreakpoint.cpp | 14 | ||||
-rw-r--r-- | lldb/source/Commands/Options.td | 2 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 722d5c4..3f88a2f 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -110,7 +110,19 @@ public: case 't': { lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID; if (option_arg[0] != '\0') { - if (option_arg.getAsInteger(0, thread_id)) + if (option_arg == "current") { + if (!execution_context) { + error.SetErrorStringWithFormat("No context to determine current " + "thread"); + } else { + ThreadSP ctx_thread_sp = execution_context->GetThreadSP(); + if (!ctx_thread_sp || !ctx_thread_sp->IsValid()) { + error.SetErrorStringWithFormat("No currently selected thread"); + } else { + thread_id = ctx_thread_sp->GetID(); + } + } + } else if (option_arg.getAsInteger(0, thread_id)) error.SetErrorStringWithFormat("invalid thread id string '%s'", option_arg.str().c_str()); } diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td index 6abb478..b78fb37 100644 --- a/lldb/source/Commands/Options.td +++ b/lldb/source/Commands/Options.td @@ -73,7 +73,7 @@ let Command = "breakpoint modify" in { "index matches this argument.">; def breakpoint_modify_thread_id : Option<"thread-id", "t">, Group<1>, Arg<"ThreadID">, Desc<"The breakpoint stops only for the thread whose TID " - "matches this argument.">; + "matches this argument. The token 'current' resolves to the current thread's ID.">; def breakpoint_modify_thread_name : Option<"thread-name", "T">, Group<1>, Arg<"ThreadName">, Desc<"The breakpoint stops only for the thread whose " "thread name matches this argument.">; |