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