1""" 2Test that we work properly with classes with the trivial_abi attribute 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class TestTrivialABI(TestBase): 14 15 mydir = TestBase.compute_mydir(__file__) 16 NO_DEBUG_INFO_TESTCASE = True 17 18 @skipUnlessSupportedTypeAttribute("trivial_abi") 19 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995") 20 @expectedFailureAll(archs=["aarch64"], oslist=["linux"], 21 bugnumber="llvm.org/pr44161") 22 def test_call_trivial(self): 23 """Test that we can print a variable & call a function with a trivial ABI class.""" 24 self.build() 25 self.main_source_file = lldb.SBFileSpec("main.cpp") 26 self.expr_test(True) 27 28 @skipUnlessSupportedTypeAttribute("trivial_abi") 29 # fixed for SysV-x86_64 ABI, but not Windows-x86_64 30 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr36870") 31 @expectedFailureAll(archs=["aarch64"], oslist=["linux"], 32 bugnumber="llvm.org/pr44161") 33 @expectedFailureAll(archs=["arm64", "arm64e"], bugnumber="<rdar://problem/57844240>") 34 def test_call_nontrivial(self): 35 """Test that we can print a variable & call a function on the same class w/o the trivial ABI marker.""" 36 self.build() 37 self.main_source_file = lldb.SBFileSpec("main.cpp") 38 self.expr_test(False) 39 40 def check_value(self, test_var, ivar_value): 41 self.assertTrue(test_var.GetError().Success(), "Invalid valobj: %s"%(test_var.GetError().GetCString())) 42 ivar = test_var.GetChildMemberWithName("ivar") 43 self.assertTrue(test_var.GetError().Success(), "Failed to fetch ivar") 44 self.assertEqual(ivar_value, ivar.GetValueAsSigned(), "Got the right value for ivar") 45 46 def check_frame(self, thread): 47 frame = thread.frames[0] 48 inVal_var = frame.FindVariable("inVal") 49 self.check_value(inVal_var, 10) 50 51 options = lldb.SBExpressionOptions() 52 inVal_expr = frame.EvaluateExpression("inVal", options) 53 self.check_value(inVal_expr, 10) 54 55 thread.StepOut() 56 outVal_ret = thread.GetStopReturnValue() 57 self.check_value(outVal_ret, 30) 58 59 def expr_test(self, trivial): 60 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, 61 "Set a breakpoint here", self.main_source_file) 62 63 # Stop in a function that takes a trivial value, and try both frame var & expr to get its value: 64 if trivial: 65 self.check_frame(thread) 66 return 67 68 # Now continue to the same thing without the trivial_abi and see if we get that right: 69 threads = lldbutil.continue_to_breakpoint(process, bkpt) 70 self.assertEqual(len(threads), 1, "Hit my breakpoint the second time.") 71 72 self.check_frame(threads[0]) 73