forked from OSchip/llvm-project
Modify the test script to better handle the different inlining behaviors of
clang/gcc/llvm-gcc. If the first breakpoint is due to stop at an inlined frame, test that the call site corresponds to where it should be. Also add an expecr for a second break stop, if the first break stop corresponds to an inlined call frame #0. rdar://problem/9741470 llvm-svn: 135100
This commit is contained in:
parent
3c4d652210
commit
13ea11afde
|
@ -395,7 +395,8 @@ def print_stacktrace(thread, string_buffer = False):
|
|||
print >> output, " frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}".format(
|
||||
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))
|
||||
file=files[i], line=lines[i],
|
||||
args=get_args_as_string(frame, showFuncName=False) if not frame.IsInlined() else '()')
|
||||
|
||||
if string_buffer:
|
||||
return output.getvalue()
|
||||
|
|
|
@ -25,6 +25,15 @@ class InlinedFrameAPITestCase(TestBase):
|
|||
self.buildDwarf()
|
||||
self.do_stop_at_outer_inline()
|
||||
|
||||
def setUp(self):
|
||||
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to of function 'c'.
|
||||
self.source = 'inlines.c'
|
||||
self.first_stop = line_number(self.source, '// This should correspond to the first break stop.')
|
||||
self.second_stop = line_number(self.source, '// This should correspond to the second break stop.')
|
||||
|
||||
def do_stop_at_outer_inline(self):
|
||||
"""Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName()."""
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
|
@ -33,8 +42,8 @@ class InlinedFrameAPITestCase(TestBase):
|
|||
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')
|
||||
# Now create a breakpoint on main.c by the name of 'inner_inline'.
|
||||
breakpoint = target.BreakpointCreateByName('inner_inline', 'a.out')
|
||||
#print "breakpoint:", breakpoint
|
||||
self.assertTrue(breakpoint and
|
||||
breakpoint.GetNumLocations() > 1,
|
||||
|
@ -47,17 +56,35 @@ class InlinedFrameAPITestCase(TestBase):
|
|||
self.assertTrue(process.GetState() == lldb.eStateStopped,
|
||||
PROCESS_STOPPED)
|
||||
|
||||
self.runCmd("bt")
|
||||
import lldbutil
|
||||
stack_traces1 = lldbutil.print_stacktraces(process, string_buffer=True)
|
||||
if self.TraceOn():
|
||||
print "Full stack traces when first stopped on the breakpoint 'outer_inline':"
|
||||
import lldbutil
|
||||
print lldbutil.print_stacktraces(process, string_buffer=True)
|
||||
print "Full stack traces when first stopped on the breakpoint 'inner_inline':"
|
||||
print stack_traces1
|
||||
|
||||
# The first breakpoint should correspond to an inlined call frame.
|
||||
# If it's an inlined call frame, expect to find, in the stack trace,
|
||||
# that there is a frame which corresponds to the following call site:
|
||||
#
|
||||
# outer_inline (argc);
|
||||
#
|
||||
frame0 = process.GetThreadAtIndex(0).GetFrameAtIndex(0)
|
||||
self.assertTrue(frame0.IsInlined() and
|
||||
frame0.GetFunctionName() == 'outer_inline')
|
||||
if frame0.IsInlined():
|
||||
filename = frame0.GetLineEntry().GetFileSpec().GetFilename()
|
||||
self.assertTrue(filename == self.source)
|
||||
self.expect(stack_traces1, "First stop at %s:%d" % (self.source, self.first_stop), exe=False,
|
||||
substrs = ['%s:%d' % (self.source, self.first_stop)])
|
||||
|
||||
# Expect to break again for the second time.
|
||||
process.Continue()
|
||||
self.assertTrue(process.GetState() == lldb.eStateStopped,
|
||||
PROCESS_STOPPED)
|
||||
stack_traces2 = lldbutil.print_stacktraces(process, string_buffer=True)
|
||||
if self.TraceOn():
|
||||
print "Full stack traces when stopped on the breakpoint 'inner_inline' for the second time:"
|
||||
print stack_traces2
|
||||
self.expect(stack_traces2, "Second stop at %s:%d" % (self.source, self.second_stop), exe=False,
|
||||
substrs = ['%s:%d' % (self.source, self.second_stop)])
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
|
|
|
@ -43,9 +43,9 @@ main (int argc, char **argv)
|
|||
int (*func_ptr) (int);
|
||||
func_ptr = outer_inline;
|
||||
|
||||
outer_inline (argc);
|
||||
outer_inline (argc); // This should correspond to the first break stop.
|
||||
|
||||
func_ptr (argc);
|
||||
func_ptr (argc); // This should correspond to the second break stop.
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue