blob: ca95f36e8387f91690cbf3c053bbc4660c9034ab [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
Robert Flack13c7ad92015-03-30 14:12:17 +000015 @skipUnlessDarwin
Johnny Chenb417dcd2012-08-23 00:32:22 +000016 @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
Hafiz Abid Qadeer93ad6b32015-02-08 20:21:08 +000046 # Check breakpoint with full file path.
47 full_path = os.path.join(os.getcwd(), self.source)
48 break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (full_path, self.line))
49 lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1)
50
Johnny Chenb417dcd2012-08-23 00:32:22 +000051 self.runCmd("run", RUN_SUCCEEDED)
52
53 # The stop reason of the thread should be breakpoint.
54 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
55 substrs = ['stopped',
56 'stop reason = breakpoint'])
57
58
59if __name__ == '__main__':
60 import atexit
61 lldb.SBDebugger.Initialize()
62 atexit.register(lambda: lldb.SBDebugger.Terminate())
63 unittest2.main()