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