summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2018-11-15 01:18:15 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2018-11-15 01:18:15 +0000
commite103ae92ef2336854587778bd3ae88a87e409a5e (patch)
treea474b4d1db388480dd129f0ab61a690a4f504ca5 /lldb/packages/Python/lldbsuite/test
parentdf14b94243e9e8ade2747e6adb8a3d9d2cfa71ae (diff)
downloadbcm5719-llvm-e103ae92ef2336854587778bd3ae88a87e409a5e.tar.gz
bcm5719-llvm-e103ae92ef2336854587778bd3ae88a87e409a5e.zip
Add setting to require hardware breakpoints.
When debugging read-only memory we cannot use software breakpoint. We already have support for hardware breakpoints and users can specify them with `-H`. However, there's no option to force LLDB to use hardware breakpoints internally, for example while stepping. This patch adds a setting target.require-hardware-breakpoint that forces LLDB to always use hardware breakpoints. Because hardware breakpoints are a limited resource and can fail to resolve, this patch also extends error handling in thread plans, where breakpoints are used for stepping. Differential revision: https://reviews.llvm.org/D54221 llvm-svn: 346920
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/Makefile9
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py102
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/main.c9
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py2
4 files changed, 121 insertions, 1 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/Makefile
new file mode 100644
index 00000000000..7934cd5db42
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+
+ifneq (,$(findstring icc,$(CC)))
+ CFLAGS += -debug inline-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py
new file mode 100644
index 00000000000..1a1ee2eaa89
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py
@@ -0,0 +1,102 @@
+"""
+Test require hardware breakpoints.
+"""
+
+from __future__ import print_function
+
+import os
+import time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class BreakpointLocationsTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_breakpoint(self):
+ """Test regular breakpoints when hardware breakpoints are required."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ target = self.dbg.CreateTarget(exe)
+
+ self.runCmd("settings set target.require-hardware-breakpoint true")
+
+ breakpoint = target.BreakpointCreateByLocation("main.c", 1)
+ self.assertTrue(breakpoint.IsHardware())
+
+ def test_step_range(self):
+ """Test stepping when hardware breakpoints are required."""
+ self.build()
+
+ _, _, thread, _ = lldbutil.run_to_line_breakpoint(
+ self, lldb.SBFileSpec("main.c"), 1)
+
+ self.runCmd("settings set target.require-hardware-breakpoint true")
+
+ # Ensure we fail in the interpreter.
+ self.expect("thread step-in")
+ self.expect("thread step-in", error=True)
+
+ # Ensure we fail when stepping through the API.
+ error = lldb.SBError()
+ thread.StepInto('', 4, error)
+ self.assertTrue(error.Fail())
+ self.assertTrue("Could not create hardware breakpoint for thread plan"
+ in error.GetCString())
+
+ def test_step_out(self):
+ """Test stepping out when hardware breakpoints are required."""
+ self.build()
+
+ _, _, thread, _ = lldbutil.run_to_line_breakpoint(
+ self, lldb.SBFileSpec("main.c"), 1)
+
+ self.runCmd("settings set target.require-hardware-breakpoint true")
+
+ # Ensure this fails in the command interpreter.
+ self.expect("thread step-out", error=True)
+
+ # Ensure we fail when stepping through the API.
+ error = lldb.SBError()
+ thread.StepOut(error)
+ self.assertTrue(error.Fail())
+ self.assertTrue("Could not create hardware breakpoint for thread plan"
+ in error.GetCString())
+
+ def test_step_over(self):
+ """Test stepping over when hardware breakpoints are required."""
+ self.build()
+
+ _, _, thread, _ = lldbutil.run_to_line_breakpoint(
+ self, lldb.SBFileSpec("main.c"), 7)
+
+ self.runCmd("settings set target.require-hardware-breakpoint true")
+
+ # Step over doesn't fail immediately but fails later on.
+ self.expect("thread step-over")
+ self.expect(
+ "process status",
+ substrs=[
+ 'step over failed',
+ 'Could not create hardware breakpoint for thread plan'
+ ])
+
+ def test_step_until(self):
+ """Test stepping until when hardware breakpoints are required."""
+ self.build()
+
+ _, _, thread, _ = lldbutil.run_to_line_breakpoint(
+ self, lldb.SBFileSpec("main.c"), 7)
+
+ self.runCmd("settings set target.require-hardware-breakpoint true")
+
+ self.expect("thread until 5", error=True)
+
+ # Ensure we fail when stepping through the API.
+ error = thread.StepOverUntil(lldb.SBFrame(), lldb.SBFileSpec(), 5)
+ self.assertTrue(error.Fail())
+ self.assertTrue("Could not create hardware breakpoint for thread plan"
+ in error.GetCString())
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/main.c
new file mode 100644
index 00000000000..7d49a57d4c7
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/main.c
@@ -0,0 +1,9 @@
+int break_on_me() {
+ int i = 10;
+ i++;
+ return i;
+}
+
+int main() {
+ return break_on_me();
+}
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py b/lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py
index 1c254c56476..a111ede6739 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py
@@ -35,7 +35,7 @@ class StepScriptedTestCase(TestBase):
self.assertEqual("foo", frame.GetFunctionName())
err = thread.StepUsingScriptedThreadPlan(name)
- self.assertTrue(err.Success(), "Failed to step out")
+ self.assertTrue(err.Success(), err.GetCString())
frame = thread.GetFrameAtIndex(0)
self.assertEqual("main", frame.GetFunctionName())
OpenPOWER on IntegriCloud