Johnny Chen | fe14162 | 2012-01-12 23:09:42 +0000 | [diff] [blame] | 1 | """Test breaking inside functions defined within a BSD archive file libfoo.a.""" |
| 2 | |
| 3 | import os, time |
| 4 | import unittest2 |
| 5 | import lldb |
| 6 | from lldbtest import * |
| 7 | |
| 8 | class BSDArchivesTestCase(TestBase): |
| 9 | |
| 10 | mydir = os.path.join("functionalities", "archives") |
| 11 | |
| 12 | def test_with_dwarf(self): |
| 13 | """Break inside a() and b() defined within libfoo.a.""" |
| 14 | self.buildDwarf() |
| 15 | self.break_inside_bsd_archives() |
| 16 | |
| 17 | def setUp(self): |
| 18 | # Call super's setUp(). |
| 19 | TestBase.setUp(self) |
| 20 | # Find the line number in a(int) to break at. |
| 21 | self.line = line_number('a.c', '// Set file and line breakpoint inside a().') |
| 22 | |
| 23 | def break_inside_bsd_archives(self): |
| 24 | """Break inside a() and b() defined within libfoo.a.""" |
| 25 | exe = os.path.join(os.getcwd(), "a.out") |
| 26 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 27 | |
| 28 | # Break inside a() by file and line first. |
| 29 | self.expect("breakpoint set -f a.c -l %d" % self.line, BREAKPOINT_CREATED, |
| 30 | startstr = "Breakpoint created: 1: file ='a.c', line = %d" % |
| 31 | self.line) |
| 32 | self.runCmd("run", RUN_SUCCEEDED) |
| 33 | |
| 34 | # The stop reason of the thread should be breakpoint. |
| 35 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 36 | substrs = ['stopped', |
| 37 | 'stop reason = breakpoint']) |
| 38 | |
| 39 | # Break at a(int) first. |
| 40 | self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, |
| 41 | substrs = ['(int) arg = 1']) |
| 42 | self.expect("frame variable __a_global", VARIABLES_DISPLAYED_CORRECTLY, |
| 43 | substrs = ['(int) __a_global = 1']) |
| 44 | |
| 45 | # Set breakpoint for b() next. |
| 46 | self.expect("breakpoint set -n b", BREAKPOINT_CREATED, |
| 47 | startstr = "Breakpoint created: 2: name = 'b'", |
| 48 | substrs = ['resolved = 1']) |
| 49 | |
| 50 | # Continue the program, we should break at b(int) next. |
| 51 | self.runCmd("continue") |
| 52 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 53 | substrs = ['stopped', |
| 54 | 'stop reason = breakpoint']) |
| 55 | self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, |
| 56 | substrs = ['(int) arg = 2']) |
| 57 | self.expect("frame variable __b_global", VARIABLES_DISPLAYED_CORRECTLY, |
| 58 | substrs = ['(int) __b_global = 2']) |
| 59 | |
| 60 | |
| 61 | if __name__ == '__main__': |
| 62 | import atexit |
| 63 | lldb.SBDebugger.Initialize() |
| 64 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 65 | unittest2.main() |