[Lldb-commits] [lldb] r140279 - in /lldb/trunk: include/lldb/Breakpoint/WatchpointLocation.h include/lldb/Target/StopInfo.h source/Breakpoint/WatchpointLocation.cpp source/Target/StopInfo.cpp source/Target/ThreadPlanBase.cpp
Johnny Chen
johnny.chen at apple.com
Wed Sep 21 15:47:15 PDT 2011
Author: johnny
Date: Wed Sep 21 17:47:15 2011
New Revision: 140279
URL: http://llvm.org/viewvc/llvm-project?rev=140279&view=rev
Log:
StopInfoWatchpoint should override the StopInfo::ShouldStop() virtual method and delegate to
the WatchpointLocation object to check whether it should stop and allow it to update the hit
count, among other bookkeepings.
Modified:
lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h
lldb/trunk/include/lldb/Target/StopInfo.h
lldb/trunk/source/Breakpoint/WatchpointLocation.cpp
lldb/trunk/source/Target/StopInfo.cpp
lldb/trunk/source/Target/ThreadPlanBase.cpp
Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h?rev=140279&r1=140278&r2=140279&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h Wed Sep 21 17:47:15 2011
@@ -40,12 +40,14 @@
void
SetEnabled (bool enabled);
+ virtual bool
+ ShouldStop (StoppointCallbackContext *context);
+
bool WatchpointRead () const;
bool WatchpointWrite () const;
uint32_t GetIgnoreCount () const;
void SetIgnoreCount (uint32_t n);
void SetWatchpointType (uint32_t type);
- bool BreakpointWasHit (StoppointCallbackContext *context);
bool SetCallback (WatchpointHitCallback callback, void *callback_baton);
void SetDeclInfo (std::string &str);
void GetDescription (Stream *s, lldb::DescriptionLevel level);
Modified: lldb/trunk/include/lldb/Target/StopInfo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StopInfo.h?rev=140279&r1=140278&r2=140279&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StopInfo.h (original)
+++ lldb/trunk/include/lldb/Target/StopInfo.h Wed Sep 21 17:47:15 2011
@@ -53,7 +53,7 @@
// ----------------------------------------------
// eStopReasonBreakpoint BreakpointSiteID
// eStopReasonSignal Signal number
- // eStopReasonWatchpoint WatchpointSiteID
+ // eStopReasonWatchpoint WatchpointLocationID
// eStopReasonPlanComplete No significance
uint64_t
Modified: lldb/trunk/source/Breakpoint/WatchpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocation.cpp?rev=140279&r1=140278&r2=140279&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/WatchpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Wed Sep 21 17:47:15 2011
@@ -62,7 +62,7 @@
// should continue.
bool
-WatchpointLocation::BreakpointWasHit (StoppointCallbackContext *context)
+WatchpointLocation::ShouldStop (StoppointCallbackContext *context)
{
m_hit_count++;
@@ -73,7 +73,11 @@
access |= LLDB_WATCH_TYPE_READ;
if (m_watch_was_written)
access |= LLDB_WATCH_TYPE_WRITE;
- return m_callback(m_callback_baton, context, GetID(), access);
+
+ if (m_callback)
+ return m_callback(m_callback_baton, context, GetID(), access);
+ else
+ return true;
}
return false;
}
Modified: lldb/trunk/source/Target/StopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=140279&r1=140278&r2=140279&view=diff
==============================================================================
--- lldb/trunk/source/Target/StopInfo.cpp (original)
+++ lldb/trunk/source/Target/StopInfo.cpp Wed Sep 21 17:47:15 2011
@@ -324,8 +324,10 @@
public:
StopInfoWatchpoint (Thread &thread, break_id_t watch_id) :
- StopInfo (thread, watch_id),
- m_description()
+ StopInfo(thread, watch_id),
+ m_description(),
+ m_should_stop(false),
+ m_should_stop_is_valid(false)
{
}
@@ -339,6 +341,40 @@
return eStopReasonWatchpoint;
}
+ virtual bool
+ ShouldStop (Event *event_ptr)
+ {
+ // ShouldStop() method is idempotent and should not affect hit count.
+ if (m_should_stop_is_valid)
+ return m_should_stop;
+
+ WatchpointLocationSP wp_loc_sp =
+ m_thread.GetProcess().GetTarget().GetWatchpointLocationList().FindByID(GetValue());
+ if (wp_loc_sp)
+ {
+ // Check if we should stop at a watchpoint.
+ StoppointCallbackContext context (event_ptr,
+ &m_thread.GetProcess(),
+ &m_thread,
+ m_thread.GetStackFrameAtIndex(0).get(),
+ true);
+
+ m_should_stop = wp_loc_sp->ShouldStop (&context);
+ }
+ else
+ {
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+
+ if (log)
+ log->Printf ("Process::%s could not find watchpoint location id: %lld...",
+ __FUNCTION__, GetValue());
+
+ m_should_stop = true;
+ }
+ m_should_stop_is_valid = true;
+ return m_should_stop;
+ }
+
virtual const char *
GetDescription ()
{
@@ -351,10 +387,10 @@
return m_description.c_str();
}
-
-
private:
std::string m_description;
+ bool m_should_stop;
+ bool m_should_stop_is_valid;
};
Modified: lldb/trunk/source/Target/ThreadPlanBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanBase.cpp?rev=140279&r1=140278&r2=140279&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanBase.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanBase.cpp Wed Sep 21 17:47:15 2011
@@ -99,6 +99,7 @@
return false;
case eStopReasonBreakpoint:
+ case eStopReasonWatchpoint:
if (stop_info_sp->ShouldStop(event_ptr))
{
// If we are going to stop for a breakpoint, then unship the other plans
More information about the lldb-commits
mailing list