xref: /llvm-project/lldb/test/API/commands/apropos/with-process/TestAproposWithProcess.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test that apropos env doesn't crash trying to touch the process plugin command
3"""
4
5
6import lldb
7from lldbsuite.test.lldbtest import *
8import lldbsuite.test.lldbutil as lldbutil
9
10
11class AproposWithProcessTestCase(TestBase):
12    NO_DEBUG_INFO_TESTCASE = True
13
14    def setUp(self):
15        # Call super's setUp().
16        TestBase.setUp(self)
17        # Find the line number to break inside main().
18        self.line = line_number("main.cpp", "// break here")
19
20    def test_apropos_with_process(self):
21        """Test that apropos env doesn't crash trying to touch the process plugin command."""
22        self.build()
23        exe = self.getBuildArtifact("a.out")
24        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
25
26        # Break in main() after the variables are assigned values.
27        lldbutil.run_break_set_by_file_and_line(
28            self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True
29        )
30
31        self.runCmd("run", RUN_SUCCEEDED)
32
33        # The stop reason of the thread should be breakpoint.
34        self.expect(
35            "thread list",
36            STOPPED_DUE_TO_BREAKPOINT,
37            substrs=["stopped", "stop reason = breakpoint"],
38        )
39
40        # The breakpoint should have a hit count of 1.
41        lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
42
43        self.runCmd("apropos env")
44