0911f37
http://sourceware.org/ml/gdb-patches/2009-10/msg00142.html
0911f37
Subject: [patch] Fix GNU/Linux core open: Can't read pathname for load map:  Input/output error.
0911f37
a930df3
[ New patch variant.  ]
0911f37
556378e
Index: gdb-7.5.50.20130118/gdb/solib-svr4.c
11eae30
===================================================================
556378e
--- gdb-7.5.50.20130118.orig/gdb/solib-svr4.c	2013-01-18 23:05:19.414210015 +0100
556378e
+++ gdb-7.5.50.20130118/gdb/solib-svr4.c	2013-01-18 23:05:34.813231664 +0100
11eae30
@@ -1221,8 +1221,17 @@ svr4_read_so_list (CORE_ADDR lm, struct
254f0e9
 			  SO_NAME_MAX_PATH_SIZE - 1, &errcode);
254f0e9
       if (errcode != 0)
254f0e9
 	{
254f0e9
-	  warning (_("Can't read pathname for load map: %s."),
254f0e9
-		   safe_strerror (errcode));
254f0e9
+	  /* During the first ever DSO list reading some strings may be
254f0e9
+	     unreadable as residing in the ld.so readonly memory not being
254f0e9
+	     present in a dumped core file.  Delay the error check after
254f0e9
+	     the first pass of DSO list scanning when ld.so should be
254f0e9
+	     already mapped in and all the DSO list l_name memory gets
254f0e9
+	     readable.  */
0911f37
+
254f0e9
+	  if (master_so_list () != NULL)
254f0e9
+	    warning (_("Can't read pathname for load map: %s."),
254f0e9
+		     safe_strerror (errcode));
254f0e9
+
254f0e9
 	  do_cleanups (old_chain);
254f0e9
 	  continue;
254f0e9
 	}
556378e
Index: gdb-7.5.50.20130118/gdb/solib.c
11eae30
===================================================================
556378e
--- gdb-7.5.50.20130118.orig/gdb/solib.c	2013-01-18 23:05:19.415210017 +0100
556378e
+++ gdb-7.5.50.20130118/gdb/solib.c	2013-01-18 23:05:57.421263173 +0100
556378e
@@ -666,7 +666,7 @@ solib_used (const struct so_list *const
a930df3
    processes we've just attached to, so that's okay.  */
a930df3
 
a930df3
 static void
a930df3
-update_solib_list (int from_tty, struct target_ops *target)
a930df3
+update_solib_list_1 (int from_tty, struct target_ops *target)
a930df3
 {
556378e
   struct target_so_ops *ops = solib_ops (target_gdbarch ());
0911f37
   struct so_list *inferior = ops->current_sos();
556378e
@@ -837,6 +837,21 @@ Do you need \"set solib-search-path\" or
a930df3
     }
a930df3
 }
a930df3
 
a930df3
+/* Wrapper for Fedora: gdb-core-open-vdso-warning.patch  */
a930df3
+
a930df3
+static void
a930df3
+update_solib_list (int from_tty, struct target_ops *target)
a930df3
+{
0911f37
+  struct so_list *saved_so_list_head = so_list_head;
a930df3
+
a930df3
+  update_solib_list_1 (from_tty, target);
a930df3
+
a930df3
+  /* If this was the very first DSO list scan and we possibly read in ld.so
a930df3
+     recheck all the formerly unreadable DSO names strings.  */
a930df3
+
a930df3
+  if (saved_so_list_head == NULL && so_list_head != NULL)
a930df3
+    update_solib_list_1 (from_tty, target);
a930df3
+}
0911f37
 
