This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] Fix solib-precsave.exp,solib-reverse.exp
- From: Doug Evans <dje at google dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 12 Apr 2013 16:13:41 -0700
- Subject: [RFA] Fix solib-precsave.exp,solib-reverse.exp
Hi.
These two tests are failing for me.
They make the assumption that debug info for libc isn't installed.
To fix this I've created a library of wrappers for the affected libc
functions and compiled it without debug info.
Ok to check in?
2013-04-12 Doug Evans <dje@google.com>
* gdb.reverse/sys-wrappers.c: New file.
* gdb.reverse/solib-precsave.exp: Update to build wrapper library
of system calls.
* gdb.reverse/solib-reverse.exp: Ditto.
* solib-reverse.c (main): Update.
Index: gdb.reverse/solib-precsave.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.reverse/solib-precsave.exp,v
retrieving revision 1.13
diff -u -p -r1.13 solib-precsave.exp
--- gdb.reverse/solib-precsave.exp 1 Jan 2013 06:41:26 -0000 1.13
+++ gdb.reverse/solib-precsave.exp 12 Apr 2013 23:12:05 -0000
@@ -26,20 +26,30 @@ if {[skip_shlib_tests]} {
standard_testfile solib-reverse.c
set precsave [standard_output_file solib.precsave]
-set libfile "shr2"
-set libsrc ${libfile}.c
-set library [standard_output_file ${libfile}.sl]
+set lib1file "sys-wrappers"
+set lib1src ${lib1file}.c
+set library1 [standard_output_file ${lib1file}.sl]
+set lib2file "shr2"
+set lib2src ${lib2file}.c
+set library2 [standard_output_file ${lib2file}.sl]
if [get_compiler_info] {
return -1
}
-if { [gdb_compile_shlib ${srcdir}/${subdir}/${libsrc} ${library} "debug"] != "" } {
- untested "Could not compile shared library."
+# Compile the library of system wrappers without debug info so that
+# stepping and reverse stepping doesn't end up inside them.
+if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib1src} ${library1} ""] != "" } {
+ untested "Could not compile shared library1."
return -1
}
-set exec_opts [list debug shlib=${library}]
+if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib2src} ${library2} "debug"] != "" } {
+ untested "Could not compile shared library2."
+ return -1
+}
+
+set exec_opts [list debug shlib=${library1} shlib=${library2}]
# Attempt to prevent -Wl,-z,relro which may happen by default with some
# toolchain configurations. Due to PR corefiles/11804 GDB will then produce
@@ -62,7 +72,8 @@ gdb_test_no_output "set debug-file-direc
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
-gdb_load_shlibs $library
+gdb_load_shlibs $library1
+gdb_load_shlibs $library2
runto main
@@ -135,11 +146,11 @@ gdb_test "reverse-next" " generic statem
# Test reverse-step into debuggable solib function
#
-gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function one"
+gdb_test "reverse-step" "${lib2src}.*" "reverse-step into solib function one"
gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one"
gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one"
-gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function two"
+gdb_test "reverse-step" "${lib2src}.*" "reverse-step into solib function two"
gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two"
gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two"
Index: gdb.reverse/solib-reverse.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.reverse/solib-reverse.c,v
retrieving revision 1.6
diff -u -p -r1.6 solib-reverse.c
--- gdb.reverse/solib-reverse.c 1 Jan 2013 06:41:26 -0000 1.6
+++ gdb.reverse/solib-reverse.c 12 Apr 2013 23:12:05 -0000
@@ -19,7 +19,11 @@
#include <stdio.h>
-/* Shared library function */
+/* sys-wrappers.c shared library functions */
+extern void my_sleep (int seconds);
+extern void my_printf (const char *format, ...);
+
+/* shr2.c shared library function */
extern int shr2(int);
int main ()
@@ -27,16 +31,25 @@ int main ()
char* cptr = "String 1";
int b[2] = {5,8};
+ /* Call these functions once before we start testing so that they get
+ resolved by the dynamic loader. If the system has debug info for
+ the dynamic loader installed, reverse-stepping for the first call
+ will otherwise record being in the dynamic loader, which is not what
+ we want. */
+ my_sleep (0);
+ my_printf ("");
+ shr2 (0);
+
b[0] = shr2(12); /* begin part two */
b[1] = shr2(17); /* middle part two */
b[0] = 6; b[1] = 9; /* generic statement, end part two */
- printf ("message 1\n"); /* printf one */
- printf ("message 2\n"); /* printf two */
- printf ("message 3\n"); /* printf three */
- sleep (0); /* sleep one */
- sleep (0); /* sleep two */
- sleep (0); /* sleep three */
+ my_printf ("message 1\n"); /* printf one */
+ my_printf ("message 2\n"); /* printf two */
+ my_printf ("message 3\n"); /* printf three */
+ my_sleep (0); /* sleep one */
+ my_sleep (0); /* sleep two */
+ my_sleep (0); /* sleep three */
return 0; /* end part one */
} /* end of main */
Index: gdb.reverse/solib-reverse.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.reverse/solib-reverse.exp,v
retrieving revision 1.11
diff -u -p -r1.11 solib-reverse.exp
--- gdb.reverse/solib-reverse.exp 1 Jan 2013 06:41:26 -0000 1.11
+++ gdb.reverse/solib-reverse.exp 12 Apr 2013 23:12:05 -0000
@@ -24,20 +24,30 @@ if {[skip_shlib_tests]} {
}
standard_testfile
-set libfile "shr2"
-set libsrc ${libfile}.c
-set library [standard_output_file ${libfile}.sl]
+set lib1file "sys-wrappers"
+set lib1src ${lib1file}.c
+set library1 [standard_output_file ${lib1file}.sl]
+set lib2file "shr2"
+set lib2src ${lib2file}.c
+set library2 [standard_output_file ${lib2file}.sl]
if [get_compiler_info] {
return -1
}
-if { [gdb_compile_shlib ${srcdir}/${subdir}/${libsrc} ${library} "debug"] != "" } {
- untested "Could not compile shared library."
+# Compile the library of system wrappers without debug info so that
+# stepping and reverse stepping doesn't end up inside them.
+if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib1src} ${library1} ""] != "" } {
+ untested "Could not compile shared library1."
return -1
}
-set exec_opts [list debug shlib=${library}]
+if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib2src} ${library2} "debug"] != "" } {
+ untested "Could not compile shared library2."
+ return -1
+}
+
+set exec_opts [list debug shlib=${library1} shlib=${library2}]
if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } {
untested "Could not compile $binfile."
@@ -54,7 +64,8 @@ gdb_test_no_output "set debug-file-direc
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
-gdb_load_shlibs $library
+gdb_load_shlibs $library1
+gdb_load_shlibs $library2
runto main
@@ -109,11 +120,11 @@ gdb_test "reverse-next" " generic statem
# Test reverse-step into debuggable solib function
#
-gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function one"
+gdb_test "reverse-step" "${lib2src}.*" "reverse-step into solib function one"
gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one"
gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one"
-gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function two"
+gdb_test "reverse-step" "${lib2src}.*" "reverse-step into solib function two"
gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two"
gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two"
Index: gdb.reverse/sys-wrappers.c
===================================================================
RCS file: gdb.reverse/sys-wrappers.c
diff -N gdb.reverse/sys-wrappers.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb.reverse/sys-wrappers.c 12 Apr 2013 23:12:05 -0000
@@ -0,0 +1,35 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2013 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+#include <stdio.h>
+
+void
+my_sleep (int seconds)
+{
+ sleep (seconds);
+}
+
+void
+my_printf (const char *format, ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ vprintf (format, args);
+ va_end (args);
+}