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