xref: /llvm-project/lldb/test/API/commands/target/dump-symtab-demangle/TestDumpSymtabDemangle.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test 'target modules dump symtab -m' doesn't demangle symbols.
3"""
4
5from lldbsuite.test.decorators import *
6from lldbsuite.test.lldbtest import *
7from lldbsuite.test import lldbutil
8
9
10class TestCase(TestBase):
11    @no_debug_info_test
12    def test(self):
13        src_dir = self.getSourceDir()
14        yaml_path = os.path.join(src_dir, "a.yaml")
15        yaml_base, ext = os.path.splitext(yaml_path)
16        obj_path = self.getBuildArtifact("main.o")
17        self.yaml2obj(yaml_path, obj_path)
18
19        # Create a target with the object file we just created from YAML
20        target = self.dbg.CreateTarget(obj_path)
21        self.assertTrue(target, VALID_TARGET)
22
23        # First test that we demangle by default and our mangled symbol isn't in the output.
24        self.expect("target modules dump symtab", substrs=["foo::bar(int)"])
25        self.expect(
26            "target modules dump symtab", matching=False, substrs=["_ZN3foo3barEi"]
27        )
28
29        # Turn off demangling and make sure that we now see the mangled name in the output.
30        self.expect("target modules dump symtab -m", substrs=["_ZN3foo3barEi"])
31