summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Breakpoint/Watchpoint.h4
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py23
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/main.c1
-rw-r--r--lldb/source/API/SBWatchpoint.cpp15
4 files changed, 35 insertions, 8 deletions
diff --git a/lldb/include/lldb/Breakpoint/Watchpoint.h b/lldb/include/lldb/Breakpoint/Watchpoint.h
index c2530b3f077..97f2e282acc 100644
--- a/lldb/include/lldb/Breakpoint/Watchpoint.h
+++ b/lldb/include/lldb/Breakpoint/Watchpoint.h
@@ -71,6 +71,10 @@ public:
bool IsEnabled() const;
+ // This doesn't really enable/disable the watchpoint.
+ // It is currently just for use in the Process plugin's
+ // {Enable,Disable}Watchpoint, which should be used instead.
+
void SetEnabled(bool enabled, bool notify = true);
bool IsHardware() const override;
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py
index a18cbe2dab4..aac001e9db5 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py
@@ -21,13 +21,21 @@ class TestWatchpointSetEnable(TestBase):
@expectedFailureAll(
oslist=["windows"],
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
- @expectedFailureAll(bugnumber="llvm.org/pr30789, <rdar://problem/28944061>")
def test_disable_works (self):
"""Set a watchpoint, disable it, and make sure it doesn't get hit."""
self.build()
- self.disable_works()
+ self.do_test(False)
- def disable_works(self):
+ @expectedFailureAndroid(archs=['arm', 'aarch64'])
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
+ def test_disable_enable_works (self):
+ """Set a watchpoint, disable it, and make sure it doesn't get hit."""
+ self.build()
+ self.do_test(True)
+
+ def do_test(self, test_enable):
"""Set a watchpoint, disable it and make sure it doesn't get hit."""
exe = 'a.out'
@@ -69,7 +77,12 @@ class TestWatchpointSetEnable(TestBase):
stop_reason = thread.GetStopReason()
- self.assertEqual(stop_reason, lldb.eStopReasonWatchpoint, "We didn't stop at our watchpoint.")
+ self.assertEqual(stop_reason, lldb.eStopReasonBreakpoint, "We didn't stop at our breakpoint.")
-
+ if test_enable:
+ wp.SetEnabled(True)
+ self.assertTrue(wp.IsEnabled(), "The watchpoint thinks it is still disabled.")
+ process.Continue()
+ stop_reason = thread.GetStopReason()
+ self.assertEqual(stop_reason, lldb.eStopReasonWatchpoint, "We didn't stop at our watchpoint")
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/main.c
index d9192f53741..dcbc766c594 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/main.c
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/main.c
@@ -8,5 +8,6 @@ main()
printf("Set a breakpoint here: %d.\n", global_var);
global_var = 20;
printf("We should have stopped on the previous line: %d.\n", global_var);
+ global_var = 30;
return 0;
}
diff --git a/lldb/source/API/SBWatchpoint.cpp b/lldb/source/API/SBWatchpoint.cpp
index f5d72076487..2cd48a53163 100644
--- a/lldb/source/API/SBWatchpoint.cpp
+++ b/lldb/source/API/SBWatchpoint.cpp
@@ -19,6 +19,7 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
@@ -126,9 +127,17 @@ size_t SBWatchpoint::GetWatchSize() {
void SBWatchpoint::SetEnabled(bool enabled) {
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp) {
- std::lock_guard<std::recursive_mutex> guard(
- watchpoint_sp->GetTarget().GetAPIMutex());
- watchpoint_sp->SetEnabled(enabled);
+ Target &target = watchpoint_sp->GetTarget();
+ std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex());
+ ProcessSP process_sp = target.GetProcessSP();
+ if (process_sp) {
+ if (enabled)
+ process_sp->EnableWatchpoint(watchpoint_sp.get(), false);
+ else
+ process_sp->DisableWatchpoint(watchpoint_sp.get(), false);
+ } else {
+ watchpoint_sp->SetEnabled(enabled);
+ }
}
}
OpenPOWER on IntegriCloud