Blame SOURCES/gdb-rhbz1218710-reverse-debugging-ppc-1of7.patch

7b26da
  Date: Mon, 15 Apr 2013 11:04:10 -0700
7b26da
  Message-ID: <CADPb22TTQCsFsuNtjTiUUQU_FN8R6cxfPeCRvNp_Ad2XS6XUag@mail.gmail.com>
7b26da
  Subject: Re: [RFA] Fix solib-precsave.exp,solib-reverse.exp
7b26da
  From: Doug Evans <dje at google dot com>
7b26da
  To: Pedro Alves <palves at redhat dot com>
7b26da
  Cc: gdb-patches <gdb-patches at sourceware dot org>
7b26da
7b26da
  On Mon, Apr 15, 2013 at 10:33 AM, Pedro Alves <palves@redhat.com> wrote:
7b26da
  > On 04/13/2013 12:13 AM, Doug Evans wrote:
7b26da
  >> Hi.
7b26da
  >>
7b26da
  >> These two tests are failing for me.
7b26da
  >> They make the assumption that debug info for libc isn't installed.
7b26da
  >>
7b26da
  >> To fix this I've created a library of wrappers for the affected libc
7b26da
  >> functions and compiled it without debug info.
7b26da
  >>
7b26da
  >> Ok to check in?
7b26da
  >
7b26da
  > This the certainly the right idea for fixing the problem, but it took me a
7b26da
  > while to realize that the fact that the functions currently called are
7b26da
  > printf and sleep, and that the new library has wrappers for those has no
7b26da
  > importance.  They really are just used as proxy for "functions in library
7b26da
  > with no debug info".  Not even the output of printf is used.  I think that
7b26da
  > calling the library a syscall wrapper makes it prone to causing such doubt
7b26da
  > and confusion in other readers (of either the patch or the resulting code
7b26da
  > in the tree), as it has caused me.
7b26da
  >
7b26da
  > How about we just call it "shr1", and have it export some non-libc related
7b26da
  > functions like e.g., "shr1_foo" and "shr1_bar"?
7b26da
7b26da
  Blech.  That's how I originally had it.
7b26da
  The original code used printf and sleep and I figured someone would
7b26da
  want to keep them.
7b26da
  I don't have a preference for either way.  Anyone else?
7b26da
  In any case we need to document that one cannot call libc functions
7b26da
  (or similar) as is.
7b26da
7b26da
  >>  int main ()
7b26da
  >> @@ -27,16 +31,25 @@ int main ()
7b26da
  >>    char* cptr = "String 1";
7b26da
  >>    int b[2] = {5,8};
7b26da
  >>
7b26da
  >> +  /* Call these functions once before we start testing so that they get
7b26da
  >> +     resolved by the dynamic loader.  If the system has debug info for
7b26da
  >> +     the dynamic loader installed, reverse-stepping for the first call
7b26da
  >> +     will otherwise record being in the dynamic loader, which is not what
7b26da
  >
7b26da
  > reverse-stepping doesn't record.  Did you mean "report", or even
7b26da
  > "reverse-stepping the first call will otherwise stop in the
7b26da
  > dynamic loader", perhaps?
7b26da
7b26da
  Yeah.
7b26da
7b26da
commit c2a96e8cafeeda6132399e9ea94dafad6366ccc5
7b26da
Author: Doug Evans <dje@google.com>
7b26da
Date:   Mon May 6 22:07:13 2013 +0000
7b26da
7b26da
    	* gdb.reverse/shr.h: New file.
7b26da
    	* gdb.reverse/shr1.c: New file.
7b26da
    	* gdb.reverse/shr2.c: #include "shr.h".
7b26da
    	* gdb.reverse/solib-reverse.c: Remove #include <stdio.h>.
7b26da
    	#include "shr.h".  Replace calls to printf,sleep to call shr1 instead.
7b26da
    	* gdb.reverse/solib-precsave.exp: Build shr2.sl.
7b26da
    	Update tests using sleep/printf to use shr2.sl instead.
7b26da
    	* gdb.reverse/solib-reverse.exp: Ditt.o
7b26da
7b26da
Index: gdb-7.6.1/gdb/testsuite/gdb.reverse/shr1.c
7b26da
===================================================================
7b26da
--- /dev/null
7b26da
+++ gdb-7.6.1/gdb/testsuite/gdb.reverse/shr1.c
7b26da
@@ -0,0 +1,24 @@
7b26da
+/* This testcase is part of GDB, the GNU debugger.
7b26da
+
7b26da
+   Copyright 2013 Free Software Foundation, Inc.
7b26da
+
7b26da
+   This program is free software; you can redistribute it and/or modify
7b26da
+   it under the terms of the GNU General Public License as published by
7b26da
+   the Free Software Foundation; either version 3 of the License, or
7b26da
+   (at your option) any later version.
7b26da
+
7b26da
+   This program is distributed in the hope that it will be useful,
7b26da
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
7b26da
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7b26da
+   GNU General Public License for more details.
7b26da
+
7b26da
+   You should have received a copy of the GNU General Public License
7b26da
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
7b26da
+
7b26da
+#include "shr.h"
7b26da
+
7b26da
+void
7b26da
+shr1 (const char *s)
7b26da
+{
7b26da
+  /* nothing to do */
7b26da
+}
7b26da
Index: gdb-7.6.1/gdb/testsuite/gdb.reverse/shr2.c
7b26da
===================================================================
7b26da
--- gdb-7.6.1.orig/gdb/testsuite/gdb.reverse/shr2.c
7b26da
+++ gdb-7.6.1/gdb/testsuite/gdb.reverse/shr2.c
7b26da
@@ -15,6 +15,8 @@
7b26da
    You should have received a copy of the GNU General Public License
