[Lldb-commits] [lldb] r186325 - Adds a passing test for step-over and step-out when the inferior is about to call longjmp (non-local goto) in a single-threaded inferior.
Ashok Thirumurthi
ashok.thirumurthi at intel.com
Mon Jul 15 08:05:33 PDT 2013
Author: athirumu
Date: Mon Jul 15 10:05:33 2013
New Revision: 186325
URL: http://llvm.org/viewvc/llvm-project?rev=186325&view=rev
Log:
Adds a passing test for step-over and step-out when the inferior is about to call longjmp (non-local goto) in a single-threaded inferior.
Added:
lldb/trunk/test/functionalities/longjmp/
lldb/trunk/test/functionalities/longjmp/Makefile
lldb/trunk/test/functionalities/longjmp/TestLongjmp.py
lldb/trunk/test/functionalities/longjmp/main.c
Added: lldb/trunk/test/functionalities/longjmp/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/longjmp/Makefile?rev=186325&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/longjmp/Makefile (added)
+++ lldb/trunk/test/functionalities/longjmp/Makefile Mon Jul 15 10:05:33 2013
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules
Added: lldb/trunk/test/functionalities/longjmp/TestLongjmp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/longjmp/TestLongjmp.py?rev=186325&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/longjmp/TestLongjmp.py (added)
+++ lldb/trunk/test/functionalities/longjmp/TestLongjmp.py Mon Jul 15 10:05:33 2013
@@ -0,0 +1,74 @@
+"""
+Test the use of setjmp/longjmp for non-local goto operations in a single-threaded inferior.
+"""
+
+import os
+import unittest2
+import lldb
+import lldbutil
+from lldbtest import *
+
+class LongjmpTestCase(TestBase):
+
+ mydir = os.path.join("functionalities", "longjmp")
+
+ def setUp(self):
+ TestBase.setUp(self)
+
+ def test_step_out(self):
+ """Test stepping when the inferior calls setjmp/longjmp, in particular, thread step-out."""
+ self.buildDefault()
+ self.step_out()
+
+ def test_step_over(self):
+ """Test stepping when the inferior calls setjmp/longjmp, in particular, thread step-over a longjmp."""
+ self.buildDefault()
+ self.step_over()
+
+ def test_step_back_out(self):
+ """Test stepping when the inferior calls setjmp/longjmp, in particular, thread step-out after thread step-in."""
+ self.buildDefault()
+ self.step_back_out()
+
+ def start_test(self, symbol):
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break in main().
+ lldbutil.run_break_set_by_symbol (self, symbol, num_expected_locations=-1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped', 'stop reason = breakpoint'])
+
+ def step_out(self):
+ self.start_test("do_jump")
+
+ self.runCmd("thread step-out", RUN_SUCCEEDED)
+ self.expect("process status", PROCESS_STOPPED,
+ patterns = ['Process .* exited with status = 0'])
+
+ def step_over(self):
+ self.start_test("do_jump")
+
+ self.runCmd("thread step-over", RUN_SUCCEEDED)
+ self.expect("process status", PROCESS_STOPPED,
+ patterns = ['Process .* exited with status = 0'])
+
+ def step_back_out(self):
+ self.start_test("main")
+
+ self.runCmd("thread step-over", RUN_SUCCEEDED)
+ self.runCmd("thread step-in", RUN_SUCCEEDED)
+ self.runCmd("thread step-out", RUN_SUCCEEDED)
+ self.expect("process status", PROCESS_STOPPED,
+ patterns = ['Process .* exited with status = 0'])
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
Added: lldb/trunk/test/functionalities/longjmp/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/longjmp/main.c?rev=186325&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/longjmp/main.c (added)
+++ lldb/trunk/test/functionalities/longjmp/main.c Mon Jul 15 10:05:33 2013
@@ -0,0 +1,27 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <setjmp.h>
+#include <stdio.h>
+
+jmp_buf j;
+
+void do_jump(void)
+{
+ longjmp(j, 1); // non-local goto
+}
+
+int main (void)
+{
+ if (setjmp(j) == 0)
+ do_jump();
+ else
+ return 0; // destination of longjmp
+
+ return 1;
+}
More information about the lldb-commits
mailing list