[Lldb-commits] [lldb] r203993 - Test cases for stepping out past frames with no debug info if that is turned on.

Jim Ingham jingham at apple.com
Fri Mar 14 17:57:49 PDT 2014


Author: jingham
Date: Fri Mar 14 19:57:48 2014
New Revision: 203993

URL: http://llvm.org/viewvc/llvm-project?rev=203993&view=rev
Log:
Test cases for stepping out past frames with no debug info if that is turned on.

Added:
    lldb/trunk/test/functionalities/step-avoids-no-debug/
    lldb/trunk/test/functionalities/step-avoids-no-debug/Makefile
    lldb/trunk/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py
    lldb/trunk/test/functionalities/step-avoids-no-debug/with-debug.c
    lldb/trunk/test/functionalities/step-avoids-no-debug/without-debug.c

Added: lldb/trunk/test/functionalities/step-avoids-no-debug/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/step-avoids-no-debug/Makefile?rev=203993&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/step-avoids-no-debug/Makefile (added)
+++ lldb/trunk/test/functionalities/step-avoids-no-debug/Makefile Fri Mar 14 19:57:48 2014
@@ -0,0 +1,8 @@
+LEVEL = ../../make
+
+C_SOURCES := with-debug.c without-debug.c
+
+include $(LEVEL)/Makefile.rules
+
+without-debug.o: without-debug.c
+	$(CC) $(CFLAGS_NO_DEBUG) -c without-debug.c	

