diff options
author | Johnny Chen <johnny.chen@apple.com> | 2011-07-13 22:34:29 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2011-07-13 22:34:29 +0000 |
commit | 13ea11afdeb17e5e035a22f10ab8f96ec92571c3 (patch) | |
tree | bcec8ce10408d63c67f2694d9e5447623c89a042 | |
parent | 3c4d652210e1c7c217cd5ce7ace8d2af2b9b0e96 (diff) | |
download | llvm-13ea11afdeb17e5e035a22f10ab8f96ec92571c3.zip llvm-13ea11afdeb17e5e035a22f10ab8f96ec92571c3.tar.gz llvm-13ea11afdeb17e5e035a22f10ab8f96ec92571c3.tar.bz2 |
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
-rw-r--r-- | lldb/test/lldbutil.py | 3 | ||||
-rw-r--r-- | lldb/test/python_api/frame/inlines/TestInlinedFrame.py | 43 | ||||
-rw-r--r-- | lldb/test/python_api/frame/inlines/inlines.c | 4 |
3 files changed, 39 insertions, 11 deletions
diff --git a/lldb/test/lldbutil.py b/lldb/test/lldbutil.py index 4a1aa35..8966f07 100644 --- a/lldb/test/lldbutil.py +++ b/lldb/test/lldbutil.py @@ -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() diff --git a/lldb/test/python_api/frame/inlines/TestInlinedFrame.py b/lldb/test/python_api/frame/inlines/TestInlinedFrame.py index 2ccbbc6..cebfae9 100644 --- a/lldb/test/python_api/frame/inlines/TestInlinedFrame.py +++ b/lldb/test/python_api/frame/inlines/TestInlinedFrame.py @@ -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 diff --git a/lldb/test/python_api/frame/inlines/inlines.c b/lldb/test/python_api/frame/inlines/inlines.c index 1e920f1..a2a8212 100644 --- a/lldb/test/python_api/frame/inlines/inlines.c +++ b/lldb/test/python_api/frame/inlines/inlines.c @@ -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; } |