[Lldb-commits] [lldb] r139410 - in /lldb/trunk/tools/debugserver/source/MacOSX: i386/DNBArchImplI386.cpp x86_64/DNBArchImplX86_64.cpp

Johnny Chen johnny.chen at apple.com
Fri Sep 9 14:11:26 PDT 2011


Author: johnny
Date: Fri Sep  9 16:11:25 2011
New Revision: 139410

URL: http://llvm.org/viewvc/llvm-project?rev=139410&view=rev
Log:
Reset the debug status register, only if necessary, before we resume,
which saves unnecessary traffic to the kernel.

Modified:
    lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp

Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp?rev=139410&r1=139409&r2=139410&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp Fri Sep  9 16:11:25 2011
@@ -546,15 +546,24 @@
         EnableHardwareSingleStep(true);
     }
 
-    // Reset the debug status register before we resume.
+    // Reset the debug status register, if necessary, before we resume.
     kern_return_t kret = GetDBGState(false);
-    DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplI386::ThreadWillResume() GetDBGState() => 0x%8.8x.", kret);
-    if (kret == KERN_SUCCESS)
+    DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::ThreadWillResume() GetDBGState() => 0x%8.8x.", kret);
+    if (kret != KERN_SUCCESS)
+        return;
+
+    DBG debug_state = m_state.context.dbg;
+    bool need_reset = false;
+    uint32_t i, num = NumSupportedHardwareWatchpoints();
+    for (i = 0; i < num; ++i)
+        if (IsWatchpointHit(debug_state, i))
+            need_reset = true;
+
+    if (need_reset)
     {
-        DBG debug_state = m_state.context.dbg;
         ClearWatchpointHits(debug_state);
         kret = SetDBGState();
-        DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplI386::ThreadWillResume() SetDBGState() => 0x%8.8x.", kret);
+        DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::ThreadWillResume() SetDBGState() => 0x%8.8x.", kret);
     }
 }
 

Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=139410&r1=139409&r2=139410&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Fri Sep  9 16:11:25 2011
@@ -475,12 +475,21 @@
         EnableHardwareSingleStep(true);
     }
 
-    // Reset the debug status register before we resume.
+    // Reset the debug status register, if necessary, before we resume.
     kern_return_t kret = GetDBGState(false);
     DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::ThreadWillResume() GetDBGState() => 0x%8.8x.", kret);
-    if (kret == KERN_SUCCESS)
+    if (kret != KERN_SUCCESS)
+        return;
+
+    DBG debug_state = m_state.context.dbg;
+    bool need_reset = false;
+    uint32_t i, num = NumSupportedHardwareWatchpoints();
+    for (i = 0; i < num; ++i)
+        if (IsWatchpointHit(debug_state, i))
+            need_reset = true;
+
+    if (need_reset)
     {
-        DBG debug_state = m_state.context.dbg;
         ClearWatchpointHits(debug_state);
         kret = SetDBGState();
         DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::ThreadWillResume() SetDBGState() => 0x%8.8x.", kret);
@@ -807,7 +816,7 @@
 DNBArchImplX86_64::GetHardwareWatchpointHit(nub_addr_t &addr)
 {
     // Read the debug state
-    kern_return_t kret = GetDBGState(false);
+    kern_return_t kret = GetDBGState(true);
     DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::GetHardwareWatchpointHit() GetDBGState() => 0x%8.8x.", kret);
     if (kret == KERN_SUCCESS)
     {





More information about the lldb-commits mailing list