[Lldb-commits] [lldb] r139198 - in /lldb/trunk: include/lldb/Breakpoint/WatchpointLocation.h source/Breakpoint/WatchpointLocation.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
Johnny Chen
johnny.chen at apple.com
Tue Sep 6 15:38:36 PDT 2011
Author: johnny
Date: Tue Sep 6 17:38:36 2011
New Revision: 139198
URL: http://llvm.org/viewvc/llvm-project?rev=139198&view=rev
Log:
Fill out implementation of Enable/DisableWatchpoint() for ProcessGDBRemote class (Not Tested Yet).
Also update the signature of WatchpointLocation::SetEnable() to take a bool as input arg.
Modified:
lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h
lldb/trunk/source/Breakpoint/WatchpointLocation.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h?rev=139198&r1=139197&r2=139198&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h Tue Sep 6 17:38:36 2011
@@ -37,7 +37,7 @@
IsEnabled () const;
void
- SetEnabled (uint32_t enabled);
+ SetEnabled (bool enabled);
bool WatchpointRead () const;
bool WatchpointWrite () const;
Modified: lldb/trunk/source/Breakpoint/WatchpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocation.cpp?rev=139198&r1=139197&r2=139198&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/WatchpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Tue Sep 6 17:38:36 2011
@@ -99,7 +99,7 @@
}
void
-WatchpointLocation::SetEnabled(uint32_t enabled)
+WatchpointLocation::SetEnabled(bool enabled)
{
if (!enabled)
SetHardwareIndex(LLDB_INVALID_INDEX32);
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=139198&r1=139197&r2=139198&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Sep 6 17:38:36 2011
@@ -1882,6 +1882,24 @@
return error;
}
+// Pre-requisite: wp != NULL.
+static GDBStoppointType
+GetGDBStoppointType (WatchpointLocation *wp)
+{
+ assert(wp);
+ bool watch_read = wp->WatchpointRead();
+ bool watch_write = wp->WatchpointWrite();
+
+ // watch_read and watch_write cannot both be false.
+ assert(watch_read || watch_write);
+ if (watch_read && watch_write)
+ return eWatchpointReadWrite;
+ if (watch_read)
+ return eWatchpointRead;
+ if (watch_write)
+ return eWatchpointWrite;
+}
+
Error
ProcessGDBRemote::EnableWatchpoint (WatchpointLocation *wp)
{
@@ -1899,11 +1917,21 @@
log->Printf("ProcessGDBRemote::EnableWatchpoint(watchID = %d) addr = 0x%8.8llx: watchpoint already enabled.", watchID, (uint64_t)addr);
return error;
}
- else
+
+ GDBStoppointType type = GetGDBStoppointType(wp);
+ // Pass down an appropriate z/Z packet...
+ if (m_gdb_comm.SupportsGDBStoppointPacket (type))
{
- // Pass down an appropriate z/Z packet...
- error.SetErrorString("watchpoints not supported");
+ if (m_gdb_comm.SendGDBStoppointTypePacket(type, true, addr, wp->GetByteSize()) == 0)
+ {
+ wp->SetEnabled(true);
+ return error;
+ }
+ else
+ error.SetErrorString("sending gdb watchpoint packet failed");
}
+ else
+ error.SetErrorString("watchpoints not supported");
}
else
{
@@ -1928,10 +1956,24 @@
if (log)
log->Printf ("ProcessGDBRemote::DisableWatchpoint (watchID = %d) addr = 0x%8.8llx", watchID, (uint64_t)addr);
+ if (!wp->IsEnabled())
+ {
+ if (log)
+ log->Printf ("ProcessGDBRemote::DisableWatchpoint (watchID = %d) addr = 0x%8.8llx -- SUCCESS (already disabled)", watchID, (uint64_t)addr);
+ return error;
+ }
+
if (wp->IsHardware())
{
+ GDBStoppointType type = GetGDBStoppointType(wp);
// Pass down an appropriate z/Z packet...
- error.SetErrorString("watchpoints not supported");
+ if (m_gdb_comm.SendGDBStoppointTypePacket(type, false, addr, wp->GetByteSize()) == 0)
+ {
+ wp->SetEnabled(false);
+ return error;
+ }
+ else
+ error.SetErrorString("sending gdb watchpoint packet failed");
}
// TODO: clear software watchpoints if we implement them
}
More information about the lldb-commits
mailing list