brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · fed3a88 Raw
97 lines · python
1import lldbsuite.test.lldbutil as lldbutil2from lldbsuite.test.lldbtest import *3from lldbsuite.test.decorators import *4import shutil5import os6 7 8class TestCTF(TestBase):9    NO_DEBUG_INFO_TESTCASE = True10 11    def no_ctf_convert(self):12        if not shutil.which("ctfconvert"):13            return "ctfconvert not found in path"14        return None15 16    def no_objcopy(self):17        if not "OBJCOPY" in os.environ:18            return "llvm-objcopy not found in environment"19        return None20 21    @skipTestIfFn(no_ctf_convert)22    @skipTestIfFn(no_objcopy)23    @skipUnlessDarwin24    def test(self):25        self.build()26        self.do_test()27 28    @skipTestIfFn(no_ctf_convert)29    @skipTestIfFn(no_objcopy)30    @skipUnlessDarwin31    def test_compressed(self):32        self.build(dictionary={"COMPRESS_CTF": "YES"})33        self.do_test()34 35    def do_test(self):36        lldbutil.run_to_name_breakpoint(self, "printf")37 38        symbol_file = self.getBuildArtifact("a.ctf")39 40        if self.TraceOn():41            self.runCmd("log enable -v lldb symbol")42 43        self.runCmd("target symbols add {}".format(symbol_file))44        self.expect(45            "target variable foo",46            substrs=[47                "(MyStructT) foo",48                "i = 1",49                "foo",50                "'c'",51                "[0] = 'c'",52                "[1] = 'a'",53                "[2] = 'b'",54                "[3] = 'c'",55                'u = (i = 1, s = "")',56                "b = false",57                "f = 0x0000000000000000",58            ],59        )60        self.expect("target variable foo.n.i", substrs=["(MyInt) foo.n.i = 1"])61        self.expect(62            "target variable foo.n.s", substrs=["(const char *) foo.n.s", '"foo"']63        )64        self.expect(65            "target variable foo.n.c", substrs=["(volatile char) foo.n.c = 'c'"]66        )67        self.expect(68            "target variable foo.n.a",69            substrs=[70                "(char[4]:8) foo.n.a",71                "[0] = 'c'",72                "[1] = 'a'",73                "[2] = 'b'",74                "[3] = 'c'",75            ],76        )77        self.expect(78            "target variable foo.n.u", substrs=['(MyUnionT) foo.n.u = (i = 1, s = "")']79        )80        self.expect(81            "target variable foo.f",82            substrs=["(void (*)(int)) foo.f = 0x0000000000000000"],83        )84 85        self.expect(86            "type lookup MyEnum",87            substrs=[88                "enum MyEnum {",89                "eOne,",90                "eTwo,",91                "eThree",92                "}",93            ],94        )95 96        self.expect("type lookup RecursiveStruct", substrs=["RecursiveStruct *n;"])97