summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Breakpoint/Watchpoint.h9
-rw-r--r--lldb/source/Breakpoint/Watchpoint.cpp20
-rw-r--r--lldb/source/Target/StopInfo.cpp6
3 files changed, 34 insertions, 1 deletions
diff --git a/lldb/include/lldb/Breakpoint/Watchpoint.h b/lldb/include/lldb/Breakpoint/Watchpoint.h
index 2b72a2fd4fe..13a37041af4 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 7c048fadf4a..3736adb3b73 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 2d48dccaca4..400829ff782 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;
OpenPOWER on IntegriCloud