]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / breakpoint / breakpoint_command / TestRegexpBreakCommand.py
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 time
10 import lldb
11 from lldbsuite.test.lldbtest import *
12 import lldbsuite.test.lldbutil as lldbutil
13
14
15 class RegexpBreakCommandTestCase(TestBase):
16
17     mydir = TestBase.compute_mydir(__file__)
18
19     def test(self):
20         """Test _regexp-break command."""
21         self.build()
22         self.regexp_break_command()
23
24     def setUp(self):
25         # Call super's setUp().
26         TestBase.setUp(self)
27         # Find the line number to break inside main().
28         self.source = 'main.c'
29         self.line = line_number(
30             self.source, '// Set break point at this line.')
31
32     def regexp_break_command(self):
33         """Test the super consie "b" command, which is analias for _regexp-break."""
34         exe = os.path.join(os.getcwd(), "a.out")
35         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
36
37         break_results = lldbutil.run_break_set_command(
38             self, "b %d" %
39             self.line)
40         lldbutil.check_breakpoint_result(
41             self,
42             break_results,
43             file_name='main.c',
44             line_number=self.line,
45             num_locations=1)
46
47         break_results = lldbutil.run_break_set_command(
48             self, "b %s:%d" % (self.source, self.line))
49         lldbutil.check_breakpoint_result(
50             self,
51             break_results,
52             file_name='main.c',
53             line_number=self.line,
54             num_locations=1)
55
56         # Check breakpoint with full file path.
57         full_path = os.path.join(os.getcwd(), self.source)
58         break_results = lldbutil.run_break_set_command(
59             self, "b %s:%d" % (full_path, self.line))
60         lldbutil.check_breakpoint_result(
61             self,
62             break_results,
63             file_name='main.c',
64             line_number=self.line,
65             num_locations=1)
66
67         self.runCmd("run", RUN_SUCCEEDED)
68
69         # The stop reason of the thread should be breakpoint.
70         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
71                     substrs=['stopped',
72                              'stop reason = breakpoint'])