blob: 57b0f0f405ea476646aae98e2a6d072ca96fa2a0 [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
Zachary Turner35d017f2015-10-23 17:04:29 +00005from __future__ import print_function
6
Zachary Turner0a0490b2015-10-27 20:12:05 +00007import use_lldb_suite
Zachary Turner77db4a82015-10-22 20:06:20 +00008
Johnny Chenb417dcd2012-08-23 00:32:22 +00009import os, time
Johnny Chenb417dcd2012-08-23 00:32:22 +000010import lldb
11from lldbtest import *
Jim Ingham63dfc722012-09-22 00:05:11 +000012import lldbutil
Johnny Chenb417dcd2012-08-23 00:32:22 +000013
14class RegexpBreakCommandTestCase(TestBase):
15
Greg Clayton4570d3e2013-12-10 23:19:29 +000016 mydir = TestBase.compute_mydir(__file__)
Johnny Chenb417dcd2012-08-23 00:32:22 +000017
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000018 def test(self):
Johnny Chenb417dcd2012-08-23 00:32:22 +000019 """Test _regexp-break command."""
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000020 self.build()
Johnny Chenb417dcd2012-08-23 00:32:22 +000021 self.regexp_break_command()
22
23 def setUp(self):
24 # Call super's setUp().
25 TestBase.setUp(self)
26 # Find the line number to break inside main().
27 self.source = 'main.c'
28 self.line = line_number(self.source, '// Set break point at this line.')
29
30 def regexp_break_command(self):
31 """Test the super consie "b" command, which is analias for _regexp-break."""
32 exe = os.path.join(os.getcwd(), "a.out")
33 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
34
Jim Ingham63dfc722012-09-22 00:05:11 +000035 break_results = lldbutil.run_break_set_command (self, "b %d" % self.line)
36 lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1)
37
38 break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (self.source, self.line))
39 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 +000040
Hafiz Abid Qadeer93ad6b32015-02-08 20:21:08 +000041 # Check breakpoint with full file path.
42 full_path = os.path.join(os.getcwd(), self.source)
43 break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (full_path, self.line))
44 lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1)
45
Sean Callanan05834cd2015-07-01 23:56:30 +000046 self.runCmd("run", RUN_SUCCEEDED)
Johnny Chenb417dcd2012-08-23 00:32:22 +000047
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'])