[Lldb-commits] [lldb] r117116 - in /lldb/trunk/test: breakpoint_conditions/TestBreakpointConditions.py lldbtest.py
Johnny Chen
johnny.chen at apple.com
Fri Oct 22 11:10:25 PDT 2010
Author: johnny
Date: Fri Oct 22 13:10:25 2010
New Revision: 117116
URL: http://llvm.org/viewvc/llvm-project?rev=117116&view=rev
Log:
Add test case for using SBBreakpointLocation to set break condition.
Modified:
lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py
lldb/trunk/test/lldbtest.py
Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=117116&r1=117115&r2=117116&view=diff
==============================================================================
--- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original)
+++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Fri Oct 22 13:10:25 2010
@@ -18,11 +18,22 @@
self.buildDsym()
self.breakpoint_conditions()
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ def test_with_dsym_and_python_api(self):
+ """Use Python APIs to set breakpoint conditions."""
+ self.buildDsym()
+ self.breakpoint_conditions_python()
+
def test_with_dwarf_and_run_command(self):
"""Exercise breakpoint condition with 'breakpoint modify -c <expr> id'."""
self.buildDwarf()
self.breakpoint_conditions()
+ def test_with_dwarf_and_python_api(self):
+ """Use Python APIs to set breakpoint conditions."""
+ self.buildDwarf()
+ self.breakpoint_conditions_python()
+
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
@@ -62,7 +73,51 @@
patterns = ["frame #0.*main.c:%d" % self.line1,
"frame #1.*main.c:%d" % self.line2])
+ def breakpoint_conditions_python(self):
+ """Use Python APIs to set breakpoint conditions."""
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target.IsValid(), VALID_TARGET)
+
+ # Now create a breakpoint on main.c by name 'c'.
+ breakpoint = target.BreakpointCreateByName('c', 'a.out')
+ print "breakpoint:", breakpoint
+ self.assertTrue(breakpoint.IsValid() and
+ breakpoint.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ # Get the breakpoint location from breakpoint after we verified that,
+ # indeed, it has one location.
+ location = breakpoint.GetLocationAtIndex(0)
+ self.assertTrue(location.IsValid() and
+ location.IsEnabled(),
+ VALID_BREAKPOINT_LOCATION)
+
+ # Set the condition on the breakpoint location.
+ location.SetCondition('val == 3')
+ self.expect(location.GetCondition(), exe=False,
+ startstr = 'val == 3')
+
+ # Now launch the process, and do not stop at entry point.
+ self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False)
+
+ self.process = target.GetProcess()
+ self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
+
+ # Frame #0 should be on self.line1 and the break condition should hold.
+ frame0 = self.process.GetThreadAtIndex(0).GetFrameAtIndex(0)
+ var = frame0.LookupVarInScope('val', 'parameter')
+ self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and
+ var.GetValue(frame0) == '3')
+
+ # The hit count for the breakpoint should be 3.
+ self.assertTrue(breakpoint.GetHitCount() == 3)
+
+ self.process.Continue()
+
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=117116&r1=117115&r2=117116&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Fri Oct 22 13:10:25 2010
@@ -163,6 +163,8 @@
VALID_BREAKPOINT = "Got a valid breakpoint"
+VALID_BREAKPOINT_LOCATION = "Got a valid breakpoint location"
+
VALID_FILESPEC = "Got a valid filespec"
VALID_PROCESS = "Got a valid process"
More information about the lldb-commits
mailing list