[Lldb-commits] [lldb] r139034 - in /lldb/trunk/tools/debugserver/source: DNBArch.h MacOSX/i386/DNBArchImplI386.cpp MacOSX/i386/DNBArchImplI386.h MacOSX/x86_64/DNBArchImplX86_64.cpp MacOSX/x86_64/DNBArchImplX86_64.h
Johnny Chen
johnny.chen at apple.com
Fri Sep 2 14:13:08 PDT 2011
Author: johnny
Date: Fri Sep 2 16:13:07 2011
New Revision: 139034
URL: http://llvm.org/viewvc/llvm-project?rev=139034&view=rev
Log:
Watchpoint work in progress:
Add a virtual method GetHardwareWatchpointHit() to the DNBArchProtocol base class
which consults the architecture to return the watchpoint hit; otherwise return an
invalid index.
Add impl. of the method to X86_64 and I386 subclasses, plus reset the debug status
register before we resume execution of the inferior thread.
Modified:
lldb/trunk/tools/debugserver/source/DNBArch.h
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/DNBArch.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBArch.h?rev=139034&r1=139033&r2=139034&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNBArch.h (original)
+++ lldb/trunk/tools/debugserver/source/DNBArch.h Fri Sep 2 16:13:07 2011
@@ -79,6 +79,7 @@
virtual uint32_t EnableHardwareWatchpoint (nub_addr_t addr, nub_size_t size, bool read, bool write) { return INVALID_NUB_HW_INDEX; }
virtual bool DisableHardwareBreakpoint (uint32_t hw_index) { return false; }
virtual bool DisableHardwareWatchpoint (uint32_t hw_index) { return false; }
+ virtual uint32_t GetHardwareWatchpointHit() { return INVALID_NUB_HW_INDEX; }
virtual bool StepNotComplete () { return false; }
};
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=139034&r1=139033&r2=139034&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp Fri Sep 2 16:13:07 2011
@@ -545,6 +545,17 @@
// This is the primary thread, let the arch do anything it needs
EnableHardwareSingleStep(true);
}
+
+ // Reset the debug status register before we resume.
+ kern_return_t kret = GetDBGState(false);
+ DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplI386::ThreadWillResume() GetDBGState() => 0x%8.8x.", kret);
+ if (kret == KERN_SUCCESS)
+ {
+ DBG debug_state = m_state.context.dbg;
+ ClearWatchpointHits(debug_state);
+ kret = SetDBGState();
+ DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplI386::ThreadWillResume() SetDBGState() => 0x%8.8x.", kret);
+ }
}
bool
@@ -625,6 +636,29 @@
return false;
}
+// Iterate through the debug status register; return the index of the first hit.
+uint32_t
+DNBArchImplI386::GetHardwareWatchpointHit()
+{
+ // Read the debug state
+ kern_return_t kret = GetDBGState(false);
+ DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplI386::GetHardwareWatchpointHit() GetDBGState() => 0x%8.8x.", kret);
+ if (kret == KERN_SUCCESS)
+ {
+ DBG debug_state = m_state.context.dbg;
+ uint32_t i, num = NumSupportedHardwareWatchpoints();
+ for (i = 0; i < num; ++i)
+ {
+ if (IsWatchpointHit(debug_state, i))
+ {
+ DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::GetHardwareWatchpointHit() found => %u.", i);
+ return i;
+ }
+ }
+ }
+ return INVALID_NUB_HW_INDEX;
+}
+
uint32_t
DNBArchImplI386::NumSupportedHardwareWatchpoints()
{
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=139034&r1=139033&r2=139034&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h Fri Sep 2 16:13:07 2011
@@ -54,6 +54,7 @@
virtual uint32_t NumSupportedHardwareWatchpoints();
virtual uint32_t EnableHardwareWatchpoint (nub_addr_t addr, nub_size_t size, bool read, bool write);
virtual bool DisableHardwareWatchpoint (uint32_t hw_break_index);
+ virtual uint32_t GetHardwareWatchpointHit();
protected:
kern_return_t EnableHardwareSingleStep (bool enable);
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=139034&r1=139033&r2=139034&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 2 16:13:07 2011
@@ -474,6 +474,17 @@
// This is the primary thread, let the arch do anything it needs
EnableHardwareSingleStep(true);
}
+
+ // Reset the debug status register before we resume.
+ kern_return_t kret = GetDBGState(false);
+ DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::ThreadWillResume() GetDBGState() => 0x%8.8x.", kret);
+ if (kret == KERN_SUCCESS)
+ {
+ DBG debug_state = m_state.context.dbg;
+ ClearWatchpointHits(debug_state);
+ kret = SetDBGState();
+ DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::ThreadWillResume() SetDBGState() => 0x%8.8x.", kret);
+ }
}
bool
@@ -759,6 +770,29 @@
return false;
}
+// Iterate through the debug status register; return the index of the first hit.
+uint32_t
+DNBArchImplX86_64::GetHardwareWatchpointHit()
+{
+ // Read the debug state
+ kern_return_t kret = GetDBGState(false);
+ DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::GetHardwareWatchpointHit() GetDBGState() => 0x%8.8x.", kret);
+ if (kret == KERN_SUCCESS)
+ {
+ DBG debug_state = m_state.context.dbg;
+ uint32_t i, num = NumSupportedHardwareWatchpoints();
+ for (i = 0; i < num; ++i)
+ {
+ if (IsWatchpointHit(debug_state, i))
+ {
+ DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::GetHardwareWatchpointHit() found => %u.", i);
+ return i;
+ }
+ }
+ }
+ return INVALID_NUB_HW_INDEX;
+}
+
// Set the single step bit in the processor status register.
kern_return_t
DNBArchImplX86_64::EnableHardwareSingleStep (bool enable)
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=139034&r1=139033&r2=139034&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 Fri Sep 2 16:13:07 2011
@@ -53,6 +53,7 @@
virtual uint32_t NumSupportedHardwareWatchpoints();
virtual uint32_t EnableHardwareWatchpoint (nub_addr_t addr, nub_size_t size, bool read, bool write);
virtual bool DisableHardwareWatchpoint (uint32_t hw_break_index);
+ virtual uint32_t GetHardwareWatchpointHit();
protected:
kern_return_t EnableHardwareSingleStep (bool enable);
More information about the lldb-commits
mailing list