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 | |
Zachary Turner | 35d017f | 2015-10-23 17:04:29 +0000 | [diff] [blame] | 5 | from __future__ import print_function |
| 6 | |
Zachary Turner | 0a0490b | 2015-10-27 20:12:05 +0000 | [diff] [blame^] | 7 | import use_lldb_suite |
Zachary Turner | 77db4a8 | 2015-10-22 20:06:20 +0000 | [diff] [blame] | 8 | |
Johnny Chen | b417dcd | 2012-08-23 00:32:22 +0000 | [diff] [blame] | 9 | import os, time |
Johnny Chen | b417dcd | 2012-08-23 00:32:22 +0000 | [diff] [blame] | 10 | import lldb |
| 11 | from lldbtest import * |
Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 12 | import lldbutil |
Johnny Chen | b417dcd | 2012-08-23 00:32:22 +0000 | [diff] [blame] | 13 | |
| 14 | class RegexpBreakCommandTestCase(TestBase): |
| 15 | |
Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 16 | mydir = TestBase.compute_mydir(__file__) |
Johnny Chen | b417dcd | 2012-08-23 00:32:22 +0000 | [diff] [blame] | 17 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 18 | def test(self): |
Johnny Chen | b417dcd | 2012-08-23 00:32:22 +0000 | [diff] [blame] | 19 | """Test _regexp-break command.""" |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 20 | self.build() |
Johnny Chen | b417dcd | 2012-08-23 00:32:22 +0000 | [diff] [blame] | 21 | self.regexp_break_command() |
| 22 | |
| 23 | def setUp(self): |
| 24 | # Call super's setUp(). |
| 25 | TestBase.setUp(self) |
| 26 | # Find the line number to break inside main(). |
| 27 | self.source = 'main.c' |
| 28 | self.line = line_number(self.source, '// Set break point at this line.') |
| 29 | |
| 30 | def regexp_break_command(self): |
| 31 | """Test the super consie "b" command, which is analias for _regexp-break.""" |
| 32 | exe = os.path.join(os.getcwd(), "a.out") |
| 33 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 34 | |
Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 35 | break_results = lldbutil.run_break_set_command (self, "b %d" % self.line) |
| 36 | lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1) |
| 37 | |
| 38 | break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (self.source, self.line)) |
| 39 | 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] | 40 | |
Hafiz Abid Qadeer | 93ad6b3 | 2015-02-08 20:21:08 +0000 | [diff] [blame] | 41 | # Check breakpoint with full file path. |
| 42 | full_path = os.path.join(os.getcwd(), self.source) |
| 43 | break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (full_path, self.line)) |
| 44 | lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1) |
| 45 | |
Sean Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame] | 46 | self.runCmd("run", RUN_SUCCEEDED) |
Johnny Chen | b417dcd | 2012-08-23 00:32:22 +0000 | [diff] [blame] | 47 | |
| 48 | # The stop reason of the thread should be breakpoint. |
| 49 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 50 | substrs = ['stopped', |
| 51 | 'stop reason = breakpoint']) |