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