blob: 26764fabcefe6a5db57e807e5b3bff47e4be7c44 [file] [log] [blame]
Johnny Chenb417dcd2012-08-23 00:32:22 +00001"""
2Test _regexp-break command which uses regular expression matching to dispatch to other built in breakpoint commands.
3"""
4
5import os, time
6import unittest2
7import lldb
8from lldbtest import *
Jim Ingham63dfc722012-09-22 00:05:11 +00009import lldbutil
Johnny Chenb417dcd2012-08-23 00:32:22 +000010
11class RegexpBreakCommandTestCase(TestBase):
12
Greg Clayton4570d3e2013-12-10 23:19:29 +000013 mydir = TestBase.compute_mydir(__file__)
Johnny Chenb417dcd2012-08-23 00:32:22 +000014
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
Jim Ingham63dfc722012-09-22 00:05:11 +000040 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)
Johnny Chenb417dcd2012-08-23 00:32:22 +000045
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
54if __name__ == '__main__':
55 import atexit
56 lldb.SBDebugger.Initialize()
57 atexit.register(lambda: lldb.SBDebugger.Terminate())
58 unittest2.main()