diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py --- a/lldb/packages/Python/lldbsuite/test/lldbutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py @@ -492,7 +492,7 @@ return get_bpno_from_match(break_results) -def run_break_set_command(test, command): +def run_break_set_command(test, command, error=False, error_msg=None): """Run the command passed in - it must be some break set variant - and analyze the result. Returns a dictionary of information gleaned from the command-line results. Will assert if the breakpoint setting fails altogether. @@ -514,9 +514,17 @@ patterns = [ r"^Breakpoint (?P[0-9]+): (?P[0-9]+) locations\.$", r"^Breakpoint (?P[0-9]+): (?Pno) locations \(pending\)\.", + r"^Breakpoint (?P[0-9]+): address = (?P
0x[0-9a-fA-F]+)$", r"^Breakpoint (?P[0-9]+): where = (?P.*)`(?P[+\-]{0,1}[^+]+)( \+ (?P[0-9]+)){0,1}( \[inlined\] (?P.*)){0,1} at (?P[^:]+):(?P[0-9]+)(?P(:[0-9]+)?), address = (?P
0x[0-9a-fA-F]+)$", r"^Breakpoint (?P[0-9]+): where = (?P.*)`(?P.*)( \+ (?P[0-9]+)){0,1}, address = (?P
0x[0-9a-fA-F]+)$"] - match_object = test.match(command, patterns) + match_object = test.match(command, patterns, error=error, matching=not error) + + if error: + test.assertFalse(test.res.Succeeded(),"Command '%s' is expected to fail!" % command) + if error_msg: + test.assertIn(error_msg, test.res.GetError()) + return + break_results = match_object.groupdict() # We always insert the breakpoint number, setting it to -1 if we couldn't find it @@ -544,6 +552,15 @@ if 'line_no' in break_results: break_results['line_no'] = int(break_results['line_no']) + + if 'column' in break_results: + if break_results['column']: + # The 'column' regex match group matches (:[0-9]+), strip off the ':' prefix. + break_results['column'] = int(break_results['column'][1:]) + else: + # The matching group was empty; delete it to not be confusing. + del break_results['column'] + return break_results @@ -557,6 +574,7 @@ file_name=None, line_number=-1, column_number=0, + address=None, symbol_name=None, symbol_match_exact=True, module_name=None, @@ -642,6 +660,16 @@ (out_module_name, module_name)) + if address: + out_address = 0 + if 'address' in break_results: + out_address = break_results['address'] + + test.assertTrue( + address == out_address, + "Breakpoint address %s doesn't match resultant address %s." % + (address, out_address)) + def check_breakpoint( test, bpno, diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py --- a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py +++ b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py @@ -12,11 +12,6 @@ class RegexpBreakCommandTestCase(TestBase): - def test(self): - """Test _regexp-break command.""" - self.build() - self.regexp_break_command() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -25,14 +20,15 @@ self.line = line_number( self.source, '// Set break point at this line.') - def regexp_break_command(self): - """Test the super consie "b" command, which is analias for _regexp-break.""" + def test_regexp_break_command(self): + """Test the super concise "b" command, which is an alias for _regexp-break.""" + self.build() exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + # break_results = lldbutil.run_break_set_command( - self, "b %d" % - self.line) + self, "b %d" % self.line) lldbutil.check_breakpoint_result( self, break_results, @@ -40,6 +36,7 @@ line_number=self.line, num_locations=1) + # : break_results = lldbutil.run_break_set_command( self, "b %s:%d" % (self.source, self.line)) lldbutil.check_breakpoint_result( @@ -49,6 +46,71 @@ line_number=self.line, num_locations=1) + # :: + self.assertIn('column', break_results) + col = break_results['column'] + break_results = lldbutil.run_break_set_command( + self, "b %s:%d:%d" % (self.source, self.line, col)) + lldbutil.check_breakpoint_result( + self, + break_results, + file_name='main.c', + line_number=self.line, + column_number=col, + num_locations=1) + + # + break_results = lldbutil.run_break_set_command( + self, "b main") + lldbutil.check_breakpoint_result( + self, + break_results, + file_name='main.c', + symbol_name='main', + num_locations=1) + + # 0x
+ self.assertIn('address', break_results) + main_address = break_results['address'] + break_results = lldbutil.run_break_set_command( + self, "b %s" % main_address) + lldbutil.check_breakpoint_result( + self, + break_results, + address=main_address, + num_locations=1) + + # ` + break_results = lldbutil.run_break_set_command( + self, "b a.out`main") + lldbutil.check_breakpoint_result( + self, + break_results, + module_name='a.out', + file_name='main.c', + symbol_name='main', + num_locations=1) + + # & + break_results = lldbutil.run_break_set_command( + self, "b &main") + lldbutil.check_breakpoint_result( + self, + break_results, + file_name='main.c', + symbol_name='main', + num_locations=1) + + # // + break_results = lldbutil.run_break_set_command( + self, "b /Set b[a-z]+k poi[mn]t at this linx*e/") + lldbutil.check_breakpoint_result( + self, + break_results, + file_name='main.c', + line_number=self.line, + num_locations=1) + # Check breakpoint with full file path. full_path = os.path.join(self.getSourceDir(), self.source) break_results = lldbutil.run_break_set_command(