[Lldb-commits] [lldb] r107719 - in /lldb/trunk/test/dead-strip: TestDeadStrip.py main.c
Johnny Chen
johnny.chen at apple.com
Tue Jul 6 15:52:00 PDT 2010
Author: johnny
Date: Tue Jul 6 17:52:00 2010
New Revision: 107719
URL: http://llvm.org/viewvc/llvm-project?rev=107719&view=rev
Log:
Test that breakpoint works correctly in the presence of dead-code stripping.
Added:
lldb/trunk/test/dead-strip/TestDeadStrip.py
Modified:
lldb/trunk/test/dead-strip/main.c
Added: lldb/trunk/test/dead-strip/TestDeadStrip.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dead-strip/TestDeadStrip.py?rev=107719&view=auto
==============================================================================
--- lldb/trunk/test/dead-strip/TestDeadStrip.py (added)
+++ lldb/trunk/test/dead-strip/TestDeadStrip.py Tue Jul 6 17:52:00 2010
@@ -0,0 +1,89 @@
+"""
+Test that breakpoint works correctly in the presence of dead-code stripping.
+"""
+
+import os, time
+import unittest
+import lldb
+import lldbtest
+
+class TestClassTypes(lldbtest.TestBase):
+
+ mydir = "dead-strip"
+
+ def test_dead_strip(self):
+ """Test breakpoint works correctly with dead-code stripping."""
+ res = self.res
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.ci.HandleCommand("file " + exe, res)
+ self.assertTrue(res.Succeeded())
+
+ # Break by function name f1 (live code).
+ self.ci.HandleCommand("breakpoint set -s a.out -n f1", res)
+ self.assertTrue(res.Succeeded())
+ self.assertTrue(res.GetOutput().startswith(
+ "Breakpoint created: 1: name = 'f1', module = a.out, locations = 1"
+ ))
+
+ # Break by function name f2 (dead code).
+ self.ci.HandleCommand("breakpoint set -s a.out -n f2", res)
+ self.assertTrue(res.Succeeded())
+ self.assertTrue(res.GetOutput().startswith(
+ "Breakpoint created: 2: name = 'f2', module = a.out, locations = 0 "
+ "(pending)"))
+
+ # Break by function name f3 (live code).
+ self.ci.HandleCommand("breakpoint set -s a.out -n f3", res)
+ self.assertTrue(res.Succeeded())
+ self.assertTrue(res.GetOutput().startswith(
+ "Breakpoint created: 3: name = 'f3', module = a.out, locations = 1"
+ ))
+
+ self.ci.HandleCommand("run", res)
+ time.sleep(0.1)
+ self.assertTrue(res.Succeeded())
+
+ # The stop reason of the thread should be breakpoint (breakpoint #1).
+ self.ci.HandleCommand("thread list", res)
+ output = res.GetOutput()
+ self.assertTrue(res.Succeeded())
+ self.assertTrue(output.find('state is Stopped') > 0 and
+ output.find('main.c:20') > 0 and
+ output.find('where = a.out`f1') > 0 and
+ output.find('stop reason = breakpoint') > 0)
+
+ # The breakpoint should have a hit count of 1.
+ self.ci.HandleCommand("breakpoint list 1", res)
+ self.assertTrue(res.Succeeded())
+ self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0)
+
+ self.ci.HandleCommand("continue", res)
+ self.assertTrue(res.Succeeded())
+
+ # The stop reason of the thread should be breakpoint (breakpoint #3).
+ self.ci.HandleCommand("thread list", res)
+ output = res.GetOutput()
+ self.assertTrue(res.Succeeded())
+ self.assertTrue(output.find('state is Stopped') > 0 and
+ # TODO:
+ #
+ # Uncomment 'main.c:40' line when rdar://problem/8163668
+ # is fixed.
+ #
+ #output.find('main.c:40') > 0 and
+ output.find('where = a.out`f3') > 0 and
+ output.find('stop reason = breakpoint') > 0)
+
+ # The breakpoint should have a hit count of 1.
+ self.ci.HandleCommand("breakpoint list 3", res)
+ self.assertTrue(res.Succeeded())
+ self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0)
+
+ self.ci.HandleCommand("continue", res)
+ self.assertTrue(res.Succeeded())
+
+
+if __name__ == '__main__':
+ lldb.SBDebugger.Initialize()
+ unittest.main()
+ lldb.SBDebugger.Terminate()
Modified: lldb/trunk/test/dead-strip/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dead-strip/main.c?rev=107719&r1=107718&r2=107719&view=diff
==============================================================================
--- lldb/trunk/test/dead-strip/main.c (original)
+++ lldb/trunk/test/dead-strip/main.c Tue Jul 6 17:52:00 2010
@@ -14,7 +14,7 @@
int f3 (char *s);
-// We want f1 to start on line 10
+// We want f1 to start on line 20
int f1 (char *s)
{
return printf("f1: %s\n", s);
@@ -24,7 +24,7 @@
-// We want f2 to start on line 20, this should get stripped
+// We want f2 to start on line 30, this should get stripped
int f2 (char *s)
{
return printf("f2: %s\n", s);
@@ -34,7 +34,7 @@
-// We want f3 to start on line 30
+// We want f3 to start on line 40
int f3 (char *s)
{
return printf("f3: %s\n", s);
@@ -44,7 +44,7 @@
-// We want main to start on line 40
+// We want main to start on line 50
int main (int argc, const char * argv[])
{
f1("carp");
More information about the lldb-commits
mailing list