blob: 13c6d0e962245593b570b0d0b640ce81f9f8d3fc [file] [log] [blame]
Johnny Chen843f6892010-07-07 21:10:55 +00001"""
2Test that breakpoint by symbol name works correctly dlopen'ing a dynamic lib.
3"""
4
5import os, time
6import unittest
7import lldb
8import lldbtest
9
10class TestClassTypes(lldbtest.TestBase):
11
12 mydir = "load_unload"
13
14 def test_dead_strip(self):
15 """Test breakpoint by name works correctly with dlopen'ing."""
16 res = self.res
17 exe = os.path.join(os.getcwd(), "a.out")
18 self.ci.HandleCommand("file " + exe, res)
19 self.assertTrue(res.Succeeded())
20
21 # Break by function name a_function (not yet loaded).
22 self.ci.HandleCommand("breakpoint set -n a_function", res)
23 self.assertTrue(res.Succeeded())
24 self.assertTrue(res.GetOutput().startswith(
25 "Breakpoint created: 1: name = 'a_function', locations = 0 "
26 "(pending)"
27 ))
28
29 self.ci.HandleCommand("run", res)
30 time.sleep(0.1)
31 self.assertTrue(res.Succeeded())
32
33 # The stop reason of the thread should be breakpoint and at a_function.
34 self.ci.HandleCommand("thread list", res)
35 output = res.GetOutput()
36 self.assertTrue(res.Succeeded())
37 self.assertTrue(output.find('state is Stopped') > 0 and
38 output.find('a_function') > 0 and
39 output.find('a.c:14') > 0 and
40 output.find('stop reason = breakpoint') > 0)
41
42 # The breakpoint should have a hit count of 1.
43 self.ci.HandleCommand("breakpoint list", res)
44 self.assertTrue(res.Succeeded())
45 self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0)
46
47 self.ci.HandleCommand("continue", res)
48 self.assertTrue(res.Succeeded())
49
50# # We should stop agaian at a_function.
51# # The stop reason of the thread should be breakpoint and at a_function.
52# self.ci.HandleCommand("thread list", res)
53# output = res.GetOutput()
54# self.assertTrue(res.Succeeded())
55# self.assertTrue(output.find('state is Stopped') > 0 and
56# output.find('a_function') > 0 and
57# output.find('a.c:14') > 0 and
58# output.find('stop reason = breakpoint') > 0)
59
60# # The breakpoint should have a hit count of 2.
61# self.ci.HandleCommand("breakpoint list", res)
62# self.assertTrue(res.Succeeded())
63# self.assertTrue(res.GetOutput().find(' resolved, hit count = 2') > 0)
64
65# self.ci.HandleCommand("continue", res)
66# self.assertTrue(res.Succeeded())
67
68
69if __name__ == '__main__':
70 lldb.SBDebugger.Initialize()
71 unittest.main()
72 lldb.SBDebugger.Terminate()