-Index: gdb-6.8.50.20090302/gdb/corelow.c
+Index: gdb-6.8.91.20090925/gdb/corelow.c
===================================================================
---- gdb-6.8.50.20090302.orig/gdb/corelow.c 2009-02-23 01:03:48.000000000 +0100
-+++ gdb-6.8.50.20090302/gdb/corelow.c 2009-03-07 17:04:57.000000000 +0100
+--- gdb-6.8.91.20090925.orig/gdb/corelow.c 2009-07-31 17:25:21.000000000 +0200
++++ gdb-6.8.91.20090925/gdb/corelow.c 2009-09-25 09:39:09.000000000 +0200
@@ -45,6 +45,10 @@
#include "exceptions.h"
#include "solib.h"
#ifndef O_LARGEFILE
-@@ -267,6 +271,56 @@ add_to_thread_list (bfd *abfd, asection
+@@ -273,6 +277,52 @@ add_to_thread_list (bfd *abfd, asection
inferior_ptid = ptid; /* Yes, make it current */
}
+ struct build_id *build_id;
+ char *exec_filename, *debug_filename;
+ char *build_id_filename;
++ struct cleanup *back_to;
+
-+ if (exec_bfd != NULL)
++ if (exec_bfd != NULL || symfile_objfile != NULL)
+ return;
+
+ if (target_auxv_search (¤t_target, AT_ENTRY, &at_entry) <= 0)
+ if (build_id == NULL)
+ return;
+
++ /* SYMFILE_OBJFILE should refer to the main executable (not only to its
++ separate debug info file). gcc44+ keeps .eh_frame only in the main
++ executable without its duplicate .debug_frame in the separate debug info
++ file - such .eh_frame would not be found if SYMFILE_OBJFILE would refer
++ directly to the separate debug info file. */
++
+ exec_filename = build_id_to_filename (build_id, &build_id_filename, 0);
-+ if (exec_filename != NULL)
-+ exec_file_attach (exec_filename, from_tty);
-+ else
-+ debug_print_missing (_("the main executable file"), build_id_filename);
-+ xfree (build_id_filename);
++ back_to = make_cleanup (xfree, build_id_filename);
+
-+ /* `.note.gnu.build-id' section exists even for files without a separate
-+ debuginfo. */
-+ debug_filename = build_id_to_filename (build_id, &build_id_filename, 1);
-+ if (debug_filename != NULL)
++ if (exec_filename != NULL)
+ {
-+ symbol_file_add_main (debug_filename, from_tty);
-+ xfree (debug_filename);
++ make_cleanup (xfree, exec_filename);
++ exec_file_attach (exec_filename, from_tty);
++ symbol_file_add_main (exec_filename, from_tty);
++ if (symfile_objfile != NULL)
++ symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED;
+ }
+ else
-+ {
-+ if (exec_filename != NULL)
-+ symbol_file_add_main (exec_filename, from_tty);
-+ /* For EXEC_FILENAME NULL we were already complaining above. */
-+ if (symfile_objfile == NULL && exec_filename != NULL)
-+ debug_print_missing (exec_filename, build_id_filename);
-+ }
-+ xfree (build_id_filename);
++ debug_print_missing (_("the main executable file"), build_id_filename);
+
-+ xfree (exec_filename);
++ do_cleanups (back_to);
+
+ /* No automatic SOLIB_ADD as the libraries would get read twice. */
+}
/* This routine opens and sets up the core file bfd. */
static void
-@@ -363,6 +417,12 @@ core_open (char *filename, int from_tty)
+@@ -371,6 +421,12 @@ core_open (char *filename, int from_tty)
push_target (&core_ops);
discard_cleanups (old_chain);
add_inferior_silent (corelow_pid);
/* Do this before acknowledging the inferior, so if
-@@ -751,4 +811,11 @@ _initialize_corelow (void)
+@@ -878,4 +934,11 @@ _initialize_corelow (void)
init_core_ops ();
add_target (&core_ops);
+ NULL, NULL, NULL,
+ &setlist, &showlist);
}
-Index: gdb-6.8.50.20090302/gdb/doc/gdb.texinfo
+Index: gdb-6.8.91.20090925/gdb/doc/gdb.texinfo
===================================================================
---- gdb-6.8.50.20090302.orig/gdb/doc/gdb.texinfo 2009-03-07 17:04:56.000000000 +0100
-+++ gdb-6.8.50.20090302/gdb/doc/gdb.texinfo 2009-03-07 17:04:57.000000000 +0100
-@@ -13294,6 +13294,27 @@ information files.
+--- gdb-6.8.91.20090925.orig/gdb/doc/gdb.texinfo 2009-09-25 09:29:58.000000000 +0200
++++ gdb-6.8.91.20090925/gdb/doc/gdb.texinfo 2009-09-25 09:29:58.000000000 +0200
+@@ -13895,6 +13895,27 @@ information files.
@end table
@cindex @code{.gnu_debuglink} sections
@cindex debug link sections
A debug link is a special section of the executable file named
-Index: gdb-6.8.50.20090302/gdb/solib-svr4.c
+Index: gdb-6.8.91.20090925/gdb/solib-svr4.c
===================================================================
---- gdb-6.8.50.20090302.orig/gdb/solib-svr4.c 2009-03-07 17:04:52.000000000 +0100
-+++ gdb-6.8.50.20090302/gdb/solib-svr4.c 2009-03-07 17:04:57.000000000 +0100
-@@ -1000,9 +1000,33 @@ svr4_current_sos (void)
+--- gdb-6.8.91.20090925.orig/gdb/solib-svr4.c 2009-09-25 09:29:57.000000000 +0200
++++ gdb-6.8.91.20090925/gdb/solib-svr4.c 2009-09-25 09:43:14.000000000 +0200
+@@ -1101,9 +1101,49 @@ svr4_current_sos (void)
safe_strerror (errcode));
else
{
+ xfree (name);
+ }
+ else
-+ debug_print_missing (new->so_name, build_id_filename);
++ {
++ 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;
++ }
+
+ xfree (build_id_filename);
+ xfree (build_id);
}
xfree (buffer);
-Index: gdb-6.8.50.20090302/gdb/symfile.c
+Index: gdb-6.8.91.20090925/gdb/symfile.c
===================================================================
---- gdb-6.8.50.20090302.orig/gdb/symfile.c 2009-03-07 17:04:53.000000000 +0100
-+++ gdb-6.8.50.20090302/gdb/symfile.c 2009-03-07 17:22:21.000000000 +0100
-@@ -54,6 +54,7 @@
+--- gdb-6.8.91.20090925.orig/gdb/symfile.c 2009-09-25 09:29:57.000000000 +0200
++++ gdb-6.8.91.20090925/gdb/symfile.c 2009-09-25 09:29:58.000000000 +0200
+@@ -56,6 +56,7 @@
#include "elf-bfd.h"
#include "solib.h"
#include "remote.h"
#include <sys/types.h>
#include <fcntl.h>
-@@ -1185,16 +1186,65 @@ symbol_file_clear (int from_tty)
- printf_unfiltered (_("No symbol file now.\n"));
+@@ -1173,16 +1174,65 @@ symbol_file_clear (int from_tty)
+ printf_unfiltered (_("No symbol file now.\n"));
}
+/* Locate NT_GNU_BUILD_ID and return its matching debug filename.
{
struct build_id *retval;
-@@ -1210,6 +1260,348 @@ build_id_bfd_get (bfd *abfd)
+@@ -1198,6 +1248,348 @@ build_id_bfd_get (bfd *abfd)
return retval;
}
/* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */
static int
-@@ -1227,7 +1619,7 @@ build_id_verify (const char *filename, s
+@@ -1215,7 +1607,7 @@ build_id_verify (const char *filename, s
if (abfd == NULL)
return 0;
if (found == NULL)
warning (_("File \"%s\" has no build-id, file skipped"), filename);
-@@ -1246,8 +1638,9 @@ build_id_verify (const char *filename, s
+@@ -1234,8 +1626,9 @@ build_id_verify (const char *filename, s
return retval;
}
{
char *link, *s, *retval = NULL;
gdb_byte *data = build_id->data;
-@@ -1255,7 +1648,9 @@ build_id_to_debug_filename (struct build
+@@ -1243,7 +1636,9 @@ build_id_to_debug_filename (struct build
/* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */
link = xmalloc (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1
s = link + sprintf (link, "%s/.build-id/", debug_file_directory);
if (size > 0)
{
-@@ -1266,12 +1661,14 @@ build_id_to_debug_filename (struct build
+@@ -1254,12 +1649,14 @@ build_id_to_debug_filename (struct build
*s++ = '/';
while (size-- > 0)
s += sprintf (s, "%02x", (unsigned) *data++);
if (retval != NULL && !build_id_verify (retval, build_id))
{
-@@ -1279,9 +1676,142 @@ build_id_to_debug_filename (struct build
+@@ -1267,9 +1664,150 @@ build_id_to_debug_filename (struct build
retval = NULL;
}
+ else
+ xfree (link);
+
-+ return retval;
-+}
-+
+ return retval;
+ }
+
+/* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
+ Try to install the hash file ...
+ avoidance. */
+
+ retval = obstack_alloc (&missing_filepair_obstack, size);
+ memset (retval, 0, size);
- return retval;
- }
-
++ return retval;
++}
++
+static hashval_t
+missing_filepair_hash_func (const struct missing_filepair *elem)
+{
+ const struct missing_filepair *elem2)
+{
+ return strcmp (elem1->binary, elem2->binary) == 0
-+ && ((elem1->debug == NULL && elem2->debug == NULL)
-+ || strcmp (elem1->debug, elem2->debug) == 0);
++ && ((elem1->debug == NULL) == (elem2->debug == NULL))
++ && (elem1->debug == NULL || strcmp (elem1->debug, elem2->debug) == 0);
+}
+
+static void
+{
+ size_t binary_len0 = strlen (binary) + 1;
+ size_t debug_len0 = debug ? strlen (debug) + 1 : 0;
++ struct missing_filepair missing_filepair_find;
+ struct missing_filepair *missing_filepair;
+ struct missing_filepair **slot;
+
+ missing_filepair_xcalloc, NULL);
+ }
+
++ /* Use MISSING_FILEPAIR_FIND first instead of calling obstack_alloc with
++ obstack_free in the case of a (rare) match. The problem is ALLOC_F for
++ MISSING_FILEPAIR_HASH allocates from MISSING_FILEPAIR_OBSTACK maintenance
++ structures for MISSING_FILEPAIR_HASH. Calling obstack_free would possibly
++ not to free only MISSING_FILEPAIR but also some such structures (allocated
++ during the htab_find_slot call). */
++
++ missing_filepair_find.binary = (char *) binary;
++ missing_filepair_find.debug = (char *) debug;
++ slot = (struct missing_filepair **) htab_find_slot (missing_filepair_hash,
++ &missing_filepair_find,
++ INSERT);
++
++ /* While it may be still printed duplicitely with the missing debuginfo file
++ * it is due to once printing about the binary file build-id link and once
++ * about the .debug file build-id link as both the build-id symlinks are
++ * located in the debuginfo package. */
++
++ if (*slot != NULL)
++ return;
++
+ missing_filepair = obstack_alloc (&missing_filepair_obstack,
+ sizeof (*missing_filepair) - 1
+ + binary_len0 + debug_len0);
+ else
+ missing_filepair->debug = NULL;
+
-+ slot = (struct missing_filepair **) htab_find_slot (missing_filepair_hash,
-+ missing_filepair,
-+ INSERT);
-+
-+ /* While it may be still printed duplicitely with the missing debuginfo file
-+ * it is due to once printing about the binary file build-id link and once
-+ * about the .debug file build-id link as both the build-id symlinks are
-+ * located in the debuginfo package. */
-+
-+ if (*slot != NULL)
-+ {
-+ obstack_free (&missing_filepair_obstack, missing_filepair);
-+ return;
-+ }
+ *slot = missing_filepair;
+
+ /* We do not collect and flush these messages as each such message
static char *
get_debug_link_info (struct objfile *objfile, unsigned long *crc32_out)
{
-@@ -1364,32 +1894,36 @@ static char *
+@@ -1352,32 +1890,36 @@ static char *
find_separate_debug_file (struct objfile *objfile)
{
asection *sect;
}
basename = get_debug_link_info (objfile, &crc32);
-@@ -1397,7 +1931,7 @@ find_separate_debug_file (struct objfile
+@@ -1385,7 +1927,7 @@ find_separate_debug_file (struct objfile
if (basename == NULL)
/* There's no separate debug info, hence there's no way we could
load it => no warning. */
dir = xstrdup (objfile->name);
-@@ -1413,23 +1947,19 @@ find_separate_debug_file (struct objfile
- gdb_assert (i >= 0 && IS_DIR_SEPARATOR (dir[i]));
- dir[i+1] = '\0';
+@@ -1407,24 +1949,19 @@ find_separate_debug_file (struct objfile
+ if (canon_name && strlen (canon_name) > i)
+ i = strlen (canon_name);
- debugfile = alloca (strlen (debug_file_directory) + 1
-- + strlen (dir)
+- + i
- + strlen (DEBUG_SUBDIRECTORY)
- + strlen ("/")
- + strlen (basename)
- + 1);
+ debugfile = xmalloc (strlen (debug_file_directory) + 1
-+ + strlen (dir)
++ + i
+ + strlen (DEBUG_SUBDIRECTORY)
+ + strlen ("/")
+ + strlen (basename)
- {
- xfree (basename);
- xfree (dir);
+- xfree (canon_name);
- return xstrdup (debugfile);
- }
+ goto cleanup_return_debugfile;
/* Then try in the subdirectory named DEBUG_SUBDIRECTORY. */
strcpy (debugfile, dir);
-@@ -1438,11 +1968,7 @@ find_separate_debug_file (struct objfile
+@@ -1433,12 +1970,7 @@ find_separate_debug_file (struct objfile
strcat (debugfile, basename);
if (separate_debug_file_exists (debugfile, crc32, objfile->name))
- {
- xfree (basename);
- xfree (dir);
+- xfree (canon_name);
- return xstrdup (debugfile);
- }
+ goto cleanup_return_debugfile;
/* Then try in the global debugfile directory. */
strcpy (debugfile, debug_file_directory);
-@@ -1451,11 +1977,7 @@ find_separate_debug_file (struct objfile
+@@ -1447,12 +1979,7 @@ find_separate_debug_file (struct objfile
strcat (debugfile, basename);
if (separate_debug_file_exists (debugfile, crc32, objfile->name))
- {
- xfree (basename);
- xfree (dir);
+- xfree (canon_name);
- return xstrdup (debugfile);
- }
+ goto cleanup_return_debugfile;
/* If the file is in the sysroot, try using its base path in the
global debugfile directory. */
-@@ -1470,20 +1992,18 @@ find_separate_debug_file (struct objfile
+@@ -1466,20 +1993,18 @@ find_separate_debug_file (struct objfile
strcat (debugfile, basename);
if (separate_debug_file_exists (debugfile, crc32, objfile->name))
- xfree (dir);
- return xstrdup (debugfile);
- }
-+ goto cleanup_return_debugfile;
++ goto cleanup_return_debugfile;
}
--
+
- if (canon_name)
- xfree (canon_name);
-
+ debugfile = NULL;
+ debug_print_missing (objfile->name, build_id_filename);
-+
+
+cleanup_return_debugfile:
+ xfree (build_id_filename);
+ xfree (canon_name);
}
-@@ -4216,4 +4736,16 @@ Show printing of symbol loading messages
- NULL,
- NULL,
- &setprintlist, &showprintlist);
-+
-+ add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose,
-+ _("\
-+Set debugging level of the build-id locator."), _("\
-+Show debugging level of the build-id locator."), _("\
-+Level 1 (default) enables printing the missing debug filenames,\n\
-+level 2 also prints the parsing of binaries to find the identificators."),
-+ NULL,
-+ show_build_id_verbose,
-+ &setlist, &showlist);
-+
-+ observer_attach_executable_changed (debug_print_executable_changed);
+@@ -4229,4 +4754,16 @@ the global debug-file directory prepende
+ NULL,
+ show_debug_file_directory,
+ &setlist, &showlist);
++
++ add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose,
++ _("\
++ Set debugging level of the build-id locator."), _("\
++ Show debugging level of the build-id locator."), _("\
++ Level 1 (default) enables printing the missing debug filenames,\n\
++ level 2 also prints the parsing of binaries to find the identificators."),
++ NULL,
++ show_build_id_verbose,
++ &setlist, &showlist);
++
++ observer_attach_executable_changed (debug_print_executable_changed);
}
-Index: gdb-6.8.50.20090302/gdb/symfile.h
+Index: gdb-6.8.91.20090925/gdb/symfile.h
===================================================================
---- gdb-6.8.50.20090302.orig/gdb/symfile.h 2009-03-07 17:04:52.000000000 +0100
-+++ gdb-6.8.50.20090302/gdb/symfile.h 2009-03-07 17:13:33.000000000 +0100
-@@ -372,6 +372,13 @@ extern int symfile_map_offsets_to_segmen
+--- gdb-6.8.91.20090925.orig/gdb/symfile.h 2009-09-25 09:29:57.000000000 +0200
++++ gdb-6.8.91.20090925/gdb/symfile.h 2009-09-25 09:29:58.000000000 +0200
+@@ -381,6 +381,13 @@ extern int symfile_map_offsets_to_segmen
struct symfile_segment_data *get_symfile_segment_data (bfd *abfd);
void free_symfile_segment_data (struct symfile_segment_data *data);
/* From dwarf2read.c */
extern int dwarf2_has_info (struct objfile *);
-Index: gdb-6.8.50.20090302/gdb/testsuite/lib/gdb.exp
+Index: gdb-6.8.91.20090925/gdb/testsuite/lib/gdb.exp
===================================================================
---- gdb-6.8.50.20090302.orig/gdb/testsuite/lib/gdb.exp 2009-03-07 17:04:52.000000000 +0100
-+++ gdb-6.8.50.20090302/gdb/testsuite/lib/gdb.exp 2009-03-07 17:13:33.000000000 +0100
-@@ -1230,6 +1230,16 @@ proc default_gdb_start { } {
+--- gdb-6.8.91.20090925.orig/gdb/testsuite/lib/gdb.exp 2009-09-25 09:29:57.000000000 +0200
++++ gdb-6.8.91.20090925/gdb/testsuite/lib/gdb.exp 2009-09-25 09:29:58.000000000 +0200
+@@ -1248,6 +1248,16 @@ proc default_gdb_start { } {
warning "Couldn't set the width to 0."
}
}
return 0;
}
---- ./gdb/testsuite/lib/mi-support.exp 2009-03-21 21:09:09.000000000 +0100
-+++ ./gdb/testsuite/lib/mi-support.exp 2009-03-22 16:37:58.000000000 +0100
+Index: gdb-6.8.91.20090925/gdb/testsuite/lib/mi-support.exp
+===================================================================
+--- gdb-6.8.91.20090925.orig/gdb/testsuite/lib/mi-support.exp 2009-09-15 20:51:26.000000000 +0200
++++ gdb-6.8.91.20090925/gdb/testsuite/lib/mi-support.exp 2009-09-25 09:29:58.000000000 +0200
@@ -221,6 +221,16 @@ proc default_mi_gdb_start { args } {
}
}
detect_async
+Index: gdb-6.8.91.20090925/gdb/objfiles.h
+===================================================================
+--- gdb-6.8.91.20090925.orig/gdb/objfiles.h 2009-09-25 09:29:57.000000000 +0200
++++ gdb-6.8.91.20090925/gdb/objfiles.h 2009-09-25 09:38:27.000000000 +0200
+@@ -428,6 +428,10 @@ struct objfile
+
+ #define OBJF_MAIN (1 << 7)
+
++/* This file was loaded according to the BUILD_ID_CORE_LOADS rules. */
++
++#define OBJF_BUILD_ID_CORE_LOADED (1 << 12)
++
+ /* The object file that the main symbol table was loaded from (e.g. the
+ argument to the "symbol-file" or "file" command). */
+