This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch+7.5.1] Work around PR libc/13097 "linux-vdso.so.1" #3


On 11/22/2012 06:17 PM, Jan Kratochvil wrote:
Hi,

this is an updated version of
	[RFC] Work around PR libc/13097 "linux-vdso.so.1" #2
	http://sourceware.org/ml/gdb-patches/2011-08/msg00331.html
according to the Tom's comment
	http://sourceware.org/bugzilla/show_bug.cgi?id=14466#c3

I remembered it when Joel plans 7.5.1 release, the patch is safe enough and it
is a FAQ at least on IRC.

Fedora does not have this issue with its Fedora glibc but I have it
reproducible with FSF glibc build:
	./gdb -ex r --args $HOME/glibc-root/lib/ld-linux-x86-64.so.2 --library-path $HOME/glibc-root/lib /bin/true
	Starting program: /home/.../glibc-root/lib/ld-linux-x86-64.so.2 --library-path /home/.../glibc-root/lib /bin/true
	warning: Could not load shared library symbols for linux-vdso.so.1.
	Do you need "set solib-search-path" or "set sysroot"?
	[Inferior 1 (process 31807) exited normally]

So there is no testcase as I do not know a real OS where it fails (it probably
fails on Ubuntu AFAIK).

No regressions on {x86_64,x86_64-m32,i686}-fedora18-linux-gnu.


Thanks, Jan


gdb/ 2012-11-22 Jan Kratochvil<jan.kratochvil@redhat.com>

	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.
	* gdbarch.sh (solib_file_not_found_is_ok): New.
	Include solib.h.
	* linux-tdep.c (linux_solib_file_not_found_is_ok): New function.
	(linux_init_abi): Install it.
	* solib.c (default_solib_file_not_found_is_ok): New function.
	(update_solib_list): New variable gdbarch.  Substitute it for variable
	ops.  Call gdbarch_solib_file_not_found_is_ok.
	* solib.h (default_solib_file_not_found_is_ok): New declaration.

diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 81a70b0..76f0ec9 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -955,6 +955,10 @@ M:void:info_proc:char *args, enum info_proc_what what:args, what
  # inspected when the symbol search was requested.
  m:void:iterate_over_objfiles_in_search_order:iterate_over_objfiles_in_search_order_cb_ftype *cb, void *cb_data, struct objfile *current_objfile:cb, cb_data, current_objfile:0:default_iterate_over_objfiles_in_search_order::0

+# Return non-zero if it is OK we failed to locate shared library file.
+# For example these libraries may exist only in memory (vDSO).
+f:int:solib_file_not_found_is_ok:const char *so_name:so_name:0:default_solib_file_not_found_is_ok::0
+
  EOF
  }

@@ -1411,6 +1415,7 @@ cat<<EOF
  #include "observer.h"
  #include "regcache.h"
  #include "objfiles.h"
+#include "solib.h"

/* Static function declarations */

diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index dbeed36..c4f7bdd 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -941,6 +941,17 @@ linux_make_corefile_notes_1 (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
  				      linux_collect_thread_registers);
  }

+/* Newer glibc no longer clears the Linux vDSO name to "" empty string.  */
+
+static int
+linux_solib_file_not_found_is_ok (const char *so_name)
+{
+  return (strcmp (so_name, "linux-gate.so.1") == 0
+	  || strcmp (so_name, "linux-vdso.so.1") == 0
+	  || strcmp (so_name, "linux-vdso32.so.1") == 0
+	  || strcmp (so_name, "linux-vdso64.so.1") == 0);
+}
+
  /* To be called from the various GDB_OSABI_LINUX handlers for the
     various GNU/Linux architectures and machine types.  */

@@ -953,6 +964,8 @@ linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
    set_gdbarch_make_corefile_notes (gdbarch, linux_make_corefile_notes_1);
    set_gdbarch_has_shared_address_space (gdbarch,
  					linux_has_shared_address_space);
+  set_gdbarch_solib_file_not_found_is_ok (gdbarch,
+					  linux_solib_file_not_found_is_ok);
  }

  /* Provide a prototype to silence -Wmissing-prototypes.  */
diff --git a/gdb/solib.c b/gdb/solib.c
index db3842a..7976679 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -642,6 +642,15 @@ solib_used (const struct so_list *const known)
    return 0;
  }

+/* By default GDB complains on any missing shared library file via
+   gdbarch_solib_file_not_found_is_ok.  */
+
+int
+default_solib_file_not_found_is_ok (const char *so_name)
+{
+  return 0;
+}
+
  /* Synchronize GDB's shared object list with inferior's.

     Extract the list of currently loaded shared objects from the
@@ -668,7 +677,8 @@ solib_used (const struct so_list *const known)
  static void
  update_solib_list (int from_tty, struct target_ops *target)
  {
-  struct target_so_ops *ops = solib_ops (target_gdbarch ());
+  struct gdbarch *gdbarch = target_gdbarch ();
+  struct target_so_ops *ops = solib_ops (gdbarch);
    struct so_list *inferior = ops->current_sos();
    struct so_list *gdb, **gdb_link;

@@ -798,7 +808,9 @@ update_solib_list (int from_tty, struct target_ops *target)
  	  TRY_CATCH (e, RETURN_MASK_ERROR)
  	    {
  	      /* Fill in the rest of the `struct so_list' node.  */
-	      if (!solib_map_sections (i))
+	      if (!solib_map_sections (i)
+	&&  !gdbarch_solib_file_not_found_is_ok (gdbarch,
+							  i->so_original_name))
  		{
  		  not_found++;
  		  if (not_found_filename == NULL)
diff --git a/gdb/solib.h b/gdb/solib.h
index 7a2ff84..04510b8 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -91,4 +91,6 @@ extern CORE_ADDR gdb_bfd_lookup_symbol_from_symtab (bfd *abfd,
  								      void *),
  						    void *data);

+extern int default_solib_file_not_found_is_ok (const char *so_name);
+
  #endif /* SOLIB_H */


Thansk for the patch.


I don't know about the others, but i find the name "solib_not_found_is_ok" a little odd. What about "is_ignored_dso", or "ignored_solib_p" or something in those veins?

What about linux-gate(32|64).so?

Regards,
Luis


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]