[Lldb-commits] [PATCH 6/9] Fix implementation of LinuxThread::HardwareSingleStep.

Stephen Wilson wilsons at start.ca
Tue Jan 18 14:39:12 PST 2011


Previous version simply resumed the associated thread to single step over a
single instruction which is not the intended semantics for this method.  Set the
appropriate bit in the rflags register instead.

diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp
index 4dddce8..e16a3de 100644
--- a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp
+++ b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp
@@ -690,7 +690,28 @@ RegisterContextLinux_x86_64::ConvertRegisterKindToRegisterNumber(uint32_t kind,
 bool
 RegisterContextLinux_x86_64::HardwareSingleStep(bool enable)
 {
-    return GetMonitor().SingleStep(GetThreadID());
+    enum { TRACE_BIT = 0x100 };
+    uint64_t rflags;
+
+    if ((rflags = ReadRegisterAsUnsigned(gpr_rflags, -1UL)) == -1UL)
+        return false;
+    
+    if (enable)
+    {
+        if (rflags & TRACE_BIT)
+            return true;
+
+        rflags |= TRACE_BIT;
+    }
+    else
+    {
+        if (!(rflags & TRACE_BIT))
+            return false;
+
+        rflags &= ~TRACE_BIT;
+    }
+
+    return WriteRegisterFromUnsigned(gpr_rflags, rflags);
 }
 
 bool
-- 
1.7.3.5




More information about the lldb-commits mailing list