[gdb/f15] Fix loading of core files without build-ids but with build-ids in executables.

Jan Kratochvil jankratochvil at fedoraproject.org
Sat Mar 17 11:41:23 UTC 2012


commit ab6e61f8eb580f292d0c44494308213bbcdb1f39
Author: Jan Kratochvil <jan.kratochvil at redhat.com>
Date:   Sat Mar 17 12:41:17 2012 +0100

    Fix loading of core files without build-ids but with build-ids in executables.

 gdb-6.6-buildid-locate-solib-missing-ids.patch |   60 ++++++++++++++++++++++++
 gdb-core-open-vdso-warning.patch               |    4 +-
 gdb.spec                                       |    9 +++-
 3 files changed, 70 insertions(+), 3 deletions(-)
---
diff --git a/gdb-6.6-buildid-locate-solib-missing-ids.patch b/gdb-6.6-buildid-locate-solib-missing-ids.patch
new file mode 100644
index 0000000..07a39a2
--- /dev/null
+++ b/gdb-6.6-buildid-locate-solib-missing-ids.patch
@@ -0,0 +1,60 @@
+--- gdb-7.2/gdb/solib-svr4.c.orig	2012-03-17 09:39:54.874090162 +0100
++++ gdb-7.2/gdb/solib-svr4.c	2012-03-17 09:42:12.561810807 +0100
+@@ -1179,14 +1179,30 @@ svr4_current_sos (void)
+ 		     safe_strerror (errcode));
+ 	  else
+ 	    {
+-	      struct build_id *build_id;
++	      struct build_id *build_id = NULL;
+ 
+ 	      strncpy (new->so_original_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
+ 	      new->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
+ 	      /* May get overwritten below.  */
+ 	      strcpy (new->so_name, new->so_original_name);
+ 
+-	      build_id = build_id_addr_get (LM_DYNAMIC_FROM_LINK_MAP (new));
++	      /* In the case the main executable was found according to its
++		 build-id (from a core file) prevent loading a different build
++		 of a library with accidentally the same SO_NAME.
++
++		 It suppresses bogus backtraces (and prints "??" there instead)
++		 if the on-disk files no longer match the running program
++		 version.
++		 
++		 If the main executable was not loaded according to its
++		 build-id do not do any build-id checking of the libraries.
++		 There may be missing build-ids dumped in the core file and we
++		 would map all the libraries to the only existing file loaded
++		 that time - the executable.  */
++
++	      if (symfile_objfile != NULL
++		  && (symfile_objfile->flags & OBJF_BUILD_ID_CORE_LOADED) != 0)
++		build_id = build_id_addr_get (LM_DYNAMIC_FROM_LINK_MAP (new));
+ 	      if (build_id != NULL)
+ 		{
+ 		  char *name, *build_id_filename;
+@@ -1224,23 +1240,7 @@ svr4_current_sos (void)
+ 		      xfree (name);
+ 		    }
+ 		  else
+-		    {
+-		      debug_print_missing (new->so_name, build_id_filename);
+-
+-		      /* In the case the main executable was found according to
+-			 its build-id (from a core file) prevent loading
+-			 a different build of a library with accidentally the
+-			 same SO_NAME.
+-
+-			 It suppresses bogus backtraces (and prints "??" there
+-			 instead) if the on-disk files no longer match the
+-			 running program version.  */
+-
+-		      if (symfile_objfile != NULL
+-			  && (symfile_objfile->flags
+-			      & OBJF_BUILD_ID_CORE_LOADED) != 0)
+-			new->so_name[0] = 0;
+-		    }
++		    debug_print_missing (new->so_name, build_id_filename);
+ 
+ 		  xfree (build_id_filename);
+ 		  xfree (build_id);
diff --git a/gdb-core-open-vdso-warning.patch b/gdb-core-open-vdso-warning.patch
index 056a28c..a631b51 100644
--- a/gdb-core-open-vdso-warning.patch
+++ b/gdb-core-open-vdso-warning.patch
@@ -37,7 +37,7 @@ Index: gdb-7.1.90.20100711/gdb/solib-svr4.c
 ===================================================================
 --- gdb-7.1.90.20100711.orig/gdb/solib-svr4.c	2010-07-12 23:07:35.000000000 +0200
 +++ gdb-7.1.90.20100711/gdb/solib-svr4.c	2010-07-13 00:19:03.000000000 +0200
-@@ -1177,8 +1177,18 @@ svr4_current_sos (void)
+@@ -1175,8 +1175,18 @@ svr4_current_sos (void)
  	  target_read_string (LM_NAME (new), &buffer,
  			      SO_NAME_MAX_PATH_SIZE - 1, &errcode);
  	  if (errcode != 0)
@@ -57,7 +57,7 @@ Index: gdb-7.1.90.20100711/gdb/solib-svr4.c
 +	    }
  	  else
  	    {
- 	      struct build_id *build_id;
+ 	      struct build_id *build_id = NULL;
 Index: gdb-7.1.90.20100711/gdb/solib.c
 ===================================================================
 --- gdb-7.1.90.20100711.orig/gdb/solib.c	2010-05-17 01:49:58.000000000 +0200
diff --git a/gdb.spec b/gdb.spec
index 4071eb6..d9e8049 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -27,7 +27,7 @@ Version: 7.3.1
 
 # 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: 47%{?_with_upstream:.upstream}%{?dist}
+Release: 48%{?_with_upstream:.upstream}%{?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
@@ -303,6 +303,9 @@ Patch271: gdb-6.5-bz243845-stale-testing-zombie-test.patch
 # New locating of the matching binaries from the pure core file (build-id).
 #=push
 Patch274: gdb-6.6-buildid-locate.patch
+# Fix loading of core files without build-ids but with build-ids in executables.
+#=push
+Patch659: gdb-6.6-buildid-locate-solib-missing-ids.patch
 #=push
 Patch353: gdb-6.6-buildid-locate-rpm.patch
 #=push
@@ -792,6 +795,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
 %patch266 -p1
 %patch271 -p1
 %patch274 -p1
+%patch659 -p1
 %patch353 -p1
 %patch282 -p1
 %patch284 -p1
@@ -1288,6 +1292,9 @@ fi
 %{_infodir}/gdb.info*
 
 %changelog
+* Sat Mar 17 2012 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.3.1-48.fc15
+- Fix loading of core files without build-ids but with build-ids in executables.
+
 * Wed Dec 21 2011 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.3.1-47.fc15
 - [python] Fix crash when pretty printer fails (Phil Muldoon, BZ 712715).
 


More information about the scm-commits mailing list