xref: /llvm-project/lldb/test/API/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py (revision 95367da43ddd16fc9c4cbe06a1823119f7841f48)
1"""Test that forward declarations don't cause bogus conflicts in namespaced types"""
2
3
4
5import lldb
6from lldbsuite.test.lldbtest import *
7from lldbsuite.test.decorators import *
8import lldbsuite.test.lldbutil as lldbutil
9
10
11class NamespaceDefinitionsTestCase(TestBase):
12
13    # See also llvm.org/pr28948
14    @expectedFailureAll(
15        bugnumber="llvm.org/pr50814",
16        compiler="gcc")
17    @expectedFailureAll(
18        bugnumber="llvm.org/pr28948",
19        oslist=['linux'], compiler="gcc", archs=['arm','aarch64'])
20    @expectedFailureAll(oslist=["windows"])
21    def test_expr(self):
22        self.build()
23        self.common_setup()
24
25        self.expect(
26            "expression -- Foo::MyClass()",
27            VARIABLES_DISPLAYED_CORRECTLY,
28            substrs=['thing = '])
29
30    def setUp(self):
31        # Call super's setUp().
32        TestBase.setUp(self)
33        # Find the line number to break inside main().
34        self.source = 'main.cpp'
35        self.line = line_number(self.source, '// Set breakpoint here')
36        self.shlib_names = ["a", "b"]
37
38    def common_setup(self):
39        # Run in synchronous mode
40        self.dbg.SetAsync(False)
41
42        # Create a target by the debugger.
43        target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
44        self.assertTrue(target, VALID_TARGET)
45
46        # Break inside the foo function which takes a bar_ptr argument.
47        lldbutil.run_break_set_by_file_and_line(
48            self, self.source, self.line, num_expected_locations=1, loc_exact=True)
49
50        # Register our shared libraries for remote targets so they get
51        # automatically uploaded
52        environment = self.registerSharedLibrariesWithTarget(
53            target, self.shlib_names)
54
55        # Now launch the process, and do not stop at entry point.
56        process = target.LaunchSimple(
57            None, environment, self.get_process_working_directory())
58        self.assertTrue(process, PROCESS_IS_VALID)
59
60        # The stop reason of the thread should be breakpoint.
61        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
62                    substrs=['stopped',
63                             'stop reason = breakpoint'])
64
65        # The breakpoint should have a hit count of 1.
66        lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
67