1import lldbsuite.test.lldbutil as lldbutil 2from lldbsuite.test.lldbtest import * 3from lldbsuite.test.decorators import * 4import shutil 5import os 6 7 8class TestCTF(TestBase): 9 NO_DEBUG_INFO_TESTCASE = True 10 11 def no_ctf_convert(self): 12 if not shutil.which("ctfconvert"): 13 return "ctfconvert not found in path" 14 return None 15 16 def no_objcopy(self): 17 if not "OBJCOPY" in os.environ: 18 return "llvm-objcopy not found in environment" 19 return None 20 21 @skipTestIfFn(no_ctf_convert) 22 @skipTestIfFn(no_objcopy) 23 @skipUnlessDarwin 24 def test(self): 25 self.build() 26 self.do_test() 27 28 @skipTestIfFn(no_ctf_convert) 29 @skipTestIfFn(no_objcopy) 30 @skipUnlessDarwin 31 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 "f = 0x0000000000000000", 57 ], 58 ) 59 self.expect("target variable foo.n.i", substrs=["(MyInt) foo.n.i = 1"]) 60 self.expect( 61 "target variable foo.n.s", substrs=["(const char *) foo.n.s", '"foo"'] 62 ) 63 self.expect( 64 "target variable foo.n.c", substrs=["(volatile char) foo.n.c = 'c'"] 65 ) 66 self.expect( 67 "target variable foo.n.a", 68 substrs=[ 69 "(char[4]:8) foo.n.a", 70 "[0] = 'c'", 71 "[1] = 'a'", 72 "[2] = 'b'", 73 "[3] = 'c'", 74 ], 75 ) 76 self.expect( 77 "target variable foo.n.u", substrs=['(MyUnionT) foo.n.u = (i = 1, s = "")'] 78 ) 79 self.expect( 80 "target variable foo.f", 81 substrs=["(void (*)(int)) foo.f = 0x0000000000000000"], 82 ) 83 84 self.expect( 85 "type lookup MyEnum", 86 substrs=[ 87 "enum MyEnum {", 88 "eOne,", 89 "eTwo,", 90 "eThree", 91 "}", 92 ], 93 ) 94