From 5e3fe047cd9300c096e6006294e25c60b526ee83 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Wed, 11 Feb 2015 00:37:54 +0000 Subject: [PATCH] As part of the cleanup when a process dies, tell watchpoints to forget their previously recorded values Because types are not reliably protected against the death of their owners, having ValueObjects lurking around like that past the useful lifetime of their owner processes is a potential source of crashes That is - in itself - worth fixing at some point, but for this case, watchpoints holding on to old values don't offer enough value to make the larger fix worth Fixes rdar://19788756 llvm-svn: 228777 --- lldb/include/lldb/Breakpoint/Watchpoint.h | 13 ++++++++++++- lldb/include/lldb/Target/Target.h | 3 +++ lldb/include/lldb/Utility/SharingPtr.h | 11 ++++++++++- lldb/source/Target/Target.cpp | 21 +++++++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/lldb/include/lldb/Breakpoint/Watchpoint.h b/lldb/include/lldb/Breakpoint/Watchpoint.h index 8493775..9bb03b9 100644 --- a/lldb/include/lldb/Breakpoint/Watchpoint.h +++ b/lldb/include/lldb/Breakpoint/Watchpoint.h @@ -205,7 +205,18 @@ private: friend class Target; friend class WatchpointList; - void ResetHitCount() { m_hit_count = 0; } + void + ResetHitCount () + { + m_hit_count = 0; + } + + void + ResetHistoricValues () + { + m_old_value_sp.reset(nullptr); + m_new_value_sp.reset(nullptr); + } Target &m_target; bool m_enabled; // Is this watchpoint enabled diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 7ec197c..e9389cf 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -783,6 +783,9 @@ public: ClearAllWatchpointHitCounts (); bool + ClearAllWatchpointHistoricValues (); + + bool IgnoreAllWatchpoints (uint32_t ignore_count); bool diff --git a/lldb/include/lldb/Utility/SharingPtr.h b/lldb/include/lldb/Utility/SharingPtr.h index 1b5f86b..5c77dad 100644 --- a/lldb/include/lldb/Utility/SharingPtr.h +++ b/lldb/include/lldb/Utility/SharingPtr.h @@ -154,6 +154,7 @@ public: void swap(SharingPtr& r); void reset(); template void reset(Y* p); + void reset(std::nullptr_t); element_type* get() const {return ptr_;} element_type& operator*() const {return *ptr_;} @@ -295,6 +296,14 @@ SharingPtr::reset() } template +inline +void +SharingPtr::reset (std::nullptr_t p) +{ + reset(); +} + +template template inline void @@ -547,7 +556,7 @@ public: if (cb_) cb_(baton_, *this, false); } - + void SetCallback(Callback cb, void* baton) { cb_ = cb; diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 4d53055..8ea6942 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -175,6 +175,7 @@ Target::CleanupProcess () this->GetWatchpointList().GetListMutex(locker); DisableAllWatchpoints(false); ClearAllWatchpointHitCounts(); + ClearAllWatchpointHistoricValues(); } void @@ -907,6 +908,26 @@ Target::ClearAllWatchpointHitCounts () return true; // Success! } +// Assumption: Caller holds the list mutex lock for m_watchpoint_list. +bool +Target::ClearAllWatchpointHistoricValues () +{ + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); + if (log) + log->Printf ("Target::%s\n", __FUNCTION__); + + size_t num_watchpoints = m_watchpoint_list.GetSize(); + for (size_t i = 0; i < num_watchpoints; ++i) + { + WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i); + if (!wp_sp) + return false; + + wp_sp->ResetHistoricValues(); + } + return true; // Success! +} + // Assumption: Caller holds the list mutex lock for m_watchpoint_list // during these operations. bool -- 2.7.4