blob: b6b1e6d3fb6d31ff63c570858b1077539718d708 [file] [log] [blame]
Johnny Chen4cfd07e2011-06-20 00:26:39 +00001"""
2Testlldb Python SBFrame APIs IsInlined() and GetFunctionName().
3"""
4
5import os, time
6import re
7import unittest2
8import lldb, lldbutil
9from lldbtest import *
10
11class InlinedFrameAPITestCase(TestBase):
12
13 mydir = os.path.join("python_api", "frame", "inlines")
14
15 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
16 @python_api_test
17 def test_stop_at_outer_inline_dsym(self):
18 """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName()."""
19 self.buildDsym()
20 self.do_stop_at_outer_inline()
21
22 @python_api_test
23 def test_stop_at_outer_inline_with_dwarf(self):
24 """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName()."""
25 self.buildDwarf()
26 self.do_stop_at_outer_inline()
27
28 def do_stop_at_outer_inline(self):
29 """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName()."""
30 exe = os.path.join(os.getcwd(), "a.out")
31
32 # Create a target by the debugger.
33 target = self.dbg.CreateTarget(exe)
34 self.assertTrue(target, VALID_TARGET)
35
36 # Now create a breakpoint on main.c by name 'c'.
37 breakpoint = target.BreakpointCreateByName('outer_inline', 'a.out')
38 #print "breakpoint:", breakpoint
39 self.assertTrue(breakpoint and
40 breakpoint.GetNumLocations() > 1,
41 VALID_BREAKPOINT)
42
43 # Now launch the process, and do not stop at the entry point.
44 process = target.LaunchSimple(None, None, os.getcwd())
45
46 process = target.GetProcess()
47 self.assertTrue(process.GetState() == lldb.eStateStopped,
48 PROCESS_STOPPED)
49
50 # The first breakpoint should correspond to an inlined call frame.
51 frame0 = process.GetThreadAtIndex(0).GetFrameAtIndex(0)
52 self.assertTrue(frame0.IsInlined() and
53 frame0.GetFunctionName() == 'outer_inline')
54
55 self.runCmd("bt")
56 if self.TraceOn():
57 print "Full stack traces when first stopped on the breakpoint 'outer_inline':"
58 import lldbutil
59 print lldbutil.print_stacktraces(process)
60
61
62if __name__ == '__main__':
63 import atexit
64 lldb.SBDebugger.Initialize()
65 atexit.register(lambda: lldb.SBDebugger.Terminate())
66 unittest2.main()