1""" 2Test _regexp-break command which uses regular expression matching to dispatch to other built in breakpoint commands. 3""" 4 5 6 7import os 8import lldb 9from lldbsuite.test.lldbtest import * 10import lldbsuite.test.lldbutil as lldbutil 11 12 13class RegexpBreakCommandTestCase(TestBase): 14 15 mydir = TestBase.compute_mydir(__file__) 16 17 def test(self): 18 """Test _regexp-break command.""" 19 self.build() 20 self.regexp_break_command() 21 22 def setUp(self): 23 # Call super's setUp(). 24 TestBase.setUp(self) 25 # Find the line number to break inside main(). 26 self.source = 'main.c' 27 self.line = line_number( 28 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 = self.getBuildArtifact("a.out") 33 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 34 35 break_results = lldbutil.run_break_set_command( 36 self, "b %d" % 37 self.line) 38 lldbutil.check_breakpoint_result( 39 self, 40 break_results, 41 file_name='main.c', 42 line_number=self.line, 43 num_locations=1) 44 45 break_results = lldbutil.run_break_set_command( 46 self, "b %s:%d" % (self.source, self.line)) 47 lldbutil.check_breakpoint_result( 48 self, 49 break_results, 50 file_name='main.c', 51 line_number=self.line, 52 num_locations=1) 53 54 # Check breakpoint with full file path. 55 full_path = os.path.join(self.getSourceDir(), self.source) 56 break_results = lldbutil.run_break_set_command( 57 self, "b %s:%d" % (full_path, self.line)) 58 lldbutil.check_breakpoint_result( 59 self, 60 break_results, 61 file_name='main.c', 62 line_number=self.line, 63 num_locations=1) 64 65 self.runCmd("run", RUN_SUCCEEDED) 66 67 # The stop reason of the thread should be breakpoint. 68 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 69 substrs=['stopped', 70 'stop reason = breakpoint']) 71