Home | History | Annotate | Download | only in breakpoint_command
      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 *
      9 import lldbutil
     10 
     11 class RegexpBreakCommandTestCase(TestBase):
     12 
     13     mydir = os.path.join("functionalities", "breakpoint", "breakpoint_command")
     14 
     15     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     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 
     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)
     45 
     46         self.runCmd("run", RUN_SUCCEEDED)
     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'])
     52 
     53 
     54 if __name__ == '__main__':
     55     import atexit
     56     lldb.SBDebugger.Initialize()
     57     atexit.register(lambda: lldb.SBDebugger.Terminate())
     58     unittest2.main()
     59