8774d3763a6aedd05c1f1d08907462594ade8341
[platform/upstream/llvm.git] /
1 """
2 Test _regexp-break command which uses regular expression matching to dispatch to other built in breakpoint commands.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import lldb
10 from lldbsuite.test.lldbtest import *
11 import lldbsuite.test.lldbutil as lldbutil
12
13
14 class RegexpBreakCommandTestCase(TestBase):
15
16     mydir = TestBase.compute_mydir(__file__)
17
18     def test(self):
19         """Test _regexp-break command."""
20         self.build()
21         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(
29             self.source, '// Set break point at this line.')
30
31     def regexp_break_command(self):
32         """Test the super consie "b" command, which is analias for _regexp-break."""
33         exe = self.getBuildArtifact("a.out")
34         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
35
36         break_results = lldbutil.run_break_set_command(
37             self, "b %d" %
38             self.line)
39         lldbutil.check_breakpoint_result(
40             self,
41             break_results,
42             file_name='main.c',
43             line_number=self.line,
44             num_locations=1)
45
46         break_results = lldbutil.run_break_set_command(
47             self, "b %s:%d" % (self.source, self.line))
48         lldbutil.check_breakpoint_result(
49             self,
50             break_results,
51             file_name='main.c',
52             line_number=self.line,
53             num_locations=1)
54
55         # Check breakpoint with full file path.
56         full_path = os.path.join(self.getSourceDir(), self.source)
57         break_results = lldbutil.run_break_set_command(
58             self, "b %s:%d" % (full_path, self.line))
59         lldbutil.check_breakpoint_result(
60             self,
61             break_results,
62             file_name='main.c',
63             line_number=self.line,
64             num_locations=1)
65
66         self.runCmd("run", RUN_SUCCEEDED)
67
68         # The stop reason of the thread should be breakpoint.
69         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
70                     substrs=['stopped',
71                              'stop reason = breakpoint'])