Added: lldb/trunk/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py?rev=203993&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py (added)
+++ lldb/trunk/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py Fri Mar 14 19:57:48 2014
@@ -0,0 +1,142 @@
+"""
+Test thread step-in, step-over and step-out work with the "Avoid no debug" option.
+"""
+
+import os
+import re
+import unittest2
+import lldb, lldbutil
+from lldbtest import *
+
+class ReturnValueTestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    @python_api_test
+    @dsym_test
+    def test_step_out_with_dsym_python(self):
+        """Test stepping out using avoid-no-debug with dsyms."""
+        self.buildDsym()
+        self.get_to_starting_point()
+        self.do_step_out_past_nodebug()
+
+    @python_api_test
+    @dwarf_test
+    def test_step_out_with_dwarf_python(self):
+        """Test stepping out using avoid-no-debug with dsyms."""
+        self.buildDwarf()
+        self.get_to_starting_point()
+        self.do_step_out_past_nodebug()
+
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    @python_api_test
+    @dsym_test
+    def test_step_over_with_dsym_python(self):
+        """Test stepping over using avoid-no-debug with dsyms."""
+        self.buildDsym()
+        self.get_to_starting_point()
+        self.do_step_over_past_nodebug()
+
+    @python_api_test
+    @dwarf_test
+    def test_step_over_with_dwarf_python(self):
+        """Test stepping over using avoid-no-debug with dwarf."""
+        self.buildDwarf()
+        self.get_to_starting_point()
+        self.do_step_over_past_nodebug()
+
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    @python_api_test
+    @dsym_test
+    def test_step_in_with_dsym_python(self):
+        """Test stepping in using avoid-no-debug with dsyms."""
+        self.buildDsym()
+        self.get_to_starting_point()
+        self.do_step_in_past_nodebug()
+
+    @python_api_test
+    @dwarf_test
+    def test_step_in_with_dwarf_python(self):
+        """Test stepping in using avoid-no-debug with dwarf."""
+        self.buildDwarf()
+        self.get_to_starting_point()
+        self.do_step_in_past_nodebug()
+
+    def setUp (self):
+        TestBase.setUp(self)
+        self.main_source = "with-debug.c"
+        self.main_source_spec = lldb.SBFileSpec("with-debug.c")
+        self.dbg.HandleCommand ("settings set target.process.thread.step-out-avoid-nodebug true")
+
+    def tearDown (self):
+        self.dbg.HandleCommand ("settings set target.process.thread.step-out-avoid-nodebug false")
+
+    def hit_correct_line (self, pattern):
+        target_line = line_number (self.main_source, pattern)
+        self.assertTrue (target_line != 0, "Could not find source pattern " + pattern)
+        cur_line = self.thread.frames[0].GetLineEntry().GetLine()
+        self.assertTrue (cur_line == target_line, "Stepped to line %d instead of expected %d with pattern '%s'."%(cur_line, target_line, pattern))
+
+    def hit_correct_function (self, pattern):
+        name = self.thread.frames[0].GetFunctionName()
+        self.assertTrue (pattern in name, "Got to '%s' not the expected function '%s'."%(name, pattern))
+
+    def get_to_starting_point (self):
+        exe = os.path.join(os.getcwd(), "a.out")
+        error = lldb.SBError()
+
+        self.target = self.dbg.CreateTarget(exe)
+        self.assertTrue(self.target, VALID_TARGET)
+
+        inner_bkpt = self.target.BreakpointCreateBySourceRegex("Stop here and step out of me", self.main_source_spec)
+        self.assertTrue(inner_bkpt, VALID_BREAKPOINT)
+
+        # Now launch the process, and do not stop at entry point.
+        self.process = self.target.LaunchSimple (None, None, self.get_process_working_directory())
+
+        self.assertTrue(self.process, PROCESS_IS_VALID)
+
+        # Now finish, and make sure the return value is correct.
+        threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, inner_bkpt)
+        self.assertTrue(len(threads) == 1, "Stopped at inner breakpoint.")
+        self.thread = threads[0]
+    
+    def do_step_out_past_nodebug(self):
+        # The first step out takes us to the called_from_nodebug frame, just to make sure setting
+        # step-out-avoid-nodebug doesn't change the behavior in frames with debug info.
+        self.thread.StepOut()
+        self.hit_correct_line ("intermediate_return_value = called_from_nodebug_actual(some_value)")
+        self.thread.StepOut()
+        self.hit_correct_line ("int return_value = no_debug_caller(5, called_from_nodebug)")
+
+    def do_step_over_past_nodebug (self):
+        self.thread.StepOver()
+        self.hit_correct_line ("intermediate_return_value = called_from_nodebug_actual(some_value)")
+        self.thread.StepOver()
+        self.hit_correct_line ("return intermediate_return_value")
+        self.thread.StepOver()
+        # Note, lldb doesn't follow gdb's distinction between "step-out" and "step-over/step-in"
+        # when exiting a frame.  In all cases we leave the pc at the point where we exited the
+        # frame.  In gdb, step-over/step-in move to the end of the line they stepped out to.
+        # If we ever change this we will need to fix this test.
+        self.hit_correct_line ("int return_value = no_debug_caller(5, called_from_nodebug)")
+
+    def do_step_in_past_nodebug (self):
+        self.thread.StepInto()
+        self.hit_correct_line ("intermediate_return_value = called_from_nodebug_actual(some_value)")
+        self.thread.StepInto()
+        self.hit_correct_line ("return intermediate_return_value")
+        self.thread.StepInto()
+        # Note, lldb doesn't follow gdb's distinction between "step-out" and "step-over/step-in"
+        # when exiting a frame.  In all cases we leave the pc at the point where we exited the
+        # frame.  In gdb, step-over/step-in move to the end of the line they stepped out to.
+        # If we ever change this we will need to fix this test.
+        self.hit_correct_line ("int return_value = no_debug_caller(5, called_from_nodebug)")
+
+        
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Added: lldb/trunk/test/functionalities/step-avoids-no-debug/with-debug.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/step-avoids-no-debug/with-debug.c?rev=203993&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/step-avoids-no-debug/with-debug.c (added)
+++ lldb/trunk/test/functionalities/step-avoids-no-debug/with-debug.c Fri Mar 14 19:57:48 2014
@@ -0,0 +1,29 @@
+#include <stdio.h>
+
+typedef int (*debug_callee) (int);
+
+extern int no_debug_caller (int, debug_callee);
+
+int
+called_from_nodebug_actual(int some_value)
+{
+  int return_value = 0;
+  return_value  = printf ("Length: %d.\n", some_value);
+  return return_value; // Stop here and step out of me
+}
+
+int
+called_from_nodebug(int some_value)
+{
+  int intermediate_return_value = 0;
+  intermediate_return_value = called_from_nodebug_actual(some_value);
+  return intermediate_return_value;
+}
+
+int
+main()
+{
+  int return_value = no_debug_caller(5, called_from_nodebug);
+  printf ("I got: %d.\n", return_value);
+  return 0;
+}

Added: lldb/trunk/test/functionalities/step-avoids-no-debug/without-debug.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/step-avoids-no-debug/without-debug.c?rev=203993&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/step-avoids-no-debug/without-debug.c (added)
+++ lldb/trunk/test/functionalities/step-avoids-no-debug/without-debug.c Fri Mar 14 19:57:48 2014
@@ -0,0 +1,17 @@
+typedef int (*debug_callee) (int);
+
+int
+no_debug_caller_intermediate(int input, debug_callee callee)
+{
+  int return_value = 0;
+  return_value = callee(input);
+  return return_value;
+}
+
+int
+no_debug_caller (int input, debug_callee callee)
+{
+  int return_value = 0;
+  return_value = no_debug_caller_intermediate (input, callee);
+  return return_value;
+}





More information about the lldb-commits mailing list