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