summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorBoris Ulasevich <boris.ulasevich@gmail.com>2017-02-15 11:42:47 +0000
committerBoris Ulasevich <boris.ulasevich@gmail.com>2017-02-15 11:42:47 +0000
commit86aaa8a28d3faa928f471c74e74cc7e1689face9 (patch)
treea1047b0d900acb4777494dac1d7a013b22eafc46 /lldb/packages/Python/lldbsuite/test
parent216bb2df3687b7972f91db4a009545a87cb5475c (diff)
downloadbcm5719-llvm-86aaa8a28d3faa928f471c74e74cc7e1689face9.tar.gz
bcm5719-llvm-86aaa8a28d3faa928f471c74e74cc7e1689face9.zip
Bug 30863 - Step doesn't stop with conditional breakpoint on the next line
Differential Revisions: https://reviews.llvm.org/D26497 (committed r290168, temporary reverted r290197) https://reviews.llvm.org/D28945 (fix for Ubuntu tests fail) https://reviews.llvm.org/D29909 (fix for TestCallThatThrows test fail) llvm-svn: 295168
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/Makefile9
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py119
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/main.cpp12
3 files changed, 140 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/Makefile
new file mode 100644
index 00000000000..f89b52a972e
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+ifneq (,$(findstring icc,$(CC)))
+ CXXFLAGS += -debug inline-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
new file mode 100644
index 00000000000..0dd09994e12
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
@@ -0,0 +1,119 @@
+"""
+Test that breakpoints do not affect stepping.
+Check for correct StopReason when stepping to the line with breakpoint
+which chould be eStopReasonBreakpoint in general,
+and eStopReasonPlanComplete when breakpoint's condition fails.
+"""
+
+from __future__ import print_function
+
+import unittest2
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class StepOverBreakpointsTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ TestBase.setUp(self)
+
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+ src = lldb.SBFileSpec("main.cpp")
+
+ # Create a target by the debugger.
+ self.target = self.dbg.CreateTarget(exe)
+ self.assertTrue(self.target, VALID_TARGET)
+
+ # Setup four breakpoints, two of them with false condition
+ self.line1 = line_number('main.cpp', "breakpoint_1")
+ self.line4 = line_number('main.cpp', "breakpoint_4")
+
+ self.breakpoint1 = self.target.BreakpointCreateByLocation(src, self.line1)
+ self.assertTrue(
+ self.breakpoint1 and self.breakpoint1.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ self.breakpoint2 = self.target.BreakpointCreateBySourceRegex("breakpoint_2", src)
+ self.breakpoint2.GetLocationAtIndex(0).SetCondition('false')
+
+ self.breakpoint3 = self.target.BreakpointCreateBySourceRegex("breakpoint_3", src)
+ self.breakpoint3.GetLocationAtIndex(0).SetCondition('false')
+
+ self.breakpoint4 = self.target.BreakpointCreateByLocation(src, self.line4)
+
+ # Start debugging
+ self.process = self.target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertIsNotNone(self.process, PROCESS_IS_VALID)
+ self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint1)
+ self.assertIsNotNone(self.thread, "Didn't stop at breakpoint 1.")
+
+ def test_step_instruction(self):
+ # Count instructions between breakpoint_1 and breakpoint_4
+ contextList = self.target.FindFunctions('main', lldb.eFunctionNameTypeAuto)
+ self.assertEquals(contextList.GetSize(), 1)
+ symbolContext = contextList.GetContextAtIndex(0)
+ function = symbolContext.GetFunction()
+ self.assertTrue(function)
+ instructions = function.GetInstructions(self.target)
+ addr_1 = self.breakpoint1.GetLocationAtIndex(0).GetAddress()
+ addr_4 = self.breakpoint4.GetLocationAtIndex(0).GetAddress()
+ for i in range(instructions.GetSize()) :
+ addr = instructions.GetInstructionAtIndex(i).GetAddress()
+ if (addr == addr_1) : index_1 = i
+ if (addr == addr_4) : index_4 = i
+
+ steps_expected = index_4 - index_1
+ step_count = 0
+ # Step from breakpoint_1 to breakpoint_4
+ while True:
+ self.thread.StepInstruction(True)
+ step_count = step_count + 1
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertTrue(self.thread.GetStopReason() == lldb.eStopReasonPlanComplete or
+ self.thread.GetStopReason() == lldb.eStopReasonBreakpoint)
+ if (self.thread.GetStopReason() == lldb.eStopReasonBreakpoint) :
+ # we should not stop on breakpoint_2 and _3 because they have false condition
+ self.assertEquals(self.thread.GetFrameAtIndex(0).GetLineEntry().GetLine(), self.line4)
+ # breakpoint_2 and _3 should not affect step count
+ self.assertTrue(step_count >= steps_expected)
+ break
+
+ # Run the process until termination
+ self.process.Continue()
+ self.assertEquals(self.process.GetState(), lldb.eStateExited)
+
+ def test_step_over(self):
+ #lldb.DBG.EnableLog("lldb", ["step","breakpoint"])
+
+ self.thread.StepOver()
+ # We should be stopped at the breakpoint_2 line with stop plan complete reason
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete)
+
+ self.thread.StepOver()
+ # We should be stopped at the breakpoint_3 line with stop plan complete reason
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete)
+
+ self.thread.StepOver()
+ # We should be stopped at the breakpoint_4
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonBreakpoint)
+ thread1 = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint4)
+ self.assertEquals(self.thread, thread1, "Didn't stop at breakpoint 4.")
+
+ # Check that stepping does not affect breakpoint's hit count
+ self.assertEquals(self.breakpoint1.GetHitCount(), 1)
+ self.assertEquals(self.breakpoint2.GetHitCount(), 0)
+ self.assertEquals(self.breakpoint3.GetHitCount(), 0)
+ self.assertEquals(self.breakpoint4.GetHitCount(), 1)
+
+ # Run the process until termination
+ self.process.Continue()
+ self.assertEquals(self.process.GetState(), lldb.eStateExited)
+
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/main.cpp
new file mode 100644
index 00000000000..8cfd34b73b5
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/main.cpp
@@ -0,0 +1,12 @@
+
+int func() { return 1; }
+
+int
+main(int argc, char const *argv[])
+{
+ int a = 0; // breakpoint_1
+ int b = func(); // breakpoint_2
+ a = b + func(); // breakpoint_3
+ return 0; // breakpoint_4
+}
+
OpenPOWER on IntegriCloud