summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-09-10 12:04:04 +0000
committerRaphael Isemann <teemperor@gmail.com>2019-09-10 12:04:04 +0000
commitd9442afba1bd65fd0b5c93b67922eaed923445e2 (patch)
tree4cf657a31d92a6a17d07dd8a81e85bd00fe22d39 /lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints
parent3729b17cff53b536d2019b2d4c90e2a6f17754d1 (diff)
downloadbcm5719-llvm-d9442afba1bd65fd0b5c93b67922eaed923445e2.tar.gz
bcm5719-llvm-d9442afba1bd65fd0b5c93b67922eaed923445e2.zip
[lldb] Readd missing functionalities/breakpoint tests
It seems when I restructured the test folders the functionalities/breakpoint was deleted. This just reverts this change and re-adds the tests. llvm-svn: 371512
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/Makefile6
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py105
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp50
3 files changed, 161 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/Makefile
new file mode 100644
index 00000000000..3665ae323e7
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../../make
+
+ENABLE_THREADS := YES
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
new file mode 100644
index 00000000000..95c7966716c
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
@@ -0,0 +1,105 @@
+"""
+Test hardware breakpoints for multiple threads.
+"""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+# Hardware breakpoints are supported only by platforms mentioned in oslist.
+@skipUnlessPlatform(oslist=['linux'])
+class HardwareBreakpointMultiThreadTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ # LLDB supports hardware breakpoints for arm and aarch64 architectures.
+ @skipIf(archs=no_match(['arm', 'aarch64']))
+ def test_hw_break_set_delete_multi_thread(self):
+ self.build()
+ self.setTearDownCleanup()
+ self.break_multi_thread('delete')
+
+ # LLDB supports hardware breakpoints for arm and aarch64 architectures.
+ @skipIf(archs=no_match(['arm', 'aarch64']))
+ def test_hw_break_set_disable_multi_thread(self):
+ self.build()
+ self.setTearDownCleanup()
+ self.break_multi_thread('disable')
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Our simple source filename.
+ self.source = 'main.cpp'
+ # Find the line number to break inside main().
+ self.first_stop = line_number(
+ self.source, 'Starting thread creation with hardware breakpoint set')
+
+ def break_multi_thread(self, removal_type):
+ """Test that lldb hardware breakpoints work for multiple threads."""
+ self.runCmd("file " + self.getBuildArtifact("a.out"),
+ CURRENT_EXECUTABLE_SET)
+
+ # Stop in main before creating any threads.
+ lldbutil.run_break_set_by_file_and_line(
+ self, None, self.first_stop, num_expected_locations=1)
+
+ # Run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # We should be stopped again due to the breakpoint.
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # Now set a hardware breakpoint in thread function.
+ self.expect("breakpoint set -b hw_break_function --hardware",
+ substrs=[
+ 'Breakpoint',
+ 'hw_break_function',
+ 'address = 0x'])
+
+ # We should stop in hw_break_function function for 4 threads.
+ count = 0
+
+ while count < 2 :
+
+ self.runCmd("process continue")
+
+ # We should be stopped in hw_break_function
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=[
+ 'stop reason = breakpoint',
+ 'hw_break_function'])
+
+ # Continue the loop and test that we are stopped 4 times.
+ count += 1
+
+ if removal_type == 'delete':
+ self.runCmd("settings set auto-confirm true")
+
+ # Now 'breakpoint delete' should just work fine without confirmation
+ # prompt from the command interpreter.
+ self.expect("breakpoint delete",
+ startstr="All breakpoints removed")
+
+ # Restore the original setting of auto-confirm.
+ self.runCmd("settings clear auto-confirm")
+
+ elif removal_type == 'disable':
+ self.expect("breakpoint disable",
+ startstr="All breakpoints disabled.")
+
+ # Continue. Program should exit without stopping anywhere.
+ self.runCmd("process continue")
+
+ # Process should have stopped and exited with status = 0
+ self.expect("process status", PROCESS_STOPPED,
+ patterns=['Process .* exited with status = 0'])
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp
new file mode 100644
index 00000000000..94a12c6241d
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp
@@ -0,0 +1,50 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <chrono>
+#include <cstdio>
+#include <mutex>
+#include <random>
+#include <thread>
+
+#define NUM_OF_THREADS 4
+
+std::mutex hw_break_mutex;
+
+void
+hw_break_function (uint32_t thread_index) {
+ printf ("%s called by Thread #%u...\n", __FUNCTION__, thread_index);
+}
+
+
+void
+thread_func (uint32_t thread_index) {
+ printf ("%s (thread index = %u) starting...\n", __FUNCTION__, thread_index);
+
+ hw_break_mutex.lock();
+
+ hw_break_function(thread_index); // Call hw_break_function
+
+ hw_break_mutex.unlock();
+}
+
+
+int main (int argc, char const *argv[])
+{
+ std::thread threads[NUM_OF_THREADS];
+
+ printf ("Starting thread creation with hardware breakpoint set...\n");
+
+ for (auto &thread : threads)
+ thread = std::thread{thread_func, std::distance(threads, &thread)};
+
+ for (auto &thread : threads)
+ thread.join();
+
+ return 0;
+}
OpenPOWER on IntegriCloud