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

Johnny Chen johnny.chen at apple.com
Wed Aug 31 12:05:55 PDT 2011


Author: johnny
Date: Wed Aug 31 14:05:55 2011
New Revision: 138881

URL: http://llvm.org/viewvc/llvm-project?rev=138881&view=rev
Log:
Add a couple of helper methods to check/clear the debug status register
which contains the watchpoint hit information.

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

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=138881&r1=138880&r2=138881&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp Wed Aug 31 14:05:55 2011
@@ -733,6 +733,29 @@
     return (debug_state.__dr7 & (3 << (2*hw_index))) == 0;
 }
 
+// Resets local copy of debug status register to wait for the next debug excpetion.
+void
+DNBArchImplI386::ClearWatchpointHit(DBG &debug_state)
+{
+    // See also IsWatchpointHit().
+    debug_state.__dr6 = 0;
+    return;
+}
+
+bool
+DNBArchImplI386::IsWatchpointHit(const DBG &debug_state, uint32_t hw_index)
+{
+    // Check dr6 (debug status register) whether a watchpoint hits:
+    //          is watchpoint hit?
+    //                  |
+    //                  v
+    //      dr0 -> bits{0}
+    //      dr1 -> bits{1}
+    //      dr2 -> bits{2}
+    //      dr3 -> bits{3}
+    return (debug_state.__dr6 & (1 << hw_index));
+}
+
 uint32_t
 DNBArchImplI386::EnableHardwareWatchpoint (nub_addr_t addr, nub_size_t size, bool read, bool write)
 {

Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h?rev=138881&r1=138880&r2=138881&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h Wed Aug 31 14:05:55 2011
@@ -230,6 +230,8 @@
     static void SetWatchpoint(DBG &debug_state, uint32_t hw_index, nub_addr_t addr, nub_size_t size, bool read, bool write);
     static void ClearWatchpoint(DBG &debug_state, uint32_t hw_index);
     static bool IsVacantWatchpoint(const DBG &debug_state, uint32_t hw_index);
+    static void ClearWatchpointHit(DBG &debug_state);
+    static bool IsWatchpointHit(const DBG &debug_state, uint32_t hw_index);
 
     MachThread *m_thread;
     State       m_state;

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=138881&r1=138880&r2=138881&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 Wed Aug 31 14:05:55 2011
@@ -661,6 +661,29 @@
     return (debug_state.__dr7 & (3 << (2*hw_index))) == 0;
 }
 
+// Resets local copy of debug status register to wait for the next debug excpetion.
+void
+DNBArchImplX86_64::ClearWatchpointHit(DBG &debug_state)
+{
+    // See also IsWatchpointHit().
+    debug_state.__dr6 = 0;
+    return;
+}
+
+bool
+DNBArchImplX86_64::IsWatchpointHit(const DBG &debug_state, uint32_t hw_index)
+{
+    // Check dr6 (debug status register) whether a watchpoint hits:
+    //          is watchpoint hit?
+    //                  |
+    //                  v
+    //      dr0 -> bits{0}
+    //      dr1 -> bits{1}
+    //      dr2 -> bits{2}
+    //      dr3 -> bits{3}
+    return (debug_state.__dr6 & (1 << hw_index));
+}
+
 uint32_t
 DNBArchImplX86_64::EnableHardwareWatchpoint (nub_addr_t addr, nub_size_t size, bool read, bool write)
 {

Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h?rev=138881&r1=138880&r2=138881&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h Wed Aug 31 14:05:55 2011
@@ -237,6 +237,8 @@
     static void SetWatchpoint(DBG &debug_state, uint32_t hw_index, nub_addr_t addr, nub_size_t size, bool read, bool write);
     static void ClearWatchpoint(DBG &debug_state, uint32_t hw_index);
     static bool IsVacantWatchpoint(const DBG &debug_state, uint32_t hw_index);
+    static void ClearWatchpointHit(DBG &debug_state);
+    static bool IsWatchpointHit(const DBG &debug_state, uint32_t hw_index);
 
     MachThread *m_thread;
     State        m_state;





More information about the lldb-commits mailing list