[Lldb-commits] [lldb] r139246 - in /lldb/trunk/tools/debugserver/source: MacOSX/MachThreadList.cpp RNBRemote.cpp

Johnny Chen johnny.chen at apple.com
Wed Sep 7 12:03:50 PDT 2011


Author: johnny
Date: Wed Sep  7 14:03:50 2011
New Revision: 139246

URL: http://llvm.org/viewvc/llvm-project?rev=139246&view=rev
Log:
Add logic to MachThreadList::GetThreadID() for the use case of setting a watchpoint
(MachThreadList::EnableHardwareWatchpoint()) where the watchpoint is not associated
with a thread and the current thread, if set, is returned, otherwise we return the
first thread.

Plus minor change to RNBRemote::HandlePacket_z() to use the existing macros to check
the validity of break_id/watch_id.

Modified:
    lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp
    lldb/trunk/tools/debugserver/source/RNBRemote.cpp

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp?rev=139246&r1=139245&r2=139246&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Wed Sep  7 14:03:50 2011
@@ -99,14 +99,26 @@
     PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
     MachThreadSP thread_sp;
     const size_t num_threads = m_threads.size();
-    for (size_t idx = 0; idx < num_threads; ++idx)
+    if (MachThread::ThreadIDIsValid(tid))
     {
-        if (m_threads[idx]->ThreadID() == tid)
+        for (size_t idx = 0; idx < num_threads; ++idx)
         {
-            thread_sp = m_threads[idx];
-            break;
+            if (m_threads[idx]->ThreadID() == tid)
+            {
+                thread_sp = m_threads[idx];
+                break;
+            }
         }
     }
+    else if (num_threads > 0)
+    {
+        // See DNBWatchpointSet() -> MachProcess::CreateWatchpoint() -> MachProcess::EnableWatchpoint()
+        // -> MachThreadList::EnableHardwareWatchpoint() for a use case of this branch.
+        if (m_current_thread)
+            thread_sp = m_current_thread;
+        else
+            thread_sp = m_threads[0];
+    }
     return thread_sp;
 }
 

Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=139246&r1=139245&r2=139246&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original)
+++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Wed Sep  7 14:03:50 2011
@@ -2885,7 +2885,7 @@
                     // We do NOT already have a breakpoint at this address, So lets
                     // create one.
                     nub_break_t break_id = DNBBreakpointSet (pid, addr, byte_size, hardware);
-                    if (break_id != INVALID_NUB_BREAK_ID)
+                    if (NUB_BREAK_ID_IS_VALID(break_id))
                     {
                         // We successfully created a breakpoint, now lets full out
                         // a ref count structure with the breakID and add it to our
@@ -2930,7 +2930,7 @@
                     // We do NOT already have a watchpoint at this address, So lets
                     // create one.
                     nub_watch_t watch_id = DNBWatchpointSet (pid, addr, byte_size, watch_flags, hardware);
-                    if (watch_id != INVALID_NUB_WATCH_ID)
+                    if (NUB_WATCH_ID_IS_VALID(watch_id))
                     {
                         // We successfully created a watchpoint, now lets full out
                         // a ref count structure with the watch_id and add it to our





More information about the lldb-commits mailing list