2 Test that we work properly with classes with the trivial_abi attribute
5 from __future__ import print_function
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 from lldbsuite.test import lldbutil
17 class TestTrivialABI(TestBase):
19 mydir = TestBase.compute_mydir(__file__)
20 NO_DEBUG_INFO_TESTCASE = True
22 @skipUnlessSupportedTypeAttribute("trivial_abi")
23 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995")
24 def test_call_trivial(self):
25 """Test that we can print a variable & call a function with a trivial ABI class."""
27 self.main_source_file = lldb.SBFileSpec("main.cpp")
30 @skipUnlessSupportedTypeAttribute("trivial_abi")
31 @expectedFailureAll(bugnumber="llvm.org/pr36870")
32 def test_call_nontrivial(self):
33 """Test that we can print a variable & call a function on the same class w/o the trivial ABI marker."""
35 self.main_source_file = lldb.SBFileSpec("main.cpp")
39 # Call super's setUp().
42 def check_value(self, test_var, ivar_value):
43 self.assertTrue(test_var.GetError().Success(), "Invalid valobj: %s"%(test_var.GetError().GetCString()))
44 ivar = test_var.GetChildMemberWithName("ivar")
45 self.assertTrue(test_var.GetError().Success(), "Failed to fetch ivar")
46 self.assertEqual(ivar_value, ivar.GetValueAsSigned(), "Got the right value for ivar")
48 def check_frame(self, thread):
49 frame = thread.frames[0]
50 inVal_var = frame.FindVariable("inVal")
51 self.check_value(inVal_var, 10)
53 options = lldb.SBExpressionOptions()
54 inVal_expr = frame.EvaluateExpression("inVal", options)
55 self.check_value(inVal_expr, 10)
58 outVal_ret = thread.GetStopReturnValue()
59 self.check_value(outVal_ret, 30)
61 def expr_test(self, trivial):
62 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
63 "Set a breakpoint here", self.main_source_file)
65 # Stop in a function that takes a trivial value, and try both frame var & expr to get its value:
67 self.check_frame(thread)
70 # Now continue to the same thing without the trivial_abi and see if we get that right:
71 threads = lldbutil.continue_to_breakpoint(process, bkpt)
72 self.assertEqual(len(threads), 1, "Hit my breakpoint the second time.")
74 self.check_frame(threads[0])