aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart')
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py43
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp25
3 files changed, 73 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py
new file mode 100644
index 000000000000..4ca93765b656
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py
@@ -0,0 +1,43 @@
+"""
+Test inferior restart when breakpoint is set on running target.
+"""
+
+import os
+import lldb
+from lldbsuite.test.lldbtest import *
+
+class BreakpointSetRestart(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ BREAKPOINT_TEXT = 'Set a breakpoint here'
+
+ def test_breakpoint_set_restart(self):
+ self.build()
+
+ cwd = os.getcwd()
+ exe = os.path.join(cwd, 'a.out')
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ self.dbg.SetAsync(True)
+ process = target.LaunchSimple(None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ event = lldb.SBEvent()
+ # Wait for inferior to transition to running state
+ while self.dbg.GetListener().WaitForEvent(2, event):
+ if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning:
+ break
+
+ bp = target.BreakpointCreateBySourceRegex(self.BREAKPOINT_TEXT,
+ lldb.SBFileSpec(os.path.join(cwd, 'main.cpp')))
+ self.assertTrue(bp.IsValid() and bp.GetNumLocations() == 1, VALID_BREAKPOINT)
+
+ while self.dbg.GetListener().WaitForEvent(2, event):
+ if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateStopped and lldb.SBProcess.GetRestartedFromEvent(event):
+ continue
+ if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning:
+ continue
+ self.fail("Setting a breakpoint generated an unexpected event: %s" % lldb.SBDebugger.StateAsCString(lldb.SBProcess.GetStateFromEvent(event)))
+
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp
new file mode 100644
index 000000000000..e6d3a95d017f
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp
@@ -0,0 +1,25 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <chrono>
+#include <stdio.h>
+#include <thread>
+
+
+int main(int argc, char const *argv[])
+{
+ static bool done = false;
+ while (!done)
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds{100});
+ }
+ printf("Set a breakpoint here.\n");
+ return 0;
+}
+