[Lldb-commits] [lldb] r133404 - in /lldb/trunk/test: lldbutil.py python_api/frame/inlines/ python_api/frame/inlines/Makefile python_api/frame/inlines/TestInlinedFrame.py
Johnny Chen
johnny.chen at apple.com
Sun Jun 19 17:26:39 PDT 2011
Author: johnny
Date: Sun Jun 19 19:26:39 2011
New Revision: 133404
URL: http://llvm.org/viewvc/llvm-project?rev=133404&view=rev
Log:
Add TestInlinedFrame.py to exercise the newly added SBFrame APIs: IsInlined() and GetFunctionName().
Added:
lldb/trunk/test/python_api/frame/inlines/
- copied from r133401, lldb/trunk/test/inlines/
lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py
Modified:
lldb/trunk/test/lldbutil.py
lldb/trunk/test/python_api/frame/inlines/Makefile
Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=133404&r1=133403&r2=133404&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Sun Jun 19 19:26:39 2011
@@ -293,7 +293,7 @@
Returns a sequence of function names from the stack frames of this thread.
"""
def GetFuncName(i):
- return thread.GetFrameAtIndex(i).GetFunction().GetName()
+ return thread.GetFrameAtIndex(i).GetFunctionName()
return map(GetFuncName, range(thread.GetNumFrames()))
@@ -393,8 +393,9 @@
num=i, addr=load_addr, mod=mods[i], symbol=symbols[i], offset=symbol_offset)
else:
print >> output, " frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}".format(
- num=i, addr=load_addr, mod=mods[i], func=funcs[i], file=files[i], line=lines[i],
- args=get_args_as_string(frame, showFuncName=False))
+ num=i, addr=load_addr, mod=mods[i],
+ func='%s [inlined]' % funcs[i] if frame.IsInlined() else funcs[i],
+ file=files[i], line=lines[i], args=get_args_as_string(frame, showFuncName=False))
if string_buffer:
return output.getvalue()
Modified: lldb/trunk/test/python_api/frame/inlines/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/inlines/Makefile?rev=133404&r1=133401&r2=133404&view=diff
==============================================================================
--- lldb/trunk/test/python_api/frame/inlines/Makefile (original)
+++ lldb/trunk/test/python_api/frame/inlines/Makefile Sun Jun 19 19:26:39 2011
@@ -1,4 +1,4 @@
-LEVEL = ../make
+LEVEL = ../../../make
C_SOURCES := inlines.c
Added: lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py?rev=133404&view=auto
==============================================================================
--- lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py (added)
+++ lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py Sun Jun 19 19:26:39 2011
@@ -0,0 +1,66 @@
+"""
+Testlldb Python SBFrame APIs IsInlined() and GetFunctionName().
+"""
+
+import os, time
+import re
+import unittest2
+import lldb, lldbutil
+from lldbtest import *
+
+class InlinedFrameAPITestCase(TestBase):
+
+ mydir = os.path.join("python_api", "frame", "inlines")
+
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ @python_api_test
+ def test_stop_at_outer_inline_dsym(self):
+ """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName()."""
+ self.buildDsym()
+ self.do_stop_at_outer_inline()
+
+ @python_api_test
+ def test_stop_at_outer_inline_with_dwarf(self):
+ """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName()."""
+ self.buildDwarf()
+ self.do_stop_at_outer_inline()
+
+ def do_stop_at_outer_inline(self):
+ """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName()."""
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint on main.c by name 'c'.
+ breakpoint = target.BreakpointCreateByName('outer_inline', 'a.out')
+ #print "breakpoint:", breakpoint
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() > 1,
+ VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at the entry point.
+ process = target.LaunchSimple(None, None, os.getcwd())
+
+ process = target.GetProcess()
+ self.assertTrue(process.GetState() == lldb.eStateStopped,
+ PROCESS_STOPPED)
+
+ # The first breakpoint should correspond to an inlined call frame.
+ frame0 = process.GetThreadAtIndex(0).GetFrameAtIndex(0)
+ self.assertTrue(frame0.IsInlined() and
+ frame0.GetFunctionName() == 'outer_inline')
+
+ self.runCmd("bt")
+ if self.TraceOn():
+ print "Full stack traces when first stopped on the breakpoint 'outer_inline':"
+ import lldbutil
+ print lldbutil.print_stacktraces(process)
+
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
More information about the lldb-commits
mailing list