a930df3
 /* Return non-zero if NAME is the libpthread shared library.
a930df3
 
556378e
Index: gdb-7.5.50.20130118/gdb/testsuite/gdb.base/corefile.exp
11eae30
===================================================================
556378e
--- gdb-7.5.50.20130118.orig/gdb/testsuite/gdb.base/corefile.exp	2013-01-18 23:05:19.416210020 +0100
556378e
+++ gdb-7.5.50.20130118/gdb/testsuite/gdb.base/corefile.exp	2013-01-18 23:05:34.814231667 +0100
5387893
@@ -286,3 +286,19 @@ if {$buildid == ""} {
5387893
     gdb_test "info files" "Local exec file:\r\n\[ \t\]*`[string_to_regexp $debugdir/$buildid]', file type .*"
5387893
     pass $wholetest
a930df3
 }
0911f37
+
5387893
+
a930df3
+# Test Linux specific vDSO warning:
a930df3
+# warning: Can't read pathname for load map: Input/output error.
0911f37
+
a930df3
+clean_restart ${testfile}
a930df3
+
a930df3
+set test "core-file vdso warning"
a930df3
+gdb_test_multiple "core-file $corefile" $test {
a930df3
+    -re "warning: Can't read pathname for load map: Input/output error\\.\r\n.*\r\n$gdb_prompt $" {
a930df3
+	fail $test
a930df3
+    }
a930df3
+    -re "\r\n$gdb_prompt $" {
a930df3
+	pass $test
a930df3
+    }
a930df3
+}
556378e
Index: gdb-7.5.50.20130118/gdb/testsuite/gdb.base/solib-symbol.exp
11eae30
===================================================================
556378e
--- gdb-7.5.50.20130118.orig/gdb/testsuite/gdb.base/solib-symbol.exp	2013-01-18 23:05:19.416210020 +0100
556378e
+++ gdb-7.5.50.20130118/gdb/testsuite/gdb.base/solib-symbol.exp	2013-01-18 23:05:34.814231667 +0100
11eae30
@@ -27,7 +27,8 @@ set lib_flags [list debug ldflags=-Wl,-B
a930df3
 # Binary file.
a930df3
 set testfile "solib-symbol-main"
a930df3
 set srcfile ${srcdir}/${subdir}/${testfile}.c
a930df3
-set binfile ${objdir}/${subdir}/${testfile}
a930df3
+set executable ${testfile}
a930df3
+set binfile ${objdir}/${subdir}/${executable}
a930df3
 set bin_flags [list debug shlib=${binfile_lib}]
a930df3
 
11eae30
 if [get_compiler_info] {
a930df3
@@ -72,8 +73,26 @@ gdb_test "br foo2" \
a930df3
 	 "Breakpoint.*: foo2. .2 locations..*" \
a930df3
 	 "foo2 in mdlib"
a930df3
 
a930df3
-gdb_exit
a930df3
+# Test GDB warns for shared libraris which have not been found.
a930df3
 
a930df3
-return 0
a930df3
+gdb_test "info sharedlibrary" "/${libname}.*"
a930df3
 
a930df3
+clean_restart ${executable}
a930df3
+gdb_breakpoint "main"
a930df3
+gdb_run_cmd
a930df3
+set test "no warning for missing libraries"
a930df3
+gdb_test_multiple "" $test {
a930df3
+    -re "warning: Could not load shared library symbols for \[0-9\]+ libraries,.*\r\n$gdb_prompt $" {
a930df3
+	fail $test
a930df3
+    }
a930df3
+    -re "Breakpoint \[0-9\]+, main .*\r\n$gdb_prompt $" {
a930df3
+	pass $test
a930df3
+    }
a930df3
+}
a930df3
 
a930df3
+clean_restart ${executable}
a930df3
+gdb_test_no_output "set solib-absolute-prefix /doESnotEXIST"
a930df3
+gdb_breakpoint "main"
a930df3
+gdb_run_cmd
a930df3
+gdb_test "" "warning: Could not load shared library symbols for \[0-9\]+ libraries,.*\r\nBreakpoint \[0-9\]+, main .*" \
a930df3
+	 "warning for missing libraries"