Johnny Chen | b417dcd | 2012-08-23 00:32:22 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test _regexp-break command which uses regular expression matching to dispatch to other built in breakpoint commands. |
| 3 | """ |
| 4 | |
| 5 | import os, time |
| 6 | import unittest2 |
| 7 | import lldb |
| 8 | from lldbtest import * |
Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 9 | import lldbutil |
Johnny Chen | b417dcd | 2012-08-23 00:32:22 +0000 | [diff] [blame] | 10 | |
| 11 | class RegexpBreakCommandTestCase(TestBase): |
| 12 | |
Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 13 | mydir = TestBase.compute_mydir(__file__) |
Johnny Chen | b417dcd | 2012-08-23 00:32:22 +0000 | [diff] [blame] | 14 | |
Robert Flack | 13c7ad9 | 2015-03-30 14:12:17 +0000 | [diff] [blame] | 15 | @skipUnlessDarwin |
Johnny Chen | b417dcd | 2012-08-23 00:32:22 +0000 | [diff] [blame] | 16 | @dsym_test |
| 17 | def test_with_dsym(self): |
| 18 | """Test _regexp-break command.""" |
| 19 | self.buildDsym() |
| 20 | self.regexp_break_command() |
| 21 | |
| 22 | @dwarf_test |
| 23 | def test_with_dwarf(self): |
| 24 | """Test _regexp-break command.""" |
| 25 | self.buildDwarf() |
| 26 | self.regexp_break_command() |
| 27 | |
| 28 | def setUp(self): |
| 29 | # Call super's setUp(). |
| 30 | TestBase.setUp(self) |
| 31 | # Find the line number to break inside main(). |
| 32 | self.source = 'main.c' |
| 33 | self.line = line_number(self.source, '// Set break point at this line.') |
| 34 | |
| 35 | def regexp_break_command(self): |
| 36 | """Test the super consie "b" command, which is analias for _regexp-break.""" |
| 37 | exe = os.path.join(os.getcwd(), "a.out") |
| 38 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 39 | |
Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 40 | break_results = lldbutil.run_break_set_command (self, "b %d" % self.line) |
| 41 | lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1) |
| 42 | |
| 43 | break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (self.source, self.line)) |
| 44 | lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1) |
Johnny Chen | b417dcd | 2012-08-23 00:32:22 +0000 | [diff] [blame] | 45 | |
Hafiz Abid Qadeer | 93ad6b3 | 2015-02-08 20:21:08 +0000 | [diff] [blame] | 46 | # Check breakpoint with full file path. |
| 47 | full_path = os.path.join(os.getcwd(), self.source) |
| 48 | break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (full_path, self.line)) |
| 49 | lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1) |
| 50 | |
Johnny Chen | b417dcd | 2012-08-23 00:32:22 +0000 | [diff] [blame] | 51 | self.runCmd("run", RUN_SUCCEEDED) |
| 52 | |
| 53 | # The stop reason of the thread should be breakpoint. |
| 54 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 55 | substrs = ['stopped', |
| 56 | 'stop reason = breakpoint']) |
| 57 | |
| 58 | |
| 59 | if __name__ == '__main__': |
| 60 | import atexit |
| 61 | lldb.SBDebugger.Initialize() |
| 62 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 63 | unittest2.main() |