7b26da
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
7b26da
 
7b26da
+#include "shr.h"
7b26da
+
7b26da
 #ifdef PROTOTYPES
7b26da
 int shr2(int x)
7b26da
 #else
7b26da
Index: gdb-7.6.1/gdb/testsuite/gdb.reverse/shr.h
7b26da
===================================================================
7b26da
--- /dev/null
7b26da
+++ gdb-7.6.1/gdb/testsuite/gdb.reverse/shr.h
7b26da
@@ -0,0 +1,24 @@
7b26da
+/* This testcase is part of GDB, the GNU debugger.
7b26da
+
7b26da
+   Copyright 2013 Free Software Foundation, Inc.
7b26da
+
7b26da
+   This program is free software; you can redistribute it and/or modify
7b26da
+   it under the terms of the GNU General Public License as published by
7b26da
+   the Free Software Foundation; either version 3 of the License, or
7b26da
+   (at your option) any later version.
7b26da
+
7b26da
+   This program is distributed in the hope that it will be useful,
7b26da
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
7b26da
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7b26da
+   GNU General Public License for more details.
7b26da
+
7b26da
+   You should have received a copy of the GNU General Public License
7b26da
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
7b26da
+
7b26da
+#ifndef GDB_REVERSE_SHR_H
7b26da
+#define GDB_REVERSE_SHR_H
7b26da
+
7b26da
+extern void shr1 (const char *);
7b26da
+extern int shr2 (int);
7b26da
+
7b26da
+#endif /* GDB_REVERSE_SHR_H */
7b26da
Index: gdb-7.6.1/gdb/testsuite/gdb.reverse/solib-precsave.exp
7b26da
===================================================================
7b26da
--- gdb-7.6.1.orig/gdb/testsuite/gdb.reverse/solib-precsave.exp
7b26da
+++ gdb-7.6.1/gdb/testsuite/gdb.reverse/solib-precsave.exp
7b26da
@@ -26,20 +26,30 @@ if {[skip_shlib_tests]} {
7b26da
 
7b26da
 standard_testfile solib-reverse.c
7b26da
 set precsave [standard_output_file solib.precsave]
7b26da
-set libfile  "shr2"
7b26da
-set libsrc   ${libfile}.c
7b26da
-set library  [standard_output_file ${libfile}.sl]
7b26da
+set lib1file "shr1"
7b26da
+set lib1src  ${lib1file}.c
7b26da
+set library1 [standard_output_file ${lib1file}.sl]
7b26da
+set lib2file "shr2"
7b26da
+set lib2src  ${lib2file}.c
7b26da
+set library2 [standard_output_file ${lib2file}.sl]
7b26da
 
7b26da
 if [get_compiler_info] {
7b26da
     return -1
7b26da
 }
7b26da
 
7b26da
-if { [gdb_compile_shlib ${srcdir}/${subdir}/${libsrc} ${library} "debug"] != "" } {
7b26da
-    untested "Could not compile shared library."
7b26da
+# Compile the first without debug info so that
7b26da
+# stepping and reverse stepping doesn't end up inside them.
7b26da
+if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib1src} ${library1} ""] != "" } {
7b26da
+    untested "Could not compile shared library1."
7b26da
     return -1
7b26da
 }
7b26da
 
7b26da
-set exec_opts [list debug shlib=${library}]
7b26da
+if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib2src} ${library2} "debug"] != "" } {
7b26da
+    untested "Could not compile shared library2."
7b26da
+    return -1
7b26da
+}
7b26da
+
7b26da
+set exec_opts [list debug shlib=${library1} shlib=${library2}]
7b26da
 
7b26da
 # Attempt to prevent -Wl,-z,relro which may happen by default with some
7b26da
 # toolchain configurations.  Due to PR corefiles/11804 GDB will then produce
7b26da
@@ -57,12 +67,17 @@ if { [gdb_compile ${srcdir}/${subdir}/${
7b26da
 gdb_exit
7b26da
 gdb_start
7b26da
 
7b26da
-# Clear it to never find any separate system debug infos.
7b26da
-gdb_test_no_output "set debug-file-directory"
7b26da
+# Note: The test previously did "set debug-file-directory" to (try to)
7b26da
+# ensure the debug info for the dynamic loader and libc weren't found.
7b26da
+# This doesn't work if the debug info is in the .debug subdirectory.
7b26da
+# Avoiding debug info for system libraries is not germaine to this test
7b26da
+# and is no longer attempted.  Instead, the test does not make assumptions
7b26da
+# about whether the debug info is present or not.
7b26da
 
7b26da
 gdb_reinitialize_dir $srcdir/$subdir
7b26da
 gdb_load ${binfile}
7b26da
-gdb_load_shlibs $library
7b26da
+gdb_load_shlibs $library1
7b26da
+gdb_load_shlibs $library2
7b26da
 
7b26da
 runto main
7b26da
 
7b26da
@@ -99,15 +114,10 @@ set end_part_one [gdb_get_line_number "
7b26da
 set end_part_two [gdb_get_line_number " end part two" "$srcfile"]
7b26da
 gdb_test "until $end_part_one" " end part one.*" "run until end part one"
7b26da
 
7b26da
-gdb_test "reverse-step" " sleep three .*" "reverse-step third sleep"
7b26da
-gdb_test "reverse-step" " sleep two .*"   "reverse-step second sleep"
7b26da
-gdb_test "reverse-step" " sleep one .*"   \
7b26da
-		    "reverse-step first sleep, dynsym resolve"
7b26da
-
7b26da
-gdb_test "reverse-step" " printf three .*" "reverse-step third printf"
7b26da
-gdb_test "reverse-step" " printf two .*"   "reverse-step second printf"
7b26da
-gdb_test "reverse-step" " printf one .*"   \
7b26da
-		    "reverse-step first printf, dynsym resolve"
7b26da
+gdb_test "reverse-step" " shr1 three .*" "reverse-step third shr1"
7b26da
+gdb_test "reverse-step" " shr1 two .*"   "reverse-step second shr1"
7b26da
+gdb_test "reverse-step" " shr1 one .*"   "reverse-step first shr1"
7b26da
+
7b26da
 gdb_test "reverse-step" " generic statement.*" "reverse-step generic"
7b26da
 
7b26da
 
7b26da
@@ -119,15 +129,10 @@ gdb_test "reverse-step" " generic statem
7b26da
 
7b26da
 gdb_test "until $end_part_one" " end part one.*" "forward to end part one"
7b26da
 
7b26da
-gdb_test "reverse-next" " sleep three .*" "reverse-next third sleep"
7b26da
-gdb_test "reverse-next" " sleep two .*"   "reverse-next second sleep"
7b26da
-gdb_test "reverse-next" " sleep one .*"   \
7b26da
-		    "reverse-next first sleep, dynsym resolve"
7b26da
-
7b26da
-gdb_test "reverse-next" " printf three .*" "reverse-next third printf"
7b26da
-gdb_test "reverse-next" " printf two .*"   "reverse-next second printf"
7b26da
-gdb_test "reverse-next" " printf one .*"   \
7b26da
-		    "reverse-next first printf, dynsym resolve"
7b26da
+gdb_test "reverse-next" " shr1 three .*" "reverse-next third shr1"
7b26da
+gdb_test "reverse-next" " shr1 two .*"   "reverse-next second shr1"
7b26da
+gdb_test "reverse-next" " shr1 one .*"   "reverse-next first shr1"
7b26da
+
7b26da
 gdb_test "reverse-next" " generic statement.*" "reverse-next generic"
7b26da
 
7b26da
 
7b26da
@@ -135,11 +140,11 @@ gdb_test "reverse-next" " generic statem
7b26da
 # Test reverse-step into debuggable solib function
7b26da
 #
7b26da
 
7b26da
-gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function one"
7b26da
+gdb_test "reverse-step" "${lib2src}.*" "reverse-step into solib function one"
7b26da
 gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one"
7b26da
 gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one"
7b26da
 
7b26da
-gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function two"
7b26da
+gdb_test "reverse-step" "${lib2src}.*" "reverse-step into solib function two"
7b26da
 gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two"
7b26da
 gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two"
7b26da
 
7b26da
Index: gdb-7.6.1/gdb/testsuite/gdb.reverse/solib-reverse.c
7b26da
===================================================================
7b26da
--- gdb-7.6.1.orig/gdb/testsuite/gdb.reverse/solib-reverse.c
7b26da
+++ gdb-7.6.1/gdb/testsuite/gdb.reverse/solib-reverse.c
7b26da
@@ -15,28 +15,33 @@
7b26da
    You should have received a copy of the GNU General Public License
7b26da
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
7b26da
 
7b26da
-/* Test reverse debugging of shared libraries.  */
7b26da
+/* Test reverse debugging of shared libraries.
7b26da
 
7b26da
-#include <stdio.h>
7b26da
+   N.B. Do not call system routines here, we don't want to have to deal with
7b26da
+   whether or not there is debug info present for them.  */
7b26da
 
7b26da
-/* Shared library function */
7b26da
-extern int shr2(int);
7b26da
+#include "shr.h"
7b26da
 
7b26da
 int main ()
7b26da
 {
7b26da
   char* cptr = "String 1";
7b26da
   int b[2] = {5,8};
7b26da
 
7b26da
+  /* Call these functions once before we start testing so that they get
7b26da
+     resolved by the dynamic loader.  If the system has debug info for
7b26da
+     the dynamic loader installed, reverse-stepping for the first call
7b26da
+     will otherwise stop in the dynamic loader, which is not what we want.  */
7b26da
+  shr1 ("");
7b26da
+  shr2 (0);
7b26da
+
7b26da
   b[0] = shr2(12);		/* begin part two */
7b26da
   b[1] = shr2(17);		/* middle part two */
7b26da
 
7b26da
   b[0] = 6;   b[1] = 9;		/* generic statement, end part two */
7b26da
-  printf ("message 1\n");	/* printf one */
7b26da
-  printf ("message 2\n");	/* printf two */
7b26da
-  printf ("message 3\n");	/* printf three */
7b26da
-  sleep (0);			/* sleep one */
7b26da
-  sleep (0);			/* sleep two */
7b26da
-  sleep (0);			/* sleep three */
7b26da
+
7b26da
+  shr1 ("message 1\n");		/* shr1 one */
7b26da
+  shr1 ("message 2\n");		/* shr1 two */
7b26da
+  shr1 ("message 3\n");		/* shr1 three */
7b26da
 
7b26da
   return 0;			/* end part one */
7b26da
 } /* end of main */
7b26da
Index: gdb-7.6.1/gdb/testsuite/gdb.reverse/solib-reverse.exp
7b26da
===================================================================
7b26da
--- gdb-7.6.1.orig/gdb/testsuite/gdb.reverse/solib-reverse.exp
7b26da
+++ gdb-7.6.1/gdb/testsuite/gdb.reverse/solib-reverse.exp
7b26da
@@ -24,20 +24,30 @@ if {[skip_shlib_tests]} {
7b26da
 }
7b26da
 
7b26da
 standard_testfile
7b26da
-set libfile  "shr2"
7b26da
-set libsrc   ${libfile}.c
7b26da
-set library  [standard_output_file ${libfile}.sl]
7b26da
+set lib1file "shr1"
7b26da
+set lib1src  ${lib1file}.c
7b26da
+set library1 [standard_output_file ${lib1file}.sl]
7b26da
+set lib2file "shr2"
7b26da
+set lib2src  ${lib2file}.c
7b26da
+set library2 [standard_output_file ${lib2file}.sl]
7b26da
 
7b26da
 if [get_compiler_info] {
7b26da
     return -1
7b26da
 }
7b26da
 
7b26da
-if { [gdb_compile_shlib ${srcdir}/${subdir}/${libsrc} ${library} "debug"] != "" } {
7b26da
-    untested "Could not compile shared library."
7b26da
+# Compile the first without debug info so that
7b26da
+# stepping and reverse stepping doesn't end up inside them.
7b26da
+if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib1src} ${library1} ""] != "" } {
7b26da
+    untested "Could not compile shared library1."
7b26da
     return -1
7b26da
 }
7b26da
 
7b26da
-set exec_opts [list debug shlib=${library}]
7b26da
+if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib2src} ${library2} "debug"] != "" } {
7b26da
+    untested "Could not compile shared library2."
7b26da
+    return -1
7b26da
+}
7b26da
+
7b26da
+set exec_opts [list debug shlib=${library1} shlib=${library2}]
7b26da
 
7b26da
 if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } {
7b26da
     untested "Could not compile $binfile."
7b26da
@@ -49,12 +59,17 @@ if { [gdb_compile ${srcdir}/${subdir}/${
7b26da
 gdb_exit
7b26da
 gdb_start
7b26da
 
7b26da
-# Clear it to never find any separate system debug infos.
7b26da
-gdb_test_no_output "set debug-file-directory"
7b26da
+# Note: The test previously did "set debug-file-directory" to (try to)
7b26da
+# ensure the debug info for the dynamic loader and libc weren't found.
7b26da
+# This doesn't work if the debug info is in the .debug subdirectory.
7b26da
+# Avoiding debug info for system libraries is not germaine to this test
7b26da
+# and is no longer attempted.  Instead, the test does not make assumptions
7b26da
+# about whether the debug info is present or not.
7b26da
 
7b26da
 gdb_reinitialize_dir $srcdir/$subdir
7b26da
 gdb_load ${binfile}
7b26da
-gdb_load_shlibs $library
7b26da
+gdb_load_shlibs $library1
7b26da
+gdb_load_shlibs $library2
7b26da
 
7b26da
 runto main
7b26da
 
7b26da
@@ -73,15 +88,10 @@ set end_part_one [gdb_get_line_number "
7b26da
 set end_part_two [gdb_get_line_number " end part two" "$srcfile"]
7b26da
 gdb_test "until $end_part_one" " end part one.*" "run until end part one"
7b26da
 
7b26da
-gdb_test "reverse-step" " sleep three .*" "reverse-step third sleep"
7b26da
-gdb_test "reverse-step" " sleep two .*"   "reverse-step second sleep"
7b26da
-gdb_test "reverse-step" " sleep one .*"   \
7b26da
-		    "reverse-step first sleep, dynsym resolve"
7b26da
-
7b26da
-gdb_test "reverse-step" " printf three .*" "reverse-step third printf"
7b26da
-gdb_test "reverse-step" " printf two .*"   "reverse-step second printf"
7b26da
-gdb_test "reverse-step" " printf one .*"   \
7b26da
-		    "reverse-step first printf, dynsym resolve"
7b26da
+gdb_test "reverse-step" " shr1 three .*" "reverse-step third shr1"
7b26da
+gdb_test "reverse-step" " shr1 two .*"   "reverse-step second shr1"
7b26da
+gdb_test "reverse-step" " shr1 one .*"   "reverse-step first shr1"
7b26da
+
7b26da
 gdb_test "reverse-step" " generic statement.*" "reverse-step generic"
7b26da
 
7b26da
 
7b26da
@@ -93,15 +103,10 @@ gdb_test "reverse-step" " generic statem
7b26da
 
7b26da
 gdb_test "until $end_part_one" " end part one.*" "forward to end part one"
7b26da
 
7b26da
-gdb_test "reverse-next" " sleep three .*" "reverse-next third sleep"
7b26da
-gdb_test "reverse-next" " sleep two .*"   "reverse-next second sleep"
7b26da
-gdb_test "reverse-next" " sleep one .*"   \
7b26da
-		    "reverse-next first sleep, dynsym resolve"
7b26da
-
7b26da
-gdb_test "reverse-next" " printf three .*" "reverse-next third printf"
7b26da
-gdb_test "reverse-next" " printf two .*"   "reverse-next second printf"
7b26da
-gdb_test "reverse-next" " printf one .*"   \
7b26da
-		    "reverse-next first printf, dynsym resolve"
7b26da
+gdb_test "reverse-next" " shr1 three .*" "reverse-next third shr1"
7b26da
+gdb_test "reverse-next" " shr1 two .*"   "reverse-next second shr1"
7b26da
+gdb_test "reverse-next" " shr1 one .*"   "reverse-next first shr1"
7b26da
+
7b26da
 gdb_test "reverse-next" " generic statement.*" "reverse-next generic"
7b26da
 
7b26da
 
7b26da
@@ -109,11 +114,11 @@ gdb_test "reverse-next" " generic statem
7b26da
 # Test reverse-step into debuggable solib function
7b26da
 #
7b26da
 
7b26da
-gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function one"
7b26da
+gdb_test "reverse-step" "${lib2src}.*" "reverse-step into solib function one"
7b26da
 gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one"
7b26da
 gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one"
7b26da
 
7b26da
-gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function two"
7b26da
+gdb_test "reverse-step" "${lib2src}.*" "reverse-step into solib function two"
7b26da
 gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two"
7b26da
 gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two"
7b26da