From 4fe2302ae218217e52563d3f78183283960cd4bb Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Tue, 21 Aug 2012 23:17:04 +0000 Subject: [PATCH] Fix test failures in TestWatchpointIter.py due to http://llvm.org/viewvc/llvm-project?rev=162322&view=rev. llvm-svn: 162328 --- lldb/include/lldb/Breakpoint/Watchpoint.h | 9 +++++++++ lldb/source/Breakpoint/Watchpoint.cpp | 20 +++++++++++++++++++- lldb/source/Target/StopInfo.cpp | 6 ++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lldb/include/lldb/Breakpoint/Watchpoint.h b/lldb/include/lldb/Breakpoint/Watchpoint.h index 2b72a2fd4fe7..13a37041af4c 100644 --- a/lldb/include/lldb/Breakpoint/Watchpoint.h +++ b/lldb/include/lldb/Breakpoint/Watchpoint.h @@ -150,6 +150,12 @@ public: //------------------------------------------------------------------ const char *GetConditionText () const; + void + TurnOnEphemeralMode(); + + void + TurnOffEphemeralMode(); + private: friend class Target; friend class WatchpointList; @@ -161,6 +167,9 @@ private: bool m_enabled; // Is this watchpoint enabled bool m_is_hardware; // Is this a hardware watchpoint bool m_is_watch_variable; // True if set via 'watchpoint set variable'. + bool m_is_ephemeral; // True if the watchpoint is in the ephemeral mode, meaning that it is + // undergoing a pair of temporary disable/enable actions to avoid recursively + // triggering further watchpoint events. uint32_t m_watch_read:1, // 1 if we stop when the watched data is read from m_watch_write:1, // 1 if we stop when the watched data is written to m_watch_was_read:1, // Set to 1 when watchpoint is hit for a read access diff --git a/lldb/source/Breakpoint/Watchpoint.cpp b/lldb/source/Breakpoint/Watchpoint.cpp index 7c048fadf4a7..3736adb3b730 100644 --- a/lldb/source/Breakpoint/Watchpoint.cpp +++ b/lldb/source/Breakpoint/Watchpoint.cpp @@ -29,6 +29,7 @@ Watchpoint::Watchpoint (lldb::addr_t addr, size_t size, bool hardware) : m_enabled(false), m_is_hardware(hardware), m_is_watch_variable(false), + m_is_ephemeral(false), m_watch_read(0), m_watch_write(0), m_watch_was_read(0), @@ -307,12 +308,29 @@ Watchpoint::IsEnabled() const return m_enabled; } +// Within StopInfo.cpp, we purposely turn on the ephemeral mode right before temporarily disable the watchpoint +// in order to perform possible watchpoint actions without triggering further watchpoint events. +// After the temporary disabled watchpoint is enabled, we then turn off the ephemeral mode. + +void +Watchpoint::TurnOnEphemeralMode() +{ + m_is_ephemeral = true; +} + +void +Watchpoint::TurnOffEphemeralMode() +{ + m_is_ephemeral = false; +} + void Watchpoint::SetEnabled(bool enabled) { if (!enabled) { - SetHardwareIndex(LLDB_INVALID_INDEX32); + if (!m_is_ephemeral) + SetHardwareIndex(LLDB_INVALID_INDEX32); // Don't clear the snapshots for now. // Within StopInfo.cpp, we purposely do disable/enable watchpoint while performing watchpoint actions. //ClearSnapshots(); diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp index 2d48dccaca48..400829ff7824 100644 --- a/lldb/source/Target/StopInfo.cpp +++ b/lldb/source/Target/StopInfo.cpp @@ -454,12 +454,18 @@ public: watchpoint(w) { if (process && watchpoint) + { + watchpoint->TurnOnEphemeralMode(); process->DisableWatchpoint(watchpoint); + } } ~WatchpointSentry() { if (process && watchpoint) + { process->EnableWatchpoint(watchpoint); + watchpoint->TurnOffEphemeralMode(); + } } private: Process *process;