Fix regression of undisplayed missing shared libraries caused by a fix for:

GNU/Linux core open: Can't read pathname for load map: Input/output error.
This commit is contained in:
Jan Kratochvil 2012-06-19 22:30:55 +02:00
parent 2b568b7d72
commit a930df3ffb
2 changed files with 108 additions and 57 deletions

View File

@ -1,43 +1,13 @@
http://sourceware.org/ml/gdb-patches/2009-10/msg00142.html
Subject: [patch] Fix GNU/Linux core open: Can't read pathname for load map: Input/output error.
Hi,
[ New patch variant. ]
GDB currently always prints on loading a core file:
warning: Can't read pathname for load map: Input/output error.
The patch is not nice but it was WONTFIXed on the glibc side in:
http://sourceware.org/ml/libc-alpha/2009-10/msg00001.html
The same message in GDB PR 8882 and glibc PR 387 was for ld-linux.so.2 l_name
but that one is now ignored thanks to IGNORE_FIRST_LINK_MAP_ENTRY.
This fix is intended for Linux system vDSO l_name which is a second entry in
the DSO list.
Regression tested on {x86_86,x86_64-m32,i686}-fedora11-linux-gnu.
Thanks,
Jan
gdb/
2009-10-06 Jan Kratochvil <jan.kratochvil@redhat.com>
Do not print false warning on reading core file with vDSO on GNU/Linux.
* solib-svr4.c (svr4_current_sos): Suppress the warning if
MASTER_SO_LIST is still NULL.
* solib.c (update_solib_list): New variable saved_so_list_head.
Conditionally restart the function.
[ Context backport. ]
Index: gdb-7.4.50.20111218/gdb/solib-svr4.c
===================================================================
--- gdb-7.4.50.20111218.orig/gdb/solib-svr4.c 2011-12-19 01:14:31.000000000 +0100
+++ gdb-7.4.50.20111218/gdb/solib-svr4.c 2011-12-19 01:31:10.106752164 +0100
@@ -1222,8 +1222,17 @@ svr4_read_so_list (CORE_ADDR lm, struct
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 307e483..ba70764 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1221,8 +1221,17 @@ svr4_read_so_list (CORE_ADDR lm, struct so_list ***link_ptr_ptr,
SO_NAME_MAX_PATH_SIZE - 1, &errcode);
if (errcode != 0)
{
@ -57,28 +27,104 @@ Index: gdb-7.4.50.20111218/gdb/solib-svr4.c
do_cleanups (old_chain);
continue;
}
Index: gdb-7.4.50.20111218/gdb/solib.c
===================================================================
--- gdb-7.4.50.20111218.orig/gdb/solib.c 2011-09-12 21:00:22.000000000 +0200
+++ gdb-7.4.50.20111218/gdb/solib.c 2011-12-19 01:29:04.815227898 +0100
@@ -676,6 +676,7 @@ update_solib_list (int from_tty, struct
diff --git a/gdb/solib.c b/gdb/solib.c
index 90439ba..36e4d2a 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -669,7 +669,7 @@ solib_used (const struct so_list *const known)
processes we've just attached to, so that's okay. */
static void
-update_solib_list (int from_tty, struct target_ops *target)
+update_solib_list_1 (int from_tty, struct target_ops *target)
{
struct target_so_ops *ops = solib_ops (target_gdbarch);
struct so_list *inferior = ops->current_sos();
struct so_list *gdb, **gdb_link;
@@ -840,6 +840,21 @@ Do you need \"set solib-search-path\" or \"set sysroot\"?"),
}
}
+/* Wrapper for Fedora: gdb-core-open-vdso-warning.patch */
+
+static void
+update_solib_list (int from_tty, struct target_ops *target)
+{
+ struct so_list *saved_so_list_head = so_list_head;
/* We can reach here due to changing solib-search-path or the
sysroot, before having any inferior. */
@@ -817,6 +818,12 @@ update_solib_list (int from_tty, struct
observer_notify_solib_loaded (i);
}
+ /* If this was the very first DSO list scan and we possibly read in ld.so
+ recheck all the formerly unreadable DSO names strings. */
+
+ if (saved_so_list_head == NULL && so_list_head != NULL)
+ return update_solib_list (from_tty, target);
+ update_solib_list_1 (from_tty, target);
+
/* If a library was not found, issue an appropriate warning
message. We have to use a single call to warning in case the
front end does something special with warnings, e.g., pop up
+ /* If this was the very first DSO list scan and we possibly read in ld.so
+ recheck all the formerly unreadable DSO names strings. */
+
+ if (saved_so_list_head == NULL && so_list_head != NULL)
+ update_solib_list_1 (from_tty, target);
+}
/* Return non-zero if NAME is the libpthread shared library.
diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp
index 027eb2c..ab686f0 100644
--- a/gdb/testsuite/gdb.base/corefile.exp
+++ b/gdb/testsuite/gdb.base/corefile.exp
@@ -256,3 +256,18 @@ if ![is_remote target] {
gdb_exit
}
+
+# Test Linux specific vDSO warning:
+# warning: Can't read pathname for load map: Input/output error.
+
+clean_restart ${testfile}
+
+set test "core-file vdso warning"
+gdb_test_multiple "core-file $corefile" $test {
+ -re "warning: Can't read pathname for load map: Input/output error\\.\r\n.*\r\n$gdb_prompt $" {
+ fail $test
+ }
+ -re "\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/solib-symbol.exp
index 3c03317..0fc38d9 100644
--- a/gdb/testsuite/gdb.base/solib-symbol.exp
+++ b/gdb/testsuite/gdb.base/solib-symbol.exp
@@ -27,7 +27,8 @@ set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
# Binary file.
set testfile "solib-symbol-main"
set srcfile ${srcdir}/${subdir}/${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+set executable ${testfile}
+set binfile ${objdir}/${subdir}/${executable}
set bin_flags [list debug shlib=${binfile_lib}]
if [get_compiler_info ${binfile}] {
@@ -72,8 +73,26 @@ gdb_test "br foo2" \
"Breakpoint.*: foo2. .2 locations..*" \
"foo2 in mdlib"
-gdb_exit
+# Test GDB warns for shared libraris which have not been found.
-return 0
+gdb_test "info sharedlibrary" "/${libname}.*"
+clean_restart ${executable}
+gdb_breakpoint "main"
+gdb_run_cmd
+set test "no warning for missing libraries"
+gdb_test_multiple "" $test {
+ -re "warning: Could not load shared library symbols for \[0-9\]+ libraries,.*\r\n$gdb_prompt $" {
+ fail $test
+ }
+ -re "Breakpoint \[0-9\]+, main .*\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
+clean_restart ${executable}
+gdb_test_no_output "set solib-absolute-prefix /doESnotEXIST"
+gdb_breakpoint "main"
+gdb_run_cmd
+gdb_test "" "warning: Could not load shared library symbols for \[0-9\]+ libraries,.*\r\nBreakpoint \[0-9\]+, main .*" \
+ "warning for missing libraries"

View File

@ -35,7 +35,7 @@ Version: 7.4.50.%{snap}
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 5%{?dist}
Release: 6%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain
Group: Development/Debuggers
@ -408,6 +408,7 @@ Patch360: gdb-6.8-bz457187-largefile-test.patch
Patch381: gdb-simultaneous-step-resume-breakpoint-test.patch
# Fix GNU/Linux core open: Can't read pathname for load map: Input/output error.
# Fix regression of undisplayed missing shared libraries caused by a fix for.
#=push+work: It should be in glibc: libc-alpha: <20091004161706.GA27450@.*>
Patch382: gdb-core-open-vdso-warning.patch
@ -1356,6 +1357,10 @@ fi
%endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch"
%changelog
* Tue Jun 19 2012 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.4.50.20120603-6.fc18
- Fix regression of undisplayed missing shared libraries caused by a fix for:
GNU/Linux core open: Can't read pathname for load map: Input/output error.
* Sun Jun 17 2012 Sergio Durigan Junior <sergiodj@redhat.com> - 7.4.50.20120603-5.fc18
- Include testcase for BZ 823789.