Rebase to FSF GDB 7.7.
- New rpmbuild option: --with asan
This commit is contained in:
parent
ff3b0d487c
commit
2c55a5441d
37 changed files with 3098 additions and 4749 deletions
|
|
@ -1,18 +1,19 @@
|
|||
Index: gdb-7.6.50.20130731-cvs/gdb/corelow.c
|
||||
Index: gdb-7.6.90.20140127/gdb/corelow.c
|
||||
===================================================================
|
||||
--- gdb-7.6.50.20130731-cvs.orig/gdb/corelow.c 2013-08-02 17:07:17.886739513 +0200
|
||||
+++ gdb-7.6.50.20130731-cvs/gdb/corelow.c 2013-08-02 17:07:28.434753293 +0200
|
||||
@@ -48,6 +48,9 @@
|
||||
--- gdb-7.6.90.20140127.orig/gdb/corelow.c 2014-01-27 02:57:53.000000000 +0100
|
||||
+++ gdb-7.6.90.20140127/gdb/corelow.c 2014-02-06 16:46:52.261646499 +0100
|
||||
@@ -48,6 +48,10 @@
|
||||
#include "gdb_bfd.h"
|
||||
#include "completer.h"
|
||||
#include "filestuff.h"
|
||||
+#include "auxv.h"
|
||||
+#include "elf/common.h"
|
||||
+#include "gdbcmd.h"
|
||||
+#include "build-id.h"
|
||||
|
||||
#ifndef O_LARGEFILE
|
||||
#define O_LARGEFILE 0
|
||||
@@ -273,6 +276,53 @@ add_to_thread_list (bfd *abfd, asection
|
||||
@@ -271,6 +275,53 @@ add_to_thread_list (bfd *abfd, asection
|
||||
inferior_ptid = ptid; /* Yes, make it current. */
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +45,7 @@ Index: gdb-7.6.50.20130731-cvs/gdb/corelow.c
|
|||
+ file - such .eh_frame would not be found if SYMFILE_OBJFILE would refer
|
||||
+ directly to the separate debug info file. */
|
||||
+
|
||||
+ execfilename = build_id_to_filename (build_id, &build_id_filename, 0);
|
||||
+ execfilename = build_id_to_filename (build_id, &build_id_filename);
|
||||
+ make_cleanup (xfree, build_id_filename);
|
||||
+
|
||||
+ if (execfilename != NULL)
|
||||
|
|
@ -66,7 +67,7 @@ Index: gdb-7.6.50.20130731-cvs/gdb/corelow.c
|
|||
/* This routine opens and sets up the core file bfd. */
|
||||
|
||||
static void
|
||||
@@ -411,6 +461,14 @@ core_open (char *filename, int from_tty)
|
||||
@@ -409,6 +460,14 @@ core_open (char *filename, int from_tty)
|
||||
switch_to_thread (thread->ptid);
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +82,7 @@ Index: gdb-7.6.50.20130731-cvs/gdb/corelow.c
|
|||
post_create_inferior (&core_ops, from_tty);
|
||||
|
||||
/* Now go through the target stack looking for threads since there
|
||||
@@ -974,4 +1032,11 @@ _initialize_corelow (void)
|
||||
@@ -980,4 +1039,11 @@ _initialize_corelow (void)
|
||||
init_core_ops ();
|
||||
|
||||
add_target_with_completer (&core_ops, filename_completer);
|
||||
|
|
@ -93,11 +94,11 @@ Index: gdb-7.6.50.20130731-cvs/gdb/corelow.c
|
|||
+ NULL, NULL, NULL,
|
||||
+ &setlist, &showlist);
|
||||
}
|
||||
Index: gdb-7.6.50.20130731-cvs/gdb/doc/gdb.texinfo
|
||||
Index: gdb-7.6.90.20140127/gdb/doc/gdb.texinfo
|
||||
===================================================================
|
||||
--- gdb-7.6.50.20130731-cvs.orig/gdb/doc/gdb.texinfo 2013-08-02 17:07:17.886739513 +0200
|
||||
+++ gdb-7.6.50.20130731-cvs/gdb/doc/gdb.texinfo 2013-08-02 17:07:28.443753304 +0200
|
||||
@@ -17119,6 +17119,27 @@ information files.
|
||||
--- gdb-7.6.90.20140127.orig/gdb/doc/gdb.texinfo 2014-02-06 16:46:51.804645989 +0100
|
||||
+++ gdb-7.6.90.20140127/gdb/doc/gdb.texinfo 2014-02-06 16:46:52.110646331 +0100
|
||||
@@ -17413,6 +17413,27 @@ information files.
|
||||
|
||||
@end table
|
||||
|
||||
|
|
@ -125,11 +126,19 @@ Index: gdb-7.6.50.20130731-cvs/gdb/doc/gdb.texinfo
|
|||
@cindex @code{.gnu_debuglink} sections
|
||||
@cindex debug link sections
|
||||
A debug link is a special section of the executable file named
|
||||
Index: gdb-7.6.50.20130731-cvs/gdb/solib-svr4.c
|
||||
Index: gdb-7.6.90.20140127/gdb/solib-svr4.c
|
||||
===================================================================
|
||||
--- gdb-7.6.50.20130731-cvs.orig/gdb/solib-svr4.c 2013-08-02 17:07:17.886739513 +0200
|
||||
+++ gdb-7.6.50.20130731-cvs/gdb/solib-svr4.c 2013-08-02 17:07:28.444753305 +0200
|
||||
@@ -1365,9 +1365,52 @@ svr4_read_so_list (CORE_ADDR lm, CORE_AD
|
||||
--- gdb-7.6.90.20140127.orig/gdb/solib-svr4.c 2014-01-27 02:57:53.000000000 +0100
|
||||
+++ gdb-7.6.90.20140127/gdb/solib-svr4.c 2014-02-06 16:49:27.508819174 +0100
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "exceptions.h"
|
||||
#include "gdb_bfd.h"
|
||||
#include "probe.h"
|
||||
+#include "build-id.h"
|
||||
|
||||
static struct link_map_offsets *svr4_fetch_link_map_offsets (void);
|
||||
static int svr4_have_link_map_offsets (void);
|
||||
@@ -1369,9 +1370,52 @@ svr4_read_so_list (CORE_ADDR lm, CORE_AD
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +160,7 @@ Index: gdb-7.6.50.20130731-cvs/gdb/solib-svr4.c
|
|||
+
|
||||
+ /* Missing the build-id matching separate debug info file
|
||||
+ would be handled while SO_NAME gets loaded. */
|
||||
+ name = build_id_to_filename (build_id, &build_id_filename, 0);
|
||||
+ name = build_id_to_filename (build_id, &build_id_filename);
|
||||
+ if (name != NULL)
|
||||
+ {
|
||||
+ strncpy (new->so_name, name, SO_NAME_MAX_PATH_SIZE - 1);
|
||||
|
|
@ -185,27 +194,160 @@ Index: gdb-7.6.50.20130731-cvs/gdb/solib-svr4.c
|
|||
xfree (buffer);
|
||||
|
||||
/* If this entry has no name, or its name matches the name
|
||||
Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c
|
||||
Index: gdb-7.6.90.20140127/gdb/elfread.c
|
||||
===================================================================
|
||||
--- gdb-7.6.50.20130731-cvs.orig/gdb/elfread.c 2013-08-02 17:07:17.886739513 +0200
|
||||
+++ gdb-7.6.50.20130731-cvs/gdb/elfread.c 2013-08-02 17:09:06.460881503 +0200
|
||||
@@ -45,6 +45,11 @@
|
||||
#include "regcache.h"
|
||||
#include "bcache.h"
|
||||
#include "gdb_bfd.h"
|
||||
--- gdb-7.6.90.20140127.orig/gdb/elfread.c 2014-01-27 02:57:53.000000000 +0100
|
||||
+++ gdb-7.6.90.20140127/gdb/elfread.c 2014-02-06 16:46:52.249646486 +0100
|
||||
@@ -1316,9 +1316,10 @@ elf_symfile_read (struct objfile *objfil
|
||||
&& objfile->separate_debug_objfile == NULL
|
||||
&& objfile->separate_debug_objfile_backlink == NULL)
|
||||
{
|
||||
- char *debugfile;
|
||||
+ char *debugfile, *build_id_filename;
|
||||
|
||||
- debugfile = find_separate_debug_file_by_buildid (objfile);
|
||||
+ debugfile = find_separate_debug_file_by_buildid (objfile,
|
||||
+ &build_id_filename);
|
||||
|
||||
if (debugfile == NULL)
|
||||
debugfile = find_separate_debug_file_by_debuglink (objfile);
|
||||
@@ -1332,6 +1333,12 @@ elf_symfile_read (struct objfile *objfil
|
||||
symbol_file_add_separate (abfd, debugfile, symfile_flags, objfile);
|
||||
do_cleanups (cleanup);
|
||||
}
|
||||
+ /* Check if any separate debug info has been extracted out. */
|
||||
+ else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink")
|
||||
+ != NULL)
|
||||
+ debug_print_missing (objfile_name (objfile), build_id_filename);
|
||||
+
|
||||
+ xfree (build_id_filename);
|
||||
}
|
||||
}
|
||||
|
||||
Index: gdb-7.6.90.20140127/gdb/symfile.h
|
||||
===================================================================
|
||||
--- gdb-7.6.90.20140127.orig/gdb/symfile.h 2014-01-27 02:57:53.000000000 +0100
|
||||
+++ gdb-7.6.90.20140127/gdb/symfile.h 2014-02-06 16:46:52.250646487 +0100
|
||||
@@ -554,6 +554,10 @@ void free_symfile_segment_data (struct s
|
||||
|
||||
extern struct cleanup *increment_reading_symtab (void);
|
||||
|
||||
+/* build-id support. */
|
||||
+extern struct elf_build_id *build_id_addr_get (CORE_ADDR addr);
|
||||
+extern void debug_print_missing (const char *binary, const char *debug);
|
||||
+
|
||||
/* From dwarf2read.c */
|
||||
|
||||
/* Names for a dwarf2 debugging section. The field NORMAL is the normal
|
||||
Index: gdb-7.6.90.20140127/gdb/testsuite/lib/gdb.exp
|
||||
===================================================================
|
||||
--- gdb-7.6.90.20140127.orig/gdb/testsuite/lib/gdb.exp 2014-02-06 16:46:51.643645810 +0100
|
||||
+++ gdb-7.6.90.20140127/gdb/testsuite/lib/gdb.exp 2014-02-06 16:46:52.251646488 +0100
|
||||
@@ -1504,6 +1504,16 @@ proc default_gdb_start { } {
|
||||
warning "Couldn't set the width to 0."
|
||||
}
|
||||
}
|
||||
+ # Turn off the missing warnings as the testsuite does not expect it.
|
||||
+ send_gdb "set build-id-verbose 0\n"
|
||||
+ gdb_expect 10 {
|
||||
+ -re "$gdb_prompt $" {
|
||||
+ verbose "Disabled the missing debug infos warnings." 2
|
||||
+ }
|
||||
+ timeout {
|
||||
+ warning "Could not disable the missing debug infos warnings.."
|
||||
+ }
|
||||
+ }
|
||||
return 0
|
||||
}
|
||||
|
||||
Index: gdb-7.6.90.20140127/gdb/testsuite/lib/mi-support.exp
|
||||
===================================================================
|
||||
--- gdb-7.6.90.20140127.orig/gdb/testsuite/lib/mi-support.exp 2014-01-27 02:57:54.000000000 +0100
|
||||
+++ gdb-7.6.90.20140127/gdb/testsuite/lib/mi-support.exp 2014-02-06 16:46:52.252646489 +0100
|
||||
@@ -212,6 +212,16 @@ proc default_mi_gdb_start { args } {
|
||||
warning "Couldn't set the width to 0."
|
||||
}
|
||||
}
|
||||
+ # Turn off the missing warnings as the testsuite does not expect it.
|
||||
+ send_gdb "190-gdb-set build-id-verbose 0\n"
|
||||
+ gdb_expect 10 {
|
||||
+ -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" {
|
||||
+ verbose "Disabled the missing debug infos warnings." 2
|
||||
+ }
|
||||
+ timeout {
|
||||
+ warning "Could not disable the missing debug infos warnings.."
|
||||
+ }
|
||||
+ }
|
||||
# If allowing the inferior to have its own PTY then assign the inferior
|
||||
# its own terminal device here.
|
||||
if { $separate_inferior_pty } {
|
||||
Index: gdb-7.6.90.20140127/gdb/objfiles.h
|
||||
===================================================================
|
||||
--- gdb-7.6.90.20140127.orig/gdb/objfiles.h 2014-01-27 02:57:53.000000000 +0100
|
||||
+++ gdb-7.6.90.20140127/gdb/objfiles.h 2014-02-06 16:46:52.113646334 +0100
|
||||
@@ -436,6 +436,10 @@ struct objfile
|
||||
|
||||
#define OBJF_NOT_FILENAME (1 << 6)
|
||||
|
||||
+/* This file was loaded according to the BUILD_ID_CORE_LOADS rules. */
|
||||
+
|
||||
+#define OBJF_BUILD_ID_CORE_LOADED (1 << 12)
|
||||
+
|
||||
/* Declarations for functions defined in objfiles.c */
|
||||
|
||||
extern struct objfile *allocate_objfile (bfd *, const char *name, int);
|
||||
Index: gdb-7.6.90.20140127/gdb/testsuite/gdb.base/corefile.exp
|
||||
===================================================================
|
||||
--- gdb-7.6.90.20140127.orig/gdb/testsuite/gdb.base/corefile.exp 2014-01-27 02:57:54.000000000 +0100
|
||||
+++ gdb-7.6.90.20140127/gdb/testsuite/gdb.base/corefile.exp 2014-02-06 16:46:52.113646334 +0100
|
||||
@@ -281,3 +281,33 @@ gdb_test_multiple "core-file $corefile"
|
||||
pass $test
|
||||
}
|
||||
}
|
||||
+
|
||||
+
|
||||
+# Test auto-loading of binary files through build-id from the core file.
|
||||
+set buildid [build_id_debug_filename_get $binfile]
|
||||
+set wholetest "binfile found by build-id"
|
||||
+if {$buildid == ""} {
|
||||
+ untested "$wholetest (binary has no build-id)"
|
||||
+} else {
|
||||
+ gdb_exit
|
||||
+ gdb_start
|
||||
+
|
||||
+ regsub {\.debug$} $buildid {} buildid
|
||||
+ set debugdir ${objdir}/${subdir}/${testfile}-debugdir
|
||||
+ file delete -force -- $debugdir
|
||||
+ file mkdir $debugdir/[file dirname $buildid]
|
||||
+ file copy $binfile $debugdir/$buildid
|
||||
+
|
||||
+ set test "show debug-file-directory"
|
||||
+ gdb_test_multiple $test $test {
|
||||
+ -re "The directory where separate debug symbols are searched for is \"(.*)\"\\.\r\n$gdb_prompt $" {
|
||||
+ set debugdir_orig $expect_out(1,string)
|
||||
+ pass $test
|
||||
+ }
|
||||
+ }
|
||||
+ gdb_test_no_output "set debug-file-directory $debugdir:$debugdir_orig" "set debug-file-directory"
|
||||
+ gdb_test "show build-id-core-loads" {Whether CORE-FILE loads the build-id associated files automatically is on\.}
|
||||
+ gdb_test "core-file $corefile" "\r\nProgram terminated with .*" "core-file without executable"
|
||||
+ gdb_test "info files" "Local exec file:\r\n\[ \t\]*`[string_to_regexp $debugdir/$buildid]', file type .*"
|
||||
+ pass $wholetest
|
||||
+}
|
||||
Index: gdb-7.6.90.20140127/gdb/build-id.c
|
||||
===================================================================
|
||||
--- gdb-7.6.90.20140127.orig/gdb/build-id.c 2014-01-27 02:57:53.000000000 +0100
|
||||
+++ gdb-7.6.90.20140127/gdb/build-id.c 2014-02-06 16:46:52.113646334 +0100
|
||||
@@ -27,11 +27,65 @@
|
||||
#include "symfile.h"
|
||||
#include "objfiles.h"
|
||||
#include "filenames.h"
|
||||
+#include "libbfd.h"
|
||||
+#include "gdbcore.h"
|
||||
+#include "gdbcmd.h"
|
||||
+#include "observer.h"
|
||||
+#include <sys/stat.h>
|
||||
|
||||
extern void _initialize_elfread (void);
|
||||
|
||||
@@ -1087,10 +1092,59 @@ elf_gnu_ifunc_resolver_return_stop (stru
|
||||
update_breakpoint_locations (b, sals, sals_end);
|
||||
}
|
||||
|
||||
-/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */
|
||||
+
|
||||
+#define BUILD_ID_VERBOSE_NONE 0
|
||||
+#define BUILD_ID_VERBOSE_FILENAMES 1
|
||||
+#define BUILD_ID_VERBOSE_BINARY_PARSE 2
|
||||
|
|
@ -220,7 +362,8 @@ Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c
|
|||
+
|
||||
+/* Locate NT_GNU_BUILD_ID and return its matching debug filename.
|
||||
+ FIXME: NOTE decoding should be unified with the BFD core notes decoding. */
|
||||
+
|
||||
|
||||
-/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */
|
||||
+static struct elf_build_id *
|
||||
+build_id_buf_get (bfd *templ, gdb_byte *buf, bfd_size_type size)
|
||||
+{
|
||||
|
|
@ -253,17 +396,17 @@ Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c
|
|||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
|
||||
+/* Separate debuginfo files have corrupted PHDR but SHDR is correct there.
|
||||
+ Locate NT_GNU_BUILD_ID from ABFD and return its content. */
|
||||
|
||||
+
|
||||
static const struct elf_build_id *
|
||||
-build_id_bfd_get (bfd *abfd)
|
||||
+build_id_bfd_shdr_get (bfd *abfd)
|
||||
{
|
||||
if (!bfd_check_format (abfd, bfd_object)
|
||||
|| bfd_get_flavour (abfd) != bfd_target_elf_flavour
|
||||
@@ -1100,6 +1154,348 @@ build_id_bfd_get (bfd *abfd)
|
||||
@@ -45,6 +99,348 @@ build_id_bfd_get (bfd *abfd)
|
||||
return elf_tdata (abfd)->build_id;
|
||||
}
|
||||
|
||||
|
|
@ -609,23 +752,23 @@ Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c
|
|||
+ return retval;
|
||||
+}
|
||||
+
|
||||
/* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */
|
||||
/* See build-id.h. */
|
||||
|
||||
static int
|
||||
@@ -1114,7 +1510,7 @@ build_id_verify (const char *filename, c
|
||||
if (abfd == NULL)
|
||||
return 0;
|
||||
int
|
||||
@@ -53,7 +449,7 @@ build_id_verify (bfd *abfd, size_t check
|
||||
const struct elf_build_id *found;
|
||||
int retval = 0;
|
||||
|
||||
- found = build_id_bfd_get (abfd);
|
||||
+ found = build_id_bfd_shdr_get (abfd);
|
||||
|
||||
if (found == NULL)
|
||||
warning (_("File \"%s\" has no build-id, file skipped"), filename);
|
||||
@@ -1131,16 +1527,53 @@ build_id_verify (const char *filename, c
|
||||
warning (_("File \"%s\" has no build-id, file skipped"),
|
||||
@@ -68,20 +464,56 @@ build_id_verify (bfd *abfd, size_t check
|
||||
return retval;
|
||||
}
|
||||
|
||||
static char *
|
||||
-build_id_to_debug_filename (const struct elf_build_id *build_id)
|
||||
+static char *
|
||||
+link_resolve (const char *symlink, int level)
|
||||
+{
|
||||
+ char buf[PATH_MAX + 1], *target, *retval;
|
||||
|
|
@ -661,28 +804,33 @@ Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c
|
|||
+ return retval;
|
||||
+}
|
||||
+
|
||||
+char *
|
||||
+build_id_to_filename (const struct elf_build_id *build_id, char **link_return,
|
||||
+ int add_debug_suffix)
|
||||
/* See build-id.h. */
|
||||
|
||||
bfd *
|
||||
-build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
|
||||
+build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id,
|
||||
+ char **link_return, int add_debug_suffix)
|
||||
{
|
||||
char *link, *debugdir, *retval = NULL;
|
||||
+ char *link_all = NULL;
|
||||
- char *link, *debugdir;
|
||||
+ char *link, *debugdir, *link_all = NULL;
|
||||
VEC (char_ptr) *debugdir_vec;
|
||||
struct cleanup *back_to;
|
||||
int ix;
|
||||
bfd *abfd = NULL;
|
||||
|
||||
/* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */
|
||||
- link = alloca (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1
|
||||
- + 2 * build_id->size + (sizeof ".debug" - 1) + 1);
|
||||
+ link = xmalloc (strlen (debug_file_directory) + 2 * build_id->size + 50);
|
||||
- + 2 * build_id_len + (sizeof ".debug" - 1) + 1);
|
||||
+ link = xmalloc (strlen (debug_file_directory) + 2 * build_id_len + 50);
|
||||
|
||||
/* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
|
||||
cause "/.build-id/..." lookups. */
|
||||
@@ -1153,7 +1586,10 @@ build_id_to_debug_filename (const struct
|
||||
@@ -94,8 +526,11 @@ build_id_to_debug_bfd (size_t build_id_l
|
||||
size_t debugdir_len = strlen (debugdir);
|
||||
const gdb_byte *data = build_id->data;
|
||||
size_t size = build_id->size;
|
||||
const gdb_byte *data = build_id;
|
||||
size_t size = build_id_len;
|
||||
- char *s;
|
||||
char *filename = NULL;
|
||||
+ unsigned seqno;
|
||||
+ struct stat statbuf_trash;
|
||||
+ /* Initialize it just to avoid a GCC false warning. */
|
||||
|
|
@ -690,19 +838,18 @@ Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c
|
|||
|
||||
memcpy (link, debugdir, debugdir_len);
|
||||
s = &link[debugdir_len];
|
||||
@@ -1167,37 +1603,256 @@ build_id_to_debug_filename (const struct
|
||||
@@ -109,44 +544,282 @@ build_id_to_debug_bfd (size_t build_id_l
|
||||
*s++ = '/';
|
||||
while (size-- > 0)
|
||||
s += sprintf (s, "%02x", (unsigned) *data++);
|
||||
- strcpy (s, ".debug");
|
||||
|
||||
- /* lrealpath() is expensive even for the usually non-existent files. */
|
||||
- if (access (link, F_OK) == 0)
|
||||
- retval = lrealpath (link);
|
||||
+ for (seqno = 0;; seqno++)
|
||||
+ {
|
||||
+ char *s2;
|
||||
+
|
||||
|
||||
- /* lrealpath() is expensive even for the usually non-existent files. */
|
||||
- if (access (link, F_OK) == 0)
|
||||
- filename = lrealpath (link);
|
||||
+ if (seqno)
|
||||
+ {
|
||||
+ /* There can be multiple build-id symlinks pointing to real files
|
||||
|
|
@ -733,21 +880,39 @@ Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c
|
|||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ retval = lrealpath (link);
|
||||
+ filename = lrealpath (link);
|
||||
+ if (filename == NULL)
|
||||
+ continue;
|
||||
+
|
||||
+ if (retval != NULL && !build_id_verify (retval, build_id))
|
||||
+ /* We expect to be silent on the non-existing files. */
|
||||
+ abfd = gdb_bfd_open_maybe_remote (filename);
|
||||
+ if (abfd == NULL)
|
||||
+ {
|
||||
+ xfree (retval);
|
||||
+ retval = NULL;
|
||||
+ xfree (filename);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (retval)
|
||||
|
||||
- if (filename == NULL)
|
||||
- continue;
|
||||
+ if (build_id_verify (abfd, build_id_len, build_id))
|
||||
+ break;
|
||||
|
||||
- /* We expect to be silent on the non-existing files. */
|
||||
- abfd = gdb_bfd_open_maybe_remote (filename);
|
||||
- if (abfd == NULL)
|
||||
- continue;
|
||||
+ gdb_bfd_unref (abfd);
|
||||
+ abfd = NULL;
|
||||
|
||||
- if (build_id_verify (abfd, build_id_len, build_id))
|
||||
- break;
|
||||
+ xfree (filename);
|
||||
+ filename = NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (retval != NULL)
|
||||
+ if (filename != NULL)
|
||||
+ {
|
||||
+ /* LINK_ALL is not used below in this non-NULL RETVAL case. */
|
||||
+ /* LINK_ALL is not used below in this non-NULL FILENAME case. */
|
||||
+ xfree (link0);
|
||||
+ break;
|
||||
+ }
|
||||
|
|
@ -757,14 +922,11 @@ Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c
|
|||
+ https://bugzilla.redhat.com/show_bug.cgi?id=981154 */
|
||||
+ link0_resolved = link_resolve (link0, 0);
|
||||
+ xfree (link0);
|
||||
|
||||
- if (retval != NULL && !build_id_verify (retval, build_id))
|
||||
+
|
||||
+ if (link_all == NULL)
|
||||
+ link_all = xstrdup (link0_resolved);
|
||||
+ link_all = link0_resolved;
|
||||
+ else
|
||||
{
|
||||
- xfree (retval);
|
||||
- retval = NULL;
|
||||
+ {
|
||||
+ size_t len_orig = strlen (link_all);
|
||||
+
|
||||
+ link_all = xrealloc (link_all,
|
||||
|
|
@ -773,16 +935,17 @@ Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c
|
|||
+ /* Use whitespace instead of DIRNAME_SEPARATOR to be compatible with
|
||||
+ its possible use as an argument for installation command. */
|
||||
+ link_all[len_orig] = ' ';
|
||||
+
|
||||
+ strcpy (&link_all[len_orig + 1], link0_resolved);
|
||||
}
|
||||
+ xfree (link0_resolved);
|
||||
+ }
|
||||
|
||||
- gdb_bfd_unref (abfd);
|
||||
- abfd = NULL;
|
||||
+ strcpy (&link_all[len_orig + 1], link0_resolved);
|
||||
+ xfree (link0_resolved);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (link_return != NULL)
|
||||
+ {
|
||||
if (retval != NULL)
|
||||
- break;
|
||||
+ if (abfd != NULL)
|
||||
+ {
|
||||
+ *link_return = link;
|
||||
+ link = NULL;
|
||||
|
|
@ -797,9 +960,24 @@ Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c
|
|||
+ xfree (link_all);
|
||||
|
||||
do_cleanups (back_to);
|
||||
return retval;
|
||||
return abfd;
|
||||
}
|
||||
|
||||
+char *
|
||||
+build_id_to_filename (const struct elf_build_id *build_id, char **link_return)
|
||||
+{
|
||||
+ bfd *abfd;
|
||||
+ char *result;
|
||||
+
|
||||
+ abfd = build_id_to_debug_bfd (build_id->size, build_id->data, link_return, 0);
|
||||
+ if (abfd == NULL)
|
||||
+ return NULL;
|
||||
+
|
||||
+ result = xstrdup (bfd_get_filename (abfd));
|
||||
+ gdb_bfd_unref (abfd);
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+/* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
|
||||
+ Try to install the hash file ...
|
||||
+ avoidance. */
|
||||
|
|
@ -936,7 +1114,9 @@ Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c
|
|||
+ debug);
|
||||
+}
|
||||
+
|
||||
static char *
|
||||
/* See build-id.h. */
|
||||
|
||||
char *
|
||||
-find_separate_debug_file_by_buildid (struct objfile *objfile)
|
||||
+find_separate_debug_file_by_buildid (struct objfile *objfile,
|
||||
+ char **build_id_filename_return)
|
||||
|
|
@ -950,54 +1130,24 @@ Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c
|
|||
+ build_id = build_id_bfd_shdr_get (objfile->obfd);
|
||||
if (build_id != NULL)
|
||||
{
|
||||
char *build_id_name;
|
||||
bfd *abfd;
|
||||
|
||||
- build_id_name = build_id_to_debug_filename (build_id);
|
||||
+ build_id_name = build_id_to_filename (build_id, build_id_filename_return,
|
||||
+ 1);
|
||||
- abfd = build_id_to_debug_bfd (build_id->size, build_id->data);
|
||||
+ abfd = build_id_to_debug_bfd (build_id->size, build_id->data,
|
||||
+ build_id_filename_return, 1);
|
||||
/* Prevent looping on a stripped .debug file. */
|
||||
if (build_id_name != NULL
|
||||
&& filename_cmp (build_id_name, objfile->name) == 0)
|
||||
@@ -1207,7 +1862,7 @@ find_separate_debug_file_by_buildid (str
|
||||
xfree (build_id_name);
|
||||
}
|
||||
else if (build_id_name != NULL)
|
||||
- return build_id_name;
|
||||
+ return build_id_name;
|
||||
if (abfd != NULL
|
||||
&& filename_cmp (bfd_get_filename (abfd),
|
||||
@@ -166,3 +839,21 @@ find_separate_debug_file_by_buildid (str
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1445,9 +2100,10 @@ elf_symfile_read (struct objfile *objfil
|
||||
&& objfile->separate_debug_objfile == NULL
|
||||
&& objfile->separate_debug_objfile_backlink == NULL)
|
||||
{
|
||||
- char *debugfile;
|
||||
+ char *debugfile, *build_id_filename;
|
||||
|
||||
- debugfile = find_separate_debug_file_by_buildid (objfile);
|
||||
+ debugfile = find_separate_debug_file_by_buildid (objfile,
|
||||
+ &build_id_filename);
|
||||
|
||||
if (debugfile == NULL)
|
||||
debugfile = find_separate_debug_file_by_debuglink (objfile);
|
||||
@@ -1461,6 +2117,12 @@ elf_symfile_read (struct objfile *objfil
|
||||
symbol_file_add_separate (abfd, symfile_flags, objfile);
|
||||
do_cleanups (cleanup);
|
||||
}
|
||||
+ /* Check if any separate debug info has been extracted out. */
|
||||
+ else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink")
|
||||
+ != NULL)
|
||||
+ debug_print_missing (objfile->name, build_id_filename);
|
||||
+
|
||||
+ xfree (build_id_filename);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1790,4 +2452,16 @@ _initialize_elfread (void)
|
||||
|
||||
elf_objfile_gnu_ifunc_cache_data = register_objfile_data ();
|
||||
gnu_ifunc_fns_p = &elf_gnu_ifunc_fns;
|
||||
+extern void _initialize_build_id (void);
|
||||
+
|
||||
+void
|
||||
+_initialize_build_id (void)
|
||||
+{
|
||||
+ add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose,
|
||||
+ _("\
|
||||
+Set debugging level of the build-id locator."), _("\
|
||||
|
|
@ -1009,116 +1159,42 @@ Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c
|
|||
+ &setlist, &showlist);
|
||||
+
|
||||
+ observer_attach_executable_changed (debug_print_executable_changed);
|
||||
}
|
||||
Index: gdb-7.6.50.20130731-cvs/gdb/symfile.h
|
||||
===================================================================
|
||||
--- gdb-7.6.50.20130731-cvs.orig/gdb/symfile.h 2013-08-02 17:07:17.886739513 +0200
|
||||
+++ gdb-7.6.50.20130731-cvs/gdb/symfile.h 2013-08-02 17:07:28.446753308 +0200
|
||||
@@ -597,6 +597,12 @@ void free_symfile_segment_data (struct s
|
||||
|
||||
extern struct cleanup *increment_reading_symtab (void);
|
||||
|
||||
+/* build-id support. */
|
||||
+extern struct elf_build_id *build_id_addr_get (CORE_ADDR addr);
|
||||
+extern char *build_id_to_filename (const struct elf_build_id *build_id,
|
||||
+ char **link_return, int add_debug_suffix);
|
||||
+extern void debug_print_missing (const char *binary, const char *debug);
|
||||
+
|
||||
/* From dwarf2read.c */
|
||||
|
||||
/* Names for a dwarf2 debugging section. The field NORMAL is the normal
|
||||
Index: gdb-7.6.50.20130731-cvs/gdb/testsuite/lib/gdb.exp
|
||||
===================================================================
|
||||
--- gdb-7.6.50.20130731-cvs.orig/gdb/testsuite/lib/gdb.exp 2013-08-02 17:07:17.886739513 +0200
|
||||
+++ gdb-7.6.50.20130731-cvs/gdb/testsuite/lib/gdb.exp 2013-08-02 17:07:28.446753308 +0200
|
||||
@@ -1482,6 +1482,16 @@ proc default_gdb_start { } {
|
||||
warning "Couldn't set the width to 0."
|
||||
}
|
||||
}
|
||||
+ # Turn off the missing warnings as the testsuite does not expect it.
|
||||
+ send_gdb "set build-id-verbose 0\n"
|
||||
+ gdb_expect 10 {
|
||||
+ -re "$gdb_prompt $" {
|
||||
+ verbose "Disabled the missing debug infos warnings." 2
|
||||
+ }
|
||||
+ timeout {
|
||||
+ warning "Could not disable the missing debug infos warnings.."
|
||||
+ }
|
||||
+ }
|
||||
return 0
|
||||
}
|
||||
|
||||
Index: gdb-7.6.50.20130731-cvs/gdb/testsuite/lib/mi-support.exp
|
||||
===================================================================
|
||||
--- gdb-7.6.50.20130731-cvs.orig/gdb/testsuite/lib/mi-support.exp 2013-08-02 17:07:17.886739513 +0200
|
||||
+++ gdb-7.6.50.20130731-cvs/gdb/testsuite/lib/mi-support.exp 2013-08-02 17:07:28.447753310 +0200
|
||||
@@ -212,6 +212,16 @@ proc default_mi_gdb_start { args } {
|
||||
warning "Couldn't set the width to 0."
|
||||
}
|
||||
}
|
||||
+ # Turn off the missing warnings as the testsuite does not expect it.
|
||||
+ send_gdb "190-gdb-set build-id-verbose 0\n"
|
||||
+ gdb_expect 10 {
|
||||
+ -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" {
|
||||
+ verbose "Disabled the missing debug infos warnings." 2
|
||||
+ }
|
||||
+ timeout {
|
||||
+ warning "Could not disable the missing debug infos warnings.."
|
||||
+ }
|
||||
+ }
|
||||
# If allowing the inferior to have its own PTY then assign the inferior
|
||||
# its own terminal device here.
|
||||
if { $separate_inferior_pty } {
|
||||
Index: gdb-7.6.50.20130731-cvs/gdb/objfiles.h
|
||||
===================================================================
|
||||
--- gdb-7.6.50.20130731-cvs.orig/gdb/objfiles.h 2013-08-02 17:07:17.886739513 +0200
|
||||
+++ gdb-7.6.50.20130731-cvs/gdb/objfiles.h 2013-08-02 17:07:28.447753310 +0200
|
||||
@@ -429,6 +429,10 @@ struct objfile
|
||||
|
||||
#define OBJF_MAINLINE (1 << 5)
|
||||
|
||||
+/* This file was loaded according to the BUILD_ID_CORE_LOADS rules. */
|
||||
+
|
||||
+#define OBJF_BUILD_ID_CORE_LOADED (1 << 12)
|
||||
+
|
||||
/* The object file that contains the runtime common minimal symbols
|
||||
for SunOS4. Note that this objfile has no associated BFD. */
|
||||
|
||||
Index: gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.base/corefile.exp
|
||||
===================================================================
|
||||
--- gdb-7.6.50.20130731-cvs.orig/gdb/testsuite/gdb.base/corefile.exp 2013-08-02 17:07:17.886739513 +0200
|
||||
+++ gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.base/corefile.exp 2013-08-02 17:07:28.447753310 +0200
|
||||
@@ -255,3 +255,33 @@ if ![is_remote target] {
|
||||
|
||||
gdb_exit
|
||||
}
|
||||
+
|
||||
+
|
||||
+# Test auto-loading of binary files through build-id from the core file.
|
||||
+set buildid [build_id_debug_filename_get $binfile]
|
||||
+set wholetest "binfile found by build-id"
|
||||
+if {$buildid == ""} {
|
||||
+ untested "$wholetest (binary has no build-id)"
|
||||
+} else {
|
||||
+ gdb_exit
|
||||
+ gdb_start
|
||||
+
|
||||
+ regsub {\.debug$} $buildid {} buildid
|
||||
+ set debugdir ${objdir}/${subdir}/${testfile}-debugdir
|
||||
+ file delete -force -- $debugdir
|
||||
+ file mkdir $debugdir/[file dirname $buildid]
|
||||
+ file copy $binfile $debugdir/$buildid
|
||||
+
|
||||
+ set test "show debug-file-directory"
|
||||
+ gdb_test_multiple $test $test {
|
||||
+ -re "The directory where separate debug symbols are searched for is \"(.*)\"\\.\r\n$gdb_prompt $" {
|
||||
+ set debugdir_orig $expect_out(1,string)
|
||||
+ pass $test
|
||||
+ }
|
||||
+ }
|
||||
+ gdb_test_no_output "set debug-file-directory $debugdir:$debugdir_orig" "set debug-file-directory"
|
||||
+ gdb_test "show build-id-core-loads" {Whether CORE-FILE loads the build-id associated files automatically is on\.}
|
||||
+ gdb_test "core-file $corefile" "\r\nProgram terminated with .*" "core-file without executable"
|
||||
+ gdb_test "info files" "Local exec file:\r\n\[ \t\]*`[string_to_regexp $debugdir/$buildid]', file type .*"
|
||||
+ pass $wholetest
|
||||
+}
|
||||
Index: gdb-7.6.90.20140127/gdb/build-id.h
|
||||
===================================================================
|
||||
--- gdb-7.6.90.20140127.orig/gdb/build-id.h 2014-01-27 02:57:53.000000000 +0100
|
||||
+++ gdb-7.6.90.20140127/gdb/build-id.h 2014-02-06 16:46:52.114646335 +0100
|
||||
@@ -32,13 +32,18 @@ extern int build_id_verify (bfd *abfd,
|
||||
the caller. */
|
||||
|
||||
extern bfd *build_id_to_debug_bfd (size_t build_id_len,
|
||||
- const bfd_byte *build_id);
|
||||
+ const bfd_byte *build_id, char **link_return,
|
||||
+ int add_debug_suffix);
|
||||
+
|
||||
+extern char *build_id_to_filename (const struct elf_build_id *build_id,
|
||||
+ char **link_return);
|
||||
|
||||
/* Find the separate debug file for OBJFILE, by using the build-id
|
||||
associated with OBJFILE's BFD. If successful, returns a malloc'd
|
||||
file name for the separate debug file. The caller must free this.
|
||||
Otherwise, returns NULL. */
|
||||
|
||||
-extern char *find_separate_debug_file_by_buildid (struct objfile *objfile);
|
||||
+extern char *find_separate_debug_file_by_buildid (struct objfile *objfile,
|
||||
+ char **build_id_filename_return);
|
||||
|
||||
#endif /* BUILD_ID_H */
|
||||
Index: gdb-7.6.90.20140127/gdb/dwarf2read.c
|
||||
===================================================================
|
||||
--- gdb-7.6.90.20140127.orig/gdb/dwarf2read.c 2014-02-06 16:46:51.809645995 +0100
|
||||
+++ gdb-7.6.90.20140127/gdb/dwarf2read.c 2014-02-06 16:49:55.679850414 +0100
|
||||
@@ -2429,7 +2429,7 @@ dwarf2_get_dwz_file (void)
|
||||
}
|
||||
|
||||
if (dwz_bfd == NULL)
|
||||
- dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid);
|
||||
+ dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid, NULL, 1);
|
||||
|
||||
if (dwz_bfd == NULL)
|
||||
error (_("could not find '.gnu_debugaltlink' file for %s"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue