2 Test the use of setjmp/longjmp for non-local goto operations in a single-threaded inferior.
5 from __future__ import print_function
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
15 class LongjmpTestCase(TestBase):
17 mydir = TestBase.compute_mydir(__file__)
22 @skipIfDarwin # llvm.org/pr16769: LLDB on Mac OS X dies in function ReadRegisterBytes in GDBRemoteRegisterContext.cpp
23 @skipIfFreeBSD # llvm.org/pr17214
24 @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr20231")
25 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
26 def test_step_out(self):
27 """Test stepping when the inferior calls setjmp/longjmp, in particular, thread step-out."""
31 @skipIfDarwin # llvm.org/pr16769: LLDB on Mac OS X dies in function ReadRegisterBytes in GDBRemoteRegisterContext.cpp
32 @skipIfFreeBSD # llvm.org/pr17214
33 @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr20231")
34 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
35 def test_step_over(self):
36 """Test stepping when the inferior calls setjmp/longjmp, in particular, thread step-over a longjmp."""
40 @skipIfDarwin # llvm.org/pr16769: LLDB on Mac OS X dies in function ReadRegisterBytes in GDBRemoteRegisterContext.cpp
41 @skipIfFreeBSD # llvm.org/pr17214
42 @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr20231")
43 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
44 def test_step_back_out(self):
45 """Test stepping when the inferior calls setjmp/longjmp, in particular, thread step-out after thread step-in."""
49 def start_test(self, symbol):
50 exe = os.path.join(os.getcwd(), "a.out")
52 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
55 lldbutil.run_break_set_by_symbol (self, symbol, num_expected_locations=-1)
57 self.runCmd("run", RUN_SUCCEEDED)
59 # The stop reason of the thread should be breakpoint.
60 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
61 substrs = ['stopped', 'stop reason = breakpoint'])
63 def check_status(self):
64 # Note: Depending on the generated mapping of DWARF to assembly,
65 # the process may have stopped or exited.
66 self.expect("process status", PROCESS_STOPPED,
67 patterns = ['Process .* exited with status = 0'])
70 self.start_test("do_jump")
71 self.runCmd("thread step-out", RUN_SUCCEEDED)
75 self.start_test("do_jump")
76 self.runCmd("thread step-over", RUN_SUCCEEDED)
77 self.runCmd("thread step-over", RUN_SUCCEEDED)
80 def step_back_out(self):
81 self.start_test("main")
83 self.runCmd("thread step-over", RUN_SUCCEEDED)
84 self.runCmd("thread step-in", RUN_SUCCEEDED)
85 self.runCmd("thread step-out", RUN_SUCCEEDED)