xref: /llvm-project/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py (revision 99451b4453688a94c6014cac233d371ab4cc342d)
1"""
2Tests expressions that distinguish between static and non-static methods.
3"""
4
5import lldb
6from lldbsuite.test.decorators import *
7from lldbsuite.test.lldbtest import *
8from lldbsuite.test import lldbutil
9
10
11class CPPStaticMethodsTestCase(TestBase):
12
13    mydir = TestBase.compute_mydir(__file__)
14
15    def setUp(self):
16        TestBase.setUp(self)
17        self.line = line_number('main.cpp', '// Break at this line')
18
19    def test_with_run_command(self):
20        """Test that static methods are properly distinguished from regular methods"""
21        self.build()
22        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
23
24        lldbutil.run_break_set_by_file_and_line(
25            self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
26
27        self.runCmd("process launch", RUN_SUCCEEDED)
28
29        # The stop reason of the thread should be breakpoint.
30        self.expect("thread list",
31                    STOPPED_DUE_TO_BREAKPOINT,
32                    substrs=['stopped', 'stop reason = breakpoint'])
33
34        self.expect("expression -- A::getStaticValue()",
35                    startstr="(int) $0 = 5")
36
37        self.expect("expression -- my_a.getMemberValue()",
38                    startstr="(int) $1 = 3")
39