[Lldb-commits] [PATCH] D107015: Add "current" token for the -t option to "break set/modify"

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 6 15:30:26 PDT 2021


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf362b05d0dcd: Add a "current" token to the ThreadID option to break set/modify. (authored by jingham).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107015/new/

https://reviews.llvm.org/D107015

Files:
  lldb/source/Commands/CommandObjectBreakpoint.cpp
  lldb/source/Commands/Options.td
  lldb/test/API/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py


Index: lldb/test/API/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py
===================================================================
--- lldb/test/API/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py
+++ lldb/test/API/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py
@@ -9,11 +9,15 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-def set_thread_id(thread, breakpoint):
+def using_current(test, thread, breakpoint):
+    bp_id = breakpoint.GetID()
+    test.runCmd("break modify -t current {0}".format(bp_id))
+    
+def set_thread_id(test, thread, breakpoint):
     id = thread.id
     breakpoint.SetThreadID(id)
 
-def set_thread_name(thread, breakpoint):
+def set_thread_name(test, thread, breakpoint):
     breakpoint.SetThreadName("main-thread")
 
 class ThreadSpecificBreakTestCase(TestBase):
@@ -32,6 +36,10 @@
     def test_thread_name(self):
         self.do_test(set_thread_name)
 
+    @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], archs=['armv7', 'armv7k'], bugnumber='rdar://problem/34563920') # armv7 ios problem - breakpoint with tid qualifier isn't working
+    def test_current_token(self):
+        self.do_test(using_current)
+
     def do_test(self, setter_method):
         """Test that we obey thread conditioned breakpoints."""
         self.build()
@@ -51,7 +59,7 @@
         # thread joins the secondary thread, and then the main thread will
         # execute the code at the breakpoint.  If the thread-specific
         # breakpoint works, the next stop will be on the main thread.
-        setter_method(main_thread, thread_breakpoint)
+        setter_method(self, main_thread, thread_breakpoint)
 
         process.Continue()
         next_stop_state = process.GetState()
Index: lldb/source/Commands/Options.td
===================================================================
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -73,7 +73,7 @@
     "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.">;
Index: lldb/source/Commands/CommandObjectBreakpoint.cpp
===================================================================
--- lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -110,7 +110,19 @@
     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());
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107015.364895.patch
Type: text/x-patch
Size: 3725 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210806/33d47c63/attachment.bin>


More information about the lldb-commits mailing list