1""" 2Test that lldb can continue past a __builtin_debugtrap, but not a __builtin_trap 3""" 4 5import lldb 6import lldbsuite.test.lldbutil as lldbutil 7from lldbsuite.test.decorators import * 8from lldbsuite.test.lldbtest import * 9 10class BuiltinDebugTrapTestCase(TestBase): 11 12 NO_DEBUG_INFO_TESTCASE = True 13 14 # Currently this depends on behavior in debugserver to 15 # advance the pc past __builtin_trap instructions so that 16 # continue works. Everyone is in agreement that this 17 # should be moved up into lldb instead of depending on the 18 # remote stub rewriting the pc values. 19 @skipUnlessDarwin 20 21 def test(self): 22 self.build() 23 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( 24 self, "// Set a breakpoint here", lldb.SBFileSpec("main.cpp")) 25 26 # Continue to __builtin_debugtrap() 27 process.Continue() 28 if self.TraceOn(): 29 self.runCmd("f") 30 self.runCmd("bt") 31 self.runCmd("ta v global") 32 33 self.assertEqual(process.GetSelectedThread().GetStopReason(), 34 lldb.eStopReasonException) 35 36 list = target.FindGlobalVariables("global", 1, lldb.eMatchTypeNormal) 37 self.assertEqual(list.GetSize(), 1) 38 global_value = list.GetValueAtIndex(0) 39 40 self.assertEqual(global_value.GetValueAsUnsigned(), 5) 41 42 # Continue to the __builtin_trap() -- we should be able to 43 # continue past __builtin_debugtrap. 44 process.Continue() 45 if self.TraceOn(): 46 self.runCmd("f") 47 self.runCmd("bt") 48 self.runCmd("ta v global") 49 50 self.assertEqual(process.GetSelectedThread().GetStopReason(), 51 lldb.eStopReasonException) 52 53 # "global" is now 10. 54 self.assertEqual(global_value.GetValueAsUnsigned(), 10) 55 56 # We should be at the same point as before -- cannot advance 57 # past a __builtin_trap(). 58 process.Continue() 59 if self.TraceOn(): 60 self.runCmd("f") 61 self.runCmd("bt") 62 self.runCmd("ta v global") 63 64 self.assertEqual(process.GetSelectedThread().GetStopReason(), 65 lldb.eStopReasonException) 66 67 # "global" is still 10. 68 self.assertEqual(global_value.GetValueAsUnsigned(), 10) 69