Test that breakpoint works correctly in the presence of dead-code stripping.
llvm-svn: 107719
This commit is contained in:
parent
279a6c2669
commit
0e38f42f0a
|
@ -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()
|
|
@ -14,7 +14,7 @@ int f2 (char *s);
|
|||
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 @@ int f1 (char *s)
|
|||
|
||||
|
||||
|
||||
// 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 @@ int f2 (char *s)
|
|||
|
||||
|
||||
|
||||
// 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 @@ int f3 (char *s)
|
|||
|
||||
|
||||
|
||||
// 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");
|
||||
|
|
Loading…
Reference in New Issue