diff --git a/.gitignore b/.gitignore index 0212964..2936f1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /libstdc++-v3-python-r155978.tar.bz2 -/gdb-7.4.50.20120603.tar.bz2 +/gdb-7.4.50.20120703.tar.bz2 diff --git a/gdb-6.3-readnever-20050907.patch b/gdb-6.3-readnever-20050907.patch index cffb07b..7728070 100644 --- a/gdb-6.3-readnever-20050907.patch +++ b/gdb-6.3-readnever-20050907.patch @@ -11,11 +11,11 @@ * gdb.texinfo (File Options): Document --readnever. -Index: gdb-7.4.50.20120602/gdb/doc/gdb.texinfo +Index: gdb-7.4.50.20120703/gdb/doc/gdb.texinfo =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/doc/gdb.texinfo 2012-06-02 18:16:36.000000000 +0200 -+++ gdb-7.4.50.20120602/gdb/doc/gdb.texinfo 2012-06-02 18:25:20.300254019 +0200 -@@ -1020,6 +1020,12 @@ Read each symbol file's entire symbol ta +--- gdb-7.4.50.20120703.orig/gdb/doc/gdb.texinfo 2012-07-03 17:30:07.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/doc/gdb.texinfo 2012-07-03 17:31:40.695642449 +0200 +@@ -1023,6 +1023,12 @@ Read each symbol file's entire symbol ta the default, which is to read it incrementally as it is needed. This makes startup slower, but makes future operations faster. @@ -28,10 +28,10 @@ Index: gdb-7.4.50.20120602/gdb/doc/gdb.texinfo @end table @node Mode Options -Index: gdb-7.4.50.20120602/gdb/main.c +Index: gdb-7.4.50.20120703/gdb/main.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/main.c 2012-06-02 18:16:36.000000000 +0200 -+++ gdb-7.4.50.20120602/gdb/main.c 2012-06-02 18:25:20.302254019 +0200 +--- gdb-7.4.50.20120703.orig/gdb/main.c 2012-07-03 17:30:07.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/main.c 2012-07-03 17:31:40.696642448 +0200 @@ -414,6 +414,7 @@ captured_main (void *data) {"xdb", no_argument, &xdb_commands, 1}, {"dbx", no_argument, &dbx_commands, 1}, @@ -48,11 +48,11 @@ Index: gdb-7.4.50.20120602/gdb/main.c "), stream); fputs_unfiltered (_("\ --se=FILE Use FILE as symbol file and executable file.\n\ -Index: gdb-7.4.50.20120602/gdb/symfile.c +Index: gdb-7.4.50.20120703/gdb/symfile.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/symfile.c 2012-05-31 20:44:49.000000000 +0200 -+++ gdb-7.4.50.20120602/gdb/symfile.c 2012-06-02 18:25:20.334254013 +0200 -@@ -80,6 +80,7 @@ static void clear_symtab_users_cleanup ( +--- gdb-7.4.50.20120703.orig/gdb/symfile.c 2012-07-03 17:30:07.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/symfile.c 2012-07-03 17:31:40.697642447 +0200 +@@ -81,6 +81,7 @@ static void clear_symtab_users_cleanup ( /* Global variables owned by this file. */ int readnow_symbol_files; /* Read full symbols immediately. */ @@ -60,19 +60,19 @@ Index: gdb-7.4.50.20120602/gdb/symfile.c /* External variables and functions referenced. */ -Index: gdb-7.4.50.20120602/gdb/dwarf2read.c +Index: gdb-7.4.50.20120703/gdb/dwarf2read.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/dwarf2read.c 2012-06-02 18:16:36.000000000 +0200 -+++ gdb-7.4.50.20120602/gdb/dwarf2read.c 2012-06-02 18:25:32.837250535 +0200 -@@ -63,6 +63,7 @@ - #include "valprint.h" - #include "gdbcore.h" /* for gnutarget */ +--- gdb-7.4.50.20120703.orig/gdb/dwarf2read.c 2012-07-03 17:30:07.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/dwarf2read.c 2012-07-03 17:31:53.421627153 +0200 +@@ -65,6 +65,7 @@ + #include "gdb/gdb-index.h" #include + #include "gdb_bfd.h" +#include "top.h" #include #include "gdb_string.h" -@@ -1514,8 +1515,9 @@ dwarf2_has_info (struct objfile *objfile +@@ -1587,8 +1588,9 @@ dwarf2_has_info (struct objfile *objfile (void *) names); dwarf2_per_objfile->objfile = objfile; } @@ -84,10 +84,10 @@ Index: gdb-7.4.50.20120602/gdb/dwarf2read.c } /* When loading sections, we look either for uncompressed section or for -Index: gdb-7.4.50.20120602/gdb/top.h +Index: gdb-7.4.50.20120703/gdb/top.h =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/top.h 2012-01-23 18:12:30.000000000 +0100 -+++ gdb-7.4.50.20120602/gdb/top.h 2012-06-02 18:25:20.367254001 +0200 +--- gdb-7.4.50.20120703.orig/gdb/top.h 2012-01-23 18:12:30.000000000 +0100 ++++ gdb-7.4.50.20120703/gdb/top.h 2012-07-03 17:31:40.700642444 +0200 @@ -60,6 +60,7 @@ extern void set_prompt (const char *s); /* From random places. */ diff --git a/gdb-6.5-bz216711-clone-is-outermost.patch b/gdb-6.5-bz216711-clone-is-outermost.patch index 704e29a..41a887a 100644 --- a/gdb-6.5-bz216711-clone-is-outermost.patch +++ b/gdb-6.5-bz216711-clone-is-outermost.patch @@ -23,10 +23,10 @@ instead. Port to GDB-6.7. -Index: gdb-7.4.50.20120602/gdb/amd64-linux-tdep.c +Index: gdb-7.4.50.20120703/gdb/amd64-linux-tdep.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/amd64-linux-tdep.c 2012-06-02 21:05:45.352280128 +0200 -+++ gdb-7.4.50.20120602/gdb/amd64-linux-tdep.c 2012-06-02 21:06:25.536265325 +0200 +--- gdb-7.4.50.20120703.orig/gdb/amd64-linux-tdep.c 2012-06-13 22:36:48.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/amd64-linux-tdep.c 2012-07-03 17:32:46.547563363 +0200 @@ -271,6 +271,80 @@ amd64_linux_register_reggroup_p (struct /* Set the program counter for process PTID to PC. */ @@ -108,20 +108,20 @@ Index: gdb-7.4.50.20120602/gdb/amd64-linux-tdep.c static void amd64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) { -@@ -1330,6 +1404,8 @@ amd64_linux_init_abi (struct gdbarch_inf +@@ -1547,6 +1621,8 @@ amd64_linux_init_abi (struct gdbarch_inf - tdep->xsave_xcr0_offset = I386_LINUX_XSAVE_XCR0_OFFSET; + amd64_linux_init_abi_common (info, gdbarch); + tdep->outermost_frame_p = amd64_linux_outermost_frame; + /* GNU/Linux uses SVR4-style shared libraries. */ set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_lp64_fetch_link_map_offsets); -Index: gdb-7.4.50.20120602/gdb/amd64-tdep.c +Index: gdb-7.4.50.20120703/gdb/amd64-tdep.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/amd64-tdep.c 2012-06-02 21:05:45.352280128 +0200 -+++ gdb-7.4.50.20120602/gdb/amd64-tdep.c 2012-06-02 21:06:00.437274574 +0200 -@@ -2138,6 +2138,7 @@ amd64_frame_unwind_stop_reason (struct f +--- gdb-7.4.50.20120703.orig/gdb/amd64-tdep.c 2012-06-16 17:20:22.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/amd64-tdep.c 2012-07-03 17:32:12.335604415 +0200 +@@ -2324,6 +2324,7 @@ amd64_frame_unwind_stop_reason (struct f { struct amd64_frame_cache *cache = amd64_frame_cache (this_frame, this_cache); @@ -129,7 +129,7 @@ Index: gdb-7.4.50.20120602/gdb/amd64-tdep.c if (!cache->base_p) return UNWIND_UNAVAILABLE; -@@ -2146,6 +2147,10 @@ amd64_frame_unwind_stop_reason (struct f +@@ -2332,6 +2333,10 @@ amd64_frame_unwind_stop_reason (struct f if (cache->base == 0) return UNWIND_OUTERMOST; @@ -140,7 +140,7 @@ Index: gdb-7.4.50.20120602/gdb/amd64-tdep.c return UNWIND_NO_REASON; } -@@ -2155,6 +2160,7 @@ amd64_frame_this_id (struct frame_info * +@@ -2341,6 +2346,7 @@ amd64_frame_this_id (struct frame_info * { struct amd64_frame_cache *cache = amd64_frame_cache (this_frame, this_cache); @@ -148,7 +148,7 @@ Index: gdb-7.4.50.20120602/gdb/amd64-tdep.c if (!cache->base_p) return; -@@ -2163,6 +2169,10 @@ amd64_frame_this_id (struct frame_info * +@@ -2349,6 +2355,10 @@ amd64_frame_this_id (struct frame_info * if (cache->base == 0) return; @@ -159,11 +159,11 @@ Index: gdb-7.4.50.20120602/gdb/amd64-tdep.c (*this_id) = frame_id_build (cache->base + 16, cache->pc); } -Index: gdb-7.4.50.20120602/gdb/i386-tdep.c +Index: gdb-7.4.50.20120703/gdb/i386-tdep.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/i386-tdep.c 2012-06-02 21:05:45.352280128 +0200 -+++ gdb-7.4.50.20120602/gdb/i386-tdep.c 2012-06-02 21:06:00.466274562 +0200 -@@ -7639,6 +7639,9 @@ i386_gdbarch_init (struct gdbarch_info i +--- gdb-7.4.50.20120703.orig/gdb/i386-tdep.c 2012-06-18 19:31:34.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/i386-tdep.c 2012-07-03 17:32:12.339604409 +0200 +@@ -7655,6 +7655,9 @@ i386_gdbarch_init (struct gdbarch_info i tdep->xsave_xcr0_offset = -1; @@ -173,10 +173,10 @@ Index: gdb-7.4.50.20120602/gdb/i386-tdep.c tdep->record_regmap = i386_record_regmap; set_gdbarch_long_long_align_bit (gdbarch, 32); -Index: gdb-7.4.50.20120602/gdb/i386-tdep.h +Index: gdb-7.4.50.20120703/gdb/i386-tdep.h =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/i386-tdep.h 2012-06-02 21:05:45.352280128 +0200 -+++ gdb-7.4.50.20120602/gdb/i386-tdep.h 2012-06-02 21:06:00.486274568 +0200 +--- gdb-7.4.50.20120703.orig/gdb/i386-tdep.h 2012-06-13 22:29:15.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/i386-tdep.h 2012-07-03 17:32:12.340604408 +0200 @@ -219,6 +219,9 @@ struct gdbarch_tdep int (*i386_sysenter_record) (struct regcache *regcache); /* Parse syscall args. */ @@ -187,10 +187,10 @@ Index: gdb-7.4.50.20120602/gdb/i386-tdep.h }; /* Floating-point registers. */ -Index: gdb-7.4.50.20120602/gdb/ia64-tdep.c +Index: gdb-7.4.50.20120703/gdb/ia64-tdep.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/ia64-tdep.c 2012-06-02 21:05:45.352280128 +0200 -+++ gdb-7.4.50.20120602/gdb/ia64-tdep.c 2012-06-02 21:06:00.490274552 +0200 +--- gdb-7.4.50.20120703.orig/gdb/ia64-tdep.c 2012-07-03 17:30:09.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/ia64-tdep.c 2012-07-03 17:32:12.343604405 +0200 @@ -2176,6 +2176,138 @@ static const struct frame_unwind ia64_fr default_frame_sniffer }; @@ -338,10 +338,10 @@ Index: gdb-7.4.50.20120602/gdb/ia64-tdep.c #ifdef HAVE_LIBUNWIND_IA64_H frame_unwind_append_unwinder (gdbarch, &ia64_libunwind_sigtramp_frame_unwind); -Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/bt-clone-stop.c +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/bt-clone-stop.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/bt-clone-stop.c 2012-06-02 21:06:00.514274544 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/bt-clone-stop.c 2012-07-03 17:32:12.344604404 +0200 @@ -0,0 +1,39 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -382,10 +382,10 @@ Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/bt-clone-stop.c + for (;;) + pause(); +} -Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/bt-clone-stop.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/bt-clone-stop.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/bt-clone-stop.exp 2012-06-02 21:06:00.515274547 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/bt-clone-stop.exp 2012-07-03 17:32:12.344604404 +0200 @@ -0,0 +1,61 @@ +# Copyright 2006 Free Software Foundation, Inc. + diff --git a/gdb-6.6-buildid-locate-core-as-arg.patch b/gdb-6.6-buildid-locate-core-as-arg.patch index 9687712..c28b000 100644 --- a/gdb-6.6-buildid-locate-core-as-arg.patch +++ b/gdb-6.6-buildid-locate-core-as-arg.patch @@ -58,10 +58,10 @@ Http://sourceware.org/ml/gdb-patches/2010-01/msg00517.html * exec.c (exec_file_attach): Print a more useful error message if the user did "gdb core". -Index: gdb-7.4.50.20120602/gdb/exceptions.h +Index: gdb-7.4.50.20120703/gdb/exceptions.h =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/exceptions.h 2012-01-04 09:17:01.000000000 +0100 -+++ gdb-7.4.50.20120602/gdb/exceptions.h 2012-06-02 19:59:22.195114052 +0200 +--- gdb-7.4.50.20120703.orig/gdb/exceptions.h 2012-01-04 09:17:01.000000000 +0100 ++++ gdb-7.4.50.20120703/gdb/exceptions.h 2012-07-03 17:36:27.840297264 +0200 @@ -86,6 +86,9 @@ enum errors { /* DW_OP_GNU_entry_value resolving failed. */ NO_ENTRY_VALUE_ERROR, @@ -72,19 +72,19 @@ Index: gdb-7.4.50.20120602/gdb/exceptions.h /* Add more errors here. */ NR_ERRORS }; -Index: gdb-7.4.50.20120602/gdb/exec.c +Index: gdb-7.4.50.20120703/gdb/exec.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/exec.c 2012-05-29 16:23:39.000000000 +0200 -+++ gdb-7.4.50.20120602/gdb/exec.c 2012-06-02 19:59:22.196114052 +0200 -@@ -33,6 +33,7 @@ - #include "arch-utils.h" +--- gdb-7.4.50.20120703.orig/gdb/exec.c 2012-07-03 17:30:07.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/exec.c 2012-07-03 17:37:27.777225175 +0200 +@@ -34,6 +34,7 @@ #include "gdbthread.h" #include "progspace.h" + #include "gdb_bfd.h" +#include "exceptions.h" #include #include "readline/readline.h" -@@ -251,12 +252,27 @@ exec_file_attach (char *filename, int fr +@@ -245,12 +246,27 @@ exec_file_attach (char *filename, int fr if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching)) { @@ -114,11 +114,11 @@ Index: gdb-7.4.50.20120602/gdb/exec.c + gdb_bfd_errmsg (bfd_get_error (), matching)); } - /* FIXME - This should only be run for RS6000, but the ifdef is a poor -Index: gdb-7.4.50.20120602/gdb/main.c + gdb_bfd_stash_filename (exec_bfd); +Index: gdb-7.4.50.20120703/gdb/main.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/main.c 2012-06-02 19:11:55.000000000 +0200 -+++ gdb-7.4.50.20120602/gdb/main.c 2012-06-02 19:59:42.082107499 +0200 +--- gdb-7.4.50.20120703.orig/gdb/main.c 2012-07-03 17:31:40.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/main.c 2012-07-03 17:36:27.843297261 +0200 @@ -266,6 +266,36 @@ typedef struct cmdarg { /* Define type VEC (cmdarg_s). */ DEF_VEC_O (cmdarg_s); diff --git a/gdb-6.6-buildid-locate.patch b/gdb-6.6-buildid-locate.patch index 0a96035..f0db5d1 100644 --- a/gdb-6.6-buildid-locate.patch +++ b/gdb-6.6-buildid-locate.patch @@ -1,18 +1,18 @@ -Index: gdb-7.4.50.20120602/gdb/corelow.c +Index: gdb-7.4.50.20120703/gdb/corelow.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/corelow.c 2012-06-02 21:07:03.695251272 +0200 -+++ gdb-7.4.50.20120602/gdb/corelow.c 2012-06-02 21:07:16.464246569 +0200 -@@ -46,6 +46,9 @@ - #include "filenames.h" +--- gdb-7.4.50.20120703.orig/gdb/corelow.c 2012-07-03 17:30:07.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/corelow.c 2012-07-03 17:33:27.882513714 +0200 +@@ -47,6 +47,9 @@ #include "progspace.h" #include "objfiles.h" + #include "gdb_bfd.h" +#include "auxv.h" +#include "elf/common.h" +#include "gdbcmd.h" #ifndef O_LARGEFILE #define O_LARGEFILE 0 -@@ -275,6 +278,52 @@ add_to_thread_list (bfd *abfd, asection +@@ -274,6 +277,52 @@ add_to_thread_list (bfd *abfd, asection inferior_ptid = ptid; /* Yes, make it current. */ } @@ -65,7 +65,7 @@ Index: gdb-7.4.50.20120602/gdb/corelow.c /* This routine opens and sets up the core file bfd. */ static void -@@ -377,6 +426,12 @@ core_open (char *filename, int from_tty) +@@ -378,6 +427,12 @@ core_open (char *filename, int from_tty) push_target (&core_ops); discard_cleanups (old_chain); @@ -78,7 +78,7 @@ Index: gdb-7.4.50.20120602/gdb/corelow.c /* Do this before acknowledging the inferior, so if post_create_inferior throws (can happen easilly if you're loading a core file with the wrong exec), we aren't left with threads -@@ -935,4 +990,11 @@ _initialize_corelow (void) +@@ -941,4 +996,11 @@ _initialize_corelow (void) init_core_ops (); add_target (&core_ops); @@ -90,11 +90,11 @@ Index: gdb-7.4.50.20120602/gdb/corelow.c + NULL, NULL, NULL, + &setlist, &showlist); } -Index: gdb-7.4.50.20120602/gdb/doc/gdb.texinfo +Index: gdb-7.4.50.20120703/gdb/doc/gdb.texinfo =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/doc/gdb.texinfo 2012-06-02 21:07:03.695251272 +0200 -+++ gdb-7.4.50.20120602/gdb/doc/gdb.texinfo 2012-06-02 21:07:16.480246563 +0200 -@@ -16502,6 +16502,27 @@ information files. +--- gdb-7.4.50.20120703.orig/gdb/doc/gdb.texinfo 2012-07-03 17:31:40.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/doc/gdb.texinfo 2012-07-03 17:33:14.630529528 +0200 +@@ -16530,6 +16530,27 @@ information files. @end table @@ -122,10 +122,10 @@ Index: gdb-7.4.50.20120602/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.4.50.20120602/gdb/solib-svr4.c +Index: gdb-7.4.50.20120703/gdb/solib-svr4.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/solib-svr4.c 2012-06-02 21:07:03.695251272 +0200 -+++ gdb-7.4.50.20120602/gdb/solib-svr4.c 2012-06-02 21:07:16.510246552 +0200 +--- gdb-7.4.50.20120703.orig/gdb/solib-svr4.c 2012-06-05 17:44:03.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/solib-svr4.c 2012-07-03 17:33:14.631529527 +0200 @@ -1227,9 +1227,52 @@ svr4_read_so_list (CORE_ADDR lm, struct continue; } @@ -182,14 +182,14 @@ Index: gdb-7.4.50.20120602/gdb/solib-svr4.c xfree (buffer); /* If this entry has no name, or its name matches the name -Index: gdb-7.4.50.20120602/gdb/elfread.c +Index: gdb-7.4.50.20120703/gdb/elfread.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/elfread.c 2012-06-02 21:07:03.695251272 +0200 -+++ gdb-7.4.50.20120602/gdb/elfread.c 2012-06-02 21:07:56.264232049 +0200 -@@ -44,6 +44,11 @@ - #include "gdbthread.h" +--- gdb-7.4.50.20120703.orig/gdb/elfread.c 2012-07-03 17:30:07.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/elfread.c 2012-07-03 17:34:04.778468965 +0200 +@@ -45,6 +45,11 @@ #include "regcache.h" #include "bcache.h" + #include "gdb_bfd.h" +#include "libbfd.h" +#include "gdbcore.h" +#include "gdbcmd.h" @@ -198,7 +198,7 @@ Index: gdb-7.4.50.20120602/gdb/elfread.c extern void _initialize_elfread (void); -@@ -1072,16 +1077,65 @@ elf_gnu_ifunc_resolver_return_stop (stru +@@ -1074,16 +1079,65 @@ elf_gnu_ifunc_resolver_return_stop (stru update_breakpoint_locations (b, sals, sals_end); } @@ -266,7 +266,7 @@ Index: gdb-7.4.50.20120602/gdb/elfread.c { struct build_id *retval; -@@ -1097,6 +1151,348 @@ build_id_bfd_get (bfd *abfd) +@@ -1099,6 +1153,348 @@ build_id_bfd_get (bfd *abfd) return retval; } @@ -615,7 +615,7 @@ Index: gdb-7.4.50.20120602/gdb/elfread.c /* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */ static int -@@ -1111,7 +1507,7 @@ build_id_verify (const char *filename, s +@@ -1113,7 +1509,7 @@ build_id_verify (const char *filename, s if (abfd == NULL) return 0; @@ -624,7 +624,7 @@ Index: gdb-7.4.50.20120602/gdb/elfread.c if (found == NULL) warning (_("File \"%s\" has no build-id, file skipped"), filename); -@@ -1129,17 +1525,18 @@ build_id_verify (const char *filename, s +@@ -1131,17 +1527,18 @@ build_id_verify (const char *filename, s return retval; } @@ -647,7 +647,7 @@ Index: gdb-7.4.50.20120602/gdb/elfread.c /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will cause "/.build-id/..." lookups. */ -@@ -1152,6 +1549,8 @@ build_id_to_debug_filename (struct build +@@ -1154,6 +1551,8 @@ build_id_to_debug_filename (struct build size_t debugdir_len = strlen (debugdir); gdb_byte *data = build_id->data; size_t size = build_id->size; @@ -656,7 +656,7 @@ Index: gdb-7.4.50.20120602/gdb/elfread.c char *s; memcpy (link, debugdir, debugdir_len); -@@ -1166,37 +1565,240 @@ build_id_to_debug_filename (struct build +@@ -1168,37 +1567,240 @@ build_id_to_debug_filename (struct build *s++ = '/'; while (size-- > 0) s += sprintf (s, "%02x", (unsigned) *data++); @@ -908,7 +908,7 @@ Index: gdb-7.4.50.20120602/gdb/elfread.c xfree (build_id); /* Prevent looping on a stripped .debug file. */ if (build_id_name != NULL -@@ -1207,7 +1809,7 @@ find_separate_debug_file_by_buildid (str +@@ -1209,7 +1811,7 @@ find_separate_debug_file_by_buildid (str xfree (build_id_name); } else if (build_id_name != NULL) @@ -917,7 +917,7 @@ Index: gdb-7.4.50.20120602/gdb/elfread.c } return NULL; } -@@ -1427,9 +2029,10 @@ elf_symfile_read (struct objfile *objfil +@@ -1436,9 +2038,10 @@ elf_symfile_read (struct objfile *objfil `.note.gnu.build-id'. */ else if (!objfile_has_partial_symbols (objfile)) { @@ -930,7 +930,7 @@ Index: gdb-7.4.50.20120602/gdb/elfread.c if (debugfile == NULL) debugfile = find_separate_debug_file_by_debuglink (objfile); -@@ -1441,6 +2044,12 @@ elf_symfile_read (struct objfile *objfil +@@ -1450,6 +2053,12 @@ elf_symfile_read (struct objfile *objfil symbol_file_add_separate (abfd, symfile_flags, objfile); xfree (debugfile); } @@ -941,9 +941,9 @@ Index: gdb-7.4.50.20120602/gdb/elfread.c + + xfree (build_id_filename); } - } -@@ -1770,4 +2379,16 @@ _initialize_elfread (void) + if (symtab_create_debug) +@@ -1782,4 +2391,16 @@ _initialize_elfread (void) elf_objfile_gnu_ifunc_cache_data = register_objfile_data (); gnu_ifunc_fns_p = &elf_gnu_ifunc_fns; @@ -960,10 +960,10 @@ Index: gdb-7.4.50.20120602/gdb/elfread.c + + observer_attach_executable_changed (debug_print_executable_changed); } -Index: gdb-7.4.50.20120602/gdb/symfile.h +Index: gdb-7.4.50.20120703/gdb/symfile.h =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/symfile.h 2012-06-02 21:07:03.695251272 +0200 -+++ gdb-7.4.50.20120602/gdb/symfile.h 2012-06-02 21:07:16.524246547 +0200 +--- gdb-7.4.50.20120703.orig/gdb/symfile.h 2012-05-25 00:14:35.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/symfile.h 2012-07-03 17:33:14.632529526 +0200 @@ -615,6 +615,13 @@ void free_symfile_segment_data (struct s extern struct cleanup *increment_reading_symtab (void); @@ -978,10 +978,10 @@ Index: gdb-7.4.50.20120602/gdb/symfile.h /* From dwarf2read.c */ /* Names for a dwarf2 debugging section. The field NORMAL is the normal -Index: gdb-7.4.50.20120602/gdb/testsuite/lib/gdb.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/lib/gdb.exp =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/testsuite/lib/gdb.exp 2012-06-02 21:07:03.695251272 +0200 -+++ gdb-7.4.50.20120602/gdb/testsuite/lib/gdb.exp 2012-06-02 21:07:16.526246546 +0200 +--- gdb-7.4.50.20120703.orig/gdb/testsuite/lib/gdb.exp 2012-07-03 17:30:09.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/lib/gdb.exp 2012-07-03 17:33:14.633529524 +0200 @@ -1388,6 +1388,16 @@ proc default_gdb_start { } { warning "Couldn't set the width to 0." } @@ -999,10 +999,10 @@ Index: gdb-7.4.50.20120602/gdb/testsuite/lib/gdb.exp return 0; } -Index: gdb-7.4.50.20120602/gdb/testsuite/lib/mi-support.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/lib/mi-support.exp =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/testsuite/lib/mi-support.exp 2012-06-02 21:07:03.695251272 +0200 -+++ gdb-7.4.50.20120602/gdb/testsuite/lib/mi-support.exp 2012-06-02 21:07:16.535246544 +0200 +--- gdb-7.4.50.20120703.orig/gdb/testsuite/lib/mi-support.exp 2012-04-14 14:18:44.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/lib/mi-support.exp 2012-07-03 17:33:14.633529524 +0200 @@ -213,6 +213,16 @@ proc default_mi_gdb_start { args } { warning "Couldn't set the width to 0." } @@ -1020,10 +1020,10 @@ Index: gdb-7.4.50.20120602/gdb/testsuite/lib/mi-support.exp # 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.4.50.20120602/gdb/objfiles.h +Index: gdb-7.4.50.20120703/gdb/objfiles.h =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/objfiles.h 2012-06-02 21:07:03.695251272 +0200 -+++ gdb-7.4.50.20120602/gdb/objfiles.h 2012-06-02 21:07:16.539246541 +0200 +--- gdb-7.4.50.20120703.orig/gdb/objfiles.h 2012-07-03 17:30:07.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/objfiles.h 2012-07-03 17:33:14.633529524 +0200 @@ -432,6 +432,10 @@ struct objfile #define OBJF_MAINLINE (1 << 5) diff --git a/gdb-6.6-scheduler_locking-step-is-default.patch b/gdb-6.6-scheduler_locking-step-is-default.patch index 50af796..bfc8e96 100644 --- a/gdb-6.6-scheduler_locking-step-is-default.patch +++ b/gdb-6.6-scheduler_locking-step-is-default.patch @@ -1,8 +1,8 @@ -Index: gdb-7.3.50.20110722/gdb/infrun.c +Index: gdb-7.4.50.20120703/gdb/infrun.c =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/infrun.c 2011-07-22 19:12:56.000000000 +0200 -+++ gdb-7.3.50.20110722/gdb/infrun.c 2011-07-22 19:17:06.000000000 +0200 -@@ -1549,7 +1549,7 @@ static const char *scheduler_enums[] = { +--- gdb-7.4.50.20120703.orig/gdb/infrun.c 2012-07-03 20:26:25.060940765 +0200 ++++ gdb-7.4.50.20120703/gdb/infrun.c 2012-07-03 20:26:32.808929860 +0200 +@@ -1591,7 +1591,7 @@ static const char *const scheduler_enums schedlock_step, NULL }; @@ -11,11 +11,11 @@ Index: gdb-7.3.50.20110722/gdb/infrun.c static void show_scheduler_mode (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) -Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi-console.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.mi/mi-console.exp =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.mi/mi-console.exp 2011-01-01 16:33:47.000000000 +0100 -+++ gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi-console.exp 2011-07-22 19:17:06.000000000 +0200 -@@ -47,6 +47,9 @@ if { [gdb_compile "${srcdir}/${subdir}/ +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.mi/mi-console.exp 2012-07-03 20:26:25.060940765 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.mi/mi-console.exp 2012-07-03 20:26:32.809929858 +0200 +@@ -46,6 +46,9 @@ if { [gdb_compile "${srcdir}/${subdir}/ mi_run_to_main @@ -25,11 +25,11 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi-console.exp # Next over the hello() call which will produce lots of output mi_gdb_test "220-exec-next" \ "220\\^running(\r\n\\*running,thread-id=\"all\")?" \ -Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi2-console.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.mi/mi2-console.exp =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.mi/mi2-console.exp 2011-06-23 11:40:50.000000000 +0200 -+++ gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi2-console.exp 2011-07-22 19:17:27.000000000 +0200 -@@ -47,6 +47,9 @@ if { [gdb_compile "${srcdir}/${subdir}/ +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.mi/mi2-console.exp 2012-07-03 20:26:25.060940765 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.mi/mi2-console.exp 2012-07-03 20:26:32.809929858 +0200 +@@ -46,6 +46,9 @@ if { [gdb_compile "${srcdir}/${subdir}/ mi_run_to_main @@ -39,11 +39,11 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi2-console.exp # Next over the hello() call which will produce lots of output mi_gdb_test "220-exec-next" "220\\^running(\r\n)?(\\*running,thread-id=\"all\")?" \ "Started step over hello" -Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi-cli.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.mi/mi-cli.exp =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.mi/mi-cli.exp 2011-04-27 12:17:38.000000000 +0200 -+++ gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi-cli.exp 2011-07-22 19:17:06.000000000 +0200 -@@ -176,7 +176,7 @@ mi_execute_to "exec-continue" "breakpoin +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.mi/mi-cli.exp 2012-07-03 20:26:25.060940765 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.mi/mi-cli.exp 2012-07-03 20:26:32.810929856 +0200 +@@ -175,7 +175,7 @@ mi_execute_to "exec-continue" "breakpoin # Test that the token is output even for CLI commands # Also test that *stopped includes frame information. mi_gdb_test "34 next" \ @@ -52,3 +52,25 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi-cli.exp "34 next: run" if {!$async} { +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.mi/mi-logging.exp +=================================================================== +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.mi/mi-logging.exp 2012-06-29 00:11:23.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.mi/mi-logging.exp 2012-07-03 20:29:03.573717651 +0200 +@@ -56,7 +56,7 @@ close $chan + + set mi_log_prompt "\[(\]gdb\[)\] \[\r\n\]+" + +-if [regexp "\\^done\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] { ++if [regexp "\\^done\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"1\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"1\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] { + pass "Log file contents" + } else { + fail "Log file contents" +@@ -79,7 +79,7 @@ set chan [open $milogfile] + set logcontent [read $chan] + close $chan + +-if [regexp "1001\\^done\[\r\n\]+$mi_log_prompt.*1002\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt.*1003\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] { ++if [regexp "1001\\^done\[\r\n\]+$mi_log_prompt.*1002\\^running\[\r\n\]+\\*running,thread-id=\"1\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt.*1003\\^running\[\r\n\]+\\*running,thread-id=\"1\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] { + pass "Redirect log file contents" + } else { + fail "Redirect log file contents" diff --git a/gdb-6.8-attach-signalled-detach-stopped.patch b/gdb-6.8-attach-signalled-detach-stopped.patch index 44cc7ba..13966f2 100644 --- a/gdb-6.8-attach-signalled-detach-stopped.patch +++ b/gdb-6.8-attach-signalled-detach-stopped.patch @@ -1,7 +1,7 @@ -Index: gdb-7.4.50.20120602/gdb/linux-nat.c +Index: gdb-7.4.50.20120703/gdb/linux-nat.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/linux-nat.c 2012-06-02 20:51:58.000000000 +0200 -+++ gdb-7.4.50.20120602/gdb/linux-nat.c 2012-06-02 20:54:30.127529159 +0200 +--- gdb-7.4.50.20120703.orig/gdb/linux-nat.c 2012-07-03 17:46:55.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/linux-nat.c 2012-07-03 17:57:29.608734933 +0200 @@ -180,6 +180,9 @@ blocked. */ static struct target_ops *linux_ops; static struct target_ops linux_ops_saved; @@ -55,8 +55,8 @@ Index: gdb-7.4.50.20120602/gdb/linux-nat.c } /* Resume LP. */ -@@ -2083,6 +2099,14 @@ linux_nat_resume (struct target_ops *ops - resume_callback. */ +@@ -2104,6 +2120,14 @@ linux_nat_resume (struct target_ops *ops + linux_nat_resume_callback. */ lp->stopped = 0; + /* At this point, we are going to resume the inferior and if we @@ -68,9 +68,9 @@ Index: gdb-7.4.50.20120602/gdb/linux-nat.c + pid_was_stopped = 0; + if (resume_many) - iterate_over_lwps (ptid, resume_callback, NULL); + iterate_over_lwps (ptid, linux_nat_resume_callback, NULL); -@@ -4132,6 +4156,8 @@ linux_nat_mourn_inferior (struct target_ +@@ -4129,6 +4153,8 @@ linux_nat_mourn_inferior (struct target_ there are other viable forks to debug. Delete the exiting one and context-switch to the first available. */ linux_fork_mourn_inferior (); @@ -79,11 +79,11 @@ Index: gdb-7.4.50.20120602/gdb/linux-nat.c } /* Convert a native/host siginfo object, into/from the siginfo in the -Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/attach-stopped.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/attach-stopped.exp =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/testsuite/gdb.threads/attach-stopped.exp 2012-01-04 09:27:55.000000000 +0100 -+++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/attach-stopped.exp 2012-06-02 20:52:08.893505403 +0200 -@@ -63,7 +63,65 @@ proc corefunc { threadtype } { +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.threads/attach-stopped.exp 2012-06-26 21:23:20.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/attach-stopped.exp 2012-07-03 17:56:43.797790120 +0200 +@@ -61,7 +61,65 @@ proc corefunc { threadtype } { gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} diff --git a/gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch b/gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch index b011658..becf80e 100644 --- a/gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch +++ b/gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch @@ -1,8 +1,8 @@ -Index: gdb-7.3.50.20110722/gdb/dwarf2read.c +Index: gdb-7.4.50.20120703/gdb/gdb_bfd.c =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/dwarf2read.c 2011-07-22 19:37:15.000000000 +0200 -+++ gdb-7.3.50.20110722/gdb/dwarf2read.c 2011-07-22 19:44:42.000000000 +0200 -@@ -67,12 +67,14 @@ +--- gdb-7.4.50.20120703.orig/gdb/gdb_bfd.c 2012-07-03 17:30:07.356754655 +0200 ++++ gdb-7.4.50.20120703/gdb/gdb_bfd.c 2012-07-03 17:43:52.565762454 +0200 +@@ -26,12 +26,14 @@ #ifdef HAVE_ZLIB_H #include #endif @@ -15,37 +15,37 @@ Index: gdb-7.3.50.20110722/gdb/dwarf2read.c #endif +#endif - typedef struct symbol *symbolp; - DEF_VEC_P (symbolp); -@@ -1618,6 +1620,7 @@ dwarf2_read_section (struct objfile *obj + /* An object of this type is stored in the section's user data when + mapping a section. */ +@@ -181,6 +183,7 @@ free_one_bfd_section (bfd *abfd, asectio + + if (sect != NULL && sect->data != NULL) + { ++#ifndef __sparc__ + #ifdef HAVE_MMAP + if (sect->map_addr != NULL) + { +@@ -191,6 +194,7 @@ free_one_bfd_section (bfd *abfd, asectio + } + else + #endif ++#endif + xfree (sect->data); + } + } +@@ -425,6 +429,7 @@ gdb_bfd_map_section (asection *sectp, bf } } +#ifndef __sparc__ #ifdef HAVE_MMAP - if (pagesize == 0) - pagesize = getpagesize (); -@@ -1641,6 +1644,7 @@ dwarf2_read_section (struct objfile *obj - } - } - #endif + { + /* The page size, used when mmapping. */ +@@ -458,6 +463,7 @@ gdb_bfd_map_section (asection *sectp, bf + } + } + #endif /* HAVE_MMAP */ +#endif /* If we get here, we are a normal, not-compressed section. */ - info->buffer = buf -@@ -15983,6 +15987,7 @@ munmap_section_buffer (struct dwarf2_sec - { - if (info->map_addr != NULL) - { -+#ifndef __sparc__ - #ifdef HAVE_MMAP - int res; - -@@ -15992,6 +15997,7 @@ munmap_section_buffer (struct dwarf2_sec - /* Without HAVE_MMAP, we should never be here to begin with. */ - gdb_assert_not_reached ("no mmap support"); - #endif -+#endif - } - } diff --git a/gdb-archer.patch b/gdb-archer.patch index 6b4e799..0d15626 100644 --- a/gdb-archer.patch +++ b/gdb-archer.patch @@ -2,18 +2,46 @@ http://sourceware.org/gdb/wiki/ProjectArcher http://sourceware.org/gdb/wiki/ArcherBranchManagement GIT snapshot: -commit d10213220191589814714d71ef0f5ba64fbc3b75 +commit f07a2a24c493eebc9df6b7c9ca8c7fe0813aaffd branch `archer' - the merge of branches: archer-jankratochvil-vla archer-tromey-python +archer-tromey-dwz-multifile-rebase diff --git a/gdb/Makefile.in b/gdb/Makefile.in -index bf6b0da..f0d46dd 100644 +index a41cff9..d7786a6 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in -@@ -1304,6 +1304,12 @@ stamp-h: $(srcdir)/config.in config.status +@@ -704,7 +704,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \ + exceptions.c expprint.c \ + f-exp.y f-lang.c f-typeprint.c f-valprint.c filesystem.c \ + findcmd.c findvar.c frame.c frame-base.c frame-unwind.c \ +- gdbarch.c arch-utils.c gdbtypes.c gnu-v2-abi.c gnu-v3-abi.c \ ++ gdbarch.c arch-utils.c gdb_bfd.c gdbtypes.c gnu-v2-abi.c gnu-v3-abi.c \ + go-exp.y go-lang.c go-typeprint.c go-valprint.c \ + inf-loop.c \ + infcall.c \ +@@ -829,7 +829,7 @@ gnulib/import/extra/snippet/warn-on-use.h \ + gnulib/import/stddef.in.h gnulib/import/inttypes.in.h inline-frame.h skip.h \ + common/common-utils.h common/xml-utils.h common/buffer.h common/ptid.h \ + common/format.h \ +-common/linux-osdata.h gdb-dlfcn.h auto-load.h probe.h stap-probe.h ++common/linux-osdata.h gdb-dlfcn.h auto-load.h probe.h stap-probe.h gdb_bfd.h + + # Header files that already have srcdir in them, or which are in objdir. + +@@ -879,7 +879,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ + macrotab.o macrocmd.o macroexp.o macroscope.o \ + mi-common.o \ + event-loop.o event-top.o inf-loop.o completer.o \ +- gdbarch.o arch-utils.o gdbtypes.o osabi.o copying.o \ ++ gdbarch.o arch-utils.o gdbtypes.o gdb_bfd.o osabi.o copying.o \ + memattr.o mem-break.o target.o parse.o language.o buildsym.o \ + findcmd.o \ + std-regs.o \ +@@ -1307,6 +1307,12 @@ stamp-h: $(srcdir)/config.in config.status CONFIG_LINKS= \ $(SHELL) config.status @@ -27,10 +55,10 @@ index bf6b0da..f0d46dd 100644 $(SHELL) config.status --recheck diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c -index af0fdb5..02c6e6f 100644 +index aa090af..e672731 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c -@@ -12055,6 +12055,7 @@ ada_operator_length (const struct expression *exp, int pc, int *oplenp, +@@ -12037,6 +12037,7 @@ ada_operator_length (const struct expression *exp, int pc, int *oplenp, static int ada_operator_check (struct expression *exp, int pos, @@ -38,7 +66,7 @@ index af0fdb5..02c6e6f 100644 int (*objfile_func) (struct objfile *objfile, void *data), void *data) { -@@ -12069,12 +12070,15 @@ ada_operator_check (struct expression *exp, int pos, +@@ -12051,12 +12052,15 @@ ada_operator_check (struct expression *exp, int pos, break; default: @@ -56,11 +84,41 @@ index af0fdb5..02c6e6f 100644 && (*objfile_func) (TYPE_OBJFILE (type), data)) return 1; +diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c +index 6728800..21f53bb 100644 +--- a/gdb/bfd-target.c ++++ b/gdb/bfd-target.c +@@ -21,6 +21,7 @@ + #include "target.h" + #include "bfd-target.h" + #include "exec.h" ++#include "gdb_bfd.h" + + /* The object that is stored in the target_ops->to_data field has this + type. */ +@@ -70,7 +71,7 @@ target_bfd_xclose (struct target_ops *t, int quitting) + { + struct target_bfd_data *data = t->to_data; + +- bfd_close (data->bfd); ++ gdb_bfd_unref (data->bfd); + xfree (data->table.sections); + xfree (data); + xfree (t); +@@ -83,7 +84,7 @@ target_bfd_reopen (struct bfd *abfd) + struct target_bfd_data *data; + + data = XZALLOC (struct target_bfd_data); +- data->bfd = abfd; ++ data->bfd = gdb_bfd_ref (abfd); + build_section_table (abfd, &data->table.sections, &data->table.sections_end); + + t = XZALLOC (struct target_ops); diff --git a/gdb/block.c b/gdb/block.c -index 1503730..a522bca 100644 +index a0f82ec..097dbf6 100644 --- a/gdb/block.c +++ b/gdb/block.c -@@ -687,3 +687,21 @@ block_iter_match_next (const char *name, +@@ -692,3 +692,21 @@ block_iter_match_next (const char *name, return block_iter_match_step (iterator, name, compare, 0); } @@ -94,10 +152,10 @@ index 99c4788..6ceb704 100644 + #endif /* BLOCK_H */ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c -index a867b10..e41c692 100644 +index 555694e..9216405 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c -@@ -15154,6 +15154,24 @@ all_tracepoints (void) +@@ -15525,6 +15525,24 @@ all_tracepoints (void) return tp_vec; } @@ -122,7 +180,7 @@ index a867b10..e41c692 100644 /* This help string is used for the break, hbreak, tbreak and thbreak commands. It is defined as a macro to prevent duplication. -@@ -16097,4 +16115,7 @@ Show the channel to use for dynamic printf"), NULL, +@@ -16490,4 +16508,7 @@ agent-printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\ automatic_hardware_breakpoints = 1; observer_attach_about_to_proceed (breakpoint_about_to_proceed); @@ -130,6 +188,58 @@ index a867b10..e41c692 100644 + observer_attach_mark_used (breakpoint_types_mark_used); +#endif } +diff --git a/gdb/buildsym.c b/gdb/buildsym.c +index f1fb4be..54a0ea3 100644 +--- a/gdb/buildsym.c ++++ b/gdb/buildsym.c +@@ -941,7 +941,8 @@ block_compar (const void *ap, const void *bp) + never know about this empty file (FIXME). */ + + struct symtab * +-end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section) ++end_symtab_full (CORE_ADDR end_addr, struct objfile *objfile, int section, ++ int required) + { + struct symtab *symtab = NULL; + struct blockvector *blockvector; +@@ -1013,7 +1014,8 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section) + cleanup_undefined_stabs_types (objfile); + finish_global_stabs (objfile); + +- if (pending_blocks == NULL ++ if (!required ++ && pending_blocks == NULL + && file_symbols == NULL + && global_symbols == NULL + && have_line_numbers == 0 +@@ -1219,6 +1221,12 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section) + return symtab; + } + ++struct symtab * ++end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section) ++{ ++ return end_symtab_full (end_addr, objfile, section, 0); ++} ++ + /* Push a context block. Args are an identifying nesting level + (checkable when you pop it), and the starting PC address of this + context. */ +diff --git a/gdb/buildsym.h b/gdb/buildsym.h +index 4448267..7d9b97c 100644 +--- a/gdb/buildsym.h ++++ b/gdb/buildsym.h +@@ -261,6 +261,10 @@ extern char *pop_subfile (void); + extern struct symtab *end_symtab (CORE_ADDR end_addr, + struct objfile *objfile, int section); + ++extern struct symtab *end_symtab_full (CORE_ADDR end_addr, ++ struct objfile *objfile, int section, ++ int required); ++ + /* Defined in stabsread.c. */ + + extern void scan_file_globals (struct objfile *objfile); diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index a5892b5..2944c2d 100644 --- a/gdb/c-typeprint.c @@ -152,6 +262,492 @@ index a5892b5..2944c2d 100644 fprintf_filtered (stream, "]"); c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, +diff --git a/gdb/cc-with-dwz.sh b/gdb/cc-with-dwz.sh +deleted file mode 100755 +index f66deb1..0000000 +--- a/gdb/cc-with-dwz.sh ++++ /dev/null +@@ -1,80 +0,0 @@ +-#! /bin/sh +-# Wrapper around gcc to run 'dwz' when running the testsuite. +- +-# Copyright (C) 2010-2012 Free Software Foundation, Inc. +-# This program is free software; you can redistribute it and/or modify +-# it under the terms of the GNU General Public License as published by +-# the Free Software Foundation; either version 3 of the License, or +-# (at your option) any later version. +-# +-# This program is distributed in the hope that it will be useful, +-# but WITHOUT ANY WARRANTY; without even the implied warranty of +-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-# GNU General Public License for more details. +-# +-# You should have received a copy of the GNU General Public License +-# along with this program. If not, see . +- +-# This program requires dwz in addition to gcc. +-# +-# Example usage: +-# +-# bash$ cd $objdir/gdb/testsuite +-# bash$ runtest \ +-# CC_FOR_TARGET="/bin/sh $srcdir/cc-with-dwz.sh gcc" \ +-# CXX_FOR_TARGET="/bin/sh $srcdir/cc-with-dwz.sh g++" +-# +- +-myname=cc-with-dwz.sh +- +-DWZ=${DWZ:-dwz} +- +-have_link=unknown +-next_is_output_file=no +-output_file=a.out +- +-for arg in "$@" +-do +- if [ "$next_is_output_file" = "yes" ] +- then +- output_file="$arg" +- next_is_output_file=no +- continue +- fi +- +- # Poor man's gcc argument parser. +- # We don't need to handle all arguments, we just need to know if we're +- # doing a link and what the output file is. +- # It's not perfect, but it seems to work well enough for the task at hand. +- case "$arg" in +- "-c") have_link=no ;; +- "-E") have_link=no ;; +- "-S") have_link=no ;; +- "-o") next_is_output_file=yes ;; +- esac +-done +- +-if [ "$next_is_output_file" = "yes" ] +-then +- echo "$myname: Unable to find output file" >&2 +- exit 1 +-fi +- +-if [ "$have_link" = "no" ] +-then +- "$@" +- exit $? +-fi +- +-"$@" +-rc=$? +-[ $rc != 0 ] && exit $rc +-if [ ! -f "$output_file" ] +-then +- echo "$myname: Internal error: $output_file missing." >&2 +- exit 1 +-fi +- +-$DWZ "$output_file" > /dev/null 2>&1 +- +-exit 0 +diff --git a/gdb/cc-with-index.sh b/gdb/cc-with-index.sh +deleted file mode 100644 +index 644ba34..0000000 +--- a/gdb/cc-with-index.sh ++++ /dev/null +@@ -1,126 +0,0 @@ +-#! /bin/sh +-# Wrapper around gcc to add the .gdb_index section when running the testsuite. +- +-# Copyright (C) 2010-2012 Free Software Foundation, Inc. +-# This program is free software; you can redistribute it and/or modify +-# it under the terms of the GNU General Public License as published by +-# the Free Software Foundation; either version 3 of the License, or +-# (at your option) any later version. +-# +-# This program is distributed in the hope that it will be useful, +-# but WITHOUT ANY WARRANTY; without even the implied warranty of +-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-# GNU General Public License for more details. +-# +-# You should have received a copy of the GNU General Public License +-# along with this program. If not, see . +- +-# This program requires gdb and objcopy in addition to gcc. +-# The default values are gdb from the build tree and objcopy from $PATH. +-# They may be overridden by setting environment variables GDB and OBJCOPY +-# respectively. +-# We assume the current directory is either $obj/gdb or $obj/gdb/testsuite. +-# +-# Example usage: +-# +-# bash$ cd $objdir/gdb/testsuite +-# bash$ runtest \ +-# CC_FOR_TARGET="/bin/sh $srcdir/cc-with-index.sh gcc" \ +-# CXX_FOR_TARGET="/bin/sh $srcdir/cc-with-index.sh g++" +-# +-# For documentation on index files: info -f gdb.info -n "Index Files" +- +-myname=cc-with-index.sh +- +-if [ -z "$GDB" ] +-then +- if [ -f ./gdb ] +- then +- GDB="./gdb" +- elif [ -f ../gdb ] +- then +- GDB="../gdb" +- elif [ -f ../../gdb ] +- then +- GDB="../../gdb" +- else +- echo "$myname: unable to find usable gdb" >&2 +- exit 1 +- fi +-fi +- +-OBJCOPY=${OBJCOPY:-objcopy} +- +-have_link=unknown +-next_is_output_file=no +-output_file=a.out +- +-for arg in "$@" +-do +- if [ "$next_is_output_file" = "yes" ] +- then +- output_file="$arg" +- next_is_output_file=no +- continue +- fi +- +- # Poor man's gcc argument parser. +- # We don't need to handle all arguments, we just need to know if we're +- # doing a link and what the output file is. +- # It's not perfect, but it seems to work well enough for the task at hand. +- case "$arg" in +- "-c") have_link=no ;; +- "-E") have_link=no ;; +- "-S") have_link=no ;; +- "-o") next_is_output_file=yes ;; +- esac +-done +- +-if [ "$next_is_output_file" = "yes" ] +-then +- echo "$myname: Unable to find output file" >&2 +- exit 1 +-fi +- +-if [ "$have_link" = "no" ] +-then +- "$@" +- exit $? +-fi +- +-index_file="${output_file}.gdb-index" +-if [ -f "$index_file" ] +-then +- echo "$myname: Index file $index_file exists, won't clobber." >&2 +- exit 1 +-fi +- +-output_dir="${output_file%/*}" +-[ "$output_dir" = "$output_file" ] && output_dir="." +- +-"$@" +-rc=$? +-[ $rc != 0 ] && exit $rc +-if [ ! -f "$output_file" ] +-then +- echo "$myname: Internal error: $output_file missing." >&2 +- exit 1 +-fi +- +-$GDB --batch-silent -nx -ex "set auto-load no" -ex "file $output_file" -ex "save gdb-index $output_dir" +-rc=$? +-[ $rc != 0 ] && exit $rc +- +-# GDB might not always create an index. Cope. +-if [ -f "$index_file" ] +-then +- $OBJCOPY --add-section .gdb_index="$index_file" \ +- --set-section-flags .gdb_index=readonly \ +- "$output_file" "$output_file" +- rc=$? +-else +- rc=0 +-fi +- +-rm -f "$index_file" +-exit $rc +diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c +index 4a8b5d1..1244767 100644 +--- a/gdb/cli/cli-dump.c ++++ b/gdb/cli/cli-dump.c +@@ -32,6 +32,7 @@ + #include "readline/readline.h" + #include "gdbcore.h" + #include "cli/cli-utils.h" ++#include "gdb_bfd.h" + + #define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE))) + +@@ -111,12 +112,12 @@ bfd_openr_with_cleanup (const char *filename, const char *target) + { + bfd *ibfd; + +- ibfd = bfd_openr (filename, target); ++ ibfd = gdb_bfd_ref (bfd_openr (filename, target)); + if (ibfd == NULL) + error (_("Failed to open %s: %s."), filename, + bfd_errmsg (bfd_get_error ())); + +- make_cleanup_bfd_close (ibfd); ++ make_cleanup_bfd_unref (ibfd); + if (!bfd_check_format (ibfd, bfd_object)) + error (_("'%s' is not a recognized file format."), filename); + +@@ -131,11 +132,11 @@ bfd_openw_with_cleanup (const char *filename, const char *target, + + if (*mode == 'w') /* Write: create new file */ + { +- obfd = bfd_openw (filename, target); ++ obfd = gdb_bfd_ref (bfd_openw (filename, target)); + if (obfd == NULL) + error (_("Failed to open %s: %s."), filename, + bfd_errmsg (bfd_get_error ())); +- make_cleanup_bfd_close (obfd); ++ make_cleanup_bfd_unref (obfd); + if (!bfd_set_format (obfd, bfd_object)) + error (_("bfd_openw_with_cleanup: %s."), bfd_errmsg (bfd_get_error ())); + } +diff --git a/gdb/contrib/cc-with-tweaks.sh b/gdb/contrib/cc-with-tweaks.sh +new file mode 100755 +index 0000000..9270db4 +--- /dev/null ++++ b/gdb/contrib/cc-with-tweaks.sh +@@ -0,0 +1,162 @@ ++#! /bin/sh ++# Wrapper around gcc to tweak the output in various ways when running ++# the testsuite. ++ ++# Copyright (C) 2010-2012 Free Software Foundation, Inc. ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# This program requires gdb and objcopy in addition to gcc. ++# The default values are gdb from the build tree and objcopy from $PATH. ++# They may be overridden by setting environment variables GDB and OBJCOPY ++# respectively. ++# We assume the current directory is either $obj/gdb or $obj/gdb/testsuite. ++# ++# Example usage: ++# ++# bash$ cd $objdir/gdb/testsuite ++# bash$ runtest \ ++# CC_FOR_TARGET="/bin/sh $srcdir/cc-with-tweaks.sh ARGS gcc" \ ++# CXX_FOR_TARGET="/bin/sh $srcdir/cc-with-tweaks.sh ARGS g++" ++# ++# For documentation on index files: info -f gdb.info -n "Index Files" ++# For information about 'dwz', see the announcement: ++# http://gcc.gnu.org/ml/gcc/2012-04/msg00686.html ++# (More documentation is to come.) ++ ++# ARGS determine what is done. They can be: ++# -z compress using dwz ++# -m compress using dwz -m ++# -i make an index ++# If nothing is given, no changes are made ++ ++myname=cc-with-tweaks.sh ++ ++if [ -z "$GDB" ] ++then ++ if [ -f ./gdb ] ++ then ++ GDB="./gdb" ++ elif [ -f ../gdb ] ++ then ++ GDB="../gdb" ++ elif [ -f ../../gdb ] ++ then ++ GDB="../../gdb" ++ else ++ echo "$myname: unable to find usable gdb" >&2 ++ exit 1 ++ fi ++fi ++ ++OBJCOPY=${OBJCOPY:-objcopy} ++ ++DWZ=${DWZ:-dwz} ++ ++have_link=unknown ++next_is_output_file=no ++output_file=a.out ++ ++want_index=false ++want_dwz=false ++want_multi=false ++ ++while [ $# -gt 0 ]; do ++ case "$1" in ++ -z) want_dwz=true ;; ++ -i) want_index=true ;; ++ -m) want_multi=true ;; ++ *) break ;; ++ esac ++ shift ++done ++ ++for arg in "$@" ++do ++ if [ "$next_is_output_file" = "yes" ] ++ then ++ output_file="$arg" ++ next_is_output_file=no ++ continue ++ fi ++ ++ # Poor man's gcc argument parser. ++ # We don't need to handle all arguments, we just need to know if we're ++ # doing a link and what the output file is. ++ # It's not perfect, but it seems to work well enough for the task at hand. ++ case "$arg" in ++ "-c") have_link=no ;; ++ "-E") have_link=no ;; ++ "-S") have_link=no ;; ++ "-o") next_is_output_file=yes ;; ++ esac ++done ++ ++if [ "$next_is_output_file" = "yes" ] ++then ++ echo "$myname: Unable to find output file" >&2 ++ exit 1 ++fi ++ ++if [ "$have_link" = "no" ] ++then ++ "$@" ++ exit $? ++fi ++ ++index_file="${output_file}.gdb-index" ++if [ "$want_index" = true ] && [ -f "$index_file" ] ++then ++ echo "$myname: Index file $index_file exists, won't clobber." >&2 ++ exit 1 ++fi ++ ++output_dir="${output_file%/*}" ++[ "$output_dir" = "$output_file" ] && output_dir="." ++ ++"$@" ++rc=$? ++[ $rc != 0 ] && exit $rc ++if [ ! -f "$output_file" ] ++then ++ echo "$myname: Internal error: $output_file missing." >&2 ++ exit 1 ++fi ++ ++if [ "$want_index" = true ]; then ++ $GDB --batch-silent -nx -ex "set auto-load no" -ex "file $output_file" -ex "save gdb-index $output_dir" ++ rc=$? ++ [ $rc != 0 ] && exit $rc ++ ++ # GDB might not always create an index. Cope. ++ if [ -f "$index_file" ] ++ then ++ $OBJCOPY --add-section .gdb_index="$index_file" \ ++ --set-section-flags .gdb_index=readonly \ ++ "$output_file" "$output_file" ++ rc=$? ++ else ++ rc=0 ++ fi ++ [ $rc != 0 ] && exit $rc ++fi ++ ++if [ "$want_dwz" = true ]; then ++ $DWZ "$output_file" > /dev/null 2>&1 ++elif [ "$want_multi" = true ]; then ++ cp $output_file ${output_file}.alt ++ $DWZ -m ${output_file}.dwz "$output_file" ${output_file}.alt > /dev/null 2>&1 ++fi ++ ++rm -f "$index_file" ++exit $rc +diff --git a/gdb/corelow.c b/gdb/corelow.c +index dd62560..380c0dc 100644 +--- a/gdb/corelow.c ++++ b/gdb/corelow.c +@@ -46,6 +46,7 @@ + #include "filenames.h" + #include "progspace.h" + #include "objfiles.h" ++#include "gdb_bfd.h" + + #ifndef O_LARGEFILE + #define O_LARGEFILE 0 +@@ -215,9 +216,7 @@ core_close (int quitting) + core_data = NULL; + } + +- name = bfd_get_filename (core_bfd); +- gdb_bfd_close_or_warn (core_bfd); +- xfree (name); ++ gdb_bfd_unref (core_bfd); + core_bfd = NULL; + } + core_vec = NULL; +@@ -319,12 +318,14 @@ core_open (char *filename, int from_tty) + if (scratch_chan < 0) + perror_with_name (filename); + +- temp_bfd = bfd_fopen (filename, gnutarget, +- write_files ? FOPEN_RUB : FOPEN_RB, +- scratch_chan); ++ temp_bfd = gdb_bfd_ref (bfd_fopen (filename, gnutarget, ++ write_files ? FOPEN_RUB : FOPEN_RB, ++ scratch_chan)); + if (temp_bfd == NULL) + perror_with_name (filename); + ++ gdb_bfd_stash_filename (temp_bfd); ++ + if (!bfd_check_format (temp_bfd, bfd_core) + && !gdb_check_format (temp_bfd)) + { +@@ -332,7 +333,7 @@ core_open (char *filename, int from_tty) + /* FIXME: should be checking for errors from bfd_close (for one + thing, on error it does not free all the storage associated + with the bfd). */ +- make_cleanup_bfd_close (temp_bfd); ++ make_cleanup_bfd_unref (temp_bfd); + error (_("\"%s\" is not a core dump: %s"), + filename, bfd_errmsg (bfd_get_error ())); + } +@@ -340,7 +341,7 @@ core_open (char *filename, int from_tty) + /* Looks semi-reasonable. Toss the old core file and work on the + new. */ + +- discard_cleanups (old_chain); /* Don't free filename any more */ ++ do_cleanups (old_chain); + unpush_target (&core_ops); + core_bfd = temp_bfd; + old_chain = make_cleanup (core_close_cleanup, 0 /*ignore*/); diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in index 87c6dd4..1c26652 100644 --- a/gdb/data-directory/Makefile.in @@ -187,9 +783,18 @@ index 87c6dd4..1c26652 100644 FLAGS_TO_PASS = \ "prefix=$(prefix)" \ diff --git a/gdb/defs.h b/gdb/defs.h -index 03092aa..6d73386 100644 +index 1c6fa79..ec08348 100644 --- a/gdb/defs.h +++ b/gdb/defs.h +@@ -315,7 +315,7 @@ extern struct cleanup *make_cleanup_close (int fd); + + extern struct cleanup *make_cleanup_fclose (FILE *file); + +-extern struct cleanup *make_cleanup_bfd_close (bfd *abfd); ++extern struct cleanup *make_cleanup_bfd_unref (bfd *abfd); + + struct obstack; + extern struct cleanup *make_cleanup_obstack_free (struct obstack *obstack); @@ -353,6 +353,8 @@ extern struct cleanup *make_cleanup_restore_page_info (void); extern struct cleanup * set_batch_flag_and_make_cleanup_restore_page_info (void); @@ -200,10 +805,10 @@ index 03092aa..6d73386 100644 extern char *xfullpath (const char *); diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo -index 014cfd8..d0a8c51 100644 +index d324a93..9ccf7f1 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo -@@ -1191,6 +1191,16 @@ for remote debugging. +@@ -1194,6 +1194,16 @@ for remote debugging. Run using @var{device} for your program's standard input and output. @c FIXME: kingdon thinks there is more to -tty. Investigate. @@ -220,7 +825,7 @@ index 014cfd8..d0a8c51 100644 @c resolve the situation of these eventually @item -tui @cindex @code{--tui} -@@ -22494,8 +22504,6 @@ containing @code{end}. For example: +@@ -22541,8 +22551,6 @@ containing @code{end}. For example: @smallexample (@value{GDBP}) python @@ -229,7 +834,7 @@ index 014cfd8..d0a8c51 100644 >print 23 >end 23 -@@ -22509,6 +22517,14 @@ controlled using @code{set python print-stack}: if @code{full}, then +@@ -22556,6 +22564,14 @@ controlled using @code{set python print-stack}: if @code{full}, then full Python stack printing is enabled; if @code{none}, then Python stack and message printing is disabled; if @code{message}, the default, only the message component of the error is printed. @@ -244,7 +849,7 @@ index 014cfd8..d0a8c51 100644 @end table It is also possible to execute a Python script from the @value{GDBN} -@@ -22530,6 +22546,14 @@ and thus is always available. +@@ -22577,6 +22593,14 @@ and thus is always available. @cindex python api @cindex programming in python @@ -260,7 +865,7 @@ index 014cfd8..d0a8c51 100644 @cindex python pagination At startup, @value{GDBN} overrides Python's @code{sys.stdout} and diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo -index 267a6eb..4f159b4 100644 +index 9a440ef..dd04633 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -2103,6 +2103,18 @@ time, and so we attempt to handle symbols incrementally. For instance, @@ -404,11 +1009,55 @@ index 6827ed8..c63b901 100644 @deftypefun void test_notification (int @var{somearg}) This observer is used for internal testing. Do not use. See testsuite/gdb.gdb/observer.exp. +diff --git a/gdb/dsrec.c b/gdb/dsrec.c +index d2c99b2..66d4c13 100644 +--- a/gdb/dsrec.c ++++ b/gdb/dsrec.c +@@ -23,6 +23,7 @@ + #include + #include "gdb_assert.h" + #include "gdb_string.h" ++#include "gdb_bfd.h" + + extern void report_transfer_performance (unsigned long, time_t, time_t); + +@@ -56,19 +57,22 @@ load_srec (struct serial *desc, const char *file, bfd_vma load_offset, + int reclen; + time_t start_time, end_time; + unsigned long data_count = 0; ++ struct cleanup *cleanup; + + srec = (char *) alloca (maxrecsize + 1); + +- abfd = bfd_openr (file, 0); ++ abfd = gdb_bfd_ref (bfd_openr (file, 0)); + if (!abfd) + { + printf_filtered (_("Unable to open file %s\n"), file); + return; + } + ++ cleanup = make_cleanup_bfd_unref (abfd); + if (bfd_check_format (abfd, bfd_object) == 0) + { + printf_filtered (_("File is not an object file\n")); ++ do_cleanups (cleanup); + return; + } + +@@ -170,6 +174,7 @@ load_srec (struct serial *desc, const char *file, bfd_vma load_offset, + serial_flush_input (desc); + + report_transfer_performance (data_count, start_time, end_time); ++ do_cleanups (cleanup); + } + + /* diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c -index e0aafc7..7387711 100644 +index 214b371..d9b3751 100644 --- a/gdb/dwarf2expr.c +++ b/gdb/dwarf2expr.c -@@ -1458,6 +1458,14 @@ execute_stack_op (struct dwarf_expr_context *ctx, +@@ -1480,6 +1480,14 @@ execute_stack_op (struct dwarf_expr_context *ctx, } break; @@ -424,7 +1073,7 @@ index e0aafc7..7387711 100644 error (_("Unhandled dwarf expression opcode 0x%x"), op); } diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h -index f39ef3c..066cb10 100644 +index db49b9c..3ae0be1 100644 --- a/gdb/dwarf2expr.h +++ b/gdb/dwarf2expr.h @@ -91,12 +91,8 @@ struct dwarf_expr_context_funcs @@ -441,10 +1090,10 @@ index f39ef3c..066cb10 100644 /* The location of a value. */ diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c -index 8c97f19..a6f3e9c 100644 +index 6feeab6..80dd9bc 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c -@@ -274,6 +274,9 @@ struct dwarf_expr_baton +@@ -293,6 +293,9 @@ struct dwarf_expr_baton { struct frame_info *frame; struct dwarf2_per_cu_data *per_cu; @@ -454,7 +1103,7 @@ index 8c97f19..a6f3e9c 100644 }; /* Helper functions for dwarf2_evaluate_loc_desc. */ -@@ -333,16 +336,14 @@ static void +@@ -352,16 +355,14 @@ static void dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, const gdb_byte **start, size_t *length) { @@ -473,7 +1122,7 @@ index 8c97f19..a6f3e9c 100644 { struct dwarf2_locexpr_baton *symbaton; -@@ -355,10 +356,23 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, +@@ -374,10 +375,23 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, else *length = 0; } @@ -498,7 +1147,7 @@ index 8c97f19..a6f3e9c 100644 } /* Helper function for dwarf2_evaluate_loc_desc. Computes the CFA for -@@ -426,6 +440,85 @@ dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset) +@@ -445,6 +459,85 @@ dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset) ctx->funcs->get_frame_pc, ctx->baton); } @@ -584,7 +1233,7 @@ index 8c97f19..a6f3e9c 100644 /* Callback function for dwarf2_evaluate_loc_desc. */ static struct type * -@@ -1105,10 +1198,12 @@ dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, +@@ -1139,10 +1232,12 @@ dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, saved_ctx.gdbarch = ctx->gdbarch; saved_ctx.addr_size = ctx->addr_size; @@ -597,7 +1246,7 @@ index 8c97f19..a6f3e9c 100644 ctx->offset = dwarf2_per_cu_text_offset (baton_local.per_cu); ctx->baton = &baton_local; -@@ -1116,10 +1211,95 @@ dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, +@@ -1150,10 +1245,95 @@ dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, ctx->gdbarch = saved_ctx.gdbarch; ctx->addr_size = saved_ctx.addr_size; @@ -693,7 +1342,7 @@ index 8c97f19..a6f3e9c 100644 /* Callback function for dwarf2_evaluate_loc_desc. Fetch the address indexed by DW_OP_GNU_addr_index. */ -@@ -2053,22 +2233,6 @@ invalid_synthetic_pointer (void) +@@ -2088,22 +2268,6 @@ invalid_synthetic_pointer (void) "referenced via synthetic pointer")); } @@ -716,7 +1365,7 @@ index 8c97f19..a6f3e9c 100644 /* Evaluate a location description, starting at DATA and with length SIZE, to find the current location of variable of TYPE in the context of FRAME. BYTE_OFFSET is applied after the contents are -@@ -2081,7 +2245,6 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, +@@ -2116,7 +2280,6 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, LONGEST byte_offset) { struct value *retval; @@ -724,7 +1373,7 @@ index 8c97f19..a6f3e9c 100644 struct dwarf_expr_context *ctx; struct cleanup *old_chain, *value_chain; struct objfile *objfile = dwarf2_per_cu_objfile (per_cu); -@@ -2093,29 +2256,18 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, +@@ -2128,29 +2291,18 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, if (size == 0) return allocate_optimized_out_value (type); @@ -755,7 +1404,7 @@ index 8c97f19..a6f3e9c 100644 retval = allocate_value (type); mark_value_bytes_unavailable (retval, 0, TYPE_LENGTH (type)); return retval; -@@ -2179,6 +2331,16 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, +@@ -2214,6 +2366,16 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0); do_cleanups (value_chain); @@ -772,7 +1421,7 @@ index 8c97f19..a6f3e9c 100644 retval = allocate_value_lazy (type); VALUE_LVAL (retval) = lval_memory; if (in_stack_memory) -@@ -4048,8 +4210,7 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, +@@ -4124,8 +4286,7 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, dlbaton->per_cu); } @@ -782,7 +1431,7 @@ index 8c97f19..a6f3e9c 100644 const struct symbol_computed_ops dwarf2_loclist_funcs = { loclist_read_variable, loclist_read_variable_at_entry, -@@ -4058,6 +4219,48 @@ const struct symbol_computed_ops dwarf2_loclist_funcs = { +@@ -4134,6 +4295,48 @@ const struct symbol_computed_ops dwarf2_loclist_funcs = { loclist_tracepoint_var_ref }; @@ -852,10 +1501,145 @@ index e9d06a3..bfa6776 100644 /* Compile a DWARF location expression to an agent expression. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c -index 8dbc53e..b5b7813 100644 +index 52288e8..447dc25 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c -@@ -1348,6 +1348,9 @@ static void fill_in_loclist_baton (struct dwarf2_cu *cu, +@@ -64,20 +64,12 @@ + #include "gdbcore.h" /* for gnutarget */ + #include "gdb/gdb-index.h" + #include ++#include "gdb_bfd.h" + + #include + #include "gdb_string.h" + #include "gdb_assert.h" + #include +-#ifdef HAVE_ZLIB_H +-#include +-#endif +-#ifdef HAVE_MMAP +-#include +-#ifndef MAP_FAILED +-#define MAP_FAILED ((void *) -1) +-#endif +-#endif + + typedef struct symbol *symbolp; + DEF_VEC_P (symbolp); +@@ -95,8 +87,6 @@ static int check_physname = 0; + /* When non-zero, do not reject deprecated .gdb_index sections. */ + int use_deprecated_index_sections = 0; + +-static int pagesize; +- + /* When set, the file that we're processing is known to have debugging + info for C++ namespaces. GCC 3.3.x did not produce this information, + but later versions do. */ +@@ -110,10 +100,6 @@ struct dwarf2_section_info + asection *asection; + gdb_byte *buffer; + bfd_size_type size; +- /* Not NULL if the section was actually mmapped. */ +- void *map_addr; +- /* Page aligned size of mmapped area. */ +- bfd_size_type map_len; + /* True if we have tried to read this section. */ + int readin; + }; +@@ -226,6 +212,10 @@ struct dwarf2_per_objfile + This is NULL if the table hasn't been allocated yet. */ + htab_t dwo_files; + ++ /* The shared '.dwz' file, if one exists. This is used when the ++ original data was compressed using 'dwz -m'. */ ++ struct dwz_file *dwz_file; ++ + /* A flag indicating wether this objfile has a section loaded at a + VMA of 0. */ + int has_section_at_zero; +@@ -484,15 +474,13 @@ struct dwarf2_cu + + struct dwarf2_per_cu_data + { +- /* The start offset and length of this compilation unit. 2**29-1 +- bytes should suffice to store the length of any compilation unit +- - if it doesn't, GDB will fall over anyway. ++ /* The start offset and length of this compilation unit. + NOTE: Unlike comp_unit_head.length, this length includes + initial_length_size. + If the DIE refers to a DWO file, this is always of the original die, + not the DWO file. */ + sect_offset offset; +- unsigned int length : 29; ++ unsigned int length; + + /* Flag indicating this compilation unit will be read in before + any of the current compilation units are processed. */ +@@ -507,6 +495,9 @@ struct dwarf2_per_cu_data + /* Non-zero if this CU is from .debug_types. */ + unsigned int is_debug_types : 1; + ++ /* Non-zero if this CU is from the .dwz file. */ ++ unsigned int is_dwz : 1; ++ + /* The section this CU/TU lives in. + If the DIE refers to a DWO file, this is always the original die, + not the DWO file. */ +@@ -625,6 +616,22 @@ struct dwo_file + htab_t tus; + }; + ++/* This represents a '.dwz' file. */ ++ ++struct dwz_file ++{ ++ /* A dwz file can only contain a few sections. */ ++ struct dwarf2_section_info abbrev; ++ struct dwarf2_section_info info; ++ struct dwarf2_section_info str; ++ struct dwarf2_section_info line; ++ struct dwarf2_section_info macro; ++ struct dwarf2_section_info gdb_index; ++ ++ /* The dwz's BFD. */ ++ bfd *dwz_bfd; ++}; ++ + /* Struct used to pass misc. parameters to read_die_and_children, et + al. which are used for both .debug_info and .debug_types dies. + All parameters here are unchanging for the life of the call. This +@@ -738,6 +745,12 @@ struct partial_die_info + /* Flag set if fixup_partial_die has been called on this die. */ + unsigned int fixup_called : 1; + ++ /* Flag set if DW_TAG_imported_unit uses DW_FORM_GNU_ref_alt. */ ++ unsigned int is_dwz : 1; ++ ++ /* Flag set if spec_offset uses DW_FORM_GNU_ref_alt. */ ++ unsigned int spec_is_dwz : 1; ++ + /* The name of this DIE. Normally the value of DW_AT_name, but + sometimes a default name for unnamed DIEs. */ + char *name; +@@ -1121,7 +1134,7 @@ static gdb_byte *read_partial_die (const struct die_reader_specs *, + unsigned int, + gdb_byte *); + +-static struct partial_die_info *find_partial_die (sect_offset, ++static struct partial_die_info *find_partial_die (sect_offset, int, + struct dwarf2_cu *); + + static void fixup_partial_die (struct partial_die_info *, +@@ -1163,6 +1176,8 @@ static char *read_indirect_string (bfd *, gdb_byte *, + const struct comp_unit_head *, + unsigned int *); + ++static char *read_indirect_string_from_dwz (struct dwz_file *, LONGEST); ++ + static ULONGEST read_unsigned_leb128 (bfd *, gdb_byte *, unsigned int *); + + static LONGEST read_signed_leb128 (bfd *, gdb_byte *, unsigned int *); +@@ -1407,6 +1422,9 @@ static void fill_in_loclist_baton (struct dwarf2_cu *cu, struct dwarf2_loclist_baton *baton, struct attribute *attr); @@ -865,7 +1649,16 @@ index 8dbc53e..b5b7813 100644 static void dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, struct dwarf2_cu *cu); -@@ -1380,6 +1383,9 @@ static void age_cached_comp_units (void); +@@ -1422,7 +1440,7 @@ static hashval_t partial_die_hash (const void *item); + static int partial_die_eq (const void *item_lhs, const void *item_rhs); + + static struct dwarf2_per_cu_data *dwarf2_find_containing_comp_unit +- (sect_offset offset, struct objfile *objfile); ++ (sect_offset offset, unsigned int offset_in_dwz, struct objfile *objfile); + + static void init_one_comp_unit (struct dwarf2_cu *cu, + struct dwarf2_per_cu_data *per_cu); +@@ -1439,6 +1457,9 @@ static void age_cached_comp_units (void); static void free_one_cached_comp_unit (struct dwarf2_per_cu_data *); @@ -875,7 +1668,7 @@ index 8dbc53e..b5b7813 100644 static struct type *set_die_type (struct die_info *, struct type *, struct dwarf2_cu *); -@@ -1405,6 +1411,9 @@ static struct type *get_die_type_at_offset (sect_offset, +@@ -1464,6 +1485,9 @@ static struct type *get_die_type_at_offset (sect_offset, static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu); @@ -885,7 +1678,861 @@ index 8dbc53e..b5b7813 100644 static void dwarf2_release_queue (void *dummy); static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu, -@@ -9526,6 +9535,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -1482,6 +1506,12 @@ static void find_file_and_directory (struct die_info *die, + static char *file_full_name (int file, struct line_header *lh, + const char *comp_dir); + ++static gdb_byte *read_and_check_comp_unit_head ++ (struct comp_unit_head *header, ++ struct dwarf2_section_info *section, ++ struct dwarf2_section_info *abbrev_section, gdb_byte *info_ptr, ++ int is_debug_types_section); ++ + static void init_cutu_and_read_dies + (struct dwarf2_per_cu_data *this_cu, int use_existing_cu, int keep, + die_reader_func_ftype *die_reader_func, void *data); +@@ -1504,8 +1534,6 @@ static struct dwo_unit *lookup_dwo_type_unit + + static void free_dwo_file_cleanup (void *); + +-static void munmap_section_buffer (struct dwarf2_section_info *); +- + static void process_cu_includes (void); + + #if WORDS_BIGENDIAN +@@ -1675,85 +1703,6 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *vnames) + dwarf2_per_objfile->has_section_at_zero = 1; + } + +-/* Decompress a section that was compressed using zlib. Store the +- decompressed buffer, and its size, in OUTBUF and OUTSIZE. */ +- +-static void +-zlib_decompress_section (struct objfile *objfile, asection *sectp, +- gdb_byte **outbuf, bfd_size_type *outsize) +-{ +- bfd *abfd = sectp->owner; +-#ifndef HAVE_ZLIB_H +- error (_("Support for zlib-compressed DWARF data (from '%s') " +- "is disabled in this copy of GDB"), +- bfd_get_filename (abfd)); +-#else +- bfd_size_type compressed_size = bfd_get_section_size (sectp); +- gdb_byte *compressed_buffer = xmalloc (compressed_size); +- struct cleanup *cleanup = make_cleanup (xfree, compressed_buffer); +- bfd_size_type uncompressed_size; +- gdb_byte *uncompressed_buffer; +- z_stream strm; +- int rc; +- int header_size = 12; +- +- if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0 +- || bfd_bread (compressed_buffer, +- compressed_size, abfd) != compressed_size) +- error (_("Dwarf Error: Can't read DWARF data from '%s'"), +- bfd_get_filename (abfd)); +- +- /* Read the zlib header. In this case, it should be "ZLIB" followed +- by the uncompressed section size, 8 bytes in big-endian order. */ +- if (compressed_size < header_size +- || strncmp (compressed_buffer, "ZLIB", 4) != 0) +- error (_("Dwarf Error: Corrupt DWARF ZLIB header from '%s'"), +- bfd_get_filename (abfd)); +- uncompressed_size = compressed_buffer[4]; uncompressed_size <<= 8; +- uncompressed_size += compressed_buffer[5]; uncompressed_size <<= 8; +- uncompressed_size += compressed_buffer[6]; uncompressed_size <<= 8; +- uncompressed_size += compressed_buffer[7]; uncompressed_size <<= 8; +- uncompressed_size += compressed_buffer[8]; uncompressed_size <<= 8; +- uncompressed_size += compressed_buffer[9]; uncompressed_size <<= 8; +- uncompressed_size += compressed_buffer[10]; uncompressed_size <<= 8; +- uncompressed_size += compressed_buffer[11]; +- +- /* It is possible the section consists of several compressed +- buffers concatenated together, so we uncompress in a loop. */ +- strm.zalloc = NULL; +- strm.zfree = NULL; +- strm.opaque = NULL; +- strm.avail_in = compressed_size - header_size; +- strm.next_in = (Bytef*) compressed_buffer + header_size; +- strm.avail_out = uncompressed_size; +- uncompressed_buffer = obstack_alloc (&objfile->objfile_obstack, +- uncompressed_size); +- rc = inflateInit (&strm); +- while (strm.avail_in > 0) +- { +- if (rc != Z_OK) +- error (_("Dwarf Error: setting up DWARF uncompression in '%s': %d"), +- bfd_get_filename (abfd), rc); +- strm.next_out = ((Bytef*) uncompressed_buffer +- + (uncompressed_size - strm.avail_out)); +- rc = inflate (&strm, Z_FINISH); +- if (rc != Z_STREAM_END) +- error (_("Dwarf Error: zlib error uncompressing from '%s': %d"), +- bfd_get_filename (abfd), rc); +- rc = inflateReset (&strm); +- } +- rc = inflateEnd (&strm); +- if (rc != Z_OK +- || strm.avail_out != 0) +- error (_("Dwarf Error: concluding DWARF uncompression in '%s': %d"), +- bfd_get_filename (abfd), rc); +- +- do_cleanups (cleanup); +- *outbuf = uncompressed_buffer; +- *outsize = uncompressed_size; +-#endif +-} +- + /* A helper function that decides whether a section is empty, + or not present. */ + +@@ -1780,56 +1729,27 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) + if (info->readin) + return; + info->buffer = NULL; +- info->map_addr = NULL; + info->readin = 1; + + if (dwarf2_section_empty_p (info)) + return; + +- /* Note that ABFD may not be from OBJFILE, e.g. a DWO section. */ + abfd = sectp->owner; + +- /* Check if the file has a 4-byte header indicating compression. */ +- if (info->size > sizeof (header) +- && bfd_seek (abfd, sectp->filepos, SEEK_SET) == 0 +- && bfd_bread (header, sizeof (header), abfd) == sizeof (header)) +- { +- /* Upon decompression, update the buffer and its size. */ +- if (strncmp (header, "ZLIB", sizeof (header)) == 0) +- { +- zlib_decompress_section (objfile, sectp, &info->buffer, +- &info->size); +- return; +- } +- } +- +-#ifdef HAVE_MMAP +- if (pagesize == 0) +- pagesize = getpagesize (); +- +- /* Only try to mmap sections which are large enough: we don't want to +- waste space due to fragmentation. Also, only try mmap for sections +- without relocations. */ +- +- if (info->size > 4 * pagesize && (sectp->flags & SEC_RELOC) == 0) ++ /* If the section has relocations, we must read it ourselves. ++ Otherwise we attach it to the BFD. */ ++ if ((sectp->flags & SEC_RELOC) == 0) + { +- info->buffer = bfd_mmap (abfd, 0, info->size, PROT_READ, +- MAP_PRIVATE, sectp->filepos, +- &info->map_addr, &info->map_len); ++ const gdb_byte *bytes = gdb_bfd_map_section (sectp, &info->size); + +- if ((caddr_t)info->buffer != MAP_FAILED) +- { +-#if HAVE_POSIX_MADVISE +- posix_madvise (info->map_addr, info->map_len, POSIX_MADV_WILLNEED); +-#endif +- return; +- } ++ /* We have to cast away const here for historical reasons. ++ Fixing dwarf2read to be const-correct would be quite nice. */ ++ info->buffer = (gdb_byte *) bytes; ++ return; + } +-#endif + +- /* If we get here, we are a normal, not-compressed section. */ +- info->buffer = buf +- = obstack_alloc (&objfile->objfile_obstack, info->size); ++ buf = obstack_alloc (&objfile->objfile_obstack, info->size); ++ info->buffer = buf; + + /* When debugging .o files, we may need to apply relocations; see + http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html . +@@ -1905,6 +1825,111 @@ dwarf2_get_section_info (struct objfile *objfile, + *sizep = info->size; + } + ++/* A helper function to find the sections for a .dwz file. */ ++ ++static void ++locate_dwz_sections (bfd *abfd, asection *sectp, void *arg) ++{ ++ struct dwz_file *dwz_file = arg; ++ ++ /* Note that we only support the standard ELF names, because .dwz ++ is ELF-only (at the time of writing). */ ++ if (section_is_p (sectp->name, &dwarf2_elf_names.abbrev)) ++ { ++ dwz_file->abbrev.asection = sectp; ++ dwz_file->abbrev.size = bfd_get_section_size (sectp); ++ } ++ else if (section_is_p (sectp->name, &dwarf2_elf_names.info)) ++ { ++ dwz_file->info.asection = sectp; ++ dwz_file->info.size = bfd_get_section_size (sectp); ++ } ++ else if (section_is_p (sectp->name, &dwarf2_elf_names.str)) ++ { ++ dwz_file->str.asection = sectp; ++ dwz_file->str.size = bfd_get_section_size (sectp); ++ } ++ else if (section_is_p (sectp->name, &dwarf2_elf_names.line)) ++ { ++ dwz_file->line.asection = sectp; ++ dwz_file->line.size = bfd_get_section_size (sectp); ++ } ++ else if (section_is_p (sectp->name, &dwarf2_elf_names.macro)) ++ { ++ dwz_file->macro.asection = sectp; ++ dwz_file->macro.size = bfd_get_section_size (sectp); ++ } ++ else if (section_is_p (sectp->name, &dwarf2_elf_names.gdb_index)) ++ { ++ dwz_file->gdb_index.asection = sectp; ++ dwz_file->gdb_index.size = bfd_get_section_size (sectp); ++ } ++} ++ ++/* Open the separate '.dwz' debug file, if needed. Error if the file ++ cannot be found. */ ++ ++static struct dwz_file * ++dwarf2_get_dwz_file (void) ++{ ++ bfd *abfd, *dwz_bfd; ++ asection *section; ++ gdb_byte *data; ++ struct cleanup *cleanup; ++ const char *filename; ++ struct dwz_file *result; ++ ++ if (dwarf2_per_objfile->dwz_file != NULL) ++ return dwarf2_per_objfile->dwz_file; ++ ++ abfd = dwarf2_per_objfile->objfile->obfd; ++ section = bfd_get_section_by_name (abfd, ".gnu_debugaltlink"); ++ if (section == NULL) ++ error (_("could not find '.gnu_debugaltlink' section")); ++ if (!bfd_malloc_and_get_section (abfd, section, &data)) ++ error (_("could not read '.gnu_debugaltlink' section: %s"), ++ bfd_errmsg (bfd_get_error ())); ++ cleanup = make_cleanup (xfree, data); ++ ++ filename = data; ++ if (!IS_ABSOLUTE_PATH (filename)) ++ { ++ char *abs = gdb_realpath (dwarf2_per_objfile->objfile->name); ++ char *rel; ++ ++ make_cleanup (xfree, abs); ++ abs = ldirname (abs); ++ make_cleanup (xfree, abs); ++ ++ rel = concat (abs, SLASH_STRING, filename, (char *) NULL); ++ make_cleanup (xfree, rel); ++ filename = rel; ++ } ++ ++ /* The format is just a NUL-terminated file name, followed by the ++ build-id. For now, though, we ignore the build-id. */ ++ dwz_bfd = gdb_bfd_open (filename, gnutarget, -1); ++ if (dwz_bfd == NULL) ++ error (_("could not read '%s': %s"), filename, ++ bfd_errmsg (bfd_get_error ())); ++ ++ if (!bfd_check_format (dwz_bfd, bfd_object)) ++ { ++ gdb_bfd_unref (dwz_bfd); ++ error (_("file '%s' was not usable: %s"), filename, ++ bfd_errmsg (bfd_get_error ())); ++ } ++ ++ result = OBSTACK_ZALLOC (&dwarf2_per_objfile->objfile->objfile_obstack, ++ struct dwz_file); ++ result->dwz_bfd = dwz_bfd; ++ ++ bfd_map_over_sections (dwz_bfd, locate_dwz_sections, result); ++ ++ do_cleanups (cleanup); ++ ++ return result; ++} + + /* DWARF quick_symbols_functions support. */ + +@@ -2101,23 +2126,19 @@ extract_cu_value (const char *bytes, ULONGEST *result) + return 1; + } + +-/* Read the CU list from the mapped index, and use it to create all +- the CU objects for this objfile. Return 0 if something went wrong, +- 1 if everything went ok. */ ++/* A helper for create_cus_from_index that handles a given list of ++ CUs. */ + + static int +-create_cus_from_index (struct objfile *objfile, const gdb_byte *cu_list, +- offset_type cu_list_elements) ++create_cus_from_index_list (struct objfile *objfile, ++ const gdb_byte *cu_list, offset_type n_elements, ++ struct dwarf2_section_info *section, ++ int is_dwz, ++ int base_offset) + { + offset_type i; + +- dwarf2_per_objfile->n_comp_units = cu_list_elements / 2; +- dwarf2_per_objfile->all_comp_units +- = obstack_alloc (&objfile->objfile_obstack, +- dwarf2_per_objfile->n_comp_units +- * sizeof (struct dwarf2_per_cu_data *)); +- +- for (i = 0; i < cu_list_elements; i += 2) ++ for (i = 0; i < n_elements; i += 2) + { + struct dwarf2_per_cu_data *the_cu; + ULONGEST offset, length; +@@ -2132,15 +2153,45 @@ create_cus_from_index (struct objfile *objfile, const gdb_byte *cu_list, + the_cu->offset.sect_off = offset; + the_cu->length = length; + the_cu->objfile = objfile; +- the_cu->info_or_types_section = &dwarf2_per_objfile->info; ++ the_cu->info_or_types_section = section; + the_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack, + struct dwarf2_per_cu_quick_data); +- dwarf2_per_objfile->all_comp_units[i / 2] = the_cu; ++ the_cu->is_dwz = is_dwz; ++ dwarf2_per_objfile->all_comp_units[base_offset + i / 2] = the_cu; + } + + return 1; + } + ++/* Read the CU list from the mapped index, and use it to create all ++ the CU objects for this objfile. Return 0 if something went wrong, ++ 1 if everything went ok. */ ++ ++static int ++create_cus_from_index (struct objfile *objfile, ++ const gdb_byte *cu_list, offset_type cu_list_elements, ++ const gdb_byte *dwz_list, offset_type dwz_elements) ++{ ++ struct dwz_file *dwz; ++ ++ dwarf2_per_objfile->n_comp_units = (cu_list_elements + dwz_elements) / 2; ++ dwarf2_per_objfile->all_comp_units ++ = obstack_alloc (&objfile->objfile_obstack, ++ dwarf2_per_objfile->n_comp_units ++ * sizeof (struct dwarf2_per_cu_data *)); ++ ++ if (!create_cus_from_index_list (objfile, cu_list, cu_list_elements, ++ &dwarf2_per_objfile->info, 0, 0)) ++ return 0; ++ ++ if (dwz_elements == 0) ++ return 1; ++ ++ dwz = dwarf2_get_dwz_file (); ++ return create_cus_from_index_list (objfile, dwz_list, dwz_elements, ++ &dwz->info, 1, cu_list_elements / 2); ++} ++ + /* Create the signatured type hash table from the index. */ + + static int +@@ -2330,33 +2381,44 @@ find_slot_in_mapped_hash (struct mapped_index *index, const char *name, + } + } + +-/* Read the index file. If everything went ok, initialize the "quick" +- elements of all the CUs and return 1. Otherwise, return 0. */ ++/* A helper function that reads the .gdb_index from SECTION and fills ++ in MAP. FILENAME is the name of the file containing the section; ++ it is used for error reporting. DEPRECATED_OK is nonzero if it is ++ ok to use deprecated sections. ++ ++ CU_LIST, CU_LIST_ELEMENTS, TYPES_LIST, and TYPES_LIST_ELEMENTS are ++ out parameters that are filled in with information about the CU and ++ TU lists in the section. ++ ++ Returns 1 if all went well, 0 otherwise. */ + + static int +-dwarf2_read_index (struct objfile *objfile) ++read_index_from_section (struct objfile *objfile, ++ const char *filename, ++ int deprecated_ok, ++ struct dwarf2_section_info *section, ++ struct mapped_index *map, ++ const gdb_byte **cu_list, ++ offset_type *cu_list_elements, ++ const gdb_byte **types_list, ++ offset_type *types_list_elements) + { + char *addr; +- struct mapped_index *map; ++ offset_type version; + offset_type *metadata; +- const gdb_byte *cu_list; +- const gdb_byte *types_list = NULL; +- offset_type version, cu_list_elements; +- offset_type types_list_elements = 0; + int i; + +- if (dwarf2_section_empty_p (&dwarf2_per_objfile->gdb_index)) ++ if (dwarf2_section_empty_p (section)) + return 0; + + /* Older elfutils strip versions could keep the section in the main + executable while splitting it for the separate debug info file. */ +- if ((bfd_get_file_flags (dwarf2_per_objfile->gdb_index.asection) +- & SEC_HAS_CONTENTS) == 0) ++ if ((bfd_get_file_flags (section->asection) & SEC_HAS_CONTENTS) == 0) + return 0; + +- dwarf2_read_section (objfile, &dwarf2_per_objfile->gdb_index); ++ dwarf2_read_section (objfile, section); + +- addr = dwarf2_per_objfile->gdb_index.buffer; ++ addr = section->buffer; + /* Version check. */ + version = MAYBE_SWAP (*(offset_type *) addr); + /* Versions earlier than 3 emitted every copy of a psymbol. This +@@ -2369,7 +2431,7 @@ dwarf2_read_index (struct objfile *objfile) + if (!warning_printed) + { + warning (_("Skipping obsolete .gdb_index section in %s."), +- objfile->name); ++ filename); + warning_printed = 1; + } + return 0; +@@ -2382,14 +2444,14 @@ dwarf2_read_index (struct objfile *objfile) + set breakpoints on inlined functions by name, so we ignore these + indices unless the --use-deprecated-index-sections command line + option was supplied. */ +- if (version < 6 && !use_deprecated_index_sections) ++ if (version < 6 && !deprecated_ok) + { + static int warning_printed = 0; + if (!warning_printed) + { + warning (_("Skipping deprecated .gdb_index section in %s, pass " + "--use-deprecated-index-sections to use them anyway"), +- objfile->name); ++ filename); + warning_printed = 1; + } + return 0; +@@ -2399,22 +2461,21 @@ dwarf2_read_index (struct objfile *objfile) + if (version > 7) + return 0; + +- map = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct mapped_index); + map->version = version; +- map->total_size = dwarf2_per_objfile->gdb_index.size; ++ map->total_size = section->size; + + metadata = (offset_type *) (addr + sizeof (offset_type)); + + i = 0; +- cu_list = addr + MAYBE_SWAP (metadata[i]); +- cu_list_elements = ((MAYBE_SWAP (metadata[i + 1]) - MAYBE_SWAP (metadata[i])) +- / 8); ++ *cu_list = addr + MAYBE_SWAP (metadata[i]); ++ *cu_list_elements = ((MAYBE_SWAP (metadata[i + 1]) - MAYBE_SWAP (metadata[i])) ++ / 8); + ++i; + +- types_list = addr + MAYBE_SWAP (metadata[i]); +- types_list_elements = ((MAYBE_SWAP (metadata[i + 1]) +- - MAYBE_SWAP (metadata[i])) +- / 8); ++ *types_list = addr + MAYBE_SWAP (metadata[i]); ++ *types_list_elements = ((MAYBE_SWAP (metadata[i + 1]) ++ - MAYBE_SWAP (metadata[i])) ++ / 8); + ++i; + + map->address_table = addr + MAYBE_SWAP (metadata[i]); +@@ -2430,11 +2491,55 @@ dwarf2_read_index (struct objfile *objfile) + + map->constant_pool = addr + MAYBE_SWAP (metadata[i]); + ++ return 1; ++} ++ ++ ++/* Read the index file. If everything went ok, initialize the "quick" ++ elements of all the CUs and return 1. Otherwise, return 0. */ ++ ++static int ++dwarf2_read_index (struct objfile *objfile) ++{ ++ struct mapped_index local_map, *map; ++ const gdb_byte *cu_list, *types_list, *dwz_list = NULL; ++ offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0; ++ ++ if (!read_index_from_section (objfile, objfile->name, ++ use_deprecated_index_sections, ++ &dwarf2_per_objfile->gdb_index, &local_map, ++ &cu_list, &cu_list_elements, ++ &types_list, &types_list_elements)) ++ return 0; ++ + /* Don't use the index if it's empty. */ +- if (map->symbol_table_slots == 0) ++ if (local_map.symbol_table_slots == 0) + return 0; + +- if (!create_cus_from_index (objfile, cu_list, cu_list_elements)) ++ /* If there is a .dwz file, read it so we can get its CU list as ++ well. */ ++ if (bfd_get_section_by_name (objfile->obfd, ".gnu_debugaltlink") != NULL) ++ { ++ struct dwz_file *dwz = dwarf2_get_dwz_file (); ++ struct mapped_index dwz_map; ++ const gdb_byte *dwz_types_ignore; ++ offset_type dwz_types_elements_ignore; ++ ++ if (!read_index_from_section (objfile, bfd_get_filename (dwz->dwz_bfd), ++ 1, ++ &dwz->gdb_index, &dwz_map, ++ &dwz_list, &dwz_list_elements, ++ &dwz_types_ignore, ++ &dwz_types_elements_ignore)) ++ { ++ warning (_("could not read '.gdb_index' section from %s; skipping"), ++ bfd_get_filename (dwz->dwz_bfd)); ++ return 0; ++ } ++ } ++ ++ if (!create_cus_from_index (objfile, cu_list, cu_list_elements, ++ dwz_list, dwz_list_elements)) + return 0; + + if (types_list_elements) +@@ -2455,7 +2560,10 @@ dwarf2_read_index (struct objfile *objfile) + return 0; + } + +- create_addrmap_from_index (objfile, map); ++ create_addrmap_from_index (objfile, &local_map); ++ ++ map = obstack_alloc (&objfile->objfile_obstack, sizeof (struct mapped_index)); ++ *map = local_map; + + dwarf2_per_objfile->index_table = map; + dwarf2_per_objfile->using_index = 1; +@@ -3442,6 +3550,22 @@ read_comp_unit_head (struct comp_unit_head *cu_header, + return info_ptr; + } + ++/* Helper function that returns the proper abbrev section for ++ THIS_CU. */ ++ ++static struct dwarf2_section_info * ++get_abbrev_section_for_cu (struct dwarf2_per_cu_data *this_cu) ++{ ++ struct dwarf2_section_info *abbrev; ++ ++ if (this_cu->is_dwz) ++ abbrev = &dwarf2_get_dwz_file ()->abbrev; ++ else ++ abbrev = &dwarf2_per_objfile->abbrev; ++ ++ return abbrev; ++} ++ + /* Subroutine of read_and_check_comp_unit_head and + read_and_check_type_unit_head to simplify them. + Perform various error checking on the header. */ +@@ -3460,8 +3584,7 @@ error_check_comp_unit_head (struct comp_unit_head *header, + filename); + + if (header->abbrev_offset.sect_off +- >= dwarf2_section_size (dwarf2_per_objfile->objfile, +- &dwarf2_per_objfile->abbrev)) ++ >= dwarf2_section_size (dwarf2_per_objfile->objfile, abbrev_section)) + error (_("Dwarf Error: bad offset (0x%lx) in compilation unit header " + "(offset 0x%lx + 6) [in module %s]"), + (long) header->abbrev_offset.sect_off, (long) header->offset.sect_off, +@@ -3678,6 +3801,7 @@ create_debug_types_hash_table (struct dwo_file *dwo_file, + { + bfd *abfd; + gdb_byte *info_ptr, *end_ptr; ++ struct dwarf2_section_info *abbrev_section; + + dwarf2_read_section (objfile, section); + info_ptr = section->buffer; +@@ -3689,6 +3813,11 @@ create_debug_types_hash_table (struct dwo_file *dwo_file, + not present, in which case section->asection will be NULL. */ + abfd = section->asection->owner; + ++ if (dwo_file) ++ abbrev_section = &dwo_file->sections.abbrev; ++ else ++ abbrev_section = &dwarf2_per_objfile->abbrev; ++ + if (types_htab == NULL) + { + if (dwo_file) +@@ -3923,7 +4052,8 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu, + dwarf2_read_section (objfile, section); + + begin_info_ptr = info_ptr = section->buffer + this_cu->offset.sect_off; +- abbrev_section = &dwarf2_per_objfile->abbrev; ++ ++ abbrev_section = get_abbrev_section_for_cu (this_cu); + + if (use_existing_cu && this_cu->cu != NULL) + { +@@ -4290,7 +4420,7 @@ init_cutu_and_read_dies_simple (struct dwarf2_per_cu_data *this_cu, + void *data) + { + init_cutu_and_read_dies_no_follow (this_cu, +- &dwarf2_per_objfile->abbrev, ++ get_abbrev_section_for_cu (this_cu), + NULL, + die_reader_func, data); + } +@@ -4537,6 +4667,9 @@ set_partial_user (struct objfile *objfile) + struct partial_symtab *pst = per_cu->v.psymtab; + int j; + ++ if (pst == NULL) ++ continue; ++ + for (j = 0; j < pst->number_of_dependencies; ++j) + { + /* Set the 'user' field only if it is not already set. */ +@@ -4630,38 +4763,32 @@ load_partial_comp_unit (struct dwarf2_per_cu_data *this_cu) + init_cutu_and_read_dies (this_cu, 1, 1, load_partial_comp_unit_reader, NULL); + } + +-/* Create a list of all compilation units in OBJFILE. +- This is only done for -readnow and building partial symtabs. */ +- + static void +-create_all_comp_units (struct objfile *objfile) ++read_comp_units_from_section (struct objfile *objfile, ++ struct dwarf2_section_info *section, ++ unsigned int is_dwz, ++ int *n_allocated, ++ int *n_comp_units, ++ struct dwarf2_per_cu_data ***all_comp_units) + { +- int n_allocated; +- int n_comp_units; +- struct dwarf2_per_cu_data **all_comp_units; + gdb_byte *info_ptr; ++ bfd *abfd = section->asection->owner; + +- dwarf2_read_section (objfile, &dwarf2_per_objfile->info); +- info_ptr = dwarf2_per_objfile->info.buffer; ++ dwarf2_read_section (objfile, section); + +- n_comp_units = 0; +- n_allocated = 10; +- all_comp_units = xmalloc (n_allocated +- * sizeof (struct dwarf2_per_cu_data *)); ++ info_ptr = section->buffer; + +- while (info_ptr < dwarf2_per_objfile->info.buffer +- + dwarf2_per_objfile->info.size) ++ while (info_ptr < section->buffer + section->size) + { + unsigned int length, initial_length_size; + struct dwarf2_per_cu_data *this_cu; + sect_offset offset; + +- offset.sect_off = info_ptr - dwarf2_per_objfile->info.buffer; ++ offset.sect_off = info_ptr - section->buffer; + + /* Read just enough information to find out where the next + compilation unit is. */ +- length = read_initial_length (objfile->obfd, info_ptr, +- &initial_length_size); ++ length = read_initial_length (abfd, info_ptr, &initial_length_size); + + /* Save the compilation unit for later lookup. */ + this_cu = obstack_alloc (&objfile->objfile_obstack, +@@ -4669,20 +4796,50 @@ create_all_comp_units (struct objfile *objfile) + memset (this_cu, 0, sizeof (*this_cu)); + this_cu->offset = offset; + this_cu->length = length + initial_length_size; ++ this_cu->is_dwz = is_dwz; + this_cu->objfile = objfile; +- this_cu->info_or_types_section = &dwarf2_per_objfile->info; ++ this_cu->info_or_types_section = section; + +- if (n_comp_units == n_allocated) ++ if (*n_comp_units == *n_allocated) + { +- n_allocated *= 2; +- all_comp_units = xrealloc (all_comp_units, +- n_allocated +- * sizeof (struct dwarf2_per_cu_data *)); ++ *n_allocated *= 2; ++ *all_comp_units = xrealloc (*all_comp_units, ++ *n_allocated ++ * sizeof (struct dwarf2_per_cu_data *)); + } +- all_comp_units[n_comp_units++] = this_cu; ++ (*all_comp_units)[*n_comp_units] = this_cu; ++ ++*n_comp_units; + + info_ptr = info_ptr + this_cu->length; + } ++} ++ ++/* Create a list of all compilation units in OBJFILE. ++ This is only done for -readnow and building partial symtabs. */ ++ ++static void ++create_all_comp_units (struct objfile *objfile) ++{ ++ int n_allocated; ++ int n_comp_units; ++ struct dwarf2_per_cu_data **all_comp_units; ++ ++ n_comp_units = 0; ++ n_allocated = 10; ++ all_comp_units = xmalloc (n_allocated ++ * sizeof (struct dwarf2_per_cu_data *)); ++ ++ read_comp_units_from_section (objfile, &dwarf2_per_objfile->info, 0, ++ &n_allocated, &n_comp_units, &all_comp_units); ++ ++ if (bfd_get_section_by_name (objfile->obfd, ".gnu_debugaltlink") != NULL) ++ { ++ struct dwz_file *dwz = dwarf2_get_dwz_file (); ++ ++ read_comp_units_from_section (objfile, &dwz->info, 1, ++ &n_allocated, &n_comp_units, ++ &all_comp_units); ++ } + + dwarf2_per_objfile->all_comp_units + = obstack_alloc (&objfile->objfile_obstack, +@@ -4767,6 +4924,7 @@ scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc, + struct dwarf2_per_cu_data *per_cu; + + per_cu = dwarf2_find_containing_comp_unit (pdi->d.offset, ++ pdi->is_dwz, + cu->objfile); + + /* Go read the partial unit, if needed. */ +@@ -4824,7 +4982,8 @@ partial_die_parent_scope (struct partial_die_info *pdi, + + real_pdi = pdi; + while (real_pdi->has_specification) +- real_pdi = find_partial_die (real_pdi->spec_offset, cu); ++ real_pdi = find_partial_die (real_pdi->spec_offset, ++ real_pdi->spec_is_dwz, cu); + + parent = real_pdi->die_parent; + if (parent == NULL) +@@ -5324,6 +5483,9 @@ skip_one_die (const struct die_reader_specs *reader, gdb_byte *info_ptr, + else + info_ptr += cu->header.offset_size; + break; ++ case DW_FORM_GNU_ref_alt: ++ info_ptr += cu->header.offset_size; ++ break; + case DW_FORM_addr: + info_ptr += cu->header.addr_size; + break; +@@ -5353,6 +5515,7 @@ skip_one_die (const struct die_reader_specs *reader, gdb_byte *info_ptr, + break; + case DW_FORM_sec_offset: + case DW_FORM_strp: ++ case DW_FORM_GNU_strp_alt: + info_ptr += cu->header.offset_size; + break; + case DW_FORM_exprloc: +@@ -5999,7 +6162,9 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu, + it, by scanning the DIE's below the compilation unit. */ + get_scope_pc_bounds (cu->dies, &lowpc, &highpc, cu); + +- symtab = end_symtab (highpc + baseaddr, objfile, SECT_OFF_TEXT (objfile)); ++ symtab = end_symtab_full (highpc + baseaddr, objfile, ++ SECT_OFF_TEXT (objfile), ++ per_cu->imported_symtabs != NULL); + + if (symtab != NULL) + { +@@ -6068,9 +6233,11 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu) + struct dwarf2_per_cu_data *per_cu; + struct symtab *imported_symtab; + sect_offset offset; ++ int is_dwz; + + offset = dwarf2_get_ref_die_offset (attr); +- per_cu = dwarf2_find_containing_comp_unit (offset, cu->objfile); ++ is_dwz = (attr->form == DW_FORM_GNU_ref_alt || cu->per_cu->is_dwz); ++ per_cu = dwarf2_find_containing_comp_unit (offset, is_dwz, cu->objfile); + + /* Queue the unit, if needed. */ + if (maybe_queue_comp_unit (cu, per_cu, cu->language)) +@@ -7284,24 +7451,22 @@ try_open_dwo_file (const char *file_name) + if (desc < 0) + return NULL; + +- sym_bfd = bfd_fopen (absolute_name, gnutarget, FOPEN_RB, desc); ++ sym_bfd = gdb_bfd_open (absolute_name, gnutarget, desc); + if (!sym_bfd) + { + xfree (absolute_name); + return NULL; + } ++ gdb_bfd_stash_filename (sym_bfd); ++ xfree (absolute_name); + bfd_set_cacheable (sym_bfd, 1); + + if (!bfd_check_format (sym_bfd, bfd_object)) + { +- bfd_close (sym_bfd); /* This also closes desc. */ +- xfree (absolute_name); ++ gdb_bfd_unref (sym_bfd); /* This also closes desc. */ + return NULL; + } + +- /* bfd_usrdata exists for applications and libbfd must not touch it. */ +- gdb_assert (bfd_usrdata (sym_bfd) == NULL); +- + return sym_bfd; + } + +@@ -7493,20 +7658,7 @@ free_dwo_file (struct dwo_file *dwo_file, struct objfile *objfile) + struct dwarf2_section_info *section; + + gdb_assert (dwo_file->dwo_bfd != objfile->obfd); +- bfd_close (dwo_file->dwo_bfd); +- +- munmap_section_buffer (&dwo_file->sections.abbrev); +- munmap_section_buffer (&dwo_file->sections.info); +- munmap_section_buffer (&dwo_file->sections.line); +- munmap_section_buffer (&dwo_file->sections.loc); +- munmap_section_buffer (&dwo_file->sections.str); +- munmap_section_buffer (&dwo_file->sections.str_offsets); +- +- for (ix = 0; +- VEC_iterate (dwarf2_section_info_def, dwo_file->sections.types, +- ix, section); +- ++ix) +- munmap_section_buffer (section); ++ gdb_bfd_unref (dwo_file->dwo_bfd); + + VEC_free (dwarf2_section_info_def, dwo_file->sections.types); + } +@@ -9878,6 +10030,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) new_symbol (die, this_type, cu); } @@ -915,7 +2562,7 @@ index 8dbc53e..b5b7813 100644 /* Extract all information from a DW_TAG_array_type DIE and put it in the DIE's type field. For now, this only handles one dimensional arrays. */ -@@ -9539,7 +9571,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -9891,7 +10066,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) struct type *element_type, *range_type, *index_type; struct type **range_types = NULL; struct attribute *attr; @@ -924,7 +2571,7 @@ index 8dbc53e..b5b7813 100644 struct cleanup *back_to; char *name; -@@ -9592,17 +9624,19 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -9944,17 +10119,19 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) type = element_type; if (read_array_order (die, cu) == DW_ORD_col_major) @@ -955,7 +2602,7 @@ index 8dbc53e..b5b7813 100644 /* Understand Dwarf2 support for vector types (like they occur on the PowerPC w/ AltiVec). Gcc just adds another attribute to the -@@ -10086,29 +10120,114 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -10438,29 +10615,114 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) struct gdbarch *gdbarch = get_objfile_arch (objfile); struct type *type, *range_type, *index_type, *char_type; struct attribute *attr; @@ -1083,7 +2730,7 @@ index 8dbc53e..b5b7813 100644 char_type = language_string_char_type (cu->language_defn, gdbarch); type = create_string_type (NULL, char_type, range_type); -@@ -10412,7 +10531,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -10764,7 +11026,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) struct type *base_type; struct type *range_type; struct attribute *attr; @@ -1092,7 +2739,7 @@ index 8dbc53e..b5b7813 100644 int low_default_is_valid; char *name; LONGEST negative_mask; -@@ -10468,42 +10587,6 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -10820,42 +11082,6 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) "- DIE at 0x%x [in module %s]"), die->offset.sect_off, cu->objfile->name); @@ -1135,7 +2782,7 @@ index 8dbc53e..b5b7813 100644 /* Dwarf-2 specifications explicitly allows to create subrange types without specifying a base type. In that case, the base type must be set to the type of -@@ -10542,24 +10625,163 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -10894,24 +11120,163 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) } } @@ -1177,7 +2824,10 @@ index 8dbc53e..b5b7813 100644 + struct die_info *target_die; + struct dwarf2_cu *target_cu = cu; + struct attribute *target_loc_attr; -+ + +- /* Ada expects an empty array on no boundary attributes. */ +- if (attr == NULL && cu->language != language_ada) +- TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1; + target_die = follow_die_ref_or_sig (die, attr, &target_cu); + gdb_assert (target_cu->objfile == cu->objfile); + target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu); @@ -1215,10 +2865,7 @@ index 8dbc53e..b5b7813 100644 + if (low >= 0) + TYPE_UNSIGNED (range_type) = 1; + } - -- /* Ada expects an empty array on no boundary attributes. */ -- if (attr == NULL && cu->language != language_ada) -- TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1; ++ + attr = dwarf2_attr (die, DW_AT_upper_bound, cu); + if (!attr || (!attr_form_is_block (attr) && !attr_form_is_constant (attr) + && !is_ref_attr (attr))) @@ -1313,7 +2960,214 @@ index 8dbc53e..b5b7813 100644 name = dwarf2_name (die, cu); if (name) -@@ -13257,10 +13479,12 @@ var_decode_location (struct attribute *attr, struct symbol *sym, +@@ -11685,6 +12050,8 @@ read_partial_die (const struct die_reader_specs *reader, + case DW_AT_extension: + part_die->has_specification = 1; + part_die->spec_offset = dwarf2_get_ref_die_offset (&attr); ++ part_die->spec_is_dwz = (attr.form == DW_FORM_GNU_ref_alt ++ || cu->per_cu->is_dwz); + break; + case DW_AT_sibling: + /* Ignore absolute siblings, they might point outside of +@@ -11731,7 +12098,11 @@ read_partial_die (const struct die_reader_specs *reader, + + case DW_AT_import: + if (part_die->tag == DW_TAG_imported_unit) +- part_die->d.offset = dwarf2_get_ref_die_offset (&attr); ++ { ++ part_die->d.offset = dwarf2_get_ref_die_offset (&attr); ++ part_die->is_dwz = (attr.form == DW_FORM_GNU_ref_alt ++ || cu->per_cu->is_dwz); ++ } + break; + + default: +@@ -11802,13 +12173,14 @@ find_partial_die_in_comp_unit (sect_offset offset, struct dwarf2_cu *cu) + DW_FORM_ref_sig8). */ + + static struct partial_die_info * +-find_partial_die (sect_offset offset, struct dwarf2_cu *cu) ++find_partial_die (sect_offset offset, int offset_in_dwz, struct dwarf2_cu *cu) + { + struct objfile *objfile = cu->objfile; + struct dwarf2_per_cu_data *per_cu = NULL; + struct partial_die_info *pd = NULL; + +- if (offset_in_cu_p (&cu->header, offset)) ++ if (offset_in_dwz == cu->per_cu->is_dwz ++ && offset_in_cu_p (&cu->header, offset)) + { + pd = find_partial_die_in_comp_unit (offset, cu); + if (pd != NULL) +@@ -11827,7 +12199,8 @@ find_partial_die (sect_offset offset, struct dwarf2_cu *cu) + (long) cu->header.offset.sect_off, (long) offset.sect_off, + bfd_get_filename (objfile->obfd)); + } +- per_cu = dwarf2_find_containing_comp_unit (offset, objfile); ++ per_cu = dwarf2_find_containing_comp_unit (offset, offset_in_dwz, ++ objfile); + + if (per_cu->cu == NULL || per_cu->cu->partial_dies == NULL) + load_partial_comp_unit (per_cu); +@@ -11885,7 +12258,8 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi, + + real_pdi = struct_pdi; + while (real_pdi->has_specification) +- real_pdi = find_partial_die (real_pdi->spec_offset, cu); ++ real_pdi = find_partial_die (real_pdi->spec_offset, ++ real_pdi->spec_is_dwz, cu); + + if (real_pdi->die_parent != NULL) + return; +@@ -11933,7 +12307,8 @@ fixup_partial_die (struct partial_die_info *part_die, + { + struct partial_die_info *spec_die; + +- spec_die = find_partial_die (part_die->spec_offset, cu); ++ spec_die = find_partial_die (part_die->spec_offset, ++ part_die->spec_is_dwz, cu); + + fixup_partial_die (spec_die, cu); + +@@ -12021,6 +12396,10 @@ read_attribute_value (const struct die_reader_specs *reader, + &cu->header, &bytes_read); + info_ptr += bytes_read; + break; ++ case DW_FORM_GNU_ref_alt: ++ DW_UNSND (attr) = read_offset (abfd, info_ptr, &cu->header, &bytes_read); ++ info_ptr += bytes_read; ++ break; + case DW_FORM_addr: + DW_ADDR (attr) = read_address (abfd, info_ptr, cu, &bytes_read); + info_ptr += bytes_read; +@@ -12063,10 +12442,25 @@ read_attribute_value (const struct die_reader_specs *reader, + info_ptr += bytes_read; + break; + case DW_FORM_strp: +- DW_STRING (attr) = read_indirect_string (abfd, info_ptr, cu_header, +- &bytes_read); +- DW_STRING_IS_CANONICAL (attr) = 0; +- info_ptr += bytes_read; ++ if (!cu->per_cu->is_dwz) ++ { ++ DW_STRING (attr) = read_indirect_string (abfd, info_ptr, cu_header, ++ &bytes_read); ++ DW_STRING_IS_CANONICAL (attr) = 0; ++ info_ptr += bytes_read; ++ break; ++ } ++ /* FALLTHROUGH */ ++ case DW_FORM_GNU_strp_alt: ++ { ++ struct dwz_file *dwz = dwarf2_get_dwz_file (); ++ LONGEST str_offset = read_offset (abfd, info_ptr, cu_header, ++ &bytes_read); ++ ++ DW_STRING (attr) = read_indirect_string_from_dwz (dwz, str_offset); ++ DW_STRING_IS_CANONICAL (attr) = 0; ++ info_ptr += bytes_read; ++ } + break; + case DW_FORM_exprloc: + case DW_FORM_block: +@@ -12178,6 +12572,10 @@ read_attribute_value (const struct die_reader_specs *reader, + bfd_get_filename (abfd)); + } + ++ /* Super hack. */ ++ if (cu->per_cu->is_dwz && is_ref_attr (attr)) ++ attr->form = DW_FORM_GNU_ref_alt; ++ + /* We have seen instances where the compiler tried to emit a byte + size attribute of -1 which ended up being encoded as an unsigned + 0xffffffff. Although 0xffffffff is technically a valid size value, +@@ -12474,6 +12872,30 @@ read_indirect_string_at_offset (bfd *abfd, LONGEST str_offset) + return (char *) (dwarf2_per_objfile->str.buffer + str_offset); + } + ++/* Read a string at offset STR_OFFSET in the .debug_str section from ++ the .dwz file DWZ. Throw an error if the offset is too large. If ++ the string consists of a single NUL byte, return NULL; otherwise ++ return a pointer to the string. */ ++ ++static char * ++read_indirect_string_from_dwz (struct dwz_file *dwz, LONGEST str_offset) ++{ ++ dwarf2_read_section (dwarf2_per_objfile->objfile, &dwz->str); ++ ++ if (dwz->str.buffer == NULL) ++ error (_("DW_FORM_GNU_strp_alt used without .debug_str " ++ "section [in module %s]"), ++ bfd_get_filename (dwz->dwz_bfd)); ++ if (str_offset >= dwz->str.size) ++ error (_("DW_FORM_GNU_strp_alt pointing outside of " ++ ".debug_str section [in module %s]"), ++ bfd_get_filename (dwz->dwz_bfd)); ++ gdb_assert (HOST_CHAR_BIT == 8); ++ if (dwz->str.buffer[str_offset] == '\0') ++ return NULL; ++ return (char *) (dwz->str.buffer + str_offset); ++} ++ + static char * + read_indirect_string (bfd *abfd, gdb_byte *buf, + const struct comp_unit_head *cu_header, +@@ -12946,6 +13368,30 @@ add_file_name (struct line_header *lh, + fe->symtab = NULL; + } + ++/* A convenience function to find the proper .debug_line section for a ++ CU. */ ++ ++static struct dwarf2_section_info * ++get_debug_line_section (struct dwarf2_cu *cu) ++{ ++ struct dwarf2_section_info *section; ++ ++ /* For TUs in DWO files, the DW_AT_stmt_list attribute lives in the ++ DWO file. */ ++ if (cu->dwo_unit && cu->per_cu->is_debug_types) ++ section = &cu->dwo_unit->dwo_file->sections.line; ++ else if (cu->per_cu->is_dwz) ++ { ++ struct dwz_file *dwz = dwarf2_get_dwz_file (); ++ ++ section = &dwz->line; ++ } ++ else ++ section = &dwarf2_per_objfile->line; ++ ++ return section; ++} ++ + /* Read the statement program header starting at OFFSET in + .debug_line, or .debug_line.dwo. Return a pointer + to a struct line_header, allocated using xmalloc. +@@ -12966,13 +13412,7 @@ dwarf_decode_line_header (unsigned int offset, struct dwarf2_cu *cu) + struct dwarf2_section_info *section; + bfd *abfd; + +- /* For TUs in DWO files, the DW_AT_stmt_list attribute lives in the +- DWO file. */ +- if (cu->dwo_unit && cu->per_cu->is_debug_types) +- section = &cu->dwo_unit->dwo_file->sections.line; +- else +- section = &dwarf2_per_objfile->line; +- ++ section = get_debug_line_section (cu); + dwarf2_read_section (dwarf2_per_objfile->objfile, section); + if (section->buffer == NULL) + { +@@ -13297,7 +13737,7 @@ dwarf_decode_lines_1 (struct line_header *lh, const char *comp_dir, + GCd by the linker. Ignore it. PR gdb/12528 */ + + long line_offset +- = line_ptr - dwarf2_per_objfile->line.buffer; ++ = line_ptr - get_debug_line_section (cu)->buffer; + + complaint (&symfile_complaints, + _(".debug_line address at offset 0x%lx is 0 " +@@ -13659,10 +14099,12 @@ var_decode_location (struct attribute *attr, struct symbol *sym, (i.e. when the value of a register or memory location is referenced, or a thread-local block, etc.). Then again, it might not be worthwhile. I'm assuming that it isn't unless performance @@ -1328,7 +3182,7 @@ index 8dbc53e..b5b7813 100644 if (SYMBOL_COMPUTED_OPS (sym) == &dwarf2_loclist_funcs) cu->has_loclist = 1; -@@ -13301,6 +13525,8 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu, +@@ -13703,6 +14145,8 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu, else sym = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symbol); OBJSTAT (objfile, n_syms++); @@ -1337,7 +3191,32 @@ index 8dbc53e..b5b7813 100644 /* Cache this symbol's name and the name's demangled form (if any). */ SYMBOL_SET_LANGUAGE (sym, cu->language); -@@ -14075,6 +14301,9 @@ read_type_die_1 (struct die_info *die, struct dwarf2_cu *cu) +@@ -14126,6 +14570,7 @@ dwarf2_const_value_attr (struct attribute *attr, struct type *type, + case DW_FORM_string: + case DW_FORM_strp: + case DW_FORM_GNU_str_index: ++ case DW_FORM_GNU_strp_alt: + /* DW_STRING is already allocated on the objfile obstack, point + directly to it. */ + *bytes = (gdb_byte *) DW_STRING (attr); +@@ -14312,7 +14757,15 @@ lookup_die_type (struct die_info *die, struct attribute *attr, + + /* First see if we have it cached. */ + +- if (is_ref_attr (attr)) ++ if (attr->form == DW_FORM_GNU_ref_alt) ++ { ++ struct dwarf2_per_cu_data *per_cu; ++ sect_offset offset = dwarf2_get_ref_die_offset (attr); ++ ++ per_cu = dwarf2_find_containing_comp_unit (offset, 1, cu->objfile); ++ this_type = get_die_type_at_offset (offset, per_cu); ++ } ++ else if (is_ref_attr (attr)) + { + sect_offset offset = dwarf2_get_ref_die_offset (attr); + +@@ -14477,6 +14930,9 @@ read_type_die_1 (struct die_info *die, struct dwarf2_cu *cu) break; } @@ -1347,7 +3226,195 @@ index 8dbc53e..b5b7813 100644 return this_type; } -@@ -16472,62 +16701,100 @@ fill_in_loclist_baton (struct dwarf2_cu *cu, +@@ -15085,6 +15541,10 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die) + fprintf_unfiltered (f, "ref address: "); + fputs_filtered (hex_string (DW_UNSND (&die->attrs[i])), f); + break; ++ case DW_FORM_GNU_ref_alt: ++ fprintf_unfiltered (f, "alt ref address: "); ++ fputs_filtered (hex_string (DW_UNSND (&die->attrs[i])), f); ++ break; + case DW_FORM_ref1: + case DW_FORM_ref2: + case DW_FORM_ref4: +@@ -15116,6 +15576,7 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die) + case DW_FORM_string: + case DW_FORM_strp: + case DW_FORM_GNU_str_index: ++ case DW_FORM_GNU_strp_alt: + fprintf_unfiltered (f, "string: \"%s\" (%s canonicalized)", + DW_STRING (&die->attrs[i]) + ? DW_STRING (&die->attrs[i]) : "", +@@ -15219,6 +15680,7 @@ is_ref_attr (struct attribute *attr) + case DW_FORM_ref4: + case DW_FORM_ref8: + case DW_FORM_ref_udata: ++ case DW_FORM_GNU_ref_alt: + return 1; + default: + return 0; +@@ -15296,7 +15758,8 @@ follow_die_ref_or_sig (struct die_info *src_die, struct attribute *attr, + Returns NULL if OFFSET is invalid. */ + + static struct die_info * +-follow_die_offset (sect_offset offset, struct dwarf2_cu **ref_cu) ++follow_die_offset (sect_offset offset, int offset_in_dwz, ++ struct dwarf2_cu **ref_cu) + { + struct die_info temp_die; + struct dwarf2_cu *target_cu, *cu = *ref_cu; +@@ -15313,11 +15776,13 @@ follow_die_offset (sect_offset offset, struct dwarf2_cu **ref_cu) + if (! offset_in_cu_p (&cu->header, offset)) + return NULL; + } +- else if (! offset_in_cu_p (&cu->header, offset)) ++ else if (offset_in_dwz != cu->per_cu->is_dwz ++ || ! offset_in_cu_p (&cu->header, offset)) + { + struct dwarf2_per_cu_data *per_cu; + +- per_cu = dwarf2_find_containing_comp_unit (offset, cu->objfile); ++ per_cu = dwarf2_find_containing_comp_unit (offset, offset_in_dwz, ++ cu->objfile); + + /* If necessary, add it to the queue and load its DIEs. */ + if (maybe_queue_comp_unit (cu, per_cu, cu->language)) +@@ -15349,7 +15814,10 @@ follow_die_ref (struct die_info *src_die, struct attribute *attr, + struct dwarf2_cu *cu = *ref_cu; + struct die_info *die; + +- die = follow_die_offset (offset, ref_cu); ++ die = follow_die_offset (offset, ++ (attr->form == DW_FORM_GNU_ref_alt ++ || cu->per_cu->is_dwz), ++ ref_cu); + if (!die) + error (_("Dwarf Error: Cannot find DIE at 0x%x referenced from DIE " + "at 0x%x [in module %s]"), +@@ -15380,7 +15848,7 @@ dwarf2_fetch_die_location_block (cu_offset offset_in_cu, + load_cu (per_cu); + cu = per_cu->cu; + +- die = follow_die_offset (offset, &cu); ++ die = follow_die_offset (offset, per_cu->is_dwz, &cu); + if (!die) + error (_("Dwarf Error: Cannot find DIE at 0x%x referenced in module %s"), + offset.sect_off, per_cu->objfile->name); +@@ -16179,6 +16647,7 @@ skip_form_bytes (bfd *abfd, gdb_byte *bytes, gdb_byte *buffer_end, + + case DW_FORM_sec_offset: + case DW_FORM_strp: ++ case DW_FORM_GNU_strp_alt: + bytes += offset_size; + break; + +@@ -16334,7 +16803,7 @@ dwarf_decode_macro_bytes (bfd *abfd, gdb_byte *mac_ptr, gdb_byte *mac_end, + struct macro_source_file *current_file, + struct line_header *lh, char *comp_dir, + struct dwarf2_section_info *section, +- int section_is_gnu, ++ int section_is_gnu, int section_is_dwz, + unsigned int offset_size, + struct objfile *objfile, + htab_t include_hash) +@@ -16385,6 +16854,8 @@ dwarf_decode_macro_bytes (bfd *abfd, gdb_byte *mac_ptr, gdb_byte *mac_end, + case DW_MACRO_GNU_undef: + case DW_MACRO_GNU_define_indirect: + case DW_MACRO_GNU_undef_indirect: ++ case DW_MACRO_GNU_define_indirect_alt: ++ case DW_MACRO_GNU_undef_indirect_alt: + { + unsigned int bytes_read; + int line; +@@ -16407,11 +16878,20 @@ dwarf_decode_macro_bytes (bfd *abfd, gdb_byte *mac_ptr, gdb_byte *mac_end, + str_offset = read_offset_1 (abfd, mac_ptr, offset_size); + mac_ptr += offset_size; + +- body = read_indirect_string_at_offset (abfd, str_offset); ++ if (macinfo_type == DW_MACRO_GNU_define_indirect_alt ++ || macinfo_type == DW_MACRO_GNU_undef_indirect_alt) ++ { ++ struct dwz_file *dwz = dwarf2_get_dwz_file (); ++ ++ body = read_indirect_string_from_dwz (dwz, str_offset); ++ } ++ else ++ body = read_indirect_string_at_offset (abfd, str_offset); + } + + is_define = (macinfo_type == DW_MACRO_GNU_define +- || macinfo_type == DW_MACRO_GNU_define_indirect); ++ || macinfo_type == DW_MACRO_GNU_define_indirect ++ || macinfo_type == DW_MACRO_GNU_define_indirect_alt); + if (! current_file) + { + /* DWARF violation as no main source is present. */ +@@ -16435,7 +16915,8 @@ dwarf_decode_macro_bytes (bfd *abfd, gdb_byte *mac_ptr, gdb_byte *mac_end, + else + { + gdb_assert (macinfo_type == DW_MACRO_GNU_undef +- || macinfo_type == DW_MACRO_GNU_undef_indirect); ++ || macinfo_type == DW_MACRO_GNU_undef_indirect ++ || macinfo_type == DW_MACRO_GNU_undef_indirect_alt); + macro_undef (current_file, line, body); + } + } +@@ -16510,6 +16991,7 @@ dwarf_decode_macro_bytes (bfd *abfd, gdb_byte *mac_ptr, gdb_byte *mac_end, + break; + + case DW_MACRO_GNU_transparent_include: ++ case DW_MACRO_GNU_transparent_include_alt: + { + LONGEST offset; + void **slot; +@@ -16528,13 +17010,32 @@ dwarf_decode_macro_bytes (bfd *abfd, gdb_byte *mac_ptr, gdb_byte *mac_end, + } + else + { ++ bfd *include_bfd = abfd; ++ struct dwarf2_section_info *include_section = section; ++ struct dwarf2_section_info alt_section; ++ gdb_byte *include_mac_end = mac_end; ++ int is_dwz = section_is_dwz; ++ + *slot = mac_ptr; + +- dwarf_decode_macro_bytes (abfd, +- section->buffer + offset, +- mac_end, current_file, ++ if (macinfo_type == DW_MACRO_GNU_transparent_include_alt) ++ { ++ struct dwz_file *dwz = dwarf2_get_dwz_file (); ++ ++ dwarf2_read_section (dwarf2_per_objfile->objfile, ++ &dwz->macro); ++ ++ include_bfd = dwz->macro.asection->owner; ++ include_section = &dwz->macro; ++ include_mac_end = dwz->macro.buffer + dwz->macro.size; ++ is_dwz = 1; ++ } ++ ++ dwarf_decode_macro_bytes (include_bfd, ++ include_section->buffer + offset, ++ include_mac_end, current_file, + lh, comp_dir, +- section, section_is_gnu, ++ section, section_is_gnu, is_dwz, + offset_size, objfile, include_hash); + + htab_remove_elt (include_hash, mac_ptr); +@@ -16753,7 +17254,8 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset, + slot = htab_find_slot (include_hash, mac_ptr, INSERT); + *slot = mac_ptr; + dwarf_decode_macro_bytes (abfd, mac_ptr, mac_end, +- current_file, lh, comp_dir, section, section_is_gnu, ++ current_file, lh, comp_dir, section, ++ section_is_gnu, 0, + offset_size, objfile, include_hash); + do_cleanups (cleanup); + } +@@ -16851,62 +17353,100 @@ fill_in_loclist_baton (struct dwarf2_cu *cu, baton->from_dwo = cu->dwo_unit != NULL; } @@ -1486,7 +3553,47 @@ index 8dbc53e..b5b7813 100644 } } -@@ -16895,6 +17162,25 @@ per_cu_offset_and_type_eq (const void *item_lhs, const void *item_rhs) +@@ -17008,28 +17548,34 @@ dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *per_cu) + + static struct dwarf2_per_cu_data * + dwarf2_find_containing_comp_unit (sect_offset offset, ++ unsigned int offset_in_dwz, + struct objfile *objfile) + { + struct dwarf2_per_cu_data *this_cu; + int low, high; ++ const sect_offset *cu_off; + + low = 0; + high = dwarf2_per_objfile->n_comp_units - 1; + while (high > low) + { ++ struct dwarf2_per_cu_data *mid_cu; + int mid = low + (high - low) / 2; + +- if (dwarf2_per_objfile->all_comp_units[mid]->offset.sect_off +- >= offset.sect_off) ++ mid_cu = dwarf2_per_objfile->all_comp_units[mid]; ++ cu_off = &mid_cu->offset; ++ if (mid_cu->is_dwz >= offset_in_dwz ++ && cu_off->sect_off >= offset.sect_off) + high = mid; + else + low = mid + 1; + } + gdb_assert (low == high); +- if (dwarf2_per_objfile->all_comp_units[low]->offset.sect_off +- > offset.sect_off) ++ this_cu = dwarf2_per_objfile->all_comp_units[low]; ++ cu_off = &this_cu->offset; ++ if (this_cu->is_dwz != offset_in_dwz || cu_off->sect_off > offset.sect_off) + { +- if (low == 0) ++ if (low == 0 || this_cu->is_dwz != offset_in_dwz) + error (_("Dwarf Error: could not find partial DIE containing " + "offset 0x%lx [in module %s]"), + (long) offset.sect_off, bfd_get_filename (objfile->obfd)); +@@ -17270,6 +17816,25 @@ per_cu_offset_and_type_eq (const void *item_lhs, const void *item_rhs) && ofs_lhs->offset.sect_off == ofs_rhs->offset.sect_off); } @@ -1512,7 +3619,7 @@ index 8dbc53e..b5b7813 100644 /* Set the type associated with DIE to TYPE. Save it in CU's hash table if necessary. For convenience, return TYPE. -@@ -16919,6 +17205,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -17294,6 +17859,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) struct dwarf2_per_cu_offset_and_type **slot, ofs; struct objfile *objfile = cu->objfile; @@ -1521,8 +3628,94 @@ index 8dbc53e..b5b7813 100644 /* For Ada types, make sure that the gnat-specific data is always initialized (if not already set). There are a few types where we should not be doing so, because the type-specific area is +@@ -17471,53 +18038,13 @@ show_dwarf2_cmd (char *args, int from_tty) + cmd_show_list (show_dwarf2_cmdlist, from_tty, ""); + } + +-/* If section described by INFO was mmapped, munmap it now. */ +- +-static void +-munmap_section_buffer (struct dwarf2_section_info *info) +-{ +- if (info->map_addr != NULL) +- { +-#ifdef HAVE_MMAP +- int res; +- +- res = munmap (info->map_addr, info->map_len); +- gdb_assert (res == 0); +-#else +- /* Without HAVE_MMAP, we should never be here to begin with. */ +- gdb_assert_not_reached ("no mmap support"); +-#endif +- } +-} +- +-/* munmap debug sections for OBJFILE, if necessary. */ ++/* Free data associated with OBJFILE, if necessary. */ + + static void + dwarf2_per_objfile_free (struct objfile *objfile, void *d) + { + struct dwarf2_per_objfile *data = d; + int ix; +- struct dwarf2_section_info *section; +- +- /* This is sorted according to the order they're defined in to make it easier +- to keep in sync. */ +- munmap_section_buffer (&data->info); +- munmap_section_buffer (&data->abbrev); +- munmap_section_buffer (&data->line); +- munmap_section_buffer (&data->loc); +- munmap_section_buffer (&data->macinfo); +- munmap_section_buffer (&data->macro); +- munmap_section_buffer (&data->str); +- munmap_section_buffer (&data->ranges); +- munmap_section_buffer (&data->addr); +- munmap_section_buffer (&data->frame); +- munmap_section_buffer (&data->eh_frame); +- munmap_section_buffer (&data->gdb_index); +- +- for (ix = 0; +- VEC_iterate (dwarf2_section_info_def, data->types, ix, section); +- ++ix) +- munmap_section_buffer (section); + + for (ix = 0; ix < dwarf2_per_objfile->n_comp_units; ++ix) + VEC_free (dwarf2_per_cu_ptr, +@@ -17527,6 +18054,9 @@ dwarf2_per_objfile_free (struct objfile *objfile, void *d) + + if (data->dwo_files) + free_dwo_files (data->dwo_files, objfile); ++ ++ if (data->dwz_file && data->dwz_file->dwz_bfd) ++ gdb_bfd_unref (data->dwz_file->dwz_bfd); + } + + +diff --git a/gdb/elfread.c b/gdb/elfread.c +index 1edfb27..d9109cf 100644 +--- a/gdb/elfread.c ++++ b/gdb/elfread.c +@@ -44,6 +44,7 @@ + #include "gdbthread.h" + #include "regcache.h" + #include "bcache.h" ++#include "gdb_bfd.h" + + extern void _initialize_elfread (void); + +@@ -1123,7 +1124,7 @@ build_id_verify (const char *filename, struct build_id *check) + else + retval = 1; + +- gdb_bfd_close_or_warn (abfd); ++ gdb_bfd_unref (abfd); + + xfree (found); + diff --git a/gdb/eval.c b/gdb/eval.c -index 7f1dfac..52462bc 100644 +index 3d43406..5568b1c 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -41,6 +41,7 @@ @@ -2010,6 +4203,81 @@ index 7f1dfac..52462bc 100644 - return ndimen; + } +diff --git a/gdb/exec.c b/gdb/exec.c +index 6ba1986..540c271 100644 +--- a/gdb/exec.c ++++ b/gdb/exec.c +@@ -33,6 +33,7 @@ + #include "arch-utils.h" + #include "gdbthread.h" + #include "progspace.h" ++#include "gdb_bfd.h" + + #include + #include "readline/readline.h" +@@ -98,10 +99,8 @@ exec_close (void) + if (exec_bfd) + { + bfd *abfd = exec_bfd; +- char *name = bfd_get_filename (abfd); + +- gdb_bfd_close_or_warn (abfd); +- xfree (name); ++ gdb_bfd_unref (abfd); + + /* Removing target sections may close the exec_ops target. + Clear exec_bfd before doing so to prevent recursion. */ +@@ -137,8 +136,7 @@ exec_close_1 (int quitting) + need_symtab_cleanup = 1; + } + else if (vp->bfd != exec_bfd) +- /* FIXME-leak: We should be freeing vp->name too, I think. */ +- gdb_bfd_close_or_warn (vp->bfd); ++ gdb_bfd_unref (vp->bfd); + + xfree (vp); + } +@@ -230,11 +228,14 @@ exec_file_attach (char *filename, int from_tty) + &scratch_pathname); + } + #endif ++ ++ cleanups = make_cleanup (xfree, scratch_pathname); ++ + if (scratch_chan < 0) + perror_with_name (filename); +- exec_bfd = bfd_fopen (scratch_pathname, gnutarget, +- write_files ? FOPEN_RUB : FOPEN_RB, +- scratch_chan); ++ exec_bfd = gdb_bfd_ref (bfd_fopen (scratch_pathname, gnutarget, ++ write_files ? FOPEN_RUB : FOPEN_RB, ++ scratch_chan)); + + if (!exec_bfd) + { +@@ -242,13 +243,6 @@ exec_file_attach (char *filename, int from_tty) + scratch_pathname, bfd_errmsg (bfd_get_error ())); + } + +- /* At this point, scratch_pathname and exec_bfd->name both point to the +- same malloc'd string. However exec_close() will attempt to free it +- via the exec_bfd->name pointer, so we need to make another copy and +- leave exec_bfd as the new owner of the original copy. */ +- scratch_pathname = xstrdup (scratch_pathname); +- cleanups = make_cleanup (xfree, scratch_pathname); +- + if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching)) + { + /* Make sure to close exec_bfd, or else "run" might try to use +@@ -259,6 +253,8 @@ exec_file_attach (char *filename, int from_tty) + gdb_bfd_errmsg (bfd_get_error (), matching)); + } + ++ gdb_bfd_stash_filename (exec_bfd); ++ + /* FIXME - This should only be run for RS6000, but the ifdef is a poor + way to accomplish. */ + #ifdef DEPRECATED_IBM6000_TARGET diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 33c7418..4db1bfa 100644 --- a/gdb/f-exp.y @@ -2248,7 +4516,7 @@ index 8b84b5a..4b240a3 100644 switch (TYPE_CODE (type)) { diff --git a/gdb/findvar.c b/gdb/findvar.c -index ed7903c..e412a3d 100644 +index 66bcebe..e59e5f2 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -35,6 +35,7 @@ @@ -2259,7 +4527,7 @@ index ed7903c..e412a3d 100644 /* Basic byte-swapping routines. All 'extract' functions return a host-format integer from a target-format integer at ADDR which is -@@ -407,7 +408,10 @@ symbol_read_needs_frame (struct symbol *sym) +@@ -438,7 +439,10 @@ minsym_lookup_iterator_cb (struct objfile *objfile, void *cb_data) } /* A default implementation for the "la_read_var_value" hook in @@ -2271,7 +4539,7 @@ index ed7903c..e412a3d 100644 struct value * default_read_var_value (struct symbol *var, struct frame_info *frame) -@@ -415,16 +419,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) +@@ -446,16 +450,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) struct value *v; struct type *type = SYMBOL_TYPE (var); CORE_ADDR addr; @@ -2288,7 +4556,7 @@ index ed7903c..e412a3d 100644 if (symbol_read_needs_frame (var)) gdb_assert (frame); -@@ -434,7 +428,7 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) +@@ -465,7 +459,7 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) case LOC_CONST: /* Put the constant back in target format. */ v = allocate_value (type); @@ -2297,7 +4565,7 @@ index ed7903c..e412a3d 100644 gdbarch_byte_order (get_type_arch (type)), (LONGEST) SYMBOL_VALUE (var)); VALUE_LVAL (v) = not_lval; -@@ -459,12 +453,12 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) +@@ -490,12 +484,12 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) case LOC_CONST_BYTES: v = allocate_value (type); @@ -2312,7 +4580,7 @@ index ed7903c..e412a3d 100644 if (overlay_debugging) addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var), SYMBOL_OBJ_SECTION (var)); -@@ -478,7 +472,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) +@@ -509,7 +503,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) error (_("Unknown argument list address for `%s'."), SYMBOL_PRINT_NAME (var)); addr += SYMBOL_VALUE (var); @@ -2320,7 +4588,7 @@ index ed7903c..e412a3d 100644 break; case LOC_REF_ARG: -@@ -493,14 +486,12 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) +@@ -524,14 +517,12 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) argref += SYMBOL_VALUE (var); ref = value_at (lookup_pointer_type (type), argref); addr = value_as_address (ref); @@ -2335,7 +4603,7 @@ index ed7903c..e412a3d 100644 break; case LOC_TYPEDEF: -@@ -509,7 +500,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) +@@ -540,7 +531,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) break; case LOC_BLOCK: @@ -2343,7 +4611,7 @@ index ed7903c..e412a3d 100644 if (overlay_debugging) addr = symbol_overlayed_address (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var)); -@@ -535,7 +525,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) +@@ -566,7 +556,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) SYMBOL_PRINT_NAME (var)); addr = value_as_address (regval); @@ -2351,7 +4619,7 @@ index ed7903c..e412a3d 100644 } else { -@@ -583,7 +572,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) +@@ -615,7 +604,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) if (obj_section && (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0) addr = target_translate_tls_address (obj_section->objfile, addr); @@ -2359,7 +4627,7 @@ index ed7903c..e412a3d 100644 } break; -@@ -596,6 +584,10 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) +@@ -628,6 +616,10 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) break; } @@ -2370,7 +4638,7 @@ index ed7903c..e412a3d 100644 VALUE_LVAL (v) = lval_memory; set_value_address (v, addr); return v; -@@ -691,10 +683,11 @@ struct value * +@@ -723,10 +715,11 @@ struct value * value_from_register (struct type *type, int regnum, struct frame_info *frame) { struct gdbarch *gdbarch = get_frame_arch (frame); @@ -2384,7 +4652,7 @@ index ed7903c..e412a3d 100644 { int optim, unavail, ok; -@@ -709,7 +702,7 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame) +@@ -741,7 +734,7 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame) VALUE_LVAL (v) = lval_register; VALUE_FRAME_ID (v) = get_frame_id (frame); VALUE_REGNUM (v) = regnum; @@ -2393,6 +4661,49 @@ index ed7903c..e412a3d 100644 value_contents_raw (v), &optim, &unavail); +diff --git a/gdb/gcore.c b/gdb/gcore.c +index aedda41..f9a1389 100644 +--- a/gdb/gcore.c ++++ b/gdb/gcore.c +@@ -33,6 +33,7 @@ + #include + #include "regcache.h" + #include "regset.h" ++#include "gdb_bfd.h" + + /* The largest amount of memory to read from the target at once. We + must throttle it to limit the amount of memory used by GDB during +@@ -50,10 +51,11 @@ static int gcore_memory_sections (bfd *); + bfd * + create_gcore_bfd (char *filename) + { +- bfd *obfd = bfd_openw (filename, default_gcore_target ()); ++ bfd *obfd = gdb_bfd_ref (bfd_openw (filename, default_gcore_target ())); + + if (!obfd) + error (_("Failed to open '%s' for output."), filename); ++ gdb_bfd_stash_filename (obfd); + bfd_set_format (obfd, bfd_core); + bfd_set_arch_mach (obfd, default_gcore_arch (), default_gcore_mach ()); + return obfd; +@@ -110,7 +112,7 @@ do_bfd_delete_cleanup (void *arg) + bfd *obfd = arg; + const char *filename = obfd->filename; + +- bfd_close (arg); ++ gdb_bfd_unref (arg); + unlink (filename); + } + +@@ -154,7 +156,7 @@ gcore_command (char *args, int from_tty) + fprintf_filtered (gdb_stdout, "Saved corefile %s\n", corefilename); + + discard_cleanups (old_chain); +- bfd_close (obfd); ++ gdb_bfd_unref (obfd); + } + + static unsigned long diff --git a/gdb/gdb-gdb.gdb.in b/gdb/gdb-gdb.gdb.in index ffb7f53..a2e7e94 100644 --- a/gdb/gdb-gdb.gdb.in @@ -2413,8 +4724,562 @@ index ffb7f53..a2e7e94 100644 set complaints 1 b internal_error +diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c +new file mode 100644 +index 0000000..b43553f +--- /dev/null ++++ b/gdb/gdb_bfd.c +@@ -0,0 +1,481 @@ ++/* Definitions for BFD wrappers used by GDB. ++ ++ Copyright (C) 2011, 2012 ++ Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include "defs.h" ++#include "gdb_bfd.h" ++#include "gdb_assert.h" ++#include "gdb_string.h" ++#include "hashtab.h" ++#ifdef HAVE_ZLIB_H ++#include ++#endif ++#ifdef HAVE_MMAP ++#include ++#ifndef MAP_FAILED ++#define MAP_FAILED ((void *) -1) ++#endif ++#endif ++ ++/* An object of this type is stored in the section's user data when ++ mapping a section. */ ++ ++struct gdb_bfd_section_data ++{ ++ /* Size of the data. */ ++ bfd_size_type size; ++ /* If the data was mmapped, this is the length of the map. */ ++ bfd_size_type map_len; ++ /* The data. If NULL, the section data has not been read. */ ++ void *data; ++ /* If the data was mmapped, this is the map address. */ ++ void *map_addr; ++}; ++ ++/* See gdb_bfd.h. */ ++ ++void ++gdb_bfd_stash_filename (struct bfd *abfd) ++{ ++ char *name = bfd_get_filename (abfd); ++ char *data; ++ ++ data = bfd_alloc (abfd, strlen (name) + 1); ++ strcpy (data, name); ++ ++ /* Unwarranted chumminess with BFD. */ ++ abfd->filename = data; ++} ++ ++/* An object of this type is stored in each BFD's user data. */ ++ ++struct gdb_bfd_data ++{ ++ /* The reference count. */ ++ int refc; ++ ++ /* The mtime of the BFD at the point the cache entry was made. */ ++ time_t mtime; ++}; ++ ++/* A hash table storing all the BFDs maintained in the cache. */ ++ ++static htab_t gdb_bfd_cache; ++ ++/* The type of an object being looked up in gdb_bfd_cache. We use ++ htab's capability of storing one kind of object (BFD in this case) ++ and using a different sort of object for searching. */ ++ ++struct gdb_bfd_cache_search ++{ ++ /* The filename. */ ++ const char *filename; ++ /* The mtime. */ ++ time_t mtime; ++}; ++ ++/* A hash function for BFDs. */ ++ ++static hashval_t ++hash_bfd (const void *b) ++{ ++ const bfd *abfd = b; ++ ++ /* It is simplest to just hash the filename. */ ++ return htab_hash_string (bfd_get_filename (abfd)); ++} ++ ++/* An equality function for BFDs. Note that this expects the caller ++ to search using struct gdb_bfd_cache_search only, not BFDs. */ ++ ++static int ++eq_bfd (const void *a, const void *b) ++{ ++ const bfd *abfd = a; ++ const struct gdb_bfd_cache_search *s = b; ++ struct gdb_bfd_data *gdata = bfd_usrdata (abfd); ++ ++ return (gdata->mtime == s->mtime ++ && strcmp (bfd_get_filename (abfd), s->filename) == 0); ++} ++ ++struct bfd * ++gdb_bfd_open (const char *name, const char *target, int fd) ++{ ++ hashval_t hash; ++ void **slot; ++ bfd *abfd; ++ struct gdb_bfd_cache_search search; ++ struct stat st; ++ ++ if (gdb_bfd_cache == NULL) ++ gdb_bfd_cache = htab_create_alloc (1, hash_bfd, eq_bfd, NULL, ++ xcalloc, xfree); ++ ++ if (fd == -1) ++ { ++ fd = open (name, O_RDONLY | O_BINARY); ++ if (fd == -1) ++ { ++ bfd_set_error (bfd_error_system_call); ++ return NULL; ++ } ++ } ++ ++ search.filename = name; ++ if (fstat (fd, &st) < 0) ++ { ++ /* Weird situation here. */ ++ search.mtime = 0; ++ } ++ else ++ search.mtime = st.st_mtime; ++ ++ /* Note that this must compute the same result as hash_bfd. */ ++ hash = htab_hash_string (name); ++ /* Note that we cannot use htab_find_slot_with_hash here, because ++ opening the BFD may fail; and this would violate hashtab ++ invariants. */ ++ abfd = htab_find_with_hash (gdb_bfd_cache, &search, hash); ++ if (abfd != NULL) ++ { ++ close (fd); ++ return gdb_bfd_ref (abfd); ++ } ++ ++ abfd = bfd_fopen (name, target, FOPEN_RB, fd); ++ if (abfd == NULL) ++ return NULL; ++ ++ slot = htab_find_slot_with_hash (gdb_bfd_cache, &search, hash, INSERT); ++ gdb_assert (!*slot); ++ *slot = abfd; ++ ++ gdb_bfd_stash_filename (abfd); ++ return gdb_bfd_ref (abfd); ++} ++ ++/* A helper function that releases any section data attached to the ++ BFD. */ ++ ++static void ++free_one_bfd_section (bfd *abfd, asection *sectp, void *ignore) ++{ ++ struct gdb_bfd_section_data *sect = bfd_get_section_userdata (abfd, sectp); ++ ++ if (sect != NULL && sect->data != NULL) ++ { ++#ifdef HAVE_MMAP ++ if (sect->map_addr != NULL) ++ { ++ int res; ++ ++ res = munmap (sect->map_addr, sect->map_len); ++ gdb_assert (res == 0); ++ } ++ else ++#endif ++ xfree (sect->data); ++ } ++} ++ ++/* Close ABFD, and warn if that fails. */ ++ ++static int ++gdb_bfd_close_or_warn (struct bfd *abfd) ++{ ++ int ret; ++ char *name = bfd_get_filename (abfd); ++ ++ bfd_map_over_sections (abfd, free_one_bfd_section, NULL); ++ ++ ret = bfd_close (abfd); ++ ++ if (!ret) ++ warning (_("cannot close \"%s\": %s"), ++ name, bfd_errmsg (bfd_get_error ())); ++ ++ return ret; ++} ++ ++/* Add reference to ABFD. Returns ABFD. */ ++ ++struct bfd * ++gdb_bfd_ref (struct bfd *abfd) ++{ ++ struct gdb_bfd_data *gdata; ++ ++ if (abfd == NULL) ++ return NULL; ++ ++ gdata = bfd_usrdata (abfd); ++ ++ if (gdata != NULL) ++ { ++ gdata->refc += 1; ++ return abfd; ++ } ++ ++ gdata = bfd_zalloc (abfd, sizeof (struct gdb_bfd_data)); ++ gdata->refc = 1; ++ gdata->mtime = bfd_get_mtime (abfd); ++ bfd_usrdata (abfd) = gdata; ++ ++ return abfd; ++} ++ ++/* Unreference and possibly close ABFD. */ ++ ++void ++gdb_bfd_unref (struct bfd *abfd) ++{ ++ struct gdb_bfd_data *gdata; ++ struct gdb_bfd_cache_search search; ++ ++ if (abfd == NULL) ++ return; ++ ++ gdata = bfd_usrdata (abfd); ++ gdb_assert (gdata->refc >= 1); ++ ++ gdata->refc -= 1; ++ if (gdata->refc > 0) ++ return; ++ ++ search.filename = bfd_get_filename (abfd); ++ ++ if (gdb_bfd_cache && search.filename) ++ { ++ hashval_t hash = htab_hash_string (search.filename); ++ void **slot; ++ ++ search.mtime = gdata->mtime; ++ slot = htab_find_slot_with_hash (gdb_bfd_cache, &search, hash, ++ NO_INSERT); ++ ++ if (slot && *slot) ++ htab_clear_slot (gdb_bfd_cache, slot); ++ } ++ ++ bfd_usrdata (abfd) = NULL; /* Paranoia. */ ++ ++ gdb_bfd_close_or_warn (abfd); ++} ++ ++/* A helper function that returns the section data descriptor ++ associated with SECTION. If no such descriptor exists, a new one ++ is allocated and cleared. */ ++ ++static struct gdb_bfd_section_data * ++get_section_descriptor (asection *section) ++{ ++ struct gdb_bfd_section_data *result; ++ ++ result = bfd_get_section_userdata (section->owner, section); ++ ++ if (result == NULL) ++ { ++ result = bfd_zalloc (section->owner, sizeof (*result)); ++ bfd_set_section_userdata (section->owner, section, result); ++ } ++ ++ return result; ++} ++ ++/* Decompress a section that was compressed using zlib. Store the ++ decompressed buffer, and its size, in DESCRIPTOR. */ ++ ++static void ++zlib_decompress_section (asection *sectp, ++ struct gdb_bfd_section_data *descriptor) ++{ ++ bfd *abfd = sectp->owner; ++#ifndef HAVE_ZLIB_H ++ error (_("Support for zlib-compressed data (from '%s', section '%s') " ++ "is disabled in this copy of GDB"), ++ bfd_get_filename (abfd), ++ bfd_get_section_name (sectp)); ++#else ++ bfd_size_type compressed_size = bfd_get_section_size (sectp); ++ gdb_byte *compressed_buffer = xmalloc (compressed_size); ++ struct cleanup *cleanup = make_cleanup (xfree, compressed_buffer); ++ struct cleanup *inner_cleanup; ++ bfd_size_type uncompressed_size; ++ gdb_byte *uncompressed_buffer; ++ z_stream strm; ++ int rc; ++ int header_size = 12; ++ struct dwarf2_per_bfd_section *section_data; ++ ++ if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0 ++ || bfd_bread (compressed_buffer, ++ compressed_size, abfd) != compressed_size) ++ error (_("can't read data from '%s', section '%s'"), ++ bfd_get_filename (abfd), ++ bfd_get_section_name (abfd, sectp)); ++ ++ /* Read the zlib header. In this case, it should be "ZLIB" followed ++ by the uncompressed section size, 8 bytes in big-endian order. */ ++ if (compressed_size < header_size ++ || strncmp (compressed_buffer, "ZLIB", 4) != 0) ++ error (_("corrupt ZLIB header from '%s', section '%s'"), ++ bfd_get_filename (abfd), ++ bfd_get_section_name (abfd, sectp)); ++ uncompressed_size = compressed_buffer[4]; uncompressed_size <<= 8; ++ uncompressed_size += compressed_buffer[5]; uncompressed_size <<= 8; ++ uncompressed_size += compressed_buffer[6]; uncompressed_size <<= 8; ++ uncompressed_size += compressed_buffer[7]; uncompressed_size <<= 8; ++ uncompressed_size += compressed_buffer[8]; uncompressed_size <<= 8; ++ uncompressed_size += compressed_buffer[9]; uncompressed_size <<= 8; ++ uncompressed_size += compressed_buffer[10]; uncompressed_size <<= 8; ++ uncompressed_size += compressed_buffer[11]; ++ ++ /* It is possible the section consists of several compressed ++ buffers concatenated together, so we uncompress in a loop. */ ++ strm.zalloc = NULL; ++ strm.zfree = NULL; ++ strm.opaque = NULL; ++ strm.avail_in = compressed_size - header_size; ++ strm.next_in = (Bytef*) compressed_buffer + header_size; ++ strm.avail_out = uncompressed_size; ++ uncompressed_buffer = xmalloc (uncompressed_size); ++ inner_cleanup = make_cleanup (xfree, uncompressed_buffer); ++ rc = inflateInit (&strm); ++ while (strm.avail_in > 0) ++ { ++ if (rc != Z_OK) ++ error (_("setting up uncompression in '%s', section '%s': %d"), ++ bfd_get_filename (abfd), ++ bfd_get_section_name (abfd, sectp), ++ rc); ++ strm.next_out = ((Bytef*) uncompressed_buffer ++ + (uncompressed_size - strm.avail_out)); ++ rc = inflate (&strm, Z_FINISH); ++ if (rc != Z_STREAM_END) ++ error (_("zlib error uncompressing from '%s', section '%s': %d"), ++ bfd_get_filename (abfd), ++ bfd_get_section_name (abfd, sectp), ++ rc); ++ rc = inflateReset (&strm); ++ } ++ rc = inflateEnd (&strm); ++ if (rc != Z_OK ++ || strm.avail_out != 0) ++ error (_("concluding uncompression in '%s', section '%s': %d"), ++ bfd_get_filename (abfd), ++ bfd_get_section_name (abfd, sectp), ++ rc); ++ ++ discard_cleanups (inner_cleanup); ++ do_cleanups (cleanup); ++ ++ /* Attach the data to the BFD section. */ ++ descriptor->data = uncompressed_buffer; ++ descriptor->size = uncompressed_size; ++#endif ++} ++ ++/* See gdb_bfd.h. */ ++ ++const gdb_byte * ++gdb_bfd_map_section (asection *sectp, bfd_size_type *size) ++{ ++ bfd *abfd; ++ gdb_byte *buf, *retbuf; ++ unsigned char header[4]; ++ struct gdb_bfd_section_data *descriptor; ++ ++ gdb_assert ((sectp->flags & SEC_RELOC) == 0); ++ gdb_assert (size != NULL); ++ ++ abfd = sectp->owner; ++ ++ descriptor = get_section_descriptor (sectp); ++ ++ /* If the data was already read for this BFD, just reuse it. */ ++ if (descriptor->data != NULL) ++ goto done; ++ ++ /* Check if the file has a 4-byte header indicating compression. */ ++ if (bfd_get_section_size (sectp) > sizeof (header) ++ && bfd_seek (abfd, sectp->filepos, SEEK_SET) == 0 ++ && bfd_bread (header, sizeof (header), abfd) == sizeof (header)) ++ { ++ /* Upon decompression, update the buffer and its size. */ ++ if (strncmp (header, "ZLIB", sizeof (header)) == 0) ++ { ++ zlib_decompress_section (sectp, descriptor); ++ goto done; ++ } ++ } ++ ++#ifdef HAVE_MMAP ++ { ++ /* The page size, used when mmapping. */ ++ static int pagesize; ++ ++ if (pagesize == 0) ++ pagesize = getpagesize (); ++ ++ /* Only try to mmap sections which are large enough: we don't want ++ to waste space due to fragmentation. */ ++ ++ if (bfd_get_section_size (sectp) > 4 * pagesize) ++ { ++ descriptor->size = bfd_get_section_size (sectp); ++ descriptor->data = bfd_mmap (abfd, 0, descriptor->size, PROT_READ, ++ MAP_PRIVATE, sectp->filepos, ++ &descriptor->map_addr, ++ &descriptor->map_len); ++ ++ if ((caddr_t)descriptor->data != MAP_FAILED) ++ { ++#if HAVE_POSIX_MADVISE ++ posix_madvise (descriptor->map_addr, descriptor->map_len, ++ POSIX_MADV_WILLNEED); ++#endif ++ goto done; ++ } ++ ++ /* On failure, clear out the section data and try again. */ ++ memset (descriptor, 0, sizeof (*descriptor)); ++ } ++ } ++#endif /* HAVE_MMAP */ ++ ++ /* If we get here, we are a normal, not-compressed section. */ ++ ++ descriptor->size = bfd_get_section_size (sectp); ++ descriptor->data = xmalloc (descriptor->size); ++ ++ if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0 ++ || bfd_bread (descriptor->data, bfd_get_section_size (sectp), ++ abfd) != bfd_get_section_size (sectp)) ++ { ++ xfree (descriptor->data); ++ descriptor->data = NULL; ++ error (_("Can't read data for section '%s'"), ++ bfd_get_filename (abfd)); ++ } ++ ++ done: ++ gdb_assert (descriptor->data != NULL); ++ *size = descriptor->size; ++ return descriptor->data; ++} +diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h +new file mode 100644 +index 0000000..1dd82c3 +--- /dev/null ++++ b/gdb/gdb_bfd.h +@@ -0,0 +1,61 @@ ++/* Definitions for BFD wrappers used by GDB. ++ ++ Copyright (C) 2011, 2012 ++ Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#ifndef GDB_BFD_H ++#define GDB_BFD_H ++ ++/* Make a copy ABFD's filename using bfd_alloc, and reassign it to the ++ BFD. This ensures that the BFD's filename has the same lifetime as ++ the BFD itself. */ ++ ++void gdb_bfd_stash_filename (struct bfd *abfd); ++ ++/* Open a read-only (FOPEN_RB) BFD given arguments like bfd_fopen. ++ Returns NULL on error. On success, returns a new reference to the ++ BFD, which must be freed with gdb_bfd_unref. BFDs returned by this ++ call are shared among all callers opening the same file. If FD is ++ not -1, then after this call it is owned by BFD. */ ++ ++struct bfd *gdb_bfd_open (const char *name, const char *target, int fd); ++ ++/* Acquire a new reference to ABFD. Returns ABFD for convenience. ++ It is fine for ABFD to be NULL; in this case the function does ++ nothing and returns NULL. */ ++ ++struct bfd *gdb_bfd_ref (struct bfd *abfd); ++ ++/* Release a reference to ABFD. If this is the last reference, ABFD ++ will be freed. If ABFD is NULL, this function does nothing. */ ++ ++void gdb_bfd_unref (struct bfd *abfd); ++ ++/* Try to read or map the contents of the section SECT. If ++ successful, the section data is returned and *SIZE is set to the ++ size of the section data; this may not be the same as the size ++ according to bfd_get_section_size if the section was compressed. ++ The returned section data is associated with the BFD and will be ++ destroyed when the BFD is destroyed. There is no other way to free ++ it; for temporary uses of section data, see ++ bfd_malloc_and_get_section. SECT may not have relocations. This ++ function will throw on error. */ ++ ++const gdb_byte *gdb_bfd_map_section (asection *section, bfd_size_type *size); ++ ++#endif /* GDB_BFD_H */ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c -index e3db1ed..9a346e6 100644 +index 0eec874..7217639 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -37,6 +37,9 @@ @@ -3328,10 +6193,10 @@ index e3db1ed..9a346e6 100644 add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h -index 887dfdb..6e972d1 100644 +index cf7d398..a0f5b17 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h -@@ -213,6 +213,11 @@ enum type_instance_flag_value +@@ -214,6 +214,11 @@ enum type_instance_flag_value #define TYPE_TARGET_STUB(t) (TYPE_MAIN_TYPE (t)->flag_target_stub) @@ -3343,7 +6208,7 @@ index 887dfdb..6e972d1 100644 /* Static type. If this is set, the corresponding type had a static modifier. Note: This may be unnecessary, since static data members -@@ -296,6 +301,50 @@ enum type_instance_flag_value +@@ -297,6 +302,50 @@ enum type_instance_flag_value #define TYPE_FLAG_ENUM(t) (TYPE_MAIN_TYPE (t)->flag_flag_enum) @@ -3394,7 +6259,7 @@ index 887dfdb..6e972d1 100644 /* Constant type. If this is set, the corresponding type has a const modifier. */ -@@ -406,6 +455,15 @@ struct main_type +@@ -407,6 +456,15 @@ struct main_type /* True if this type was declared with "class" rather than "struct". */ unsigned int flag_declared_class : 1; @@ -3410,7 +6275,7 @@ index 887dfdb..6e972d1 100644 /* True if this is an enum type with disjoint values. This affects how the enum is printed. */ -@@ -486,6 +544,20 @@ struct main_type +@@ -487,6 +545,20 @@ struct main_type struct type *target_type; @@ -3431,7 +6296,7 @@ index 887dfdb..6e972d1 100644 /* For structure and union types, a description of each field. For set and pascal array types, there is one "field", whose type is the domain type of the set or array. -@@ -568,13 +640,34 @@ struct main_type +@@ -569,13 +641,34 @@ struct main_type struct range_bounds { @@ -3471,7 +6336,7 @@ index 887dfdb..6e972d1 100644 /* Flags indicating whether the values of low and high are valid. When true, the respective range value is -@@ -1016,9 +1109,9 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -1040,9 +1133,9 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type #define TYPE_CHAIN(thistype) (thistype)->chain @@ -3484,7 +6349,7 @@ index 887dfdb..6e972d1 100644 calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe. */ #define TYPE_LENGTH(thistype) (thistype)->length /* Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you want the real -@@ -1026,11 +1119,16 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -1050,11 +1143,16 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_CODE(thistype) TYPE_MAIN_TYPE(thistype)->code #define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields @@ -3503,7 +6368,7 @@ index 887dfdb..6e972d1 100644 #define TYPE_LOW_BOUND_UNDEFINED(range_type) \ TYPE_RANGE_DATA(range_type)->low_undefined #define TYPE_HIGH_BOUND_UNDEFINED(range_type) \ -@@ -1047,7 +1145,14 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -1071,7 +1169,14 @@ extern void allocate_gnat_aux_type (struct type *); (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype)))) #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \ @@ -3519,7 +6384,7 @@ index 887dfdb..6e972d1 100644 /* C++ */ -@@ -1489,6 +1594,18 @@ extern struct type *create_array_type (struct type *, struct type *, +@@ -1513,6 +1618,18 @@ extern struct type *create_array_type (struct type *, struct type *, struct type *); extern struct type *lookup_array_range_type (struct type *, int, int); @@ -3538,7 +6403,7 @@ index 887dfdb..6e972d1 100644 extern struct type *create_string_type (struct type *, struct type *, struct type *); extern struct type *lookup_string_range_type (struct type *, int, int); -@@ -1534,6 +1651,10 @@ extern int is_public_ancestor (struct type *, struct type *); +@@ -1558,6 +1675,10 @@ extern int is_public_ancestor (struct type *, struct type *); extern int is_unique_ancestor (struct type *, struct value *); @@ -3549,7 +6414,7 @@ index 887dfdb..6e972d1 100644 /* Overload resolution */ #define LENGTH_MATCH(bv) ((bv)->rank[0]) -@@ -1609,10 +1730,13 @@ extern void maintenance_print_type (char *, int); +@@ -1633,10 +1754,13 @@ extern void maintenance_print_type (char *, int); extern htab_t create_copied_types_hash (struct objfile *objfile); @@ -3565,8 +6430,287 @@ index 887dfdb..6e972d1 100644 +#endif + #endif /* GDBTYPES_H */ +diff --git a/gdb/jit.c b/gdb/jit.c +index 568d17b..6478397 100644 +--- a/gdb/jit.c ++++ b/gdb/jit.c +@@ -38,6 +38,7 @@ + #include "gdb-dlfcn.h" + #include "gdb_stat.h" + #include "exceptions.h" ++#include "gdb_bfd.h" + + static const char *jit_reader_dir = NULL; + +@@ -132,12 +133,11 @@ mem_bfd_iovec_stat (struct bfd *abfd, void *stream, struct stat *sb) + static struct bfd * + bfd_open_from_target_memory (CORE_ADDR addr, ULONGEST size, char *target) + { +- const char *filename = xstrdup (""); + struct target_buffer *buffer = xmalloc (sizeof (struct target_buffer)); + + buffer->base = addr; + buffer->size = size; +- return bfd_openr_iovec (filename, target, ++ return bfd_openr_iovec ("", target, + mem_bfd_iovec_open, + buffer, + mem_bfd_iovec_pread, +@@ -861,6 +861,7 @@ jit_bfd_try_read_symtab (struct jit_code_entry *code_entry, + puts_unfiltered (_("Error opening JITed symbol file, ignoring it.\n")); + return; + } ++ nbfd = gdb_bfd_ref (nbfd); + + /* Check the format. NOTE: This initializes important data that GDB uses! + We would segfault later without this line. */ +@@ -868,7 +869,7 @@ jit_bfd_try_read_symtab (struct jit_code_entry *code_entry, + { + printf_unfiltered (_("\ + JITed symbol file is not an object file, ignoring it.\n")); +- bfd_close (nbfd); ++ gdb_bfd_unref (nbfd); + return; + } + +diff --git a/gdb/m32r-rom.c b/gdb/m32r-rom.c +index 76e4bf1..ffda6f9 100644 +--- a/gdb/m32r-rom.c ++++ b/gdb/m32r-rom.c +@@ -40,6 +40,7 @@ + #include "inferior.h" + #include + #include "regcache.h" ++#include "gdb_bfd.h" + + /* + * All this stuff just to get my host computer's IP address! +@@ -124,13 +125,15 @@ m32r_load (char *filename, int from_tty) + bfd *abfd; + unsigned int data_count = 0; + struct timeval start_time, end_time; ++ struct cleanup *cleanup; + + if (filename == NULL || filename[0] == 0) + filename = get_exec_file (1); + +- abfd = bfd_openr (filename, 0); ++ abfd = gdb_bfd_ref (bfd_openr (filename, 0)); + if (!abfd) + error (_("Unable to open file %s."), filename); ++ cleanup = make_cleanup_bfd_unref (abfd); + if (bfd_check_format (abfd, bfd_object) == 0) + error (_("File is not an object file.")); + gettimeofday (&start_time, NULL); +@@ -188,6 +191,7 @@ m32r_load (char *filename, int from_tty) + confused... */ + + clear_symtab_users (0); ++ do_cleanups (cleanup); + } + + static void +@@ -434,6 +438,7 @@ m32r_upload_command (char *args, int from_tty) + char buf[1024]; + struct hostent *hostent; + struct in_addr inet_addr; ++ struct cleanup *cleanup; + + /* First check to see if there's an ethernet port! */ + monitor_printf ("ust\r"); +@@ -524,7 +529,8 @@ m32r_upload_command (char *args, int from_tty) + printf_filtered (" -- Ethernet load complete.\n"); + + gettimeofday (&end_time, NULL); +- abfd = bfd_openr (args, 0); ++ abfd = gdb_bfd_ref (bfd_openr (args, 0)); ++ cleanup = make_cleanup_bfd_unref (abfd); + if (abfd != NULL) + { /* Download is done -- print section statistics. */ + if (bfd_check_format (abfd, bfd_object) == 0) +@@ -565,6 +571,7 @@ m32r_upload_command (char *args, int from_tty) + confused... */ + + clear_symtab_users (0); ++ do_cleanups (cleanup); + } + + /* Provide a prototype to silence -Wmissing-prototypes. */ +diff --git a/gdb/machoread.c b/gdb/machoread.c +index 22530ab..6d309bb 100644 +--- a/gdb/machoread.c ++++ b/gdb/machoread.c +@@ -466,14 +466,14 @@ macho_add_oso_symfile (oso_el *oso, bfd *abfd, + { + warning (_("`%s': can't read symbols: %s."), oso->name, + bfd_errmsg (bfd_get_error ())); +- bfd_close (abfd); ++ gdb_bfd_unref (abfd); + return; + } + + if (abfd->my_archive == NULL && oso->mtime != bfd_get_mtime (abfd)) + { + warning (_("`%s': file time stamp mismatch."), oso->name); +- bfd_close (abfd); ++ gdb_bfd_unref (abfd); + return; + } + +@@ -482,7 +482,7 @@ macho_add_oso_symfile (oso_el *oso, bfd *abfd, + oso->nbr_syms)) + { + warning (_("`%s': can't create hash table"), oso->name); +- bfd_close (abfd); ++ gdb_bfd_unref (abfd); + return; + } + +@@ -629,10 +629,10 @@ macho_add_oso_symfile (oso_el *oso, bfd *abfd, + + bfd_hash_table_free (&table); + +- /* Make sure that the filename was malloc'ed. The current filename comes +- either from an OSO symbol name or from an archive name. Memory for both +- is not managed by gdb. */ +- abfd->filename = xstrdup (abfd->filename); ++ /* Make sure that the filename has the correct lifetime. The ++ current filename comes either from an OSO symbol name or from an ++ archive name. Memory for both is not managed by gdb. */ ++ gdb_bfd_stash_filename (abfd); + + /* We need to clear SYMFILE_MAINLINE to avoid interractive question + from symfile.c:symbol_file_add_with_addrs_or_offsets. */ +@@ -651,6 +651,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags) + int ix; + VEC (oso_el) *vec; + oso_el *oso; ++ struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); + + vec = oso_vector; + oso_vector = NULL; +@@ -677,6 +678,8 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags) + memcpy (archive_name, oso->name, pfx_len); + archive_name[pfx_len] = '\0'; + ++ make_cleanup (xfree, archive_name); ++ + /* Compute number of oso for this archive. */ + for (last_ix = ix; + VEC_iterate (oso_el, vec, last_ix, oso2); last_ix++) +@@ -686,7 +689,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags) + } + + /* Open the archive and check the format. */ +- archive_bfd = bfd_openr (archive_name, gnutarget); ++ archive_bfd = gdb_bfd_ref (bfd_openr (archive_name, gnutarget)); + if (archive_bfd == NULL) + { + warning (_("Could not open OSO archive file \"%s\""), +@@ -698,17 +701,21 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags) + { + warning (_("OSO archive file \"%s\" not an archive."), + archive_name); +- bfd_close (archive_bfd); ++ gdb_bfd_unref (archive_bfd); + ix = last_ix; + continue; + } +- member_bfd = bfd_openr_next_archived_file (archive_bfd, NULL); ++ ++ gdb_bfd_stash_filename (archive_bfd); ++ ++ member_bfd = gdb_bfd_ref (bfd_openr_next_archived_file (archive_bfd, ++ NULL)); + + if (member_bfd == NULL) + { + warning (_("Could not read archive members out of " + "OSO archive \"%s\""), archive_name); +- bfd_close (archive_bfd); ++ gdb_bfd_unref (archive_bfd); + ix = last_ix; + continue; + } +@@ -738,12 +745,13 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags) + } + + prev = member_bfd; +- member_bfd = bfd_openr_next_archived_file +- (archive_bfd, member_bfd); ++ member_bfd ++ = gdb_bfd_ref (bfd_openr_next_archived_file (archive_bfd, ++ member_bfd)); + + /* Free previous member if not referenced by an oso. */ + if (ix2 >= last_ix) +- bfd_close (prev); ++ gdb_bfd_unref (prev); + } + for (ix2 = ix; ix2 < last_ix; ix2++) + { +@@ -759,7 +767,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags) + { + bfd *abfd; + +- abfd = bfd_openr (oso->name, gnutarget); ++ abfd = gdb_bfd_ref (bfd_openr (oso->name, gnutarget)); + if (!abfd) + warning (_("`%s': can't open to read symbols: %s."), oso->name, + bfd_errmsg (bfd_get_error ())); +@@ -771,6 +779,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags) + } + + VEC_free (oso_el, vec); ++ do_cleanups (cleanup); + } + + /* DSYM (debug symbols) files contain the debug info of an executable. +@@ -808,20 +817,18 @@ macho_check_dsym (struct objfile *objfile) + warning (_("can't find UUID in %s"), objfile->name); + return NULL; + } +- dsym_filename = xstrdup (dsym_filename); +- dsym_bfd = bfd_openr (dsym_filename, gnutarget); ++ dsym_bfd = gdb_bfd_ref (bfd_openr (dsym_filename, gnutarget)); + if (dsym_bfd == NULL) + { + warning (_("can't open dsym file %s"), dsym_filename); +- xfree (dsym_filename); + return NULL; + } ++ gdb_bfd_stash_filename (dsym_filename); + + if (!bfd_check_format (dsym_bfd, bfd_object)) + { +- bfd_close (dsym_bfd); ++ gdb_bfd_unref (dsym_bfd); + warning (_("bad dsym file format: %s"), bfd_errmsg (bfd_get_error ())); +- xfree (dsym_filename); + return NULL; + } + +@@ -829,16 +836,14 @@ macho_check_dsym (struct objfile *objfile) + BFD_MACH_O_LC_UUID, &dsym_uuid) == 0) + { + warning (_("can't find UUID in %s"), dsym_filename); +- bfd_close (dsym_bfd); +- xfree (dsym_filename); ++ gdb_bfd_unref (dsym_bfd); + return NULL; + } + if (memcmp (dsym_uuid->command.uuid.uuid, main_uuid->command.uuid.uuid, + sizeof (main_uuid->command.uuid.uuid))) + { + warning (_("dsym file UUID doesn't match the one in %s"), objfile->name); +- bfd_close (dsym_bfd); +- xfree (dsym_filename); ++ gdb_bfd_unref (dsym_bfd); + return NULL; + } + return dsym_bfd; diff --git a/gdb/main.c b/gdb/main.c -index 3148d72..c5b4826 100644 +index 025bbe0..a8c1a97 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -37,6 +37,7 @@ @@ -3716,6 +6860,121 @@ index 3148d72..c5b4826 100644 --quiet Do not print version number on startup.\n\ --readnow Fully read symbol files on first access.\n\ "), stream); +diff --git a/gdb/objfiles.c b/gdb/objfiles.c +index f5e5c75..5ff0eb2 100644 +--- a/gdb/objfiles.c ++++ b/gdb/objfiles.c +@@ -53,6 +53,7 @@ + #include "complaints.h" + #include "psymtab.h" + #include "solist.h" ++#include "gdb_bfd.h" + + /* Prototypes for local functions */ + +@@ -193,9 +194,9 @@ allocate_objfile (bfd *abfd, int flags) + + /* Update the per-objfile information that comes from the bfd, ensuring + that any data that is reference is saved in the per-objfile data +- region. */ ++ region. Note that we steal a reference to ABFD. */ + +- objfile->obfd = gdb_bfd_ref (abfd); ++ objfile->obfd = abfd; + if (abfd != NULL) + { + /* Look up the gdbarch associated with the BFD. */ +@@ -1456,75 +1457,6 @@ objfiles_changed (void) + get_objfile_pspace_data (current_program_space)->objfiles_changed_p = 1; + } + +-/* Close ABFD, and warn if that fails. */ +- +-int +-gdb_bfd_close_or_warn (struct bfd *abfd) +-{ +- int ret; +- char *name = bfd_get_filename (abfd); +- +- ret = bfd_close (abfd); +- +- if (!ret) +- warning (_("cannot close \"%s\": %s"), +- name, bfd_errmsg (bfd_get_error ())); +- +- return ret; +-} +- +-/* Add reference to ABFD. Returns ABFD. */ +-struct bfd * +-gdb_bfd_ref (struct bfd *abfd) +-{ +- int *p_refcount; +- +- if (abfd == NULL) +- return NULL; +- +- p_refcount = bfd_usrdata (abfd); +- +- if (p_refcount != NULL) +- { +- *p_refcount += 1; +- return abfd; +- } +- +- p_refcount = xmalloc (sizeof (*p_refcount)); +- *p_refcount = 1; +- bfd_usrdata (abfd) = p_refcount; +- +- return abfd; +-} +- +-/* Unreference and possibly close ABFD. */ +-void +-gdb_bfd_unref (struct bfd *abfd) +-{ +- int *p_refcount; +- char *name; +- +- if (abfd == NULL) +- return; +- +- p_refcount = bfd_usrdata (abfd); +- +- /* Valid range for p_refcount: a pointer to int counter, which has a +- value of 1 (single owner) or 2 (shared). */ +- gdb_assert (*p_refcount == 1 || *p_refcount == 2); +- +- *p_refcount -= 1; +- if (*p_refcount > 0) +- return; +- +- xfree (p_refcount); +- bfd_usrdata (abfd) = NULL; /* Paranoia. */ +- +- name = bfd_get_filename (abfd); +- gdb_bfd_close_or_warn (abfd); +- xfree (name); +-} +- + /* The default implementation for the "iterate_over_objfiles_in_search_order" + gdbarch method. It is equivalent to use the ALL_OBJFILES macro, + searching the objfiles in the order they are stored internally, +diff --git a/gdb/objfiles.h b/gdb/objfiles.h +index 01c3aea..0df5798 100644 +--- a/gdb/objfiles.h ++++ b/gdb/objfiles.h +@@ -522,10 +522,6 @@ extern void set_objfile_data (struct objfile *objfile, + extern void *objfile_data (struct objfile *objfile, + const struct objfile_data *data); + +-extern struct bfd *gdb_bfd_ref (struct bfd *abfd); +-extern void gdb_bfd_unref (struct bfd *abfd); +-extern int gdb_bfd_close_or_warn (struct bfd *abfd); +- + extern void default_iterate_over_objfiles_in_search_order + (struct gdbarch *gdbarch, + iterate_over_objfiles_in_search_order_cb_ftype *cb, diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index b8434ed..98a076d 100644 --- a/gdb/p-valprint.c @@ -3797,10 +7056,10 @@ index b8434ed..98a076d 100644 void diff --git a/gdb/parse.c b/gdb/parse.c -index f54c6f2..70e9a05 100644 +index c372f40..6707c9a 100644 --- a/gdb/parse.c +++ b/gdb/parse.c -@@ -1516,6 +1516,7 @@ parser_fprintf (FILE *x, const char *y, ...) +@@ -1584,6 +1584,7 @@ parser_fprintf (FILE *x, const char *y, ...) int operator_check_standard (struct expression *exp, int pos, @@ -3808,7 +7067,7 @@ index f54c6f2..70e9a05 100644 int (*objfile_func) (struct objfile *objfile, void *data), void *data) -@@ -1557,7 +1558,7 @@ operator_check_standard (struct expression *exp, int pos, +@@ -1625,7 +1626,7 @@ operator_check_standard (struct expression *exp, int pos, struct type *type = elts[pos + 2 + arg].type; struct objfile *objfile = TYPE_OBJFILE (type); @@ -3817,7 +7076,7 @@ index f54c6f2..70e9a05 100644 return 1; } } -@@ -1575,7 +1576,8 @@ operator_check_standard (struct expression *exp, int pos, +@@ -1643,7 +1644,8 @@ operator_check_standard (struct expression *exp, int pos, /* Check objfile where the variable itself is placed. SYMBOL_OBJ_SECTION (symbol) may be NULL. */ @@ -3827,7 +7086,7 @@ index f54c6f2..70e9a05 100644 return 1; /* Check objfile where is placed the code touching the variable. */ -@@ -1588,24 +1590,27 @@ operator_check_standard (struct expression *exp, int pos, +@@ -1656,24 +1658,27 @@ operator_check_standard (struct expression *exp, int pos, /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */ @@ -3863,7 +7122,7 @@ index f54c6f2..70e9a05 100644 int (*objfile_func) (struct objfile *objfile, void *data), void *data) { -@@ -1620,7 +1625,9 @@ exp_iterate (struct expression *exp, +@@ -1688,7 +1693,9 @@ exp_iterate (struct expression *exp, pos = endpos - oplen; if (exp->language_defn->la_exp_desc->operator_check (exp, pos, @@ -3874,7 +7133,7 @@ index f54c6f2..70e9a05 100644 return 1; endpos = pos; -@@ -1651,8 +1658,29 @@ exp_uses_objfile (struct expression *exp, struct objfile *objfile) +@@ -1719,8 +1726,29 @@ exp_uses_objfile (struct expression *exp, struct objfile *objfile) { gdb_assert (objfile->separate_debug_objfile_backlink == NULL); @@ -3906,10 +7165,10 @@ index f54c6f2..70e9a05 100644 void _initialize_parse (void) diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h -index 72b9e2f..719a652 100644 +index aa600a1..554c272 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h -@@ -215,6 +215,8 @@ extern void operator_length_standard (const struct expression *, int, int *, +@@ -217,6 +217,8 @@ extern void operator_length_standard (const struct expression *, int, int *, int *); extern int operator_check_standard (struct expression *exp, int pos, @@ -3918,7 +7177,7 @@ index 72b9e2f..719a652 100644 int (*objfile_func) (struct objfile *objfile, void *data), void *data); -@@ -301,6 +303,7 @@ struct exp_descriptor +@@ -303,6 +305,7 @@ struct exp_descriptor value should be immediately returned to the caller. Otherwise zero should be returned. */ int (*operator_check) (struct expression *exp, int pos, @@ -3926,7 +7185,7 @@ index 72b9e2f..719a652 100644 int (*objfile_func) (struct objfile *objfile, void *data), void *data); -@@ -339,4 +342,10 @@ extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3); +@@ -341,4 +344,10 @@ extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3); extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile); @@ -3938,18 +7197,18 @@ index 72b9e2f..719a652 100644 + #endif /* PARSER_DEFS_H */ diff --git a/gdb/printcmd.c b/gdb/printcmd.c -index 030a4f2..306be18 100644 +index 2a0a886..c13a044 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c -@@ -49,6 +49,7 @@ - #include "charset.h" +@@ -50,6 +50,7 @@ #include "arch-utils.h" #include "cli/cli-utils.h" + #include "format.h" +#include "dwarf2loc.h" #ifdef TUI #include "tui/tui.h" /* For tui_active et al. */ -@@ -974,6 +975,11 @@ print_command_1 (char *exp, int inspect, int voidprint) +@@ -968,6 +969,11 @@ print_command_1 (char *exp, int inspect, int voidprint) else val = access_value_history (0); @@ -3961,7 +7220,7 @@ index 030a4f2..306be18 100644 if (voidprint || (val && value_type (val) && TYPE_CODE (value_type (val)) != TYPE_CODE_VOID)) { -@@ -1062,6 +1068,9 @@ output_command (char *exp, int from_tty) +@@ -1056,6 +1062,9 @@ output_command (char *exp, int from_tty) val = evaluate_expression (expr); @@ -3971,7 +7230,7 @@ index 030a4f2..306be18 100644 annotate_value_begin (value_type (val)); get_formatted_print_options (&opts, format); -@@ -1491,6 +1500,24 @@ x_command (char *exp, int from_tty) +@@ -1485,6 +1494,24 @@ x_command (char *exp, int from_tty) set_internalvar (lookup_internalvar ("__"), last_examine_value); } } @@ -3996,7 +7255,7 @@ index 030a4f2..306be18 100644 /* Add an expression to the auto-display chain. -@@ -1986,6 +2013,10 @@ print_variable_and_value (const char *name, struct symbol *var, +@@ -1980,6 +2007,10 @@ print_variable_and_value (const char *name, struct symbol *var, struct value_print_options opts; val = read_var_value (var, frame); @@ -4007,7 +7266,7 @@ index 030a4f2..306be18 100644 get_user_print_options (&opts); opts.deref_ref = 1; common_val_print (val, stream, indent, &opts, current_language); -@@ -2899,4 +2930,8 @@ Show printing of source filename and line number with ."), NULL, +@@ -2620,4 +2651,8 @@ Show printing of source filename and line number with ."), NULL, add_com ("eval", no_class, eval_command, _("\ Convert \"printf format string\", arg1, arg2, arg3, ..., argn to\n\ a command line, and call it.")); @@ -4016,6 +7275,46 @@ index 030a4f2..306be18 100644 + observer_attach_mark_used (print_types_mark_used); +#endif } +diff --git a/gdb/procfs.c b/gdb/procfs.c +index 774df2e..32cb468 100644 +--- a/gdb/procfs.c ++++ b/gdb/procfs.c +@@ -3486,7 +3486,7 @@ insert_dbx_link_bpt_in_file (int fd, CORE_ADDR ignored) + long storage_needed; + CORE_ADDR sym_addr; + +- abfd = bfd_fdopenr ("unamed", 0, fd); ++ abfd = gdb_bfd_ref (bfd_fdopenr ("unamed", 0, fd)); + if (abfd == NULL) + { + warning (_("Failed to create a bfd: %s."), bfd_errmsg (bfd_get_error ())); +@@ -3497,7 +3497,7 @@ insert_dbx_link_bpt_in_file (int fd, CORE_ADDR ignored) + { + /* Not the correct format, so we can not possibly find the dbx_link + symbol in it. */ +- bfd_close (abfd); ++ gdb_bfd_unref (abfd); + return 0; + } + +@@ -3511,14 +3511,14 @@ insert_dbx_link_bpt_in_file (int fd, CORE_ADDR ignored) + if (dbx_link_bpt == NULL) + { + warning (_("Failed to insert dbx_link breakpoint.")); +- bfd_close (abfd); ++ gdb_bfd_unref (abfd); + return 0; + } +- bfd_close (abfd); ++ gdb_bfd_unref (abfd); + return 1; + } + +- bfd_close (abfd); ++ gdb_bfd_unref (abfd); + return 0; + } + diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py new file mode 100644 index 0000000..5654546 @@ -5020,7 +8319,7 @@ index 6f67bdb..5ddd6bc 100644 diff --git a/gdb/python/python.c b/gdb/python/python.c -index 19eb7b5..0e7256e 100644 +index c66efe4..0211fcb 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -66,10 +66,13 @@ static const char *gdbpy_should_print_stack = python_excp_message; @@ -5037,7 +8336,7 @@ index 19eb7b5..0e7256e 100644 static PyMethodDef GdbMethods[]; -@@ -974,6 +977,53 @@ gdbpy_print_stack (void) +@@ -979,6 +982,53 @@ gdbpy_print_stack (void) /* Return the current Progspace. There always is one. */ @@ -5091,7 +8390,7 @@ index 19eb7b5..0e7256e 100644 static PyObject * gdbpy_get_current_progspace (PyObject *unused1, PyObject *unused2) -@@ -1415,6 +1465,8 @@ static PyMethodDef GdbMethods[] = +@@ -1420,6 +1470,8 @@ static PyMethodDef GdbMethods[] = "Get a value from history" }, { "execute", (PyCFunction) execute_gdb_command, METH_VARARGS | METH_KEYWORDS, "Execute a gdb command" }, @@ -5113,8 +8412,627 @@ index dd7066f..f0f6e90 100644 int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, +diff --git a/gdb/record.c b/gdb/record.c +index bb0fe52..ec42aac 100644 +--- a/gdb/record.c ++++ b/gdb/record.c +@@ -32,6 +32,7 @@ + #include "gcore.h" + #include "event-loop.h" + #include "inf-loop.h" ++#include "gdb_bfd.h" + + #include + +@@ -2638,7 +2639,7 @@ record_save_cleanups (void *data) + bfd *obfd = data; + char *pathname = xstrdup (bfd_get_filename (obfd)); + +- bfd_close (obfd); ++ gdb_bfd_unref (obfd); + unlink (pathname); + xfree (pathname); + } +@@ -2854,7 +2855,7 @@ cmd_record_save (char *args, int from_tty) + } + + do_cleanups (set_cleanups); +- bfd_close (obfd); ++ gdb_bfd_unref (obfd); + discard_cleanups (old_cleanups); + + /* Succeeded. */ +diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c +index 47f4405..b4b7324 100644 +--- a/gdb/remote-m32r-sdi.c ++++ b/gdb/remote-m32r-sdi.c +@@ -39,6 +39,7 @@ + #include + #include + #include ++#include "gdb_bfd.h" + + + #include "serial.h" +@@ -1257,13 +1258,13 @@ m32r_load (char *args, int from_tty) + if (!filename) + filename = get_exec_file (1); + +- pbfd = bfd_openr (filename, gnutarget); ++ pbfd = gdb_bfd_ref (bfd_openr (filename, gnutarget)); + if (pbfd == NULL) + { + perror_with_name (filename); + return; + } +- old_chain = make_cleanup_bfd_close (pbfd); ++ old_chain = make_cleanup_bfd_unref (pbfd); + + if (!bfd_check_format (pbfd, bfd_object)) + error (_("\"%s\" is not an object file: %s"), filename, +diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c +index babbf19..b46325f 100644 +--- a/gdb/remote-mips.c ++++ b/gdb/remote-mips.c +@@ -36,6 +36,7 @@ + #include + #include "mips-tdep.h" + #include "gdbthread.h" ++#include "gdb_bfd.h" + + + /* Breakpoint types. Values 0, 1, and 2 must agree with the watch +@@ -2783,20 +2784,23 @@ mips_load_srec (char *args) + unsigned int i; + unsigned int srec_frame = 200; + int reclen; ++ struct cleanup *cleanup; + static int hashmark = 1; + + buffer = alloca (srec_frame * 2 + 256); + +- abfd = bfd_openr (args, 0); ++ abfd = gdb_bfd_ref (bfd_openr (args, 0)); + if (!abfd) + { + printf_filtered ("Unable to open file %s\n", args); + return; + } + ++ cleanup = make_cleanup_bfd_unref (abfd); + if (bfd_check_format (abfd, bfd_object) == 0) + { + printf_filtered ("File is not an object file\n"); ++ do_cleanups (cleanup); + return; + } + +@@ -2850,6 +2854,7 @@ mips_load_srec (char *args) + send_srec (srec, reclen, abfd->start_address); + + serial_flush_input (mips_desc); ++ do_cleanups (cleanup); + } + + /* +@@ -3366,20 +3371,23 @@ pmon_load_fast (char *file) + int bintotal = 0; + int final = 0; + int finished = 0; ++ struct cleanup *cleanup; + + buffer = (char *) xmalloc (MAXRECSIZE + 1); + binbuf = (unsigned char *) xmalloc (BINCHUNK); + +- abfd = bfd_openr (file, 0); ++ abfd = gdb_bfd_ref (bfd_openr (file, 0)); + if (!abfd) + { + printf_filtered ("Unable to open file %s\n", file); + return; + } ++ cleanup = make_cleanup_bfd_unref (abfd); + + if (bfd_check_format (abfd, bfd_object) == 0) + { + printf_filtered ("File is not an object file\n"); ++ do_cleanups (cleanup); + return; + } + +@@ -3503,6 +3511,7 @@ pmon_load_fast (char *file) + pmon_end_download (final, bintotal); + } + ++ do_cleanups (cleanup); + return; + } + +diff --git a/gdb/remote.c b/gdb/remote.c +index 1c9367d..6ccab54 100644 +--- a/gdb/remote.c ++++ b/gdb/remote.c +@@ -42,6 +42,7 @@ + #include "cli/cli-decode.h" + #include "cli/cli-setshow.h" + #include "target-descriptions.h" ++#include "gdb_bfd.h" + + #include + #include +@@ -9823,11 +9824,15 @@ remote_filename_p (const char *filename) + bfd * + remote_bfd_open (const char *remote_file, const char *target) + { +- return bfd_openr_iovec (remote_file, target, +- remote_bfd_iovec_open, NULL, +- remote_bfd_iovec_pread, +- remote_bfd_iovec_close, +- remote_bfd_iovec_stat); ++ bfd *abfd = bfd_openr_iovec (remote_file, target, ++ remote_bfd_iovec_open, NULL, ++ remote_bfd_iovec_pread, ++ remote_bfd_iovec_close, ++ remote_bfd_iovec_stat); ++ ++ if (abfd != NULL) ++ gdb_bfd_stash_filename (abfd); ++ return abfd; + } + + void +diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c +index 0a2000a..017e997 100644 +--- a/gdb/rs6000-nat.c ++++ b/gdb/rs6000-nat.c +@@ -730,7 +730,7 @@ static struct vmap * + add_vmap (LdInfo *ldi) + { + bfd *abfd, *last; +- char *mem, *objname, *filename; ++ char *mem, *filename; + struct objfile *obj; + struct vmap *vp; + int fd; +@@ -743,21 +743,22 @@ add_vmap (LdInfo *ldi) + filename = LDI_FILENAME (ldi, arch64); + mem = filename + strlen (filename) + 1; + mem = xstrdup (mem); +- objname = xstrdup (filename); + + fd = LDI_FD (ldi, arch64); + if (fd < 0) + /* Note that this opens it once for every member; a possible + enhancement would be to only open it once for every object. */ +- abfd = bfd_openr (objname, gnutarget); ++ abfd = bfd_openr (filename, gnutarget); + else +- abfd = bfd_fdopenr (objname, gnutarget, fd); ++ abfd = bfd_fdopenr (filename, gnutarget, fd); ++ abfd = gdb_bfd_ref (abfd); + if (!abfd) + { + warning (_("Could not open `%s' as an executable file: %s"), +- objname, bfd_errmsg (bfd_get_error ())); ++ filename, bfd_errmsg (bfd_get_error ())); + return NULL; + } ++ gdb_bfd_stash_filename (abfd); + + /* Make sure we have an object file. */ + +@@ -768,23 +769,23 @@ add_vmap (LdInfo *ldi) + { + last = 0; + /* FIXME??? am I tossing BFDs? bfd? */ +- while ((last = bfd_openr_next_archived_file (abfd, last))) ++ while ((last = gdb_bfd_ref (bfd_openr_next_archived_file (abfd, last)))) + if (strcmp (mem, last->filename) == 0) + break; + + if (!last) + { +- warning (_("\"%s\": member \"%s\" missing."), objname, mem); +- bfd_close (abfd); ++ warning (_("\"%s\": member \"%s\" missing."), filename, mem); ++ gdb_bfd_unref (abfd); + return NULL; + } + + if (!bfd_check_format (last, bfd_object)) + { + warning (_("\"%s\": member \"%s\" not in executable format: %s."), +- objname, mem, bfd_errmsg (bfd_get_error ())); +- bfd_close (last); +- bfd_close (abfd); ++ filename, mem, bfd_errmsg (bfd_get_error ())); ++ gdb_bfd_unref (last); ++ gdb_bfd_unref (abfd); + return NULL; + } + +@@ -793,11 +794,11 @@ add_vmap (LdInfo *ldi) + else + { + warning (_("\"%s\": not in executable format: %s."), +- objname, bfd_errmsg (bfd_get_error ())); +- bfd_close (abfd); ++ filename, bfd_errmsg (bfd_get_error ())); ++ gdb_bfd_unref (abfd); + return NULL; + } +- obj = allocate_objfile (vp->bfd, 0); ++ obj = allocate_objfile (gdb_bfd_ref (vp->bfd), 0); + vp->objfile = obj; + + /* Always add symbols for the main objfile. */ +diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c +index d52fb46..7109ead 100644 +--- a/gdb/solib-darwin.c ++++ b/gdb/solib-darwin.c +@@ -28,6 +28,7 @@ + #include "inferior.h" + #include "regcache.h" + #include "gdbthread.h" ++#include "gdb_bfd.h" + + #include "gdb_assert.h" + +@@ -356,6 +357,7 @@ darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info) + gdb_byte *interp_name; + CORE_ADDR load_addr = 0; + bfd *dyld_bfd = NULL; ++ struct cleanup *cleanup; + + /* This method doesn't work with an attached process. */ + if (current_inferior ()->attach_flag) +@@ -366,24 +368,30 @@ darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info) + if (!interp_name) + return; + ++ cleanup = make_cleanup (null_cleanup, NULL); ++ + /* Create a bfd for the interpreter. */ +- dyld_bfd = bfd_openr (interp_name, gnutarget); ++ dyld_bfd = gdb_bfd_ref (bfd_openr (interp_name, gnutarget)); + if (dyld_bfd) + { + bfd *sub; + ++ make_cleanup_bfd_unref (dyld_bfd); + sub = bfd_mach_o_fat_extract (dyld_bfd, bfd_object, + gdbarch_bfd_arch_info (target_gdbarch)); + if (sub) +- dyld_bfd = sub; +- else + { +- bfd_close (dyld_bfd); +- dyld_bfd = NULL; ++ dyld_bfd = gdb_bfd_ref (sub); ++ make_cleanup_bfd_unref (sub); + } ++ else ++ dyld_bfd = NULL; + } + if (!dyld_bfd) +- return; ++ { ++ do_cleanups (cleanup); ++ return; ++ } + + /* We find the dynamic linker's base address by examining + the current pc (which should point at the entry point for the +@@ -395,7 +403,7 @@ darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info) + info->all_image_addr = + lookup_symbol_from_bfd (dyld_bfd, "_dyld_all_image_infos"); + +- bfd_close (dyld_bfd); ++ do_cleanups (cleanup); + + if (info->all_image_addr == 0) + return; +@@ -509,17 +517,10 @@ darwin_bfd_open (char *pathname) + gdbarch_bfd_arch_info (target_gdbarch)); + if (!res) + { +- bfd_close (abfd); +- make_cleanup (xfree, found_pathname); ++ make_cleanup_bfd_unref (abfd); + error (_("`%s': not a shared-library: %s"), +- found_pathname, bfd_errmsg (bfd_get_error ())); ++ bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ())); + } +- +- /* Make sure that the filename is malloc'ed. The current filename +- for fat-binaries BFDs is a name that was generated by BFD, usually +- a static string containing the name of the architecture. */ +- res->filename = xstrdup (pathname); +- + return res; + } + +diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c +index 2500c1f..fcc01a8 100644 +--- a/gdb/solib-dsbt.c ++++ b/gdb/solib-dsbt.c +@@ -30,6 +30,7 @@ + #include "gdbcmd.h" + #include "elf-bfd.h" + #include "exceptions.h" ++#include "gdb_bfd.h" + + #define GOT_MODULE_OFFSET 4 + +@@ -899,7 +900,7 @@ enable_break2 (void) + { + warning (_("Could not find symbol _dl_debug_addr in dynamic linker")); + enable_break_failure_warning (); +- bfd_close (tmp_bfd); ++ gdb_bfd_unref (tmp_bfd); + return 0; + } + +@@ -948,13 +949,13 @@ enable_break2 (void) + "(at address %s) from dynamic linker"), + hex_string_custom (addr + 8, 8)); + enable_break_failure_warning (); +- bfd_close (tmp_bfd); ++ gdb_bfd_unref (tmp_bfd); + return 0; + } + addr = extract_unsigned_integer (addr_buf, sizeof addr_buf, byte_order); + + /* We're done with the temporary bfd. */ +- bfd_close (tmp_bfd); ++ gdb_bfd_unref (tmp_bfd); + + /* We're also done with the loadmap. */ + xfree (ldm); +diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c +index 2f2c8b0..0f59535 100644 +--- a/gdb/solib-frv.c ++++ b/gdb/solib-frv.c +@@ -31,6 +31,7 @@ + #include "gdbcmd.h" + #include "elf/frv.h" + #include "exceptions.h" ++#include "gdb_bfd.h" + + /* Flag which indicates whether internal debug messages should be printed. */ + static int solib_frv_debug; +@@ -574,7 +575,7 @@ enable_break2 (void) + { + warning (_("Unable to determine dynamic linker loadmap address.")); + enable_break_failure_warning (); +- bfd_close (tmp_bfd); ++ gdb_bfd_unref (tmp_bfd); + return 0; + } + +@@ -589,7 +590,7 @@ enable_break2 (void) + warning (_("Unable to load dynamic linker loadmap at address %s."), + hex_string_custom (interp_loadmap_addr, 8)); + enable_break_failure_warning (); +- bfd_close (tmp_bfd); ++ gdb_bfd_unref (tmp_bfd); + return 0; + } + +@@ -623,7 +624,7 @@ enable_break2 (void) + warning (_("Could not find symbol _dl_debug_addr " + "in dynamic linker")); + enable_break_failure_warning (); +- bfd_close (tmp_bfd); ++ gdb_bfd_unref (tmp_bfd); + return 0; + } + +@@ -674,7 +675,7 @@ enable_break2 (void) + "(at address %s) from dynamic linker"), + hex_string_custom (addr + 8, 8)); + enable_break_failure_warning (); +- bfd_close (tmp_bfd); ++ gdb_bfd_unref (tmp_bfd); + return 0; + } + addr = extract_unsigned_integer (addr_buf, sizeof addr_buf, byte_order); +@@ -686,13 +687,13 @@ enable_break2 (void) + "(at address %s) from dynamic linker"), + hex_string_custom (addr, 8)); + enable_break_failure_warning (); +- bfd_close (tmp_bfd); ++ gdb_bfd_unref (tmp_bfd); + return 0; + } + addr = extract_unsigned_integer (addr_buf, sizeof addr_buf, byte_order); + + /* We're done with the temporary bfd. */ +- bfd_close (tmp_bfd); ++ gdb_bfd_unref (tmp_bfd); + + /* We're also done with the loadmap. */ + xfree (ldm); +diff --git a/gdb/solib-pa64.c b/gdb/solib-pa64.c +index 2b8d061..b55b67c 100644 +--- a/gdb/solib-pa64.c ++++ b/gdb/solib-pa64.c +@@ -362,7 +362,7 @@ manpage for methods to privately map shared library text.")); + to find any magic formula to find it for Solaris (appears to + be trivial on GNU/Linux). Therefore, we have to try an alternate + mechanism to find the dynamic linker's base address. */ +- tmp_bfd = bfd_openr (buf, gnutarget); ++ tmp_bfd = gdb_bfd_ref (bfd_openr (buf, gnutarget)); + if (tmp_bfd == NULL) + return; + +@@ -371,7 +371,7 @@ manpage for methods to privately map shared library text.")); + { + warning (_("Unable to grok dynamic linker %s as an object file"), + buf); +- bfd_close (tmp_bfd); ++ gdb_bfd_unref (tmp_bfd); + return; + } + +@@ -401,7 +401,7 @@ manpage for methods to privately map shared library text.")); + } + + /* We're done with the temporary bfd. */ +- bfd_close (tmp_bfd); ++ gdb_bfd_unref (tmp_bfd); + } + } + +diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c +index b5454e7..5eeae62 100644 +--- a/gdb/solib-spu.c ++++ b/gdb/solib-spu.c +@@ -36,6 +36,7 @@ + #include "breakpoint.h" + #include "gdbthread.h" + #include "exceptions.h" ++#include "gdb_bfd.h" + + #include "spu-tdep.h" + +@@ -325,19 +326,20 @@ spu_bfd_fopen (char *name, CORE_ADDR addr) + CORE_ADDR *open_closure = xmalloc (sizeof (CORE_ADDR)); + *open_closure = addr; + +- nbfd = bfd_openr_iovec (xstrdup (name), "elf32-spu", +- spu_bfd_iovec_open, open_closure, +- spu_bfd_iovec_pread, spu_bfd_iovec_close, +- spu_bfd_iovec_stat); ++ nbfd = gdb_bfd_ref (bfd_openr_iovec (name, "elf32-spu", ++ spu_bfd_iovec_open, open_closure, ++ spu_bfd_iovec_pread, spu_bfd_iovec_close, ++ spu_bfd_iovec_stat)); + if (!nbfd) + return NULL; + + if (!bfd_check_format (nbfd, bfd_object)) + { +- bfd_close (nbfd); ++ gdb_bfd_unref (nbfd); + return NULL; + } + ++ gdb_bfd_stash_filename (nbfd); + return nbfd; + } + +diff --git a/gdb/solib.c b/gdb/solib.c +index 90439ba..0fd955d 100644 +--- a/gdb/solib.c ++++ b/gdb/solib.c +@@ -46,6 +46,7 @@ + #include "solib.h" + #include "interps.h" + #include "filesystem.h" ++#include "gdb_bfd.h" + + /* Architecture-specific operations. */ + +@@ -360,9 +361,9 @@ solib_find (char *in_pathname, int *fd) + it is used as file handle to open the file. Throws an error if the file + could not be opened. Handles both local and remote file access. + +- PATHNAME must be malloc'ed by the caller. If successful, the new BFD's +- name will point to it. If unsuccessful, PATHNAME will be freed and the +- FD will be closed (unless FD was -1). */ ++ PATHNAME must be malloc'ed by the caller. It will be freed by this ++ function. If unsuccessful, the FD will be closed (unless FD was ++ -1). */ + + bfd * + solib_bfd_fopen (char *pathname, int fd) +@@ -389,7 +390,10 @@ solib_bfd_fopen (char *pathname, int fd) + pathname, bfd_errmsg (bfd_get_error ())); + } + +- return abfd; ++ gdb_bfd_stash_filename (abfd); ++ xfree (pathname); ++ ++ return gdb_bfd_ref (abfd); + } + + /* Find shared library PATHNAME and open a BFD for it. */ +@@ -420,17 +424,16 @@ solib_bfd_open (char *pathname) + /* Check bfd format. */ + if (!bfd_check_format (abfd, bfd_object)) + { +- bfd_close (abfd); +- make_cleanup (xfree, found_pathname); ++ make_cleanup_bfd_unref (abfd); + error (_("`%s': not in executable format: %s"), +- found_pathname, bfd_errmsg (bfd_get_error ())); ++ bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ())); + } + + /* Check bfd arch. */ + b = gdbarch_bfd_arch_info (target_gdbarch); + if (!b->compatible (b, bfd_get_arch_info (abfd))) + warning (_("`%s': Shared library architecture %s is not compatible " +- "with target architecture %s."), found_pathname, ++ "with target architecture %s."), bfd_get_filename (abfd), + bfd_get_arch_info (abfd)->printable_name, b->printable_name); + + return abfd; +@@ -466,7 +469,7 @@ solib_map_sections (struct so_list *so) + return 0; + + /* Leave bfd open, core_xfer_memory and "info files" need it. */ +- so->abfd = gdb_bfd_ref (abfd); ++ so->abfd = abfd; + + /* copy full path name into so_name, so that later symbol_file_add + can find it. */ +@@ -608,7 +611,7 @@ solib_read_symbols (struct so_list *so, int flags) + + sap = build_section_addr_info_from_section_table (so->sections, + so->sections_end); +- so->objfile = symbol_file_add_from_bfd (so->abfd, ++ so->objfile = symbol_file_add_from_bfd (gdb_bfd_ref (so->abfd), + flags, sap, OBJF_SHARED, + NULL); + so->objfile->addr_low = so->addr_low; +@@ -1233,7 +1236,7 @@ reload_shared_libraries_1 (int from_tty) + { + found_pathname = xstrdup (bfd_get_filename (abfd)); + make_cleanup (xfree, found_pathname); +- gdb_bfd_close_or_warn (abfd); ++ gdb_bfd_unref (abfd); + } + + /* If this shared library is no longer associated with its previous +diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c +index 2dfec8c..12f8211 100644 +--- a/gdb/spu-linux-nat.c ++++ b/gdb/spu-linux-nat.c +@@ -315,16 +315,17 @@ spu_bfd_open (ULONGEST addr) + ULONGEST *open_closure = xmalloc (sizeof (ULONGEST)); + *open_closure = addr; + +- nbfd = bfd_openr_iovec (xstrdup (""), "elf32-spu", ++ nbfd = bfd_openr_iovec ("", "elf32-spu", + spu_bfd_iovec_open, open_closure, + spu_bfd_iovec_pread, spu_bfd_iovec_close, + spu_bfd_iovec_stat); + if (!nbfd) + return NULL; ++ nbfd = gdb_bfd_ref (nbfd); + + if (!bfd_check_format (nbfd, bfd_object)) + { +- bfd_close (nbfd); ++ gdb_bfd_unref (nbfd); + return NULL; + } + diff --git a/gdb/stack.c b/gdb/stack.c -index 02e36ca..066407f 100644 +index 2520e2c..0472475 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -509,6 +509,10 @@ print_frame_args (struct symbol *func, struct frame_info *frame, @@ -5128,6 +9046,214 @@ index 02e36ca..066407f 100644 if (func) { struct block *b = SYMBOL_BLOCK_VALUE (func); +diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c +index e80fd25..ad87abd 100644 +--- a/gdb/symfile-mem.c ++++ b/gdb/symfile-mem.c +@@ -54,6 +54,7 @@ + #include "observer.h" + #include "auxv.h" + #include "elf/common.h" ++#include "gdb_bfd.h" + + /* Verify parameters of target_read_memory_bfd and target_read_memory are + compatible. */ +@@ -100,17 +101,19 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name, + if (nbfd == NULL) + error (_("Failed to read a valid object file image from memory.")); + ++ gdb_bfd_ref (nbfd); + if (name == NULL) +- nbfd->filename = xstrdup ("shared object read from target memory"); ++ nbfd->filename = "shared object read from target memory"; + else +- nbfd->filename = name; ++ { ++ nbfd->filename = name; ++ gdb_bfd_stash_filename (nbfd); ++ xfree (name); ++ } + + if (!bfd_check_format (nbfd, bfd_object)) + { +- /* FIXME: should be checking for errors from bfd_close (for one thing, +- on error it does not free all the storage associated with the +- bfd). */ +- bfd_close (nbfd); ++ make_cleanup_bfd_unref (nbfd); + error (_("Got object file from memory but can't read symbols: %s."), + bfd_errmsg (bfd_get_error ())); + } +diff --git a/gdb/symfile.c b/gdb/symfile.c +index 01252e2..c904011 100644 +--- a/gdb/symfile.c ++++ b/gdb/symfile.c +@@ -55,6 +55,7 @@ + #include "solib.h" + #include "remote.h" + #include "stack.h" ++#include "gdb_bfd.h" + + #include + #include +@@ -1074,7 +1075,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, + add_flags &= ~SYMFILE_NO_READ; + } + +- my_cleanups = make_cleanup_bfd_close (abfd); ++ my_cleanups = make_cleanup_bfd_unref (abfd); + + /* Give user a chance to burp if we'd be + interactively wiping out any existing symbols. */ +@@ -1372,7 +1373,7 @@ separate_debug_file_exists (const char *name, unsigned long crc, + if (abfd_stat.st_dev == parent_stat.st_dev + && abfd_stat.st_ino == parent_stat.st_ino) + { +- bfd_close (abfd); ++ gdb_bfd_unref (abfd); + return 0; + } + verified_as_different = 1; +@@ -1382,7 +1383,7 @@ separate_debug_file_exists (const char *name, unsigned long crc, + + file_crc_p = get_file_crc (abfd, &file_crc); + +- bfd_close (abfd); ++ gdb_bfd_unref (abfd); + + if (!file_crc_p) + return 0; +@@ -1690,15 +1691,22 @@ set_initial_language (void) + } + + /* If NAME is a remote name open the file using remote protocol, otherwise +- open it normally. */ ++ open it normally. Returns a new reference to the BFD. On error, ++ returns NULL with the BFD error set. */ + + bfd * + bfd_open_maybe_remote (const char *name) + { + if (remote_filename_p (name)) +- return remote_bfd_open (name, gnutarget); ++ return gdb_bfd_ref (remote_bfd_open (name, gnutarget)); + else +- return bfd_openr (name, gnutarget); ++ { ++ bfd *result = gdb_bfd_ref (bfd_openr (name, gnutarget)); ++ ++ if (result != NULL) ++ gdb_bfd_stash_filename (result); ++ return result; ++ } + } + + +@@ -1716,19 +1724,14 @@ symfile_bfd_open (char *name) + + if (remote_filename_p (name)) + { +- name = xstrdup (name); +- sym_bfd = remote_bfd_open (name, gnutarget); ++ sym_bfd = gdb_bfd_ref (remote_bfd_open (name, gnutarget)); + if (!sym_bfd) +- { +- make_cleanup (xfree, name); +- error (_("`%s': can't open to read symbols: %s."), name, +- bfd_errmsg (bfd_get_error ())); +- } ++ error (_("`%s': can't open to read symbols: %s."), name, ++ bfd_errmsg (bfd_get_error ())); + + if (!bfd_check_format (sym_bfd, bfd_object)) + { +- bfd_close (sym_bfd); +- make_cleanup (xfree, name); ++ make_cleanup_bfd_unref (sym_bfd); + error (_("`%s': can't read symbols: %s."), name, + bfd_errmsg (bfd_get_error ())); + } +@@ -1757,12 +1760,11 @@ symfile_bfd_open (char *name) + perror_with_name (name); + } + +- /* Free 1st new malloc'd copy, but keep the 2nd malloc'd copy in +- bfd. It'll be freed in free_objfile(). */ + xfree (name); + name = absolute_name; ++ make_cleanup (xfree, name); + +- sym_bfd = bfd_fopen (name, gnutarget, FOPEN_RB, desc); ++ sym_bfd = gdb_bfd_ref (bfd_fopen (name, gnutarget, FOPEN_RB, desc)); + if (!sym_bfd) + { + make_cleanup (xfree, name); +@@ -1773,17 +1775,12 @@ symfile_bfd_open (char *name) + + if (!bfd_check_format (sym_bfd, bfd_object)) + { +- /* FIXME: should be checking for errors from bfd_close (for one +- thing, on error it does not free all the storage associated +- with the bfd). */ +- bfd_close (sym_bfd); /* This also closes desc. */ +- make_cleanup (xfree, name); ++ make_cleanup_bfd_unref (sym_bfd); + error (_("`%s': can't read symbols: %s."), name, + bfd_errmsg (bfd_get_error ())); + } + +- /* bfd_usrdata exists for applications and libbfd must not touch it. */ +- gdb_assert (bfd_usrdata (sym_bfd) == NULL); ++ gdb_bfd_stash_filename (sym_bfd); + + return sym_bfd; + } +@@ -2109,17 +2106,14 @@ generic_load (char *args, int from_tty) + } + + /* Open the file for loading. */ +- loadfile_bfd = bfd_openr (filename, gnutarget); ++ loadfile_bfd = gdb_bfd_ref (bfd_openr (filename, gnutarget)); + if (loadfile_bfd == NULL) + { + perror_with_name (filename); + return; + } + +- /* FIXME: should be checking for errors from bfd_close (for one thing, +- on error it does not free all the storage associated with the +- bfd). */ +- make_cleanup_bfd_close (loadfile_bfd); ++ make_cleanup_bfd_unref (loadfile_bfd); + + if (!bfd_check_format (loadfile_bfd, bfd_object)) + { +@@ -2518,15 +2512,18 @@ reread_symbols (void) + /* Clean up any state BFD has sitting around. We don't need + to close the descriptor but BFD lacks a way of closing the + BFD without closing the descriptor. */ +- obfd_filename = bfd_get_filename (objfile->obfd); +- if (!bfd_close (objfile->obfd)) +- error (_("Can't close BFD for %s: %s"), objfile->name, +- bfd_errmsg (bfd_get_error ())); +- objfile->obfd = bfd_open_maybe_remote (obfd_filename); ++ { ++ struct bfd *obfd = objfile->obfd; ++ ++ obfd_filename = bfd_get_filename (objfile->obfd); ++ /* Open the new BFD before freeing the old one, so that ++ the filename remains live. */ ++ objfile->obfd = bfd_open_maybe_remote (obfd_filename); ++ gdb_bfd_unref (obfd); ++ } ++ + if (objfile->obfd == NULL) + error (_("Can't open %s to read symbols."), objfile->name); +- else +- objfile->obfd = gdb_bfd_ref (objfile->obfd); + /* bfd_openr sets cacheable to true, which is what we want. */ + if (!bfd_check_format (objfile->obfd, bfd_object)) + error (_("Can't read symbols from %s: %s."), objfile->name, diff --git a/gdb/testsuite/gdb.ada/packed_array.exp b/gdb/testsuite/gdb.ada/packed_array.exp index 678639c..47a2202 100644 --- a/gdb/testsuite/gdb.ada/packed_array.exp @@ -8601,7 +12727,7 @@ index 0000000..295602d + writeln(s); { set breakpoint 2 here } +end. diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp -index 83ff8fe..bddbf9f 100644 +index 993e774..52dbd17 100644 --- a/gdb/testsuite/gdb.python/py-frame.exp +++ b/gdb/testsuite/gdb.python/py-frame.exp @@ -74,8 +74,6 @@ gdb_test "python print bframe == gdb.newest_frame()" True \ @@ -8620,10 +12746,10 @@ index 83ff8fe..bddbf9f 100644 + +gdb_test "python print 'result =', f0.block ()" "" "test Frame.block" diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp -index c9d8c97..4324db0 100644 +index acfd89b..c77d9c2 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp -@@ -360,6 +360,15 @@ proc test_value_after_death {} { +@@ -358,6 +358,15 @@ proc test_value_after_death {} { "print value's type" } @@ -8639,7 +12765,7 @@ index c9d8c97..4324db0 100644 # Regression test for invalid subscript operations. The bug was that # the type of the value was not being checked before allowing a # subscript operation to proceed. -@@ -496,6 +505,7 @@ test_value_in_inferior +@@ -494,6 +503,7 @@ test_value_in_inferior test_inferior_function_call test_lazy_strings test_value_after_death @@ -8648,7 +12774,7 @@ index c9d8c97..4324db0 100644 # Test either C or C++ values. test_subscript_regression "${binfile}" "c" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp -index 1dfe564..186f9d7 100644 +index 289d4d8..da0d089 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -142,6 +142,11 @@ proc gdb_unload {} { @@ -8770,10 +12896,32 @@ index c25e705..498958a 100644 static void diff --git a/gdb/utils.c b/gdb/utils.c -index 2d607ef..d67e7dd 100644 +index 5566149..6e1aa34 100644 --- a/gdb/utils.c +++ b/gdb/utils.c -@@ -1737,6 +1737,36 @@ set_batch_flag_and_make_cleanup_restore_page_info (void) +@@ -27,6 +27,7 @@ + #include "exceptions.h" + #include "gdbthread.h" + #include "fnmatch.h" ++#include "gdb_bfd.h" + #ifdef HAVE_SYS_RESOURCE_H + #include + #endif /* HAVE_SYS_RESOURCE_H */ +@@ -198,11 +199,11 @@ make_cleanup_dyn_string_delete (dyn_string_t arg) + static void + do_bfd_close_cleanup (void *arg) + { +- bfd_close (arg); ++ gdb_bfd_unref (arg); + } + + struct cleanup * +-make_cleanup_bfd_close (bfd *abfd) ++make_cleanup_bfd_unref (bfd *abfd) + { + return make_cleanup (do_bfd_close_cleanup, abfd); + } +@@ -1738,6 +1739,36 @@ set_batch_flag_and_make_cleanup_restore_page_info (void) return back_to; } @@ -8811,7 +12959,7 @@ index 2d607ef..d67e7dd 100644 static void diff --git a/gdb/valarith.c b/gdb/valarith.c -index 0225339..f775bfc 100644 +index 96d5411..37bd464 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -197,7 +197,10 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound) @@ -8838,7 +12986,7 @@ index 0225339..f775bfc 100644 } diff --git a/gdb/valops.c b/gdb/valops.c -index feb47f5..6d14eee 100644 +index 97d889b..6ae77b8 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -45,6 +45,7 @@ @@ -8955,7 +13103,7 @@ index feb47f5..6d14eee 100644 } else if (VALUE_LVAL (val) == lval_register) { -@@ -1532,7 +1605,18 @@ address_of_variable (struct symbol *var, struct block *b) +@@ -1530,7 +1603,18 @@ address_of_variable (struct symbol *var, struct block *b) if ((VALUE_LVAL (val) == lval_memory && value_lazy (val)) || TYPE_CODE (type) == TYPE_CODE_FUNC) { @@ -8975,7 +13123,7 @@ index feb47f5..6d14eee 100644 return value_from_pointer (lookup_pointer_type (type), addr); } -@@ -1639,6 +1723,7 @@ struct value * +@@ -1637,6 +1721,7 @@ struct value * value_coerce_array (struct value *arg1) { struct type *type = check_typedef (value_type (arg1)); @@ -8983,7 +13131,7 @@ index feb47f5..6d14eee 100644 /* If the user tries to do something requiring a pointer with an array that has not yet been pushed to the target, then this would -@@ -1648,8 +1733,12 @@ value_coerce_array (struct value *arg1) +@@ -1646,8 +1731,12 @@ value_coerce_array (struct value *arg1) if (VALUE_LVAL (arg1) != lval_memory) error (_("Attempt to take address of value not located in memory.")); @@ -8997,7 +13145,7 @@ index feb47f5..6d14eee 100644 } /* Given a value which is a function, return a value which is a pointer -@@ -3772,6 +3861,8 @@ value_slice (struct value *array, int lowbound, int length) +@@ -3769,6 +3858,8 @@ value_slice (struct value *array, int lowbound, int length) TYPE_TARGET_TYPE (range_type), lowbound, lowbound + length - 1); @@ -9080,7 +13228,7 @@ index fc5942d..8333eb4 100644 /* Read LEN bytes of target memory at address MEMADDR, placing the diff --git a/gdb/value.c b/gdb/value.c -index c64e55b..cd08a0b 100644 +index a6bb718..7b08d1f 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -42,6 +42,7 @@ @@ -9152,7 +13300,7 @@ index c64e55b..cd08a0b 100644 /* Internal variables. These are variables within the debugger that hold values assigned by debugger commands. -@@ -2095,6 +2130,38 @@ call_internal_function (struct gdbarch *gdbarch, +@@ -2118,6 +2153,38 @@ call_internal_function (struct gdbarch *gdbarch, return (*ifn->handler) (gdbarch, language, ifn->cookie, argc, argv); } @@ -9191,7 +13339,7 @@ index c64e55b..cd08a0b 100644 /* The 'function' command. This does nothing -- it is just a placeholder to let "help function NAME" work. This is also used as the implementation of the sub-command that is created when -@@ -2142,11 +2209,10 @@ preserve_one_value (struct value *value, struct objfile *objfile, +@@ -2165,11 +2232,10 @@ preserve_one_value (struct value *value, struct objfile *objfile, htab_t copied_types) { if (TYPE_OBJFILE (value->type) == objfile) @@ -9205,7 +13353,7 @@ index c64e55b..cd08a0b 100644 copied_types); } -@@ -2161,7 +2227,7 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile, +@@ -2184,7 +2250,7 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile, case INTERNALVAR_INTEGER: if (var->u.integer.type && TYPE_OBJFILE (var->u.integer.type) == objfile) var->u.integer.type @@ -9214,7 +13362,7 @@ index c64e55b..cd08a0b 100644 break; case INTERNALVAR_VALUE: -@@ -3253,10 +3319,27 @@ readjust_indirect_value_type (struct value *value, struct type *enc_type, +@@ -3276,10 +3342,27 @@ readjust_indirect_value_type (struct value *value, struct type *enc_type, struct value * coerce_ref (struct value *arg) { @@ -9243,7 +13391,7 @@ index c64e55b..cd08a0b 100644 retval = coerce_ref_if_computed (arg); if (retval) return retval; -@@ -3363,4 +3446,10 @@ VARIABLE is already initialized.")); +@@ -3386,4 +3469,10 @@ VARIABLE is already initialized.")); add_prefix_cmd ("function", no_class, function_command, _("\ Placeholder command for showing help on convenience functions."), &functionlist, "function ", 0, &cmdlist); @@ -9255,7 +13403,7 @@ index c64e55b..cd08a0b 100644 +#endif } diff --git a/gdb/value.h b/gdb/value.h -index b630fc7..2f95db2 100644 +index d8b157f..f49e827 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -533,6 +533,10 @@ extern struct value *value_from_decfloat (struct type *type, @@ -9269,3 +13417,34 @@ index b630fc7..2f95db2 100644 extern struct value *value_at (struct type *type, CORE_ADDR addr); extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr); +diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c +index f16588a..6ba92d9 100644 +--- a/gdb/windows-nat.c ++++ b/gdb/windows-nat.c +@@ -752,7 +752,7 @@ windows_make_so (const char *name, LPVOID load_addr) + asection *text = NULL; + CORE_ADDR text_vma; + +- abfd = bfd_openr (so->so_name, "pei-i386"); ++ abfd = gdb_bfd_ref (bfd_openr (so->so_name, "pei-i386")); + + if (!abfd) + return so; +@@ -762,7 +762,7 @@ windows_make_so (const char *name, LPVOID load_addr) + + if (!text) + { +- bfd_close (abfd); ++ gdb_bfd_unref (abfd); + return so; + } + +@@ -773,7 +773,7 @@ windows_make_so (const char *name, LPVOID load_addr) + load_addr + 0x1000); + cygwin_load_end = cygwin_load_start + bfd_section_size (abfd, text); + +- bfd_close (abfd); ++ gdb_bfd_unref (abfd); + } + #endif + diff --git a/gdb-bz592031-siginfo-lost-4of5.patch b/gdb-bz592031-siginfo-lost-4of5.patch deleted file mode 100644 index dfa122a..0000000 --- a/gdb-bz592031-siginfo-lost-4of5.patch +++ /dev/null @@ -1,994 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2010-09/msg00360.html -Subject: [patch 3/4]#3 linux-nat: Do not respawn signals - -Hi, - -linux-nat.c is fixed to never respawn signals; possibly keeping SIGSTOP -pending, as is done in current in FSF gdbserver and as suggested by Pedro: - http://sourceware.org/ml/gdb-patches/2010-08/msg00544.html - -The last linux-nat.c removed patch chunk comes from the initial implementation -by Mark Kettenis: - [PATCH] New Linux threads support - http://sourceware.org/ml/gdb-patches/2000-09/msg00020.html - 92280a75e017683bf8e4f339f4f85640b0700509 -It gets in part reimplemented into the new stop_wait_callback step)> -part and partially just not needed as currently GDB never drops the signals as -it does not PTRACE_CONT the thread; signal is kept for processing: - "RC: Not resuming sibling %s (has pending)\n" - -In stop_wait_callback I believe breakpoints cancellation is not needed here, -it would be done later. - - -The testcase sigstep-threads.exp was written to catch a regression-like -appearance then the new step)> part of stop_wait_callback gets -removed. Still the tecase fails even with FSF HEAD: - -32 var++; /* step-1 */ -(gdb) step -Program received signal SIGUSR1, User defined signal 1. -Program received signal SIGUSR1, User defined signal 1. -31 { /* step-0 */ - -There is no reason why it shouldn't stop on line 33, between line 32 and line -33 no signal would occur. Stepping of the current thread should not be -affected by whatever happens in the other threads as select_event_lwp has: - /* Give preference to any LWP that is being single-stepped. */ - -There is a problem that with FSF HEAD GDB does PTRACE_SINGLESTEP for thread A, -PTRACE_CONT for thread B (because of set scheduler-locking off), thread B hits -SIGUSR1, so GDB tkills thread A with SIGSTOP and it can receive SIGSTOP for -thread A before the SIGTRAP for completed PTRACE_SINGLESTEP. At that moment -select_event_lwp. forgets it was stepping thread A because there is no pending -SIGTRAP event. currently_stepping still remembers thread A was stepping so it -will later stop but as thread A was PTRACE_CONT-ed in the meantime it is too -late. - -There is the new step)> part of stop_wait_callback to always track -thread A is stepping. Due to different scheduling without this part the -changed GDB would very rarely stop in this testcase otherwise, making it look -as a regression. - -I have some another patch I may post separately as if multiple signals happen -besides SIGTRAP GDB still may switch from thread A away (as not considering it -stepping) to thread B for SIGUSR and accidentally PTRACE_CONT thread A. -But I do not find this as a prerequisite for this patchset. - - - -Thanks, -Jan - - -gdb/ -2010-09-20 Jan Kratochvil - - * linux-nat.c (stop_wait_callback): New gdb_assert. Remove signals - respawning; keep TP with SIGNALLED. New debugging message "SWC: - Delayed SIGSTOP caught for %s.". Catch next signal if SIGSTOP has - been caught and LP->STEP is set. - (linux_nat_wait_1) signalled>: Remove. - -gdb/testsuite/ -2010-09-20 Jan Kratochvil - - * gdb.threads/siginfo-threads.exp: New file. - * gdb.threads/siginfo-threads.c: New file. - * gdb.threads/sigstep-threads.exp: New file. - * gdb.threads/sigstep-threads.c: New file. - -Index: gdb-7.4.50.20120602/gdb/linux-nat.c -=================================================================== ---- gdb-7.4.50.20120602.orig/gdb/linux-nat.c 2012-06-02 21:34:51.999517510 +0200 -+++ gdb-7.4.50.20120602/gdb/linux-nat.c 2012-06-02 21:35:59.930491577 +0200 -@@ -2856,6 +2856,8 @@ stop_wait_callback (struct lwp_info *lp, - { - int status; - -+ gdb_assert (lp->resumed); -+ - status = wait_lwp (lp); - if (status == 0) - return 0; -@@ -2881,110 +2883,61 @@ stop_wait_callback (struct lwp_info *lp, - - if (WSTOPSIG (status) != SIGSTOP) - { -- if (linux_nat_status_is_event (status)) -- { -- /* If a LWP other than the LWP that we're reporting an -- event for has hit a GDB breakpoint (as opposed to -- some random trap signal), then just arrange for it to -- hit it again later. We don't keep the SIGTRAP status -- and don't forward the SIGTRAP signal to the LWP. We -- will handle the current event, eventually we will -- resume all LWPs, and this one will get its breakpoint -- trap again. -- -- If we do not do this, then we run the risk that the -- user will delete or disable the breakpoint, but the -- thread will have already tripped on it. */ -- -- /* Save the trap's siginfo in case we need it later. */ -- save_siginfo (lp); -- -- save_sigtrap (lp); -- -- /* Now resume this LWP and get the SIGSTOP event. */ -- errno = 0; -- ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0); -- if (debug_linux_nat) -- { -- fprintf_unfiltered (gdb_stdlog, -- "PTRACE_CONT %s, 0, 0 (%s)\n", -- target_pid_to_str (lp->ptid), -- errno ? safe_strerror (errno) : "OK"); -- -- fprintf_unfiltered (gdb_stdlog, -- "SWC: Candidate SIGTRAP event in %s\n", -- target_pid_to_str (lp->ptid)); -- } -- /* Hold this event/waitstatus while we check to see if -- there are any more (we still want to get that SIGSTOP). */ -- stop_wait_callback (lp, NULL); -+ /* The thread was stopped with a signal other than SIGSTOP. */ - -- /* Hold the SIGTRAP for handling by linux_nat_wait. If -- there's another event, throw it back into the -- queue. */ -- if (lp->status) -- { -- if (debug_linux_nat) -- fprintf_unfiltered (gdb_stdlog, -- "SWC: kill %s, %s\n", -- target_pid_to_str (lp->ptid), -- status_to_str ((int) status)); -- kill_lwp (GET_LWP (lp->ptid), WSTOPSIG (lp->status)); -- } -- -- /* Save the sigtrap event. */ -- lp->status = status; -- return 0; -- } -- else -- { -- /* The thread was stopped with a signal other than -- SIGSTOP, and didn't accidentally trip a breakpoint. */ -+ /* Save the trap's siginfo in case we need it later. */ -+ save_siginfo (lp); - -- if (debug_linux_nat) -- { -- fprintf_unfiltered (gdb_stdlog, -- "SWC: Pending event %s in %s\n", -- status_to_str ((int) status), -- target_pid_to_str (lp->ptid)); -- } -- /* Now resume this LWP and get the SIGSTOP event. */ -- errno = 0; -- ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0); -- if (debug_linux_nat) -- fprintf_unfiltered (gdb_stdlog, -- "SWC: PTRACE_CONT %s, 0, 0 (%s)\n", -- target_pid_to_str (lp->ptid), -- errno ? safe_strerror (errno) : "OK"); -+ save_sigtrap (lp); - -- /* Hold this event/waitstatus while we check to see if -- there are any more (we still want to get that SIGSTOP). */ -- stop_wait_callback (lp, NULL); -+ if (debug_linux_nat) -+ fprintf_unfiltered (gdb_stdlog, -+ "SWC: Pending event %s in %s\n", -+ status_to_str ((int) status), -+ target_pid_to_str (lp->ptid)); - -- /* If the lp->status field is still empty, use it to -- hold this event. If not, then this event must be -- returned to the event queue of the LWP. */ -- if (lp->status) -- { -- if (debug_linux_nat) -- { -- fprintf_unfiltered (gdb_stdlog, -- "SWC: kill %s, %s\n", -- target_pid_to_str (lp->ptid), -- status_to_str ((int) status)); -- } -- kill_lwp (GET_LWP (lp->ptid), WSTOPSIG (status)); -- } -- else -- lp->status = status; -- return 0; -- } -+ /* Save the sigtrap event. */ -+ lp->status = status; -+ gdb_assert (! lp->stopped); -+ gdb_assert (lp->signalled); -+ lp->stopped = 1; - } - else - { - /* We caught the SIGSTOP that we intended to catch, so - there's no SIGSTOP pending. */ -- lp->stopped = 1; -+ -+ if (debug_linux_nat) -+ fprintf_unfiltered (gdb_stdlog, -+ "SWC: Delayed SIGSTOP caught for %s.\n", -+ target_pid_to_str (lp->ptid)); -+ -+ if (lp->step) -+ { -+ /* LP->STATUS is 0 here. That means SIGTRAP from -+ PTRACE_SINGLESTEP still has to be delivered for this inferior -+ stop. Catching the SIGTRAP event is important to prevent -+ starvation in select_event_lwp. */ -+ -+ registers_changed (); -+ linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)), -+ 1, GDB_SIGNAL_0); -+ if (debug_linux_nat) -+ fprintf_unfiltered (gdb_stdlog, -+ "SWC: %s %s, 0, 0 (discard SIGSTOP)\n", -+ "PTRACE_SINGLESTEP", -+ target_pid_to_str (lp->ptid)); -+ -+ lp->stopped = 0; -+ gdb_assert (lp->resumed); -+ stop_wait_callback (lp, NULL); -+ gdb_assert (lp->stopped); -+ } -+ else -+ lp->stopped = 1; -+ -+ /* Reset SIGNALLED only after the stop_wait_callback call above as -+ it does gdb_assert on SIGNALLED. */ - lp->signalled = 0; - } - } -@@ -3616,54 +3569,6 @@ retry: - lp = NULL; - } - -- if (lp && lp->signalled && lp->last_resume_kind != resume_stop) -- { -- /* A pending SIGSTOP may interfere with the normal stream of -- events. In a typical case where interference is a problem, -- we have a SIGSTOP signal pending for LWP A while -- single-stepping it, encounter an event in LWP B, and take the -- pending SIGSTOP while trying to stop LWP A. After processing -- the event in LWP B, LWP A is continued, and we'll never see -- the SIGTRAP associated with the last time we were -- single-stepping LWP A. */ -- -- /* Resume the thread. It should halt immediately returning the -- pending SIGSTOP. */ -- registers_changed (); -- if (linux_nat_prepare_to_resume != NULL) -- linux_nat_prepare_to_resume (lp); -- linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)), -- lp->step, GDB_SIGNAL_0); -- if (debug_linux_nat) -- fprintf_unfiltered (gdb_stdlog, -- "LLW: %s %s, 0, 0 (expect SIGSTOP)\n", -- lp->step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT", -- target_pid_to_str (lp->ptid)); -- lp->stopped = 0; -- gdb_assert (lp->resumed); -- -- /* Catch the pending SIGSTOP. */ -- status = lp->status; -- lp->status = 0; -- -- stop_wait_callback (lp, NULL); -- -- /* If the lp->status field isn't empty, we caught another signal -- while flushing the SIGSTOP. Return it back to the event -- queue of the LWP, as we already have an event to handle. */ -- if (lp->status) -- { -- if (debug_linux_nat) -- fprintf_unfiltered (gdb_stdlog, -- "LLW: kill %s, %s\n", -- target_pid_to_str (lp->ptid), -- status_to_str (lp->status)); -- kill_lwp (GET_LWP (lp->ptid), WSTOPSIG (lp->status)); -- } -- -- lp->status = status; -- } -- - if (!target_can_async_p ()) - { - /* Causes SIGINT to be passed on to the attached process. */ -Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/siginfo-threads.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/siginfo-threads.c 2012-06-02 21:35:40.268499060 +0200 -@@ -0,0 +1,447 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2010 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#define _GNU_SOURCE -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define gettid() syscall (__NR_gettid) -+#define tgkill(tgid, tid, sig) syscall (__NR_tgkill, tgid, tid, sig) -+ -+/* Terminate always in the main task, it can lock up with SIGSTOPped GDB -+ otherwise. */ -+#define TIMEOUT (gettid () == getpid() ? 10 : 15) -+ -+static pid_t thread1_tid; -+static pthread_cond_t thread1_tid_cond = PTHREAD_COND_INITIALIZER; -+static pthread_mutex_t thread1_tid_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; -+static int thread1_sigusr1_hit; -+static int thread1_sigusr2_hit; -+ -+static pid_t thread2_tid; -+static pthread_cond_t thread2_tid_cond = PTHREAD_COND_INITIALIZER; -+static pthread_mutex_t thread2_tid_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; -+static int thread2_sigusr1_hit; -+static int thread2_sigusr2_hit; -+ -+static pthread_mutex_t terminate_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; -+ -+/* Do not use alarm as it would create a ptrace event which would hang up us if -+ we are being traced by GDB which we stopped ourselves. */ -+ -+static void timed_mutex_lock (pthread_mutex_t *mutex) -+{ -+ int i; -+ struct timespec start, now; -+ -+ i = clock_gettime (CLOCK_MONOTONIC, &start); -+ assert (i == 0); -+ -+ do -+ { -+ i = pthread_mutex_trylock (mutex); -+ if (i == 0) -+ return; -+ assert (i == EBUSY); -+ -+ i = clock_gettime (CLOCK_MONOTONIC, &now); -+ assert (i == 0); -+ assert (now.tv_sec >= start.tv_sec); -+ } -+ while (now.tv_sec - start.tv_sec < TIMEOUT); -+ -+ fprintf (stderr, "Timed out waiting for internal lock!\n"); -+ exit (EXIT_FAILURE); -+} -+ -+static void -+handler (int signo, siginfo_t *siginfo, void *exception) -+{ -+ int *varp; -+ -+ assert (siginfo->si_signo == signo); -+ assert (siginfo->si_code == SI_TKILL); -+ assert (siginfo->si_pid == getpid ()); -+ -+ if (gettid () == thread1_tid) -+ { -+ if (signo == SIGUSR1) -+ varp = &thread1_sigusr1_hit; -+ else if (signo == SIGUSR2) -+ varp = &thread1_sigusr2_hit; -+ else -+ assert (0); -+ } -+ else if (gettid () == thread2_tid) -+ { -+ if (signo == SIGUSR1) -+ varp = &thread2_sigusr1_hit; -+ else if (signo == SIGUSR2) -+ varp = &thread2_sigusr2_hit; -+ else -+ assert (0); -+ } -+ else -+ assert (0); -+ -+ if (*varp) -+ { -+ fprintf (stderr, "Signal %d for TID %lu has been already hit!\n", signo, -+ (unsigned long) gettid ()); -+ exit (EXIT_FAILURE); -+ } -+ *varp = 1; -+} -+ -+static void * -+thread1_func (void *unused) -+{ -+ int i; -+ -+ timed_mutex_lock (&thread1_tid_mutex); -+ -+ /* THREAD1_TID_MUTEX must be already locked to avoid race. */ -+ thread1_tid = gettid (); -+ -+ i = pthread_cond_signal (&thread1_tid_cond); -+ assert (i == 0); -+ i = pthread_mutex_unlock (&thread1_tid_mutex); -+ assert (i == 0); -+ -+ /* Be sure the "t (tracing stop)" test can proceed for both threads. */ -+ timed_mutex_lock (&terminate_mutex); -+ i = pthread_mutex_unlock (&terminate_mutex); -+ assert (i == 0); -+ -+ if (! thread1_sigusr1_hit) -+ { -+ fprintf (stderr, "Thread 1 signal SIGUSR1 not hit!\n"); -+ exit (EXIT_FAILURE); -+ } -+ if (! thread1_sigusr2_hit) -+ { -+ fprintf (stderr, "Thread 1 signal SIGUSR2 not hit!\n"); -+ exit (EXIT_FAILURE); -+ } -+ -+ return NULL; -+} -+ -+static void * -+thread2_func (void *unused) -+{ -+ int i; -+ -+ timed_mutex_lock (&thread2_tid_mutex); -+ -+ /* THREAD2_TID_MUTEX must be already locked to avoid race. */ -+ thread2_tid = gettid (); -+ -+ i = pthread_cond_signal (&thread2_tid_cond); -+ assert (i == 0); -+ i = pthread_mutex_unlock (&thread2_tid_mutex); -+ assert (i == 0); -+ -+ /* Be sure the "t (tracing stop)" test can proceed for both threads. */ -+ timed_mutex_lock (&terminate_mutex); -+ i = pthread_mutex_unlock (&terminate_mutex); -+ assert (i == 0); -+ -+ if (! thread2_sigusr1_hit) -+ { -+ fprintf (stderr, "Thread 2 signal SIGUSR1 not hit!\n"); -+ exit (EXIT_FAILURE); -+ } -+ if (! thread2_sigusr2_hit) -+ { -+ fprintf (stderr, "Thread 2 signal SIGUSR2 not hit!\n"); -+ exit (EXIT_FAILURE); -+ } -+ -+ return NULL; -+} -+ -+static const char * -+proc_string (const char *filename, const char *line) -+{ -+ FILE *f; -+ static char buf[LINE_MAX]; -+ size_t line_len = strlen (line); -+ -+ f = fopen (filename, "r"); -+ if (f == NULL) -+ { -+ fprintf (stderr, "fopen (\"%s\") for \"%s\": %s\n", filename, line, -+ strerror (errno)); -+ exit (EXIT_FAILURE); -+ } -+ while (errno = 0, fgets (buf, sizeof (buf), f)) -+ { -+ char *s; -+ -+ s = strchr (buf, '\n'); -+ assert (s != NULL); -+ *s = 0; -+ -+ if (strncmp (buf, line, line_len) != 0) -+ continue; -+ -+ if (fclose (f)) -+ { -+ fprintf (stderr, "fclose (\"%s\") for \"%s\": %s\n", filename, line, -+ strerror (errno)); -+ exit (EXIT_FAILURE); -+ } -+ -+ return &buf[line_len]; -+ } -+ if (errno != 0) -+ { -+ fprintf (stderr, "fgets (\"%s\": %s\n", filename, strerror (errno)); -+ exit (EXIT_FAILURE); -+ } -+ fprintf (stderr, "\"%s\": No line \"%s\" found.\n", filename, line); -+ exit (EXIT_FAILURE); -+} -+ -+static unsigned long -+proc_ulong (const char *filename, const char *line) -+{ -+ const char *s = proc_string (filename, line); -+ long retval; -+ char *end; -+ -+ errno = 0; -+ retval = strtol (s, &end, 10); -+ if (retval < 0 || retval >= LONG_MAX || (end && *end)) -+ { -+ fprintf (stderr, "\"%s\":\"%s\": %ld, %s\n", filename, line, retval, -+ strerror (errno)); -+ exit (EXIT_FAILURE); -+ } -+ return retval; -+} -+ -+static void -+state_wait (pid_t process, const char *wanted) -+{ -+ char *filename; -+ int i; -+ struct timespec start, now; -+ const char *state; -+ -+ i = asprintf (&filename, "/proc/%lu/status", (unsigned long) process); -+ assert (i > 0); -+ -+ i = clock_gettime (CLOCK_MONOTONIC, &start); -+ assert (i == 0); -+ -+ do -+ { -+ state = proc_string (filename, "State:\t"); -+ -+ /* torvalds/linux-2.6.git 464763cf1c6df632dccc8f2f4c7e50163154a2c0 -+ has changed "T (tracing stop)" to "t (tracing stop)". Make the GDB -+ testcase backward compatible with older Linux kernels. */ -+ if (strcmp (state, "T (tracing stop)") == 0) -+ state = "t (tracing stop)"; -+ -+ if (strcmp (state, wanted) == 0) -+ { -+ free (filename); -+ return; -+ } -+ -+ if (sched_yield ()) -+ { -+ perror ("sched_yield()"); -+ exit (EXIT_FAILURE); -+ } -+ -+ i = clock_gettime (CLOCK_MONOTONIC, &now); -+ assert (i == 0); -+ assert (now.tv_sec >= start.tv_sec); -+ } -+ while (now.tv_sec - start.tv_sec < TIMEOUT); -+ -+ fprintf (stderr, "Timed out waiting for PID %lu \"%s\" (now it is \"%s\")!\n", -+ (unsigned long) process, wanted, state); -+ exit (EXIT_FAILURE); -+} -+ -+static volatile pid_t tracer = 0; -+static pthread_t thread1, thread2; -+ -+static void -+cleanup (void) -+{ -+ printf ("Resuming GDB PID %lu.\n", (unsigned long) tracer); -+ -+ if (tracer) -+ { -+ int i; -+ int tracer_save = tracer; -+ -+ tracer = 0; -+ -+ i = kill (tracer_save, SIGCONT); -+ assert (i == 0); -+ } -+} -+ -+int -+main (int argc, char **argv) -+{ -+ int i; -+ int standalone = 0; -+ struct sigaction act; -+ -+ if (argc == 2 && strcmp (argv[1], "-s") == 0) -+ standalone = 1; -+ else -+ assert (argc == 1); -+ -+ setbuf (stdout, NULL); -+ -+ timed_mutex_lock (&thread1_tid_mutex); -+ timed_mutex_lock (&thread2_tid_mutex); -+ -+ timed_mutex_lock (&terminate_mutex); -+ -+ errno = 0; -+ memset (&act, 0, sizeof (act)); -+ act.sa_sigaction = handler; -+ act.sa_flags = SA_RESTART | SA_SIGINFO; -+ i = sigemptyset (&act.sa_mask); -+ assert_perror (errno); -+ assert (i == 0); -+ i = sigaction (SIGUSR1, &act, NULL); -+ assert_perror (errno); -+ assert (i == 0); -+ i = sigaction (SIGUSR2, &act, NULL); -+ assert_perror (errno); -+ assert (i == 0); -+ -+ i = pthread_create (&thread1, NULL, thread1_func, NULL); -+ assert (i == 0); -+ -+ i = pthread_create (&thread2, NULL, thread2_func, NULL); -+ assert (i == 0); -+ -+ if (!standalone) -+ { -+ tracer = proc_ulong ("/proc/self/status", "TracerPid:\t"); -+ if (tracer == 0) -+ { -+ fprintf (stderr, "The testcase must be run by GDB!\n"); -+ exit (EXIT_FAILURE); -+ } -+ if (tracer != getppid ()) -+ { -+ fprintf (stderr, "The testcase parent must be our GDB tracer!\n"); -+ exit (EXIT_FAILURE); -+ } -+ } -+ -+ /* SIGCONT our debugger in the case of our crash as we would deadlock -+ otherwise. */ -+ -+ atexit (cleanup); -+ -+ printf ("Stopping GDB PID %lu.\n", (unsigned long) tracer); -+ -+ if (tracer) -+ { -+ i = kill (tracer, SIGSTOP); -+ assert (i == 0); -+ state_wait (tracer, "T (stopped)"); -+ } -+ -+ /* Threads are now waiting at timed_mutex_lock (thread1_tid_mutex) and so -+ they could not trigger the signals before GDB gets unstopped later. -+ Threads get resumed at pthread_cond_wait below. Use `while' loops for -+ protection against spurious pthread_cond_wait wakeups. */ -+ -+ printf ("Waiting till the threads initialize their TIDs.\n"); -+ -+ while (thread1_tid == 0) -+ { -+ i = pthread_cond_wait (&thread1_tid_cond, &thread1_tid_mutex); -+ assert (i == 0); -+ } -+ -+ while (thread2_tid == 0) -+ { -+ i = pthread_cond_wait (&thread2_tid_cond, &thread2_tid_mutex); -+ assert (i == 0); -+ } -+ -+ printf ("Thread 1 TID = %lu, thread 2 TID = %lu, PID = %lu.\n", -+ (unsigned long) thread1_tid, (unsigned long) thread2_tid, -+ (unsigned long) getpid ()); -+ -+ errno = 0; -+ i = tgkill (getpid (), thread1_tid, SIGUSR1); -+ assert_perror (errno); -+ assert (i == 0); -+ i = tgkill (getpid (), thread1_tid, SIGUSR2); -+ assert_perror (errno); -+ assert (i == 0); -+ i = tgkill (getpid (), thread2_tid, SIGUSR1); -+ assert_perror (errno); -+ assert (i == 0); -+ i = tgkill (getpid (), thread2_tid, SIGUSR2); -+ assert_perror (errno); -+ assert (i == 0); -+ -+ printf ("Waiting till the threads get trapped by the signals.\n"); -+ -+ if (tracer) -+ { -+ /* s390x-unknown-linux-gnu will fail with "R (running)". */ -+ -+ state_wait (thread1_tid, "t (tracing stop)"); -+ -+ state_wait (thread2_tid, "t (tracing stop)"); -+ } -+ -+ cleanup (); -+ -+ printf ("Joining the threads.\n"); -+ -+ i = pthread_mutex_unlock (&terminate_mutex); -+ assert (i == 0); -+ -+ i = pthread_join (thread1, NULL); -+ assert (i == 0); -+ -+ i = pthread_join (thread2, NULL); -+ assert (i == 0); -+ -+ printf ("Exiting.\n"); /* break-at-exit */ -+ -+ return EXIT_SUCCESS; -+} -Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/siginfo-threads.exp -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/siginfo-threads.exp 2012-06-02 21:35:40.296499050 +0200 -@@ -0,0 +1,94 @@ -+# Copyright 2010 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+set testfile "siginfo-threads" -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} -+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" ${binfile} executable [list debug additional_flags=-lrt]] != "" } { -+ return -1 -+} -+ -+clean_restart $testfile -+ -+if ![runto_main] { -+ return -1 -+} -+ -+# `nostop noprint pass' could in some cases report false PASS due to the -+# (preempt 'handle') code path. -+ -+gdb_test "handle SIGUSR1 stop print pass" "Signal\[ \t\]+Stop\[ \t\]+Print\[ \t\]+Pass to program\[ \t\]+Description\r\nSIGUSR1\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*" -+gdb_test "handle SIGUSR2 stop print pass" "Signal\[ \t\]+Stop\[ \t\]+Print\[ \t\]+Pass to program\[ \t\]+Description\r\nSIGUSR2\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*" -+ -+gdb_breakpoint [gdb_get_line_number "break-at-exit"] -+ -+set test "get pid" -+gdb_test_multiple "p getpid ()" $test { -+ -re " = (\[0-9\]+)\r\n$gdb_prompt $" { -+ set pid $expect_out(1,string) -+ pass $test -+ } -+} -+ -+for {set sigcount 0} {$sigcount < 4} {incr sigcount} { -+ set test "catch signal $sigcount" -+ set sigusr "" -+ gdb_test_multiple "continue" $test { -+ -re "Program received signal SIGUSR(\[12\]), User defined signal \[12\]\\.\r\n.*\r\n$gdb_prompt $" { -+ set sigusr $expect_out(1,string) -+ pass $test -+ } -+ } -+ if {$sigusr == ""} { -+ return -1 -+ } -+ -+ set test "signal $sigcount si_signo" -+ if {$sigusr == 1} { -+ set signo 10 -+ } else { -+ set signo 12 -+ } -+ gdb_test_multiple {p $_siginfo.si_signo} $test { -+ -re " = $signo\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { -+ unsupported $test -+ } -+ } -+ -+ set test "signal $sigcount si_code is SI_TKILL" -+ gdb_test_multiple {p $_siginfo.si_code} $test { -+ -re " = -6\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { -+ unsupported $test -+ } -+ } -+ -+ set test "signal $sigcount si_pid" -+ gdb_test_multiple {p $_siginfo._sifields._kill.si_pid} $test { -+ -re " = $pid\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { -+ unsupported $test -+ } -+ } -+} -+ -+gdb_continue_to_breakpoint break-at-exit ".*break-at-exit.*" -Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/sigstep-threads.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/sigstep-threads.c 2012-06-02 21:35:40.297499050 +0200 -@@ -0,0 +1,54 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2010 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+#include -+#include -+ -+#include -+#include -+#define tgkill(tgid, tid, sig) syscall (__NR_tgkill, (tgid), (tid), (sig)) -+#define gettid() syscall (__NR_gettid) -+ -+static volatile int var; -+ -+static void -+handler (int signo) /* step-0 */ -+{ /* step-0 */ -+ var++; /* step-1 */ -+ tgkill (getpid (), gettid (), SIGUSR1); /* step-2 */ -+} -+ -+static void * -+start (void *arg) -+{ -+ signal (SIGUSR1, handler); -+ tgkill (getpid (), gettid (), SIGUSR1); -+ assert (0); -+ -+ return NULL; -+} -+ -+int -+main (void) -+{ -+ pthread_t thread; -+ -+ pthread_create (&thread, NULL, start, NULL); -+ start (NULL); /* main-start */ -+ return 0; -+} -Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/sigstep-threads.exp -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/sigstep-threads.exp 2012-06-02 21:35:40.297499050 +0200 -@@ -0,0 +1,74 @@ -+# Copyright 2010 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+set testfile sigstep-threads -+set srcfile ${testfile}.c -+set executable ${testfile} -+set binfile ${objdir}/${subdir}/${executable} -+ -+if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -+ untested ${testfile}.exp -+ return -1 -+} -+ -+clean_restart $executable -+ -+if ![runto_main] { -+ return -1; -+} -+ -+# `noprint' would not test the full logic of GDB. -+gdb_test "handle SIGUSR1 nostop print pass" "\r\nSIGUSR1\[ \t\]+No\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*" -+ -+gdb_test_no_output "set scheduler-locking off" -+ -+gdb_breakpoint [gdb_get_line_number "step-1"] -+gdb_test_no_output {set $step1=$bpnum} -+gdb_continue_to_breakpoint "step-1" ".* step-1 .*" -+gdb_test_no_output {disable $step1} -+ -+# 1 as we are now stopped at the `step-1' label. -+set step_at 1 -+for {set i 0} {$i < 100} {incr i} { -+ set test "step $i" -+ # Presume this step failed - as in the case of a timeout. -+ set failed 1 -+ gdb_test_multiple "step" $test { -+ -re "\r\nProgram received signal SIGUSR1, User defined signal 1.\r\n" { -+ exp_continue -continue_timer -+ } -+ -re "step-(\[012\]).*\r\n$gdb_prompt $" { -+ set now $expect_out(1,string) -+ if {$step_at == 2 && $now == 1} { -+ set failed 0 -+ } elseif {$step_at == 1 && $now == 2} { -+ set failed 0 -+ # Continue over the re-signalling back to the handle entry. -+ gdb_test_no_output {enable $step1} "" -+ gdb_test "continue" " step-1 .*" "" -+ set now 1 -+ gdb_test_no_output {disable $step1} "" -+ } else { -+ fail $test -+ } -+ set step_at $now -+ } -+ } -+ if $failed { -+ return -+ } -+} -+# We can never reliably say the racy problematic case has been tested. -+pass "step" diff --git a/gdb-bz592031-siginfo-lost-5of5.patch b/gdb-bz592031-siginfo-lost-5of5.patch index b9fe18f..46cbdbc 100644 --- a/gdb-bz592031-siginfo-lost-5of5.patch +++ b/gdb-bz592031-siginfo-lost-5of5.patch @@ -26,19 +26,19 @@ gdb/ (linux_nat_set_siginfo_fixup): Use PTRACE_GETSIGINFO. * linux-nat.h (struct lwp_info) : Remove. -Index: gdb-7.4.50.20120602/gdb/linux-nat.c +Index: gdb-7.4.50.20120703/gdb/linux-nat.c =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/linux-nat.c 2012-06-02 21:36:21.067483466 +0200 -+++ gdb-7.4.50.20120602/gdb/linux-nat.c 2012-06-02 21:37:55.345447402 +0200 -@@ -1929,7 +1929,6 @@ resume_lwp (struct lwp_info *lp, int ste - step, GDB_SIGNAL_0); +--- gdb-7.4.50.20120703.orig/gdb/linux-nat.c 2012-07-03 17:33:02.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/linux-nat.c 2012-07-03 17:38:36.738142509 +0200 +@@ -1933,7 +1933,6 @@ resume_lwp (struct lwp_info *lp, int ste + step, signo); lp->stopped = 0; lp->step = step; - memset (&lp->siginfo, 0, sizeof (lp->siginfo)); lp->stopped_by_watchpoint = 0; } else -@@ -2071,7 +2070,6 @@ linux_nat_resume (struct target_ops *ops +@@ -2092,7 +2091,6 @@ linux_nat_resume (struct target_ops *ops if (linux_nat_prepare_to_resume != NULL) linux_nat_prepare_to_resume (lp); linux_ops->to_resume (linux_ops, ptid, step, signo); @@ -46,7 +46,7 @@ Index: gdb-7.4.50.20120602/gdb/linux-nat.c lp->stopped_by_watchpoint = 0; if (debug_linux_nat) -@@ -2625,22 +2623,6 @@ wait_lwp (struct lwp_info *lp) +@@ -2646,22 +2644,6 @@ wait_lwp (struct lwp_info *lp) return status; } @@ -69,7 +69,7 @@ Index: gdb-7.4.50.20120602/gdb/linux-nat.c /* Send a SIGSTOP to LP. */ static int -@@ -2885,9 +2867,6 @@ stop_wait_callback (struct lwp_info *lp, +@@ -2904,9 +2886,6 @@ stop_wait_callback (struct lwp_info *lp, { /* The thread was stopped with a signal other than SIGSTOP. */ @@ -79,7 +79,7 @@ Index: gdb-7.4.50.20120602/gdb/linux-nat.c save_sigtrap (lp); if (debug_linux_nat) -@@ -3291,12 +3270,7 @@ linux_nat_filter_event (int lwpid, int s +@@ -3288,12 +3267,7 @@ linux_nat_filter_event (int lwpid, int s } if (linux_nat_status_is_event (status)) @@ -93,7 +93,7 @@ Index: gdb-7.4.50.20120602/gdb/linux-nat.c /* Check if the thread has exited. */ if ((WIFEXITED (status) || WIFSIGNALED (status)) -@@ -3950,7 +3924,6 @@ resume_stopped_resumed_lwps (struct lwp_ +@@ -3947,7 +3921,6 @@ resume_stopped_resumed_lwps (struct lwp_ linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)), lp->step, GDB_SIGNAL_0); lp->stopped = 0; @@ -101,7 +101,7 @@ Index: gdb-7.4.50.20120602/gdb/linux-nat.c lp->stopped_by_watchpoint = 0; } -@@ -5227,11 +5200,19 @@ linux_nat_set_prepare_to_resume (struct +@@ -5224,11 +5197,19 @@ linux_nat_set_prepare_to_resume (struct siginfo_t * linux_nat_get_siginfo (ptid_t ptid) { @@ -124,10 +124,10 @@ Index: gdb-7.4.50.20120602/gdb/linux-nat.c } /* Provide a prototype to silence -Wmissing-prototypes. */ -Index: gdb-7.4.50.20120602/gdb/linux-nat.h +Index: gdb-7.4.50.20120703/gdb/linux-nat.h =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/linux-nat.h 2012-06-02 21:36:21.067483466 +0200 -+++ gdb-7.4.50.20120602/gdb/linux-nat.h 2012-06-02 21:36:27.140481144 +0200 +--- gdb-7.4.50.20120703.orig/gdb/linux-nat.h 2012-07-03 17:30:09.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/linux-nat.h 2012-07-03 17:38:13.501170247 +0200 @@ -76,10 +76,6 @@ struct lwp_info /* The kind of stepping of this LWP. */ enum resume_step step; diff --git a/gdb-core-open-vdso-warning.patch b/gdb-core-open-vdso-warning.patch index d4724ba..bde4e40 100644 --- a/gdb-core-open-vdso-warning.patch +++ b/gdb-core-open-vdso-warning.patch @@ -3,11 +3,11 @@ Subject: [patch] Fix GNU/Linux core open: Can't read pathname for load map: Inp [ New patch variant. ] -diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c -index 307e483..ba70764 100644 ---- a/gdb/solib-svr4.c -+++ b/gdb/solib-svr4.c -@@ -1221,8 +1221,17 @@ svr4_read_so_list (CORE_ADDR lm, struct so_list ***link_ptr_ptr, +Index: gdb-7.4.50.20120703/gdb/solib-svr4.c +=================================================================== +--- gdb-7.4.50.20120703.orig/gdb/solib-svr4.c 2012-07-03 17:34:18.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/solib-svr4.c 2012-07-03 17:34:35.614432174 +0200 +@@ -1221,8 +1221,17 @@ svr4_read_so_list (CORE_ADDR lm, struct SO_NAME_MAX_PATH_SIZE - 1, &errcode); if (errcode != 0) { @@ -27,11 +27,11 @@ index 307e483..ba70764 100644 do_cleanups (old_chain); continue; } -diff --git a/gdb/solib.c b/gdb/solib.c -index 90439ba..36e4d2a 100644 ---- a/gdb/solib.c -+++ b/gdb/solib.c -@@ -669,7 +669,7 @@ solib_used (const struct so_list *const known) +Index: gdb-7.4.50.20120703/gdb/solib.c +=================================================================== +--- gdb-7.4.50.20120703.orig/gdb/solib.c 2012-07-03 17:30:07.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/solib.c 2012-07-03 17:34:35.616432172 +0200 +@@ -672,7 +672,7 @@ solib_used (const struct so_list *const processes we've just attached to, so that's okay. */ static void @@ -40,7 +40,7 @@ index 90439ba..36e4d2a 100644 { struct target_so_ops *ops = solib_ops (target_gdbarch); struct so_list *inferior = ops->current_sos(); -@@ -840,6 +840,21 @@ Do you need \"set solib-search-path\" or \"set sysroot\"?"), +@@ -843,6 +843,21 @@ Do you need \"set solib-search-path\" or } } @@ -62,10 +62,10 @@ index 90439ba..36e4d2a 100644 /* Return non-zero if NAME is the libpthread shared library. -diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp -index 027eb2c..ab686f0 100644 ---- a/gdb/testsuite/gdb.base/corefile.exp -+++ b/gdb/testsuite/gdb.base/corefile.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.base/corefile.exp +=================================================================== +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.base/corefile.exp 2012-06-21 22:46:21.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.base/corefile.exp 2012-07-03 17:34:35.617432171 +0200 @@ -256,3 +256,18 @@ if ![is_remote target] { gdb_exit @@ -85,11 +85,11 @@ index 027eb2c..ab686f0 100644 + pass $test + } +} -diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/solib-symbol.exp -index 3c03317..0fc38d9 100644 ---- a/gdb/testsuite/gdb.base/solib-symbol.exp -+++ b/gdb/testsuite/gdb.base/solib-symbol.exp -@@ -27,7 +27,8 @@ set lib_flags [list debug ldflags=-Wl,-Bsymbolic] +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.base/solib-symbol.exp +=================================================================== +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.base/solib-symbol.exp 2012-06-21 22:46:22.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.base/solib-symbol.exp 2012-07-03 17:36:06.520322820 +0200 +@@ -27,7 +27,8 @@ set lib_flags [list debug ldflags=-Wl,-B # Binary file. set testfile "solib-symbol-main" set srcfile ${srcdir}/${subdir}/${testfile}.c @@ -98,7 +98,7 @@ index 3c03317..0fc38d9 100644 +set binfile ${objdir}/${subdir}/${executable} set bin_flags [list debug shlib=${binfile_lib}] - if [get_compiler_info ${binfile}] { + if [get_compiler_info] { @@ -72,8 +73,26 @@ gdb_test "br foo2" \ "Breakpoint.*: foo2. .2 locations..*" \ "foo2 in mdlib" diff --git a/gdb-dejagnu-go.patch b/gdb-dejagnu-go.patch deleted file mode 100644 index ddac07b..0000000 --- a/gdb-dejagnu-go.patch +++ /dev/null @@ -1,42 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-06/msg00050.html -Subject: [patch] dejagnu compat. - missing find_go_linker [Re: [patch, doc RFA] Go language support] - -On Wed, 25 Apr 2012 04:17:35 +0200, Doug Evans wrote: -> +if {[info procs find_go_linker] == ""} { -> + rename gdb_find_go find_go -> + rename gdb_find_go_linker find_go_linker -> + # No need to set use_gdb_compile. -> +} - -Is there a reason for it? With recent Fedora 17 update - https://bugzilla.redhat.com/show_bug.cgi?id=635651 - -dejagnu has started to support 'find_gfortran'. But it still does not support -'find_go_linker'. This has resulted in regression failing to compile any -gdb.go/*.exp files. - - -Thanks, -Jan - - -gdb/testsuite/ -2012-06-02 Jan Kratochvil - - * lib/future.exp: Set $use_gdb_compile even if only find_go_linker is - missing. - -diff --git a/gdb/testsuite/lib/future.exp b/gdb/testsuite/lib/future.exp -index 40456c0..bf47988 100644 ---- a/gdb/testsuite/lib/future.exp -+++ b/gdb/testsuite/lib/future.exp -@@ -514,7 +514,7 @@ if {[info procs find_gfortran] == ""} { - if {[info procs find_go_linker] == ""} { - rename gdb_find_go find_go - rename gdb_find_go_linker find_go_linker -- # No need to set use_gdb_compile. -+ set use_gdb_compile 1 - } - - if {$use_gdb_compile} { - diff --git a/gdb-dlopen-stap-probe-test.patch b/gdb-dlopen-stap-probe-test.patch index be5e76f..15f1c31 100644 --- a/gdb-dlopen-stap-probe-test.patch +++ b/gdb-dlopen-stap-probe-test.patch @@ -4,10 +4,10 @@ Date: Mon Aug 8 12:08:53 2011 +0200 +testcase -Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c 2012-06-02 20:03:42.711393776 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c 2012-07-03 17:44:45.797698656 +0200 @@ -0,0 +1,40 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -49,10 +49,10 @@ Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c + i = pthread_join (t, NULL); + assert (i == 0); +} -Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread.c +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/dlopen-libpthread.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread.c 2012-06-02 20:03:42.712393775 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/dlopen-libpthread.c 2012-07-03 17:44:45.798698655 +0200 @@ -0,0 +1,46 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -100,10 +100,10 @@ Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread.c + + return 0; +} -Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/dlopen-libpthread.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread.exp 2012-06-02 20:03:42.724393771 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/dlopen-libpthread.exp 2012-07-03 17:44:45.798698655 +0200 @@ -0,0 +1,74 @@ +# Copyright 2011 Free Software Foundation, Inc. +# @@ -179,15 +179,15 @@ Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread.exp +gdb_continue_to_breakpoint "notify" ".* notify-here .*" + +gdb_test "info sharedlibrary" {/libpthread\.so.*} "libpthread.so found" -Index: gdb-7.4.50.20120602/gdb/testsuite/lib/gdb.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/lib/gdb.exp =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/testsuite/lib/gdb.exp 2012-06-02 19:11:56.000000000 +0200 -+++ gdb-7.4.50.20120602/gdb/testsuite/lib/gdb.exp 2012-06-02 20:03:42.727393770 +0200 -@@ -3693,30 +3693,49 @@ proc build_executable { testname executa +--- gdb-7.4.50.20120703.orig/gdb/testsuite/lib/gdb.exp 2012-07-03 17:34:18.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/lib/gdb.exp 2012-07-03 17:46:44.316514076 +0200 +@@ -3758,23 +3758,7 @@ proc build_executable { testname executa set sources ${executable}.c } -- set binfile ${objdir}/${subdir}/${executable} +- set binfile [standard_output_file $executable] - - set objects {} - for {set i 0} "\$i<[llength $sources]" {incr i} { @@ -197,29 +197,29 @@ Index: gdb-7.4.50.20120602/gdb/testsuite/lib/gdb.exp - return -1 - } - lappend objects "${binfile}${i}.o" -+ # get_compiler_info by gdb_compile_shlib and gdb_compile_shlib_pthreads. -+ set info_options "" -+ if { [lsearch -exact $options "c++"] >= 0 } { -+ set info_options "c++" - } +- } - - if { [gdb_compile $objects "${binfile}" executable $options] != "" } { - untested $testname -+ if [get_compiler_info binfile_unused ${info_options}] { +- return -1 +- } +- ++ # get_compiler_info by gdb_compile_shlib and gdb_compile_shlib_pthreads. + set info_options "" + if { [lsearch -exact $options "c++"] >= 0 } { + set info_options "c++" +@@ -3782,6 +3766,41 @@ proc build_executable { testname executa + if [get_compiler_info ${info_options}] { return -1 } - -- set info_options "" -- if { [lsearch -exact $options "c++"] >= 0 } { -- set info_options "c++" -+ set binfile ${objdir}/${subdir}/${executable} ++ ++ set binfile [standard_output_file $executable] + + set func gdb_compile + set func_index [lsearch -regexp $options {^(pthreads|shlib|shlib_pthreads)$}] + if {$func_index != -1} { + set func "${func}_[lindex $options $func_index]" - } -- if [get_compiler_info ${binfile} ${info_options}] { ++ } + + # gdb_compile_shlib and gdb_compile_shlib_pthreads do not use the 3rd + # parameter. They also requires $sources while gdb_compile and @@ -244,16 +244,16 @@ Index: gdb-7.4.50.20120602/gdb/testsuite/lib/gdb.exp + } + if { $ret != "" } { + untested $testname - return -1 - } ++ return -1 ++ } + return 0 } -Index: gdb-7.4.50.20120602/gdb/testsuite/lib/prelink-support.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/lib/prelink-support.exp =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/testsuite/lib/prelink-support.exp 2012-01-04 09:27:56.000000000 +0100 -+++ gdb-7.4.50.20120602/gdb/testsuite/lib/prelink-support.exp 2012-06-02 20:03:42.733393768 +0200 +--- gdb-7.4.50.20120703.orig/gdb/testsuite/lib/prelink-support.exp 2012-01-04 09:27:56.000000000 +0100 ++++ gdb-7.4.50.20120703/gdb/testsuite/lib/prelink-support.exp 2012-07-03 17:44:45.803698648 +0200 @@ -95,8 +95,9 @@ proc file_copy {src dest} { # Wrap function build_executable so that the resulting executable is fully # self-sufficient (without dependencies on system libraries). Parameter @@ -306,10 +306,10 @@ Index: gdb-7.4.50.20120602/gdb/testsuite/lib/prelink-support.exp return $prelink_args } -Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.base/break-interp.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.base/break-interp.exp =================================================================== ---- gdb-7.4.50.20120602.orig/gdb/testsuite/gdb.base/break-interp.exp 2012-02-24 15:09:08.000000000 +0100 -+++ gdb-7.4.50.20120602/gdb/testsuite/gdb.base/break-interp.exp 2012-06-02 20:04:56.135369687 +0200 +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.base/break-interp.exp 2012-06-21 22:46:21.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.base/break-interp.exp 2012-07-03 17:44:45.804698647 +0200 @@ -109,14 +109,21 @@ proc strip_debug {dest} { } } diff --git a/gdb-errno-func-datatype-revert.patch b/gdb-errno-func-datatype-revert.patch new file mode 100644 index 0000000..847d76f --- /dev/null +++ b/gdb-errno-func-datatype-revert.patch @@ -0,0 +1,236 @@ +Regression: Invalid data type for function to be called. [Re: FYI: fix PR 9514] +http://sourceware.org/ml/gdb-patches/2012-07/msg00043.html + +reverted: +http://sourceware.org/ml/gdb-cvs/2012-06/msg00148.html + +diff -dup -rup gdb-7.4.50.20120703-orig/gdb/c-exp.y gdb-7.4.50.20120703/gdb/c-exp.y +--- gdb-7.4.50.20120703-orig/gdb/c-exp.y 2012-07-03 20:08:15.976418420 +0200 ++++ gdb-7.4.50.20120703/gdb/c-exp.y 2012-07-03 20:08:35.935390282 +0200 +@@ -172,10 +172,9 @@ static struct stoken operator_stoken (co + /* %type block */ + + /* Fancy type parsing. */ +-%type func_mod direct_abs_decl abs_decl ptr_operator ++%type func_mod direct_abs_decl abs_decl + %type ptype + %type array_mod +-%type conversion_type_id + + %token INT + %token FLOAT +@@ -932,7 +931,9 @@ variable: name_not_typename + ; + + space_identifier : '@' NAME +- { insert_type_address_space (copy_name ($2.stoken)); } ++ { push_type_address_space (copy_name ($2.stoken)); ++ push_type (tp_space_identifier); ++ } + ; + + const_or_volatile: const_or_volatile_noopt +@@ -951,23 +952,14 @@ const_or_volatile_or_space_identifier: + | + ; + +-ptr_operator: +- ptr_operator '*' +- { insert_type (tp_pointer); } +- const_or_volatile_or_space_identifier +- { $$ = 0; } +- | '*' +- { insert_type (tp_pointer); } +- const_or_volatile_or_space_identifier +- { $$ = 0; } ++abs_decl: '*' ++ { push_type (tp_pointer); $$ = 0; } ++ | '*' abs_decl ++ { push_type (tp_pointer); $$ = $2; } + | '&' +- { insert_type (tp_reference); $$ = 0; } +- | '&' ptr_operator +- { insert_type (tp_reference); $$ = 0; } +- ; +- +-abs_decl: ptr_operator direct_abs_decl +- | ptr_operator ++ { push_type (tp_reference); $$ = 0; } ++ | '&' abs_decl ++ { push_type (tp_reference); $$ = $2; } + | direct_abs_decl + ; + +@@ -1211,30 +1203,22 @@ nonempty_typelist + ; + + ptype : typebase +- | ptype abs_decl +- { $$ = follow_types ($1); } +- ; +- +-conversion_type_id: typebase conversion_declarator ++ | ptype const_or_volatile_or_space_identifier abs_decl const_or_volatile_or_space_identifier + { $$ = follow_types ($1); } + ; + +-conversion_declarator: /* Nothing. */ +- | ptr_operator conversion_declarator +- ; +- + const_and_volatile: CONST_KEYWORD VOLATILE_KEYWORD + | VOLATILE_KEYWORD CONST_KEYWORD + ; + + const_or_volatile_noopt: const_and_volatile +- { insert_type (tp_const); +- insert_type (tp_volatile); ++ { push_type (tp_const); ++ push_type (tp_volatile); + } + | CONST_KEYWORD +- { insert_type (tp_const); } ++ { push_type (tp_const); } + | VOLATILE_KEYWORD +- { insert_type (tp_volatile); } ++ { push_type (tp_volatile); } + ; + + operator: OPERATOR NEW +@@ -1341,7 +1325,7 @@ operator: OPERATOR NEW + { $$ = operator_stoken ("()"); } + | OPERATOR '[' ']' + { $$ = operator_stoken ("[]"); } +- | OPERATOR conversion_type_id ++ | OPERATOR ptype + { char *name; + long length; + struct ui_file *buf = mem_fileopen (); +diff -dup -rup gdb-7.4.50.20120703-orig/gdb/parse.c gdb-7.4.50.20120703/gdb/parse.c +--- gdb-7.4.50.20120703-orig/gdb/parse.c 2012-07-03 20:08:15.979418415 +0200 ++++ gdb-7.4.50.20120703/gdb/parse.c 2012-07-03 20:08:35.938390277 +0200 +@@ -1370,49 +1370,6 @@ check_type_stack_depth (void) + } + } + +-/* A helper function for insert_type and insert_type_address_space. +- This does work of expanding the type stack and inserting the new +- element, ELEMENT, into the stack at location SLOT. */ +- +-static void +-insert_into_type_stack (int slot, union type_stack_elt element) +-{ +- check_type_stack_depth (); +- +- if (slot < type_stack_depth) +- memmove (&type_stack[slot + 1], &type_stack[slot], +- (type_stack_depth - slot) * sizeof (union type_stack_elt)); +- type_stack[slot] = element; +- ++type_stack_depth; +-} +- +-/* Insert a new type, TP, at the bottom of the type stack. If TP is +- tp_pointer or tp_reference, it is inserted at the bottom. If TP is +- a qualifier, it is inserted at slot 1 (just above a previous +- tp_pointer) if there is anything on the stack, or simply pushed if +- the stack is empty. Other values for TP are invalid. */ +- +-void +-insert_type (enum type_pieces tp) +-{ +- union type_stack_elt element; +- int slot; +- +- gdb_assert (tp == tp_pointer || tp == tp_reference +- || tp == tp_const || tp == tp_volatile); +- +- /* If there is anything on the stack (we know it will be a +- tp_pointer), insert the qualifier above it. Otherwise, simply +- push this on the top of the stack. */ +- if (type_stack_depth && (tp == tp_const || tp == tp_volatile)) +- slot = 1; +- else +- slot = 0; +- +- element.piece = tp; +- insert_into_type_stack (slot, element); +-} +- + void + push_type (enum type_pieces tp) + { +@@ -1427,32 +1384,10 @@ push_type_int (int n) + type_stack[type_stack_depth++].int_val = n; + } + +-/* Insert a tp_space_identifier and the corresponding address space +- value into the stack. STRING is the name of an address space, as +- recognized by address_space_name_to_int. If the stack is empty, +- the new elements are simply pushed. If the stack is not empty, +- this function assumes that the first item on the stack is a +- tp_pointer, and the new values are inserted above the first +- item. */ +- + void +-insert_type_address_space (char *string) ++push_type_address_space (char *string) + { +- union type_stack_elt element; +- int slot; +- +- /* If there is anything on the stack (we know it will be a +- tp_pointer), insert the address space qualifier above it. +- Otherwise, simply push this on the top of the stack. */ +- if (type_stack_depth) +- slot = 1; +- else +- slot = 0; +- +- element.piece = tp_space_identifier; +- insert_into_type_stack (slot, element); +- element.int_val = address_space_name_to_int (parse_gdbarch, string); +- insert_into_type_stack (slot, element); ++ push_type_int (address_space_name_to_int (parse_gdbarch, string)); + } + + enum type_pieces +Only in gdb-7.4.50.20120703-orig/gdb: parse.c.orig +diff -dup -rup gdb-7.4.50.20120703-orig/gdb/parser-defs.h gdb-7.4.50.20120703/gdb/parser-defs.h +--- gdb-7.4.50.20120703-orig/gdb/parser-defs.h 2012-07-03 20:08:15.980418414 +0200 ++++ gdb-7.4.50.20120703/gdb/parser-defs.h 2012-07-03 20:08:35.939390275 +0200 +@@ -192,13 +192,11 @@ extern int end_arglist (void); + + extern char *copy_name (struct stoken); + +-extern void insert_type (enum type_pieces); +- + extern void push_type (enum type_pieces); + + extern void push_type_int (int); + +-extern void insert_type_address_space (char *); ++extern void push_type_address_space (char *); + + extern enum type_pieces pop_type (void); + +diff -dup -rup gdb-7.4.50.20120703-orig/gdb/testsuite/gdb.base/whatis.exp gdb-7.4.50.20120703/gdb/testsuite/gdb.base/whatis.exp +--- gdb-7.4.50.20120703-orig/gdb/testsuite/gdb.base/whatis.exp 2012-07-03 20:08:15.981418413 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.base/whatis.exp 2012-07-03 20:08:35.940390273 +0200 +@@ -465,17 +465,3 @@ gdb_test "whatis char_addr" \ + gdb_test "whatis a_char_addr" \ + "type = char_addr" \ + "whatis applied to variable defined by typedef" +- +-# Regression tests for PR 9514. +- +-gdb_test "whatis void (**)()" \ +- "type = void \\(\\*\\*\\)\\(\\)" \ +- "whatis applied to pointer to pointer to function" +- +-gdb_test "whatis void (** const)()" \ +- "type = void \\(\\*\\* const\\)\\(\\)" \ +- "whatis applied to const pointer to pointer to function" +- +-gdb_test "whatis void (* const *)()" \ +- "type = void \\(\\* const \\*\\)\\(\\)" \ +- "whatis applied to pointer to const pointer to function" diff --git a/gdb-objfile-order.patch b/gdb-objfile-order.patch deleted file mode 100644 index afd46e7..0000000 --- a/gdb-objfile-order.patch +++ /dev/null @@ -1,215 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-05/msg01105.html -Subject: [RFA/commit 1/3] Revert "Search global symbols from the expression's block objfile first." - -The search order used in this patch breaks global symbol lookups -for certain symbols when copy-relocation is used. A slightly different -search order will be implemented later. - -gdb/ChangeLog: - - Revert the following patch: - * findvar.c (default_read_var_value): For LOC_UNRESOLVED symbols, - try locating the symbol in the symbol's own objfile first, before - extending the search to all objfiles. - * symtab.c (lookup_symbol_aux_objfile): New function, extracted - out of lookup_symbol_aux_symtabs. - (lookup_symbol_aux_symtabs): Add new parameter "exclude_objfile". - Replace extracted-out code by call to lookup_symbol_aux_objfile. - Do not search EXCLUDE_OBJFILE. - (lookup_static_symbol_aux): Update call to lookup_symbol_aux_symtabs. - (lookup_symbol_global): Search for matches in the block's objfile - first, before searching all other objfiles. - -Will commit if patches #2 & #3 are OK. - ---- - gdb/findvar.c | 10 +----- - gdb/symtab.c | 108 +++++++++++++++++---------------------------------------- - 2 files changed, 33 insertions(+), 85 deletions(-) - -diff --git a/gdb/findvar.c b/gdb/findvar.c -index ed7903c..9009e6f 100644 ---- a/gdb/findvar.c -+++ b/gdb/findvar.c -@@ -562,15 +562,7 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) - struct minimal_symbol *msym; - struct obj_section *obj_section; - -- /* First, try locating the associated minimal symbol within -- the same objfile. This prevents us from selecting another -- symbol with the same name but located in a different objfile. */ -- msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, -- SYMBOL_SYMTAB (var)->objfile); -- /* If the lookup failed, try expanding the search to all -- objfiles. */ -- if (msym == NULL) -- msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL); -+ msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL); - if (msym == NULL) - error (_("No global symbol \"%s\"."), SYMBOL_LINKAGE_NAME (var)); - if (overlay_debugging) -diff --git a/gdb/symtab.c b/gdb/symtab.c -index 85ddd1d..39d8c6f 100644 ---- a/gdb/symtab.c -+++ b/gdb/symtab.c -@@ -95,8 +95,7 @@ struct symbol *lookup_symbol_aux_local (const char *name, - static - struct symbol *lookup_symbol_aux_symtabs (int block_index, - const char *name, -- const domain_enum domain, -- struct objfile *exclude_objfile); -+ const domain_enum domain); - - static - struct symbol *lookup_symbol_aux_quick (struct objfile *objfile, -@@ -1360,7 +1359,7 @@ lookup_static_symbol_aux (const char *name, const domain_enum domain) - struct objfile *objfile; - struct symbol *sym; - -- sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain, NULL); -+ sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain); - if (sym != NULL) - return sym; - -@@ -1499,61 +1498,40 @@ lookup_global_symbol_from_objfile (const struct objfile *main_objfile, - return NULL; - } - --/* Check to see if the symbol is defined in one of the OBJFILE's -- symtabs. BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK, -+/* Check to see if the symbol is defined in one of the symtabs. -+ BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK, - depending on whether or not we want to search global symbols or - static symbols. */ - - static struct symbol * --lookup_symbol_aux_objfile (struct objfile *objfile, int block_index, -- const char *name, const domain_enum domain) --{ -- struct symbol *sym = NULL; -- struct blockvector *bv; -- const struct block *block; -- struct symtab *s; -- -- if (objfile->sf) -- objfile->sf->qf->pre_expand_symtabs_matching (objfile, block_index, -- name, domain); -- -- ALL_OBJFILE_SYMTABS (objfile, s) -- if (s->primary) -- { -- bv = BLOCKVECTOR (s); -- block = BLOCKVECTOR_BLOCK (bv, block_index); -- sym = lookup_block_symbol (block, name, domain); -- if (sym) -- { -- block_found = block; -- return fixup_symbol_section (sym, objfile); -- } -- } -- -- return NULL; --} -- --/* Same as lookup_symbol_aux_objfile, except that it searches all -- objfiles except for EXCLUDE_OBJFILE. Return the first match found. -- -- If EXCLUDE_OBJFILE is NULL, then all objfiles are searched. */ -- --static struct symbol * - lookup_symbol_aux_symtabs (int block_index, const char *name, -- const domain_enum domain, -- struct objfile *exclude_objfile) -+ const domain_enum domain) - { - struct symbol *sym; - struct objfile *objfile; -+ struct blockvector *bv; -+ const struct block *block; -+ struct symtab *s; - - ALL_OBJFILES (objfile) - { -- if (objfile != exclude_objfile) -- { -- sym = lookup_symbol_aux_objfile (objfile, block_index, name, domain); -- if (sym) -- return sym; -- } -+ if (objfile->sf) -+ objfile->sf->qf->pre_expand_symtabs_matching (objfile, -+ block_index, -+ name, domain); -+ -+ ALL_OBJFILE_SYMTABS (objfile, s) -+ if (s->primary) -+ { -+ bv = BLOCKVECTOR (s); -+ block = BLOCKVECTOR_BLOCK (bv, block_index); -+ sym = lookup_block_symbol (block, name, domain); -+ if (sym) -+ { -+ block_found = block; -+ return fixup_symbol_section (sym, objfile); -+ } -+ } - } - - return NULL; -@@ -1679,46 +1657,24 @@ lookup_symbol_global (const char *name, - const domain_enum domain) - { - struct symbol *sym = NULL; -- struct objfile *block_objfile = NULL; - struct objfile *objfile = NULL; - - /* Call library-specific lookup procedure. */ -- block_objfile = lookup_objfile_from_block (block); -- if (block_objfile != NULL) -- sym = solib_global_lookup (block_objfile, name, domain); -+ objfile = lookup_objfile_from_block (block); -+ if (objfile != NULL) -+ sym = solib_global_lookup (objfile, name, domain); - if (sym != NULL) - return sym; - -- /* If BLOCK_OBJFILE is not NULL, then search this objfile first. -- In case the global symbol is defined in multiple objfiles, -- we have a better chance of finding the most relevant symbol. */ -- -- if (block_objfile != NULL) -- { -- sym = lookup_symbol_aux_objfile (block_objfile, GLOBAL_BLOCK, -- name, domain); -- if (sym == NULL) -- sym = lookup_symbol_aux_quick (block_objfile, GLOBAL_BLOCK, -- name, domain); -- if (sym != NULL) -- return sym; -- } -- -- /* Symbol not found in the BLOCK_OBJFILE, so try all the other -- objfiles, starting with symtabs first, and then partial symtabs. */ -- -- sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, domain, block_objfile); -+ sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, domain); - if (sym != NULL) - return sym; - - ALL_OBJFILES (objfile) - { -- if (objfile != block_objfile) -- { -- sym = lookup_symbol_aux_quick (objfile, GLOBAL_BLOCK, name, domain); -- if (sym) -- return sym; -- } -+ sym = lookup_symbol_aux_quick (objfile, GLOBAL_BLOCK, name, domain); -+ if (sym) -+ return sym; - } - - return NULL; --- -1.7.1 - diff --git a/gdb-parameterref-1of2.patch b/gdb-parameterref-1of2.patch deleted file mode 100644 index 029e6f9..0000000 --- a/gdb-parameterref-1of2.patch +++ /dev/null @@ -1,416 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-06/msg00458.html -Subject: [patch 1/2] Generalize call_site.parameter key ("code cleanup") - -Hi, - -previously parameter could be identified either via DW_OP_reg or via -DW_OP_fbreg (both in DW_AT_location). As [patch 2/2] adds new identification -via DW_AT_abstract_origin generalize this two state deciding into more general -enum. - - -Thanks, -Jan - - -gdb/ -2012-06-14 Jan Kratochvil - - Code cleanup: Generalize call_site.parameter key. - * dwarf2expr.c (execute_stack_op) : Remove - variable dwarf_reg. New variable kind_u. Update parameters to - push_dwarf_reg_entry_value. - (ctx_no_push_dwarf_reg_entry_value): Update parameters. - * dwarf2expr.h (enum call_site_parameter_kind) - (union call_site_parameter_u): Forward declarations. - (struct dwarf_expr_context_funcs): Update parameters and their - description for push_dwarf_reg_entry_value. - (ctx_no_push_dwarf_reg_entry_value): Update parameters. - * dwarf2loc.c (call_site_parameter_matches): New function. - (dwarf_expr_reg_to_entry_parameter): Update parameters and their - description. Use call_site_parameter_matches. - (dwarf_expr_push_dwarf_reg_entry_value, value_of_dwarf_reg_entry): - Update parameters and their description. - (value_of_dwarf_block_entry): Remove variables dwarf_reg and fb_offset. - New variable kind_u. Adjust the caller for updated parameters. - (needs_dwarf_reg_entry_value): Update parameters. - * dwarf2read.c (read_call_site_scope): New variable loc. Use it - instead of attr. Update for the changed fields of struct - call_site_parameter. - * gdbtypes.h: Include dwarf2expr.h. - (enum call_site_parameter_kind): New. - (struct call_site.parameter): New field kind. Wrap dwarf_reg and - fb_offset into new union u. - ---- a/gdb/dwarf2expr.c -+++ b/gdb/dwarf2expr.c -@@ -1355,33 +1355,35 @@ execute_stack_op (struct dwarf_expr_context *ctx, - case DW_OP_GNU_entry_value: - { - uint64_t len; -- int dwarf_reg; - CORE_ADDR deref_size; -+ union call_site_parameter_u kind_u; - - op_ptr = safe_read_uleb128 (op_ptr, op_end, &len); - if (op_ptr + len > op_end) - error (_("DW_OP_GNU_entry_value: too few bytes available.")); - -- dwarf_reg = dwarf_block_to_dwarf_reg (op_ptr, op_ptr + len); -- if (dwarf_reg != -1) -+ kind_u.dwarf_reg = dwarf_block_to_dwarf_reg (op_ptr, op_ptr + len); -+ if (kind_u.dwarf_reg != -1) - { - op_ptr += len; -- ctx->funcs->push_dwarf_reg_entry_value (ctx, dwarf_reg, -- 0 /* unused */, -+ ctx->funcs->push_dwarf_reg_entry_value (ctx, -+ CALL_SITE_PARAMETER_DWARF_REG, -+ kind_u, - -1 /* deref_size */); - goto no_push; - } - -- dwarf_reg = dwarf_block_to_dwarf_reg_deref (op_ptr, op_ptr + len, -- &deref_size); -- if (dwarf_reg != -1) -+ kind_u.dwarf_reg = dwarf_block_to_dwarf_reg_deref (op_ptr, -+ op_ptr + len, -+ &deref_size); -+ if (kind_u.dwarf_reg != -1) - { - if (deref_size == -1) - deref_size = ctx->addr_size; - op_ptr += len; -- ctx->funcs->push_dwarf_reg_entry_value (ctx, dwarf_reg, -- 0 /* unused */, -- deref_size); -+ ctx->funcs->push_dwarf_reg_entry_value (ctx, -+ CALL_SITE_PARAMETER_DWARF_REG, -+ kind_u, deref_size); - goto no_push; - } - -@@ -1533,7 +1535,8 @@ ctx_no_get_base_type (struct dwarf_expr_context *ctx, cu_offset die) - - void - ctx_no_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, -- int dwarf_reg, CORE_ADDR fb_offset, -+ enum call_site_parameter_kind kind, -+ union call_site_parameter_u kind_u, - int deref_size) - { - internal_error (__FILE__, __LINE__, ---- a/gdb/dwarf2expr.h -+++ b/gdb/dwarf2expr.h -@@ -26,6 +26,8 @@ - #include "leb128.h" - - struct dwarf_expr_context; -+enum call_site_parameter_kind; -+union call_site_parameter_u; - - /* Offset relative to the start of its containing CU (compilation unit). */ - typedef struct -@@ -77,14 +79,12 @@ struct dwarf_expr_context_funcs - struct type *(*get_base_type) (struct dwarf_expr_context *ctx, cu_offset die); - - /* Push on DWARF stack an entry evaluated for DW_TAG_GNU_call_site's -- DWARF_REG/FB_OFFSET at the caller of specified BATON. If DWARF register -- number DWARF_REG specifying the push_dwarf_reg_entry_value parameter is -- not -1 FB_OFFSET is ignored. Otherwise FB_OFFSET specifies stack -- parameter offset against caller's stack pointer (which equals the callee's -- frame base). If DEREF_SIZE is not -1 then use -- DW_AT_GNU_call_site_data_value instead of DW_AT_GNU_call_site_value. */ -+ parameter matching KIND and KIND_U at the caller of specified BATON. -+ If DEREF_SIZE is not -1 then use DW_AT_GNU_call_site_data_value instead of -+ DW_AT_GNU_call_site_value. */ - void (*push_dwarf_reg_entry_value) (struct dwarf_expr_context *ctx, -- int dwarf_reg, CORE_ADDR fb_offset, -+ enum call_site_parameter_kind kind, -+ union call_site_parameter_u kind_u, - int deref_size); - - /* Return the address indexed by DW_OP_GNU_addr_index. -@@ -289,7 +289,8 @@ void ctx_no_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset); - struct type *ctx_no_get_base_type (struct dwarf_expr_context *ctx, - cu_offset die); - void ctx_no_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, -- int dwarf_reg, CORE_ADDR fb_offset, -+ enum call_site_parameter_kind kind, -+ union call_site_parameter_u kind_u, - int deref_size); - CORE_ADDR ctx_no_get_addr_index (void *baton, unsigned int index); - ---- a/gdb/dwarf2loc.c -+++ b/gdb/dwarf2loc.c -@@ -929,16 +929,34 @@ call_site_find_chain (struct gdbarch *gdbarch, CORE_ADDR caller_pc, - return retval; - } - --/* Fetch call_site_parameter from caller matching the parameters. FRAME is for -- callee. See DWARF_REG and FB_OFFSET description at struct -- dwarf_expr_context_funcs->push_dwarf_reg_entry_value. -+/* Return 1 if KIND and KIND_U match PARAMETER. Return 0 otherwise. */ -+ -+static int -+call_site_parameter_matches (struct call_site_parameter *parameter, -+ enum call_site_parameter_kind kind, -+ union call_site_parameter_u kind_u) -+{ -+ if (kind == parameter->kind) -+ switch (kind) -+ { -+ case CALL_SITE_PARAMETER_DWARF_REG: -+ return kind_u.dwarf_reg == parameter->u.dwarf_reg; -+ case CALL_SITE_PARAMETER_FB_OFFSET: -+ return kind_u.fb_offset == parameter->u.fb_offset; -+ } -+ return 0; -+} -+ -+/* Fetch call_site_parameter from caller matching KIND and KIND_U. -+ FRAME is for callee. - - Function always returns non-NULL, it throws NO_ENTRY_VALUE_ERROR - otherwise. */ - - static struct call_site_parameter * --dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, int dwarf_reg, -- CORE_ADDR fb_offset, -+dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, -+ enum call_site_parameter_kind kind, -+ union call_site_parameter_u kind_u, - struct dwarf2_per_cu_data **per_cu_return) - { - CORE_ADDR func_addr = get_frame_func (frame); -@@ -1001,12 +1019,7 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, int dwarf_reg, - for (iparams = 0; iparams < call_site->parameter_count; iparams++) - { - parameter = &call_site->parameter[iparams]; -- if (parameter->dwarf_reg == -1 && dwarf_reg == -1) -- { -- if (parameter->fb_offset == fb_offset) -- break; -- } -- else if (parameter->dwarf_reg == dwarf_reg) -+ if (call_site_parameter_matches (parameter, kind, kind_u)) - break; - } - if (iparams == call_site->parameter_count) -@@ -1063,17 +1076,17 @@ dwarf_entry_parameter_to_value (struct call_site_parameter *parameter, - return dwarf2_evaluate_loc_desc (type, caller_frame, data, size + 1, per_cu); - } - --/* Execute call_site_parameter's DWARF block matching DEREF_SIZE for caller of -- the CTX's frame. CTX must be of dwarf_expr_ctx_funcs kind. See DWARF_REG -- and FB_OFFSET description at struct -- dwarf_expr_context_funcs->push_dwarf_reg_entry_value. -+/* Execute DWARF block of call_site_parameter which matches KIND and KIND_U. -+ Choose DEREF_SIZE value of that parameter. Search caller of the CTX's -+ frame. CTX must be of dwarf_expr_ctx_funcs kind. - - The CTX caller can be from a different CU - per_cu_dwarf_call implementation - can be more simple as it does not support cross-CU DWARF executions. */ - - static void - dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, -- int dwarf_reg, CORE_ADDR fb_offset, -+ enum call_site_parameter_kind kind, -+ union call_site_parameter_u kind_u, - int deref_size) - { - struct dwarf_expr_baton *debaton; -@@ -1090,7 +1103,7 @@ dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, - frame = debaton->frame; - caller_frame = get_prev_frame (frame); - -- parameter = dwarf_expr_reg_to_entry_parameter (frame, dwarf_reg, fb_offset, -+ parameter = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u, - &caller_per_cu); - data_src = deref_size == -1 ? parameter->value : parameter->data_value; - size = deref_size == -1 ? parameter->value_size : parameter->data_value_size; -@@ -1187,17 +1200,17 @@ static const struct lval_funcs entry_data_value_funcs = - entry_data_value_free_closure - }; - --/* Read parameter of TYPE at (callee) FRAME's function entry. DWARF_REG and -- FB_OFFSET are used to match DW_AT_location at the caller's -- DW_TAG_GNU_call_site_parameter. See DWARF_REG and FB_OFFSET description at -- struct dwarf_expr_context_funcs->push_dwarf_reg_entry_value. -+/* Read parameter of TYPE at (callee) FRAME's function entry. KIND and KIND_U -+ are used to match DW_AT_location at the caller's -+ DW_TAG_GNU_call_site_parameter. - - Function always returns non-NULL value. It throws NO_ENTRY_VALUE_ERROR if it - cannot resolve the parameter for any reason. */ - - static struct value * - value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame, -- int dwarf_reg, CORE_ADDR fb_offset) -+ enum call_site_parameter_kind kind, -+ union call_site_parameter_u kind_u) - { - struct type *checked_type = check_typedef (type); - struct type *target_type = TYPE_TARGET_TYPE (checked_type); -@@ -1207,7 +1220,7 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame, - struct dwarf2_per_cu_data *caller_per_cu; - CORE_ADDR addr; - -- parameter = dwarf_expr_reg_to_entry_parameter (frame, dwarf_reg, fb_offset, -+ parameter = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u, - &caller_per_cu); - - outer_val = dwarf_entry_parameter_to_value (parameter, -1 /* deref_size */, -@@ -1259,15 +1272,16 @@ static struct value * - value_of_dwarf_block_entry (struct type *type, struct frame_info *frame, - const gdb_byte *block, size_t block_len) - { -- int dwarf_reg; -- CORE_ADDR fb_offset; -+ union call_site_parameter_u kind_u; - -- dwarf_reg = dwarf_block_to_dwarf_reg (block, block + block_len); -- if (dwarf_reg != -1) -- return value_of_dwarf_reg_entry (type, frame, dwarf_reg, 0 /* unused */); -+ kind_u.dwarf_reg = dwarf_block_to_dwarf_reg (block, block + block_len); -+ if (kind_u.dwarf_reg != -1) -+ return value_of_dwarf_reg_entry (type, frame, CALL_SITE_PARAMETER_DWARF_REG, -+ kind_u); - -- if (dwarf_block_to_fb_offset (block, block + block_len, &fb_offset)) -- return value_of_dwarf_reg_entry (type, frame, -1, fb_offset); -+ if (dwarf_block_to_fb_offset (block, block + block_len, &kind_u.fb_offset)) -+ return value_of_dwarf_reg_entry (type, frame, CALL_SITE_PARAMETER_FB_OFFSET, -+ kind_u); - - /* This can normally happen - throw NO_ENTRY_VALUE_ERROR to get the message - suppressed during normal operation. The expression can be arbitrary if -@@ -2358,7 +2372,8 @@ needs_frame_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset) - - static void - needs_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, -- int dwarf_reg, CORE_ADDR fb_offset, int deref_size) -+ enum call_site_parameter_kind kind, -+ union call_site_parameter_u kind_u, int deref_size) - { - struct needs_frame_baton *nf_baton = ctx->baton; - ---- a/gdb/dwarf2read.c -+++ b/gdb/dwarf2read.c -@@ -7816,6 +7816,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) - child_die = sibling_die (child_die)) - { - struct call_site_parameter *parameter; -+ struct attribute *loc; - - if (child_die->tag != DW_TAG_GNU_call_site_parameter) - { -@@ -7829,8 +7830,8 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) - /* DW_AT_location specifies the register number. Value of the data - assumed for the register is contained in DW_AT_GNU_call_site_value. */ - -- attr = dwarf2_attr (child_die, DW_AT_location, cu); -- if (!attr || !attr_form_is_block (attr)) -+ loc = dwarf2_attr (child_die, DW_AT_location, cu); -+ if (loc == NULL || !attr_form_is_block (loc)) - { - complaint (&symfile_complaints, - _("No DW_FORM_block* DW_AT_location for " -@@ -7838,19 +7839,26 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) - child_die->offset.sect_off, objfile->name); - continue; - } -- parameter->dwarf_reg = dwarf_block_to_dwarf_reg (DW_BLOCK (attr)->data, -- &DW_BLOCK (attr)->data[DW_BLOCK (attr)->size]); -- if (parameter->dwarf_reg == -1 -- && !dwarf_block_to_sp_offset (gdbarch, DW_BLOCK (attr)->data, -- &DW_BLOCK (attr)->data[DW_BLOCK (attr)->size], -- ¶meter->fb_offset)) -+ else - { -- complaint (&symfile_complaints, -- _("Only single DW_OP_reg or DW_OP_fbreg is supported " -- "for DW_FORM_block* DW_AT_location for " -- "DW_TAG_GNU_call_site child DIE 0x%x [in module %s]"), -- child_die->offset.sect_off, objfile->name); -- continue; -+ parameter->u.dwarf_reg = dwarf_block_to_dwarf_reg -+ (DW_BLOCK (loc)->data, &DW_BLOCK (loc)->data[DW_BLOCK (loc)->size]); -+ if (parameter->u.dwarf_reg != -1) -+ parameter->kind = CALL_SITE_PARAMETER_DWARF_REG; -+ else if (dwarf_block_to_sp_offset (gdbarch, DW_BLOCK (loc)->data, -+ &DW_BLOCK (loc)->data[DW_BLOCK (loc)->size], -+ ¶meter->u.fb_offset)) -+ parameter->kind = CALL_SITE_PARAMETER_FB_OFFSET; -+ else -+ { -+ complaint (&symfile_complaints, -+ _("Only single DW_OP_reg or DW_OP_fbreg is supported " -+ "for DW_FORM_block* DW_AT_location is supported for " -+ "DW_TAG_GNU_call_site child DIE 0x%x " -+ "[in module %s]"), -+ child_die->offset.sect_off, objfile->name); -+ continue; -+ } - } - - attr = dwarf2_attr (child_die, DW_AT_GNU_call_site_value, cu); ---- a/gdb/gdbtypes.h -+++ b/gdb/gdbtypes.h -@@ -23,6 +23,7 @@ - #define GDBTYPES_H 1 - - #include "hashtab.h" -+#include "dwarf2expr.h" - - /* Forward declarations for prototypes. */ - struct field; -@@ -915,6 +916,17 @@ struct func_type - struct call_site *tail_call_list; - }; - -+/* struct call_site_parameter can be referenced in callees by several ways. */ -+ -+enum call_site_parameter_kind -+{ -+ /* Use field call_site_parameter.u.dwarf_reg. */ -+ CALL_SITE_PARAMETER_DWARF_REG, -+ -+ /* Use field call_site_parameter.u.fb_offset. */ -+ CALL_SITE_PARAMETER_FB_OFFSET -+}; -+ - /* A place where a function gets called from, represented by - DW_TAG_GNU_call_site. It can be looked up from symtab->call_site_htab. */ - -@@ -948,15 +960,19 @@ struct call_site - /* Describe DW_TAG_GNU_call_site's DW_TAG_formal_parameter. */ - struct call_site_parameter - { -- /* DW_TAG_formal_parameter's DW_AT_location's DW_OP_regX as DWARF -- register number, for register passed parameters. If -1 then use -- fb_offset. */ -- int dwarf_reg; -- -- /* Offset from the callee's frame base, for stack passed parameters. -- This equals offset from the caller's stack pointer. Valid only if -- DWARF_REGNUM is -1. */ -- CORE_ADDR fb_offset; -+ ENUM_BITFIELD (call_site_parameter_kind) kind : 2; -+ -+ union call_site_parameter_u -+ { -+ /* DW_TAG_formal_parameter's DW_AT_location's DW_OP_regX as DWARF -+ register number, for register passed parameters. */ -+ int dwarf_reg; -+ -+ /* Offset from the callee's frame base, for stack passed parameters. -+ This equals offset from the caller's stack pointer. */ -+ CORE_ADDR fb_offset; -+ } -+ u; - - /* DW_TAG_formal_parameter's DW_AT_GNU_call_site_value. It is never - NULL. */ - diff --git a/gdb-parameterref-2of2.patch b/gdb-parameterref-2of2.patch deleted file mode 100644 index 85e37af..0000000 --- a/gdb-parameterref-2of2.patch +++ /dev/null @@ -1,864 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-06/msg00459.html -Subject: [patch 2/2] Support gcc-4.7 DW_OP_GNU_parameter_ref - -Hi, - -this add-on to gdb.arch/amd64-entry-value.exp has been somehow forgotten: - [PATCH] Improve debug info for IPA-SRA optimized code - add DW_OP_GNU_parameter_ref support (PR debug/47858) - http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00649.html - -And for gcc-4.7+ -O2 -g code GDB may print (instead of the calculated value): - (gdb) p y - Unhandled dwarf expression opcode 0xfa - -The support is pretty simple, there is just now third kind of binding between -callers and callees parameter values. - -No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu. - - -Thanks, -Jan - - -gdb/ -2012-06-14 Jan Kratochvil - - * dwarf2expr.c (execute_stack_op): Support DW_OP_GNU_parameter_ref. - * dwarf2loc.c (call_site_parameter_matches): Support - CALL_SITE_PARAMETER_PARAM_OFFSET. - (needs_dwarf_reg_entry_value): Push stub value. - * dwarf2read.c (read_call_site_scope): New variable origin. Support - CALL_SITE_PARAMETER_PARAM_OFFSET and its DW_AT_abstract_origin. - * gdbtypes.h (enum call_site_parameter_kind): New item - CALL_SITE_PARAMETER_PARAM_OFFSET. - (struct call_site.parameter.u): New field param_offset. - -gdb/testsuite/ -2012-06-14 Jan Kratochvil - - * gdb.arch/amd64-entry-value-param.S: New file. - * gdb.arch/amd64-entry-value-param.c: New file. - * gdb.arch/amd64-entry-value-param.exp: New file. - ---- a/gdb/dwarf2expr.c -+++ b/gdb/dwarf2expr.c -@@ -1392,6 +1392,21 @@ execute_stack_op (struct dwarf_expr_context *ctx, - "or for DW_OP_breg*(0)+DW_OP_deref*")); - } - -+ case DW_OP_GNU_parameter_ref: -+ { -+ cu_offset offset; -+ union call_site_parameter_u kind_u; -+ -+ kind_u.param_offset.cu_off = extract_unsigned_integer (op_ptr, 4, -+ byte_order); -+ op_ptr += 4; -+ ctx->funcs->push_dwarf_reg_entry_value (ctx, -+ CALL_SITE_PARAMETER_PARAM_OFFSET, -+ kind_u, -+ -1 /* deref_size */); -+ } -+ goto no_push; -+ - case DW_OP_GNU_const_type: - { - cu_offset type_die; ---- a/gdb/dwarf2loc.c -+++ b/gdb/dwarf2loc.c -@@ -943,6 +943,8 @@ call_site_parameter_matches (struct call_site_parameter *parameter, - return kind_u.dwarf_reg == parameter->u.dwarf_reg; - case CALL_SITE_PARAMETER_FB_OFFSET: - return kind_u.fb_offset == parameter->u.fb_offset; -+ case CALL_SITE_PARAMETER_PARAM_OFFSET: -+ return kind_u.param_offset.cu_off == parameter->u.param_offset.cu_off; - } - return 0; - } -@@ -2378,6 +2380,9 @@ needs_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, - struct needs_frame_baton *nf_baton = ctx->baton; - - nf_baton->needs_frame = 1; -+ -+ /* The expression may require some stub values on DWARF stack. */ -+ dwarf_expr_push_address (ctx, 0, 0); - } - - /* DW_OP_GNU_addr_index doesn't require a frame. */ ---- a/gdb/dwarf2read.c -+++ b/gdb/dwarf2read.c -@@ -7816,7 +7816,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) - child_die = sibling_die (child_die)) - { - struct call_site_parameter *parameter; -- struct attribute *loc; -+ struct attribute *loc, *origin; - - if (child_die->tag != DW_TAG_GNU_call_site_parameter) - { -@@ -7827,11 +7827,23 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) - gdb_assert (call_site->parameter_count < nparams); - parameter = &call_site->parameter[call_site->parameter_count]; - -- /* DW_AT_location specifies the register number. Value of the data -- assumed for the register is contained in DW_AT_GNU_call_site_value. */ -+ /* DW_AT_location specifies the register number or DW_AT_abstract_origin -+ specifies DW_TAG_formal_parameter. Value of the data assumed for the -+ register is contained in DW_AT_GNU_call_site_value. */ - - loc = dwarf2_attr (child_die, DW_AT_location, cu); -- if (loc == NULL || !attr_form_is_block (loc)) -+ origin = dwarf2_attr (child_die, DW_AT_abstract_origin, cu); -+ if (loc == NULL && origin != NULL && is_ref_attr (origin)) -+ { -+ sect_offset offset; -+ -+ parameter->kind = CALL_SITE_PARAMETER_PARAM_OFFSET; -+ offset = dwarf2_get_ref_die_offset (origin); -+ gdb_assert (offset.sect_off >= cu->header.offset.sect_off); -+ parameter->u.param_offset.cu_off = (offset.sect_off -+ - cu->header.offset.sect_off); -+ } -+ else if (loc == NULL || origin != NULL || !attr_form_is_block (loc)) - { - complaint (&symfile_complaints, - _("No DW_FORM_block* DW_AT_location for " ---- a/gdb/gdbtypes.h -+++ b/gdb/gdbtypes.h -@@ -924,7 +924,10 @@ enum call_site_parameter_kind - CALL_SITE_PARAMETER_DWARF_REG, - - /* Use field call_site_parameter.u.fb_offset. */ -- CALL_SITE_PARAMETER_FB_OFFSET -+ CALL_SITE_PARAMETER_FB_OFFSET, -+ -+ /* Use field call_site_parameter.u.param_offset. */ -+ CALL_SITE_PARAMETER_PARAM_OFFSET - }; - - /* A place where a function gets called from, represented by -@@ -971,6 +974,11 @@ struct call_site - /* Offset from the callee's frame base, for stack passed parameters. - This equals offset from the caller's stack pointer. */ - CORE_ADDR fb_offset; -+ -+ /* Offset relative to the start of this PER_CU to -+ DW_TAG_formal_parameter which is referenced by both caller and -+ the callee. */ -+ cu_offset param_offset; - } - u; - ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param.S -@@ -0,0 +1,611 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2012 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+/* This file is compiled from gdb.arch/amd64-entry-value-param.c -+ using -g -dA -S -O2. */ -+ -+ .file "amd64-entry-value-param.c" -+ .text -+.Ltext0: -+ .p2align 4,,15 -+ .type foo.isra.0.constprop.2, @function -+foo.isra.0.constprop.2: -+.LFB4: -+ .file 1 "gdb.arch/amd64-entry-value-param.c" -+ /* gdb.arch/amd64-entry-value-param.c:21 */ -+ .loc 1 21 0 -+ .cfi_startproc -+.LVL0: -+/* BLOCK 2 freq:10000 seq:0 */ -+/* PRED: ENTRY [100.0%] (fallthru) */ -+ /* gdb.arch/amd64-entry-value-param.c:26 */ -+ .loc 1 26 0 -+ movl vv(%rip), %eax -+ addl $1, %eax -+ movl %eax, vv(%rip) -+ /* gdb.arch/amd64-entry-value-param.c:27 */ -+ .loc 1 27 0 -+ leal 3(%rdi), %eax -+/* SUCC: EXIT [100.0%] */ -+ /* gdb.arch/amd64-entry-value-param.c:28 */ -+ .loc 1 28 0 -+ ret -+ .cfi_endproc -+.LFE4: -+ .size foo.isra.0.constprop.2, .-foo.isra.0.constprop.2 -+ .p2align 4,,15 -+ .type bar.constprop.1, @function -+bar.constprop.1: -+.LFB5: -+ /* gdb.arch/amd64-entry-value-param.c:31 */ -+ .loc 1 31 0 -+ .cfi_startproc -+/* BLOCK 2 freq:10000 seq:0 */ -+/* PRED: ENTRY [100.0%] (fallthru) */ -+.LVL1: -+ pushq %rbx -+.LCFI0: -+ .cfi_def_cfa_offset 16 -+ .cfi_offset 3, -16 -+ /* gdb.arch/amd64-entry-value-param.c:33 */ -+ .loc 1 33 0 -+ movl $10, %edi -+ call foo.isra.0.constprop.2 -+.LVL2: -+ movl $10, %edi -+ movl %eax, %ebx -+ call foo.isra.0.constprop.2 -+.LVL3: -+ movl $16, %edi -+ addl %eax, %ebx -+ call foo.isra.0.constprop.2 -+.LVL4: -+ leal 10(%rbx,%rax), %eax -+ /* gdb.arch/amd64-entry-value-param.c:34 */ -+ .loc 1 34 0 -+ popq %rbx -+.LCFI1: -+ .cfi_def_cfa_offset 8 -+/* SUCC: EXIT [100.0%] */ -+ ret -+ .cfi_endproc -+.LFE5: -+ .size bar.constprop.1, .-bar.constprop.1 -+ .section .text.startup,"ax",@progbits -+ .p2align 4,,15 -+ .globl main -+ .type main, @function -+main: -+.LFB2: -+ /* gdb.arch/amd64-entry-value-param.c:38 */ -+ .loc 1 38 0 -+ .cfi_startproc -+/* BLOCK 2 freq:10000 seq:0 */ -+/* PRED: ENTRY [100.0%] (fallthru) */ -+ /* gdb.arch/amd64-entry-value-param.c:39 */ -+ .loc 1 39 0 -+ jmp bar.constprop.1 -+/* SUCC: EXIT [100.0%] (ab,sibcall) */ -+.LVL5: -+ .cfi_endproc -+.LFE2: -+ .size main, .-main -+ .comm vv,4,4 -+ .text -+.Letext0: -+ .section .debug_info,"",@progbits -+.Ldebug_info0: -+ .4byte 0x1b7 /* Length of Compilation Unit Info */ -+ .2byte 0x2 /* DWARF version number */ -+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ -+ .byte 0x8 /* Pointer Size (in bytes) */ -+ .uleb128 0x1 /* (DIE (0xb) DW_TAG_compile_unit) */ -+ .4byte .LASF0 /* DW_AT_producer: "GNU C 4.7.1 20120612 (prerelease)" */ -+ .byte 0x1 /* DW_AT_language */ -+ .4byte .LASF1 /* DW_AT_name: "gdb.arch/amd64-entry-value-param.c" */ -+ .4byte .LASF2 /* DW_AT_comp_dir: "" */ -+ .4byte .Ldebug_ranges0+0 /* DW_AT_ranges */ -+ .quad 0 /* DW_AT_low_pc */ -+ .quad 0 /* DW_AT_entry_pc */ -+ .4byte .Ldebug_line0 /* DW_AT_stmt_list */ -+ .uleb128 0x2 /* (DIE (0x31) DW_TAG_subprogram) */ -+ .ascii "foo\0" /* DW_AT_name */ -+ .byte 0x1 /* DW_AT_decl_file (gdb.arch/amd64-entry-value-param.c) */ -+ .byte 0x15 /* DW_AT_decl_line */ -+ .byte 0x1 /* DW_AT_prototyped */ -+ .4byte 0x79 /* DW_AT_type */ -+ .byte 0 /* DW_AT_inline */ -+ .4byte 0x79 /* DW_AT_sibling */ -+ .uleb128 0x3 /* (DIE (0x42) DW_TAG_formal_parameter) */ -+ .ascii "x\0" /* DW_AT_name */ -+ .byte 0x1 /* DW_AT_decl_file (gdb.arch/amd64-entry-value-param.c) */ -+ .byte 0x15 /* DW_AT_decl_line */ -+ .4byte 0x79 /* DW_AT_type */ -+ .uleb128 0x3 /* (DIE (0x4b) DW_TAG_formal_parameter) */ -+ .ascii "y\0" /* DW_AT_name */ -+ .byte 0x1 /* DW_AT_decl_file (gdb.arch/amd64-entry-value-param.c) */ -+ .byte 0x15 /* DW_AT_decl_line */ -+ .4byte 0x79 /* DW_AT_type */ -+ .uleb128 0x3 /* (DIE (0x54) DW_TAG_formal_parameter) */ -+ .ascii "z\0" /* DW_AT_name */ -+ .byte 0x1 /* DW_AT_decl_file (gdb.arch/amd64-entry-value-param.c) */ -+ .byte 0x15 /* DW_AT_decl_line */ -+ .4byte 0x79 /* DW_AT_type */ -+ .uleb128 0x4 /* (DIE (0x5d) DW_TAG_variable) */ -+ .ascii "a\0" /* DW_AT_name */ -+ .byte 0x1 /* DW_AT_decl_file (gdb.arch/amd64-entry-value-param.c) */ -+ .byte 0x17 /* DW_AT_decl_line */ -+ .4byte 0x79 /* DW_AT_type */ -+ .uleb128 0x4 /* (DIE (0x66) DW_TAG_variable) */ -+ .ascii "b\0" /* DW_AT_name */ -+ .byte 0x1 /* DW_AT_decl_file (gdb.arch/amd64-entry-value-param.c) */ -+ .byte 0x18 /* DW_AT_decl_line */ -+ .4byte 0x79 /* DW_AT_type */ -+ .uleb128 0x4 /* (DIE (0x6f) DW_TAG_variable) */ -+ .ascii "c\0" /* DW_AT_name */ -+ .byte 0x1 /* DW_AT_decl_file (gdb.arch/amd64-entry-value-param.c) */ -+ .byte 0x19 /* DW_AT_decl_line */ -+ .4byte 0x79 /* DW_AT_type */ -+ .byte 0 /* end of children of DIE 0x31 */ -+ .uleb128 0x5 /* (DIE (0x79) DW_TAG_base_type) */ -+ .byte 0x4 /* DW_AT_byte_size */ -+ .byte 0x5 /* DW_AT_encoding */ -+ .ascii "int\0" /* DW_AT_name */ -+ .uleb128 0x2 /* (DIE (0x80) DW_TAG_subprogram) */ -+ .ascii "bar\0" /* DW_AT_name */ -+ .byte 0x1 /* DW_AT_decl_file (gdb.arch/amd64-entry-value-param.c) */ -+ .byte 0x1f /* DW_AT_decl_line */ -+ .byte 0x1 /* DW_AT_prototyped */ -+ .4byte 0x79 /* DW_AT_type */ -+ .byte 0x1 /* DW_AT_inline */ -+ .4byte 0x9b /* DW_AT_sibling */ -+ .uleb128 0x3 /* (DIE (0x91) DW_TAG_formal_parameter) */ -+ .ascii "x\0" /* DW_AT_name */ -+ .byte 0x1 /* DW_AT_decl_file (gdb.arch/amd64-entry-value-param.c) */ -+ .byte 0x1f /* DW_AT_decl_line */ -+ .4byte 0x79 /* DW_AT_type */ -+ .byte 0 /* end of children of DIE 0x80 */ -+ .uleb128 0x6 /* (DIE (0x9b) DW_TAG_subprogram) */ -+ .4byte 0x31 /* DW_AT_abstract_origin */ -+ .quad .LFB4 /* DW_AT_low_pc */ -+ .quad .LFE4 /* DW_AT_high_pc */ -+ .byte 0x2 /* DW_AT_frame_base */ -+ .byte 0x77 /* DW_OP_breg7 */ -+ .sleb128 8 -+ .byte 0x1 /* DW_AT_GNU_all_call_sites */ -+ .4byte 0xf1 /* DW_AT_sibling */ -+ .uleb128 0x7 /* (DIE (0xb8) DW_TAG_formal_parameter) */ -+ .4byte 0x42 /* DW_AT_abstract_origin */ -+ .byte 0x1 /* DW_AT_location */ -+ .byte 0x55 /* DW_OP_reg5 */ -+ .uleb128 0x7 /* (DIE (0xbf) DW_TAG_formal_parameter) */ -+ .4byte 0x4b /* DW_AT_abstract_origin */ -+ .byte 0x6 /* DW_AT_location */ -+ .byte 0xfa /* DW_OP_GNU_parameter_ref */ -+ .4byte 0x4b -+ .byte 0x9f /* DW_OP_stack_value */ -+ .uleb128 0x8 /* (DIE (0xcb) DW_TAG_variable) */ -+ .4byte 0x5d /* DW_AT_abstract_origin */ -+ .byte 0x5 /* DW_AT_location */ -+ .byte 0x75 /* DW_OP_breg5 */ -+ .sleb128 0 -+ .byte 0x31 /* DW_OP_lit1 */ -+ .byte 0x24 /* DW_OP_shl */ -+ .byte 0x9f /* DW_OP_stack_value */ -+ .uleb128 0x8 /* (DIE (0xd6) DW_TAG_variable) */ -+ .4byte 0x66 /* DW_AT_abstract_origin */ -+ .byte 0x8 /* DW_AT_location */ -+ .byte 0xfa /* DW_OP_GNU_parameter_ref */ -+ .4byte 0x4b -+ .byte 0x31 /* DW_OP_lit1 */ -+ .byte 0x24 /* DW_OP_shl */ -+ .byte 0x9f /* DW_OP_stack_value */ -+ .uleb128 0x9 /* (DIE (0xe4) DW_TAG_variable) */ -+ .4byte 0x6f /* DW_AT_abstract_origin */ -+ .byte 0x6 /* DW_AT_const_value */ -+ .uleb128 0xa /* (DIE (0xea) DW_TAG_formal_parameter) */ -+ .4byte 0x54 /* DW_AT_abstract_origin */ -+ .byte 0x3 /* DW_AT_const_value */ -+ .byte 0 /* end of children of DIE 0x9b */ -+ .uleb128 0xb /* (DIE (0xf1) DW_TAG_subprogram) */ -+ .4byte 0x80 /* DW_AT_abstract_origin */ -+ .quad .LFB5 /* DW_AT_low_pc */ -+ .quad .LFE5 /* DW_AT_high_pc */ -+ .4byte .LLST0 /* DW_AT_frame_base */ -+ .byte 0x1 /* DW_AT_GNU_all_call_sites */ -+ .4byte 0x16c /* DW_AT_sibling */ -+ .uleb128 0xa /* (DIE (0x10f) DW_TAG_formal_parameter) */ -+ .4byte 0x91 /* DW_AT_abstract_origin */ -+ .byte 0xa /* DW_AT_const_value */ -+ .uleb128 0xc /* (DIE (0x115) DW_TAG_GNU_call_site) */ -+ .quad .LVL2 /* DW_AT_low_pc */ -+ .4byte 0x9b /* DW_AT_abstract_origin */ -+ .4byte 0x133 /* DW_AT_sibling */ -+ .uleb128 0xd /* (DIE (0x126) DW_TAG_GNU_call_site_parameter) */ -+ .byte 0x1 /* DW_AT_location */ -+ .byte 0x55 /* DW_OP_reg5 */ -+ .byte 0x1 /* DW_AT_GNU_call_site_value */ -+ .byte 0x3a /* DW_OP_lit10 */ -+ .uleb128 0xe /* (DIE (0x12b) DW_TAG_GNU_call_site_parameter) */ -+ .4byte 0x4b /* DW_AT_abstract_origin */ -+ .byte 0x1 /* DW_AT_GNU_call_site_value */ -+ .byte 0x32 /* DW_OP_lit2 */ -+ .byte 0 /* end of children of DIE 0x115 */ -+ .uleb128 0xc /* (DIE (0x133) DW_TAG_GNU_call_site) */ -+ .quad .LVL3 /* DW_AT_low_pc */ -+ .4byte 0x9b /* DW_AT_abstract_origin */ -+ .4byte 0x151 /* DW_AT_sibling */ -+ .uleb128 0xd /* (DIE (0x144) DW_TAG_GNU_call_site_parameter) */ -+ .byte 0x1 /* DW_AT_location */ -+ .byte 0x55 /* DW_OP_reg5 */ -+ .byte 0x1 /* DW_AT_GNU_call_site_value */ -+ .byte 0x3a /* DW_OP_lit10 */ -+ .uleb128 0xe /* (DIE (0x149) DW_TAG_GNU_call_site_parameter) */ -+ .4byte 0x4b /* DW_AT_abstract_origin */ -+ .byte 0x1 /* DW_AT_GNU_call_site_value */ -+ .byte 0x34 /* DW_OP_lit4 */ -+ .byte 0 /* end of children of DIE 0x133 */ -+ .uleb128 0xf /* (DIE (0x151) DW_TAG_GNU_call_site) */ -+ .quad .LVL4 /* DW_AT_low_pc */ -+ .4byte 0x9b /* DW_AT_abstract_origin */ -+ .uleb128 0xd /* (DIE (0x15e) DW_TAG_GNU_call_site_parameter) */ -+ .byte 0x1 /* DW_AT_location */ -+ .byte 0x55 /* DW_OP_reg5 */ -+ .byte 0x1 /* DW_AT_GNU_call_site_value */ -+ .byte 0x40 /* DW_OP_lit16 */ -+ .uleb128 0xe /* (DIE (0x163) DW_TAG_GNU_call_site_parameter) */ -+ .4byte 0x4b /* DW_AT_abstract_origin */ -+ .byte 0x1 /* DW_AT_GNU_call_site_value */ -+ .byte 0x3a /* DW_OP_lit10 */ -+ .byte 0 /* end of children of DIE 0x151 */ -+ .byte 0 /* end of children of DIE 0xf1 */ -+ .uleb128 0x10 /* (DIE (0x16c) DW_TAG_subprogram) */ -+ .byte 0x1 /* DW_AT_external */ -+ .4byte .LASF3 /* DW_AT_name: "main" */ -+ .byte 0x1 /* DW_AT_decl_file (gdb.arch/amd64-entry-value-param.c) */ -+ .byte 0x25 /* DW_AT_decl_line */ -+ .byte 0x1 /* DW_AT_prototyped */ -+ .4byte 0x79 /* DW_AT_type */ -+ .quad .LFB2 /* DW_AT_low_pc */ -+ .quad .LFE2 /* DW_AT_high_pc */ -+ .byte 0x2 /* DW_AT_frame_base */ -+ .byte 0x77 /* DW_OP_breg7 */ -+ .sleb128 8 -+ .byte 0x1 /* DW_AT_GNU_all_call_sites */ -+ .4byte 0x1a0 /* DW_AT_sibling */ -+ .uleb128 0x11 /* (DIE (0x191) DW_TAG_GNU_call_site) */ -+ .quad .LVL5 /* DW_AT_low_pc */ -+ .byte 0x1 /* DW_AT_GNU_tail_call */ -+ .4byte 0xf1 /* DW_AT_abstract_origin */ -+ .byte 0 /* end of children of DIE 0x16c */ -+ .uleb128 0x12 /* (DIE (0x1a0) DW_TAG_variable) */ -+ .ascii "vv\0" /* DW_AT_name */ -+ .byte 0x1 /* DW_AT_decl_file (gdb.arch/amd64-entry-value-param.c) */ -+ .byte 0x12 /* DW_AT_decl_line */ -+ .4byte 0x1b5 /* DW_AT_type */ -+ .byte 0x1 /* DW_AT_external */ -+ .byte 0x9 /* DW_AT_location */ -+ .byte 0x3 /* DW_OP_addr */ -+ .quad vv -+ .uleb128 0x13 /* (DIE (0x1b5) DW_TAG_volatile_type) */ -+ .4byte 0x79 /* DW_AT_type */ -+ .byte 0 /* end of children of DIE 0xb */ -+ .section .debug_abbrev,"",@progbits -+.Ldebug_abbrev0: -+ .uleb128 0x1 /* (abbrev code) */ -+ .uleb128 0x11 /* (TAG: DW_TAG_compile_unit) */ -+ .byte 0x1 /* DW_children_yes */ -+ .uleb128 0x25 /* (DW_AT_producer) */ -+ .uleb128 0xe /* (DW_FORM_strp) */ -+ .uleb128 0x13 /* (DW_AT_language) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x3 /* (DW_AT_name) */ -+ .uleb128 0xe /* (DW_FORM_strp) */ -+ .uleb128 0x1b /* (DW_AT_comp_dir) */ -+ .uleb128 0xe /* (DW_FORM_strp) */ -+ .uleb128 0x55 /* (DW_AT_ranges) */ -+ .uleb128 0x6 /* (DW_FORM_data4) */ -+ .uleb128 0x11 /* (DW_AT_low_pc) */ -+ .uleb128 0x1 /* (DW_FORM_addr) */ -+ .uleb128 0x52 /* (DW_AT_entry_pc) */ -+ .uleb128 0x1 /* (DW_FORM_addr) */ -+ .uleb128 0x10 /* (DW_AT_stmt_list) */ -+ .uleb128 0x6 /* (DW_FORM_data4) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0x2 /* (abbrev code) */ -+ .uleb128 0x2e /* (TAG: DW_TAG_subprogram) */ -+ .byte 0x1 /* DW_children_yes */ -+ .uleb128 0x3 /* (DW_AT_name) */ -+ .uleb128 0x8 /* (DW_FORM_string) */ -+ .uleb128 0x3a /* (DW_AT_decl_file) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x3b /* (DW_AT_decl_line) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x27 /* (DW_AT_prototyped) */ -+ .uleb128 0xc /* (DW_FORM_flag) */ -+ .uleb128 0x49 /* (DW_AT_type) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .uleb128 0x20 /* (DW_AT_inline) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x1 /* (DW_AT_sibling) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0x3 /* (abbrev code) */ -+ .uleb128 0x5 /* (TAG: DW_TAG_formal_parameter) */ -+ .byte 0 /* DW_children_no */ -+ .uleb128 0x3 /* (DW_AT_name) */ -+ .uleb128 0x8 /* (DW_FORM_string) */ -+ .uleb128 0x3a /* (DW_AT_decl_file) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x3b /* (DW_AT_decl_line) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x49 /* (DW_AT_type) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0x4 /* (abbrev code) */ -+ .uleb128 0x34 /* (TAG: DW_TAG_variable) */ -+ .byte 0 /* DW_children_no */ -+ .uleb128 0x3 /* (DW_AT_name) */ -+ .uleb128 0x8 /* (DW_FORM_string) */ -+ .uleb128 0x3a /* (DW_AT_decl_file) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x3b /* (DW_AT_decl_line) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x49 /* (DW_AT_type) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0x5 /* (abbrev code) */ -+ .uleb128 0x24 /* (TAG: DW_TAG_base_type) */ -+ .byte 0 /* DW_children_no */ -+ .uleb128 0xb /* (DW_AT_byte_size) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x3e /* (DW_AT_encoding) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x3 /* (DW_AT_name) */ -+ .uleb128 0x8 /* (DW_FORM_string) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0x6 /* (abbrev code) */ -+ .uleb128 0x2e /* (TAG: DW_TAG_subprogram) */ -+ .byte 0x1 /* DW_children_yes */ -+ .uleb128 0x31 /* (DW_AT_abstract_origin) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .uleb128 0x11 /* (DW_AT_low_pc) */ -+ .uleb128 0x1 /* (DW_FORM_addr) */ -+ .uleb128 0x12 /* (DW_AT_high_pc) */ -+ .uleb128 0x1 /* (DW_FORM_addr) */ -+ .uleb128 0x40 /* (DW_AT_frame_base) */ -+ .uleb128 0xa /* (DW_FORM_block1) */ -+ .uleb128 0x2117 /* (DW_AT_GNU_all_call_sites) */ -+ .uleb128 0xc /* (DW_FORM_flag) */ -+ .uleb128 0x1 /* (DW_AT_sibling) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0x7 /* (abbrev code) */ -+ .uleb128 0x5 /* (TAG: DW_TAG_formal_parameter) */ -+ .byte 0 /* DW_children_no */ -+ .uleb128 0x31 /* (DW_AT_abstract_origin) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .uleb128 0x2 /* (DW_AT_location) */ -+ .uleb128 0xa /* (DW_FORM_block1) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0x8 /* (abbrev code) */ -+ .uleb128 0x34 /* (TAG: DW_TAG_variable) */ -+ .byte 0 /* DW_children_no */ -+ .uleb128 0x31 /* (DW_AT_abstract_origin) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .uleb128 0x2 /* (DW_AT_location) */ -+ .uleb128 0xa /* (DW_FORM_block1) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0x9 /* (abbrev code) */ -+ .uleb128 0x34 /* (TAG: DW_TAG_variable) */ -+ .byte 0 /* DW_children_no */ -+ .uleb128 0x31 /* (DW_AT_abstract_origin) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .uleb128 0x1c /* (DW_AT_const_value) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0xa /* (abbrev code) */ -+ .uleb128 0x5 /* (TAG: DW_TAG_formal_parameter) */ -+ .byte 0 /* DW_children_no */ -+ .uleb128 0x31 /* (DW_AT_abstract_origin) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .uleb128 0x1c /* (DW_AT_const_value) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0xb /* (abbrev code) */ -+ .uleb128 0x2e /* (TAG: DW_TAG_subprogram) */ -+ .byte 0x1 /* DW_children_yes */ -+ .uleb128 0x31 /* (DW_AT_abstract_origin) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .uleb128 0x11 /* (DW_AT_low_pc) */ -+ .uleb128 0x1 /* (DW_FORM_addr) */ -+ .uleb128 0x12 /* (DW_AT_high_pc) */ -+ .uleb128 0x1 /* (DW_FORM_addr) */ -+ .uleb128 0x40 /* (DW_AT_frame_base) */ -+ .uleb128 0x6 /* (DW_FORM_data4) */ -+ .uleb128 0x2117 /* (DW_AT_GNU_all_call_sites) */ -+ .uleb128 0xc /* (DW_FORM_flag) */ -+ .uleb128 0x1 /* (DW_AT_sibling) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0xc /* (abbrev code) */ -+ .uleb128 0x4109 /* (TAG: DW_TAG_GNU_call_site) */ -+ .byte 0x1 /* DW_children_yes */ -+ .uleb128 0x11 /* (DW_AT_low_pc) */ -+ .uleb128 0x1 /* (DW_FORM_addr) */ -+ .uleb128 0x31 /* (DW_AT_abstract_origin) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .uleb128 0x1 /* (DW_AT_sibling) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0xd /* (abbrev code) */ -+ .uleb128 0x410a /* (TAG: DW_TAG_GNU_call_site_parameter) */ -+ .byte 0 /* DW_children_no */ -+ .uleb128 0x2 /* (DW_AT_location) */ -+ .uleb128 0xa /* (DW_FORM_block1) */ -+ .uleb128 0x2111 /* (DW_AT_GNU_call_site_value) */ -+ .uleb128 0xa /* (DW_FORM_block1) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0xe /* (abbrev code) */ -+ .uleb128 0x410a /* (TAG: DW_TAG_GNU_call_site_parameter) */ -+ .byte 0 /* DW_children_no */ -+ .uleb128 0x31 /* (DW_AT_abstract_origin) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .uleb128 0x2111 /* (DW_AT_GNU_call_site_value) */ -+ .uleb128 0xa /* (DW_FORM_block1) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0xf /* (abbrev code) */ -+ .uleb128 0x4109 /* (TAG: DW_TAG_GNU_call_site) */ -+ .byte 0x1 /* DW_children_yes */ -+ .uleb128 0x11 /* (DW_AT_low_pc) */ -+ .uleb128 0x1 /* (DW_FORM_addr) */ -+ .uleb128 0x31 /* (DW_AT_abstract_origin) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0x10 /* (abbrev code) */ -+ .uleb128 0x2e /* (TAG: DW_TAG_subprogram) */ -+ .byte 0x1 /* DW_children_yes */ -+ .uleb128 0x3f /* (DW_AT_external) */ -+ .uleb128 0xc /* (DW_FORM_flag) */ -+ .uleb128 0x3 /* (DW_AT_name) */ -+ .uleb128 0xe /* (DW_FORM_strp) */ -+ .uleb128 0x3a /* (DW_AT_decl_file) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x3b /* (DW_AT_decl_line) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x27 /* (DW_AT_prototyped) */ -+ .uleb128 0xc /* (DW_FORM_flag) */ -+ .uleb128 0x49 /* (DW_AT_type) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .uleb128 0x11 /* (DW_AT_low_pc) */ -+ .uleb128 0x1 /* (DW_FORM_addr) */ -+ .uleb128 0x12 /* (DW_AT_high_pc) */ -+ .uleb128 0x1 /* (DW_FORM_addr) */ -+ .uleb128 0x40 /* (DW_AT_frame_base) */ -+ .uleb128 0xa /* (DW_FORM_block1) */ -+ .uleb128 0x2117 /* (DW_AT_GNU_all_call_sites) */ -+ .uleb128 0xc /* (DW_FORM_flag) */ -+ .uleb128 0x1 /* (DW_AT_sibling) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0x11 /* (abbrev code) */ -+ .uleb128 0x4109 /* (TAG: DW_TAG_GNU_call_site) */ -+ .byte 0 /* DW_children_no */ -+ .uleb128 0x11 /* (DW_AT_low_pc) */ -+ .uleb128 0x1 /* (DW_FORM_addr) */ -+ .uleb128 0x2115 /* (DW_AT_GNU_tail_call) */ -+ .uleb128 0xc /* (DW_FORM_flag) */ -+ .uleb128 0x31 /* (DW_AT_abstract_origin) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0x12 /* (abbrev code) */ -+ .uleb128 0x34 /* (TAG: DW_TAG_variable) */ -+ .byte 0 /* DW_children_no */ -+ .uleb128 0x3 /* (DW_AT_name) */ -+ .uleb128 0x8 /* (DW_FORM_string) */ -+ .uleb128 0x3a /* (DW_AT_decl_file) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x3b /* (DW_AT_decl_line) */ -+ .uleb128 0xb /* (DW_FORM_data1) */ -+ .uleb128 0x49 /* (DW_AT_type) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .uleb128 0x3f /* (DW_AT_external) */ -+ .uleb128 0xc /* (DW_FORM_flag) */ -+ .uleb128 0x2 /* (DW_AT_location) */ -+ .uleb128 0xa /* (DW_FORM_block1) */ -+ .byte 0 -+ .byte 0 -+ .uleb128 0x13 /* (abbrev code) */ -+ .uleb128 0x35 /* (TAG: DW_TAG_volatile_type) */ -+ .byte 0 /* DW_children_no */ -+ .uleb128 0x49 /* (DW_AT_type) */ -+ .uleb128 0x13 /* (DW_FORM_ref4) */ -+ .byte 0 -+ .byte 0 -+ .byte 0 -+ .section .debug_loc,"",@progbits -+.Ldebug_loc0: -+.LLST0: -+ .quad .LFB5 /* Location list begin address (*.LLST0) */ -+ .quad .LCFI0 /* Location list end address (*.LLST0) */ -+ .2byte 0x2 /* Location expression size */ -+ .byte 0x77 /* DW_OP_breg7 */ -+ .sleb128 8 -+ .quad .LCFI0 /* Location list begin address (*.LLST0) */ -+ .quad .LCFI1 /* Location list end address (*.LLST0) */ -+ .2byte 0x2 /* Location expression size */ -+ .byte 0x77 /* DW_OP_breg7 */ -+ .sleb128 16 -+ .quad .LCFI1 /* Location list begin address (*.LLST0) */ -+ .quad .LFE5 /* Location list end address (*.LLST0) */ -+ .2byte 0x2 /* Location expression size */ -+ .byte 0x77 /* DW_OP_breg7 */ -+ .sleb128 8 -+ .quad 0 /* Location list terminator begin (*.LLST0) */ -+ .quad 0 /* Location list terminator end (*.LLST0) */ -+ .section .debug_aranges,"",@progbits -+ .4byte 0x3c /* Length of Address Ranges Info */ -+ .2byte 0x2 /* DWARF Version */ -+ .4byte .Ldebug_info0 /* Offset of Compilation Unit Info */ -+ .byte 0x8 /* Size of Address */ -+ .byte 0 /* Size of Segment Descriptor */ -+ .2byte 0 /* Pad to 16 byte boundary */ -+ .2byte 0 -+ .quad .Ltext0 /* Address */ -+ .quad .Letext0-.Ltext0 /* Length */ -+ .quad .LFB2 /* Address */ -+ .quad .LFE2-.LFB2 /* Length */ -+ .quad 0 -+ .quad 0 -+ .section .debug_ranges,"",@progbits -+.Ldebug_ranges0: -+ .quad .Ltext0 /* Offset 0 */ -+ .quad .Letext0 -+ .quad .LFB2 /* Offset 0x10 */ -+ .quad .LFE2 -+ .quad 0 -+ .quad 0 -+ .section .debug_line,"",@progbits -+.Ldebug_line0: -+ .section .debug_str,"MS",@progbits,1 -+.LASF1: -+ .string "gdb.arch/amd64-entry-value-param.c" -+.LASF3: -+ .string "main" -+.LASF2: -+ .string "" -+.LASF0: -+ .string "GNU C 4.7.1 20120612 (prerelease)" -+ .ident "GCC: (GNU) 4.7.1 20120612 (prerelease)" -+ .section .note.GNU-stack,"",@progbits ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param.c -@@ -0,0 +1,40 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2012 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+volatile int vv; -+ -+static __attribute__((noinline)) int -+foo (int x, int y, int z) -+{ -+ int a = x * 2; -+ int b = y * 2; -+ int c = z * 2; -+ vv++; /* break-here */ -+ return x + z; -+} -+ -+static __attribute__((noinline)) int -+bar (int x) -+{ -+ return foo (x, 2, 3) + foo (x, 4, 3) + foo (x + 6, x, 3) + x; -+} -+ -+int -+main (void) -+{ -+ return bar (10); -+} ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp -@@ -0,0 +1,51 @@ -+# Copyright (C) 2012 Free Software Foundation, Inc. -+# -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+set testfile amd64-entry-value-param -+set srcfile ${testfile}.S -+set csrcfile ${testfile}.c -+set opts {} -+ -+if [info exists COMPILE] { -+ # make check RUNTESTFLAGS="gdb.arch/amd64-entry-value-param.exp COMPILE=1" -+ set srcfile ${csrcfile} -+ lappend opts debug optimize=-O2 -+} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } { -+ verbose "Skipping amd64-entry-value-param." -+ return -+} -+ -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $opts] } { -+ return -1 -+} -+ -+if ![runto_main] { -+ return -1 -+} -+ -+set srcfile $csrcfile -+gdb_breakpoint [gdb_get_line_number "break-here"] -+ -+gdb_continue_to_breakpoint "break-here" ".* break-here .*" -+gdb_test "p y" " = 2" -+gdb_test "p b" " = 4" -+ -+gdb_continue_to_breakpoint "break-here" ".* break-here .*" -+gdb_test "p y" " = 4" -+gdb_test "p b" " = 8" -+ -+gdb_continue_to_breakpoint "break-here" ".* break-here .*" -+gdb_test "p y" " = 10" -+gdb_test "p b" " = 20" - diff --git a/gdb-rhel5-gcc44.patch b/gdb-rhel5-gcc44.patch index ccbb30a..241795a 100644 --- a/gdb-rhel5-gcc44.patch +++ b/gdb-rhel5-gcc44.patch @@ -1,10 +1,10 @@ Some functionality is available on RHEL-5.4+ only with gcc44 and gfortran44 as the default gcc and gfortran binaries are from gcc-4.1. -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.base/vla.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.base/vla.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/gdb.base/vla.exp 2011-12-18 23:35:23.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.base/vla.exp 2011-12-19 02:27:16.745327844 +0100 +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.base/vla.exp 2012-07-03 17:30:07.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.base/vla.exp 2012-07-03 17:50:57.999207540 +0200 @@ -16,7 +16,25 @@ set testfile vla set srcfile ${testfile}.c @@ -32,11 +32,11 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.base/vla.exp untested "Couldn't compile test program" return -1 } -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.base/break-interp.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.base/break-interp.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/gdb.base/break-interp.exp 2011-12-19 02:21:56.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.base/break-interp.exp 2011-12-19 02:27:16.745327844 +0100 -@@ -34,9 +34,29 @@ if [get_compiler_info ${binfile_lib}] { +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.base/break-interp.exp 2012-07-03 17:44:45.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.base/break-interp.exp 2012-07-03 17:50:58.000207539 +0200 +@@ -34,9 +34,29 @@ if [get_compiler_info] { return -1 } @@ -67,10 +67,10 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.base/break-interp.exp return -1 } -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/common-block.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/common-block.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/gdb.fortran/common-block.exp 2011-12-19 01:31:24.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/common-block.exp 2011-12-19 02:27:16.746327840 +0100 +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.fortran/common-block.exp 2012-07-03 17:36:21.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/common-block.exp 2012-07-03 17:50:58.001207537 +0200 @@ -20,7 +20,25 @@ set testfile "common-block" set srcfile ${testfile}.f90 set binfile ${objdir}/${subdir}/${testfile} @@ -98,10 +98,10 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/common-block.exp untested "Couldn't compile ${srcfile}" return -1 } -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/dwarf-stride.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/dwarf-stride.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/gdb.fortran/dwarf-stride.exp 2011-12-18 23:35:23.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/dwarf-stride.exp 2011-12-19 02:27:16.746327840 +0100 +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.fortran/dwarf-stride.exp 2012-07-03 17:30:07.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/dwarf-stride.exp 2012-07-03 17:50:58.002207535 +0200 @@ -27,7 +27,25 @@ set testfile dwarf-stride set srcfile ${testfile}.f90 @@ -129,10 +129,10 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/dwarf-stride.exp return -1 } -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/dynamic.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/dynamic.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/gdb.fortran/dynamic.exp 2011-12-18 23:35:23.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/dynamic.exp 2011-12-19 02:27:16.746327840 +0100 +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.fortran/dynamic.exp 2012-07-03 17:30:07.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/dynamic.exp 2012-07-03 17:50:58.002207535 +0200 @@ -25,7 +25,25 @@ set testfile "dynamic" set srcfile ${testfile}.f90 set binfile ${objdir}/${subdir}/${testfile} @@ -160,15 +160,15 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/dynamic.exp untested "Couldn't compile ${srcfile}" return -1 } -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/library-module.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/library-module.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/gdb.fortran/library-module.exp 2011-11-30 09:24:32.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/library-module.exp 2011-12-19 02:31:10.991318026 +0100 -@@ -25,16 +25,34 @@ if [get_compiler_info not-used] { +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.fortran/library-module.exp 2012-06-25 22:51:35.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/library-module.exp 2012-07-03 17:52:57.666062981 +0200 +@@ -23,16 +23,34 @@ if [get_compiler_info] { return -1 } --if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" $objdir/$subdir/$libfile {debug f90}] != "" } { +-if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" $libfile {debug f90}] != "" } { - untested "Couldn't compile ${srclibfile}" - return -1 +# Temporarily provide f90compiler=gfortran44 saving the original value around. @@ -186,9 +186,9 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/library-module.exp # just for the linking phase (and not the source compilation phase). And any # warnings on ignored $libfile abort the process. --if { [gdb_compile $srcdir/$subdir/$srcfile $objdir/$subdir/$binfile executable [list debug f90 shlib=$objdir/$subdir/$libfile]] != "" } { -+set err1 [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" $objdir/$subdir/$libfile {debug f90}] -+set err2 [gdb_compile $srcdir/$subdir/$srcfile $objdir/$subdir/$binfile executable [list debug f90 shlib=$objdir/$subdir/$libfile]] +-if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90 shlib=$libfile]] != "" } { ++set err1 [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" $libfile {debug f90}] ++set err2 [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90 shlib=$libfile]] + +unset_board_info f90compiler +if [info exists old_f90compiler] { @@ -203,13 +203,13 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/library-module.exp untested "Couldn't compile ${srcfile}" return -1 } -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/module.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/module.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/gdb.fortran/module.exp 2011-06-30 00:05:16.000000000 +0200 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/module.exp 2011-12-19 02:27:16.747327836 +0100 -@@ -16,7 +16,25 @@ - set testfile "module" - set srcfile ${testfile}.f90 +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.fortran/module.exp 2012-06-25 22:51:35.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/module.exp 2012-07-03 17:53:56.464992086 +0200 +@@ -15,7 +15,25 @@ + + standard_testfile .f90 -if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}] } { +# Temporarily provide f90compiler=gfortran44 saving the original value around. @@ -234,10 +234,10 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/module.exp return -1 } -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/string.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/string.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/gdb.fortran/string.exp 2011-12-18 23:35:23.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/string.exp 2011-12-19 02:27:16.747327836 +0100 +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.fortran/string.exp 2012-07-03 17:30:07.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/string.exp 2012-07-03 17:50:58.005207532 +0200 @@ -23,7 +23,25 @@ set testfile "string" set srcfile ${testfile}.f90 set binfile ${objdir}/${subdir}/${testfile} @@ -265,10 +265,10 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/string.exp untested "Couldn't compile ${srcfile}" return -1 } -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/omp-step.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/omp-step.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/gdb.fortran/omp-step.exp 2011-12-19 01:31:24.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/omp-step.exp 2011-12-19 02:27:16.748327832 +0100 +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.fortran/omp-step.exp 2012-07-03 17:36:21.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/omp-step.exp 2012-07-03 17:50:58.006207531 +0200 @@ -15,7 +15,26 @@ set testfile "omp-step" @@ -297,16 +297,15 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/omp-step.exp return -1 } -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/derived-type.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/derived-type.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/gdb.fortran/derived-type.exp 2011-06-29 19:50:47.000000000 +0200 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/derived-type.exp 2011-12-19 02:27:16.748327832 +0100 -@@ -28,8 +28,26 @@ set testfile "derived-type" - set srcfile ${testfile}.f90 - set binfile ${objdir}/${subdir}/${testfile} +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.fortran/derived-type.exp 2012-06-25 22:51:35.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/derived-type.exp 2012-07-03 17:55:46.583858849 +0200 +@@ -22,7 +22,25 @@ if { [skip_fortran_tests] } { return -1 --if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ -- executable {debug f90}] != ""} { + standard_testfile .f90 + +-if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} { +# Temporarily provide f90compiler=gfortran44 saving the original value around. + +set board [target_info name] @@ -318,28 +317,26 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/derived-type.exp +} +set_board_info f90compiler gfortran44 + -+set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ -+ executable {debug f90}] ++set err [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}] + +unset_board_info f90compiler +if [info exists old_f90compiler] { + set_board_info f90compiler $old_f90compiler +} + -+if { $err != "" } { ++if $err { return -1 } -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/subarray.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/subarray.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/gdb.fortran/subarray.exp 2011-06-29 19:50:47.000000000 +0200 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/subarray.exp 2011-12-19 02:27:16.748327832 +0100 -@@ -28,8 +28,26 @@ set testfile "subarray" - set srcfile ${testfile}.f - set binfile ${objdir}/${subdir}/${testfile} +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.fortran/subarray.exp 2012-06-25 22:51:35.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.fortran/subarray.exp 2012-07-03 17:56:20.454818198 +0200 +@@ -22,7 +22,25 @@ if { [skip_fortran_tests] } { return -1 --if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ -- executable {debug f90}] != ""} { + standard_testfile .f + +-if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} { +# Temporarily provide f90compiler=gfortran44 saving the original value around. + +set board [target_info name] @@ -351,22 +348,21 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.fortran/subarray.exp +} +set_board_info f90compiler gfortran44 + -+set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ -+ executable {debug f90}] ++set err [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}] + +unset_board_info f90compiler +if [info exists old_f90compiler] { + set_board_info f90compiler $old_f90compiler +} + -+if { $err != "" } { ++if $err { return -1 } -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/tls-sepdebug.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/tls-sepdebug.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/gdb.threads/tls-sepdebug.exp 2011-12-19 00:28:11.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/tls-sepdebug.exp 2011-12-19 02:27:16.748327832 +0100 +--- gdb-7.4.50.20120703.orig/gdb/testsuite/gdb.threads/tls-sepdebug.exp 2012-07-03 17:32:05.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/tls-sepdebug.exp 2012-07-03 17:50:58.007207530 +0200 @@ -32,7 +32,25 @@ set binshareddebugfile ${objdir}/${subdi # FIXME: gcc dependency (-Wl,-soname). @@ -394,10 +390,10 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/tls-sepdebug.exp untested "Couldn't compile test library" return -1 } -Index: gdb-7.4.50.20111218/gdb/testsuite/lib/prelink-support.exp +Index: gdb-7.4.50.20120703/gdb/testsuite/lib/prelink-support.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/lib/prelink-support.exp 2011-12-19 02:21:56.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/testsuite/lib/prelink-support.exp 2011-12-19 02:27:16.749327828 +0100 +--- gdb-7.4.50.20120703.orig/gdb/testsuite/lib/prelink-support.exp 2012-07-03 17:44:45.000000000 +0200 ++++ gdb-7.4.50.20120703/gdb/testsuite/lib/prelink-support.exp 2012-07-03 17:50:58.008207529 +0200 @@ -119,9 +119,31 @@ proc file_copy {src dest} { proc build_executable_own_libs {testname executable sources options {interp ""} {dir ""}} { global objdir subdir diff --git a/gdb-upstream.patch b/gdb-upstream.patch index 64ee72e..e69de29 100644 --- a/gdb-upstream.patch +++ b/gdb-upstream.patch @@ -1,293 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-06/msg00065.html -Subject: [commit 1/2] testsuite: code_elim.exp: unique names - -Hi, - -this is just removal of non-unique test names and one small simplification. - -Checked in. - - -Thanks, -Jan - - -http://sourceware.org/ml/gdb-cvs/2012-06/msg00011.html - -### src/gdb/testsuite/ChangeLog 2012/05/28 20:37:29 1.3209 -### src/gdb/testsuite/ChangeLog 2012/06/03 17:06:04 1.3210 -## -1,3 +1,16 @@ -+2012-06-03 Jan Kratochvil -+ -+ * gdb.base/code_elim.exp (add-symbol-file ${testfile1} 0x100000): -+ Simplify it to ... -+ (symbol-file ${testfile1}): ... here. -+ (test eliminated var my_global_symbol) -+ (test eliminated var my_static_symbol) -+ (test eliminated var my_global_func, get address of main): Wrap them to -+ 'single psymtabs' and 'single symtabs' -+ (get address of my_global_symbol, get address of my_static_symbol) -+ (get address of my_global_func, get address of main): Wrap them to -+ 'order1' and 'order2'. -+ - 2012-05-28 Jan Kratochvil - - * gdb.server/solib-list-lib.c: New file. ---- src/gdb/testsuite/gdb.base/code_elim.exp 2012/01/16 16:21:44 1.4 -+++ src/gdb/testsuite/gdb.base/code_elim.exp 2012/06/03 17:06:04 1.5 -@@ -95,16 +95,16 @@ - gdb_exit - gdb_start - --gdb_test "add-symbol-file ${binfile1} 0x100000" \ -+gdb_test "symbol-file ${binfile1}" \ - "Reading symbols from .*${testfile1}\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \ -- "add-symbol-file ${testfile1} 0x100000" \ -- "add symbol table from file \".*${testfile1}\" at\[ \t\r\n\]+\.text_addr = 0x100000\[\r\n\]+\\(y or n\\) " \ -- "y" -+ "symbol-file ${testfile1}" - --test_eliminated_var my_global_symbol --test_eliminated_var my_static_symbol --test_eliminated_var my_global_func --not_null_var_address main -+with_test_prefix "single psymtabs" { -+ test_eliminated_var my_global_symbol -+ test_eliminated_var my_static_symbol -+ test_eliminated_var my_global_func -+ not_null_var_address main -+} - - # Same thing for symtabs - -@@ -115,10 +115,12 @@ - gdb_start - set GDBFLAGS $saved_gdbflags - --test_eliminated_var my_global_symbol --test_eliminated_var my_static_symbol --test_eliminated_var my_global_func --not_null_var_address main -+with_test_prefix "single symtabs" { -+ test_eliminated_var my_global_symbol -+ test_eliminated_var my_static_symbol -+ test_eliminated_var my_global_func -+ not_null_var_address main -+} - - # binfile2 contains the symbols that have been eliminated in binfile1. Check - # the eliminated symbols does not hide these valid ones. -@@ -138,10 +140,12 @@ - "add symbol table from file \".*${testfile2}\" at\[ \t\r\n\]+\.text_addr = 0x200000\[\r\n\]+\\(y or n\\) " \ - "y" - --not_null_var_address my_global_symbol --not_null_var_address my_static_symbol --not_null_var_address my_global_func --not_null_var_address main -+with_test_prefix "order1" { -+ not_null_var_address my_global_symbol -+ not_null_var_address my_static_symbol -+ not_null_var_address my_global_func -+ not_null_var_address main -+} - - # Same thing, but loading binfile2 before binfile1. - -@@ -160,9 +164,9 @@ - "add symbol table from file \".*${testfile1}\" at\[ \t\r\n\]+\.text_addr = 0x100000\[\r\n\]+\\(y or n\\) " \ - "y" - --not_null_var_address my_global_symbol --not_null_var_address my_static_symbol --not_null_var_address my_global_func --not_null_var_address main -- -- -+with_test_prefix "order2" { -+ not_null_var_address my_global_symbol -+ not_null_var_address my_static_symbol -+ not_null_var_address my_global_func -+ not_null_var_address main -+} - - - -http://sourceware.org/ml/gdb-patches/2012-06/msg00066.html -Subject: [commit 2/2] testsuite: code_elim.exp: Fix false FAIL - -Hi, - -with Fedora 18 x86_64 (Rawhide) there is a false FAIl since: -2167931cf70f91206efb8b01e848a55d82a347ce is the first bad commit -Author: Tom Tromey -Date: Fri May 18 15:31:39 2012 +0000 -http://sourceware.org/bugzilla/show_bug.cgi?id=13907 - - print &my_global_symbol --$1 = (int *) 0x804a004 --(gdb) PASS: gdb.base/code_elim.exp: get address of my_global_symbol -+$1 = (int *) 0x804a004 -+(gdb) FAIL: gdb.base/code_elim.exp: get address of my_global_symbol - -Nothing really changed, just GDB now prints and the testcase -expects either none or suffix. - -This is because the two symbol files (their sections .data/.bss) have -overlapped so GDB chooses randomly which symbol to display. And since -Fedora 18 GCC puts there that "completed.5732" symbol. - -This may be because add-symbol-file FILE ADDR relocates to ADDR on the .text -section and leaves other sections at their original place, which is IMO a bit -unexpected; it is a FAQ people expect more ADDR to be relocation displacement -(and not relative to .text and not limited to .text). But this is really -outside of the scope of this testcase false FAIL. - -Checked in. - - -Thanks, -Jan - - -http://sourceware.org/ml/gdb-cvs/2012-06/msg00012.html - -### src/gdb/testsuite/ChangeLog 2012/06/03 17:06:04 1.3210 -### src/gdb/testsuite/ChangeLog 2012/06/03 17:10:28 1.3211 -## -11,6 +11,16 @@ - (get address of my_global_func, get address of main): Wrap them to - 'order1' and 'order2'. - -+ * gdb.base/code_elim.exp -+ (add-symbol-file ${testfile1} 0x100000) -+ (add-symbol-file ${testfile2} 0x200000): Wrap them to 'order1' and -+ 'order2'. -+ (order1: add-symbol-file ${testfile1} 0x100000) -+ (order1: add-symbol-file ${testfile2} 0x200000) -+ (order2: add-symbol-file ${testfile2} 0x200000) -+ (order2: add-symbol-file ${testfile1} 0x100000): Add -s .data and -s -+ .bss as appropriate. -+ - 2012-05-28 Jan Kratochvil - - * gdb.server/solib-list-lib.c: New file. ---- src/gdb/testsuite/gdb.base/code_elim.exp 2012/06/03 17:06:04 1.5 -+++ src/gdb/testsuite/gdb.base/code_elim.exp 2012/06/03 17:10:28 1.6 -@@ -128,19 +128,19 @@ - gdb_exit - gdb_start - --gdb_test "add-symbol-file ${binfile1} 0x100000" \ -- "Reading symbols from .*${testfile1}\\.\\.\\.done\\." \ -- "add-symbol-file ${testfile1} 0x100000" \ -- "add symbol table from file \".*${testfile1}\" at\[ \t\r\n\]+\.text_addr = 0x100000\[\r\n\]+\\(y or n\\) " \ -- "y" -- --gdb_test "add-symbol-file ${binfile2} 0x200000" \ -- "Reading symbols from .*${testfile2}\\.\\.\\.done\\." \ -- "add-symbol-file ${testfile2} 0x200000" \ -- "add symbol table from file \".*${testfile2}\" at\[ \t\r\n\]+\.text_addr = 0x200000\[\r\n\]+\\(y or n\\) " \ -- "y" -- - with_test_prefix "order1" { -+ gdb_test "add-symbol-file ${binfile1} 0x100000 -s .bss 0x120000" \ -+ "Reading symbols from .*${testfile1}\\.\\.\\.done\\." \ -+ "add-symbol-file ${testfile1} 0x100000" \ -+ "add symbol table from file \".*${testfile1}\" at.*\\(y or n\\) " \ -+ "y" -+ -+ gdb_test "add-symbol-file ${binfile2} 0x200000 -s .data 0x210000 -s .bss 0x220000" \ -+ "Reading symbols from .*${testfile2}\\.\\.\\.done\\." \ -+ "add-symbol-file ${testfile2} 0x200000" \ -+ "add symbol table from file \".*${testfile2}\" at.*\\(y or n\\) " \ -+ "y" -+ - not_null_var_address my_global_symbol - not_null_var_address my_static_symbol - not_null_var_address my_global_func -@@ -152,19 +152,19 @@ - gdb_exit - gdb_start - --gdb_test "add-symbol-file ${binfile2} 0x200000" \ -- "Reading symbols from .*${testfile2}\\.\\.\\.done\\." \ -- "add-symbol-file ${testfile2} 0x200000" \ -- "add symbol table from file \".*${testfile2}\" at\[ \t\r\n\]+\.text_addr = 0x200000\[\r\n\]+\\(y or n\\) " \ -- "y" -- --gdb_test "add-symbol-file ${binfile1} 0x100000" \ -- "Reading symbols from .*${testfile1}\\.\\.\\.done\\." \ -- "add-symbol-file ${testfile1} 0x100000" \ -- "add symbol table from file \".*${testfile1}\" at\[ \t\r\n\]+\.text_addr = 0x100000\[\r\n\]+\\(y or n\\) " \ -- "y" -- - with_test_prefix "order2" { -+ gdb_test "add-symbol-file ${binfile2} 0x200000 -s .data 0x210000 -s .bss 0x220000" \ -+ "Reading symbols from .*${testfile2}\\.\\.\\.done\\." \ -+ "add-symbol-file ${testfile2} 0x200000" \ -+ "add symbol table from file \".*${testfile2}\" at.*\\(y or n\\) " \ -+ "y" -+ -+ gdb_test "add-symbol-file ${binfile1} 0x100000 -s .bss 0x120000" \ -+ "Reading symbols from .*${testfile1}\\.\\.\\.done\\." \ -+ "add-symbol-file ${testfile1} 0x100000" \ -+ "add symbol table from file \".*${testfile1}\" at.*\\(y or n\\) " \ -+ "y" -+ - not_null_var_address my_global_symbol - not_null_var_address my_static_symbol - not_null_var_address my_global_func - - - -http://sourceware.org/ml/gdb-cvs/2012-06/msg00047.html - -### src/gdb/ChangeLog 2012/06/06 06:04:42 1.14330 -### src/gdb/ChangeLog 2012/06/06 16:57:34 1.14331 -## -1,3 +1,8 @@ -+2012-06-06 Jan Kratochvil -+ -+ * configure.ac: Move development=true below AC_INIT. -+ * configure: Regenerate. -+ - 2012-06-05 Stan Shebs - - * mi/mi-interp.c (mi_interpreter_init): Set raw_stdout from ---- src/gdb/configure 2012/06/01 18:20:18 1.366 -+++ src/gdb/configure 2012/06/06 16:57:36 1.367 -@@ -2683,6 +2683,11 @@ - - - -+# Provide more thorough testing by -lmcheck. -+# Set it to 'true' for development snapshots, 'false' for releases or -+# pre-releases. -+development=true -+ - ac_ext=c - ac_cpp='$CPP $CPPFLAGS' - ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ---- src/gdb/configure.ac 2012/06/01 18:20:18 1.177 -+++ src/gdb/configure.ac 2012/06/06 16:57:38 1.178 -@@ -18,16 +18,16 @@ - - dnl Process this file with autoconf to produce a configure script. - --dnl Provide more thorough testing by -lmcheck. --dnl Set it to 'true' for development snapshots, 'false' for releases or --dnl pre-releases. --development=true -- - AC_PREREQ(2.59)dnl - AC_INIT(main.c) - AC_CONFIG_HEADER(config.h:config.in) - AM_MAINTAINER_MODE - -+# Provide more thorough testing by -lmcheck. -+# Set it to 'true' for development snapshots, 'false' for releases or -+# pre-releases. -+development=true -+ - AC_PROG_CC - AC_USE_SYSTEM_EXTENSIONS - ACX_LARGEFILE diff --git a/gdb-x86-onstack-1of2.patch b/gdb-x86-onstack-1of2.patch deleted file mode 100644 index 7d7556c..0000000 --- a/gdb-x86-onstack-1of2.patch +++ /dev/null @@ -1,119 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-03/msg00357.html -Subject: [patch 1/2] Fix gdb.cp/gdb2495.exp regression with gcc-4.7 #5 - -Hi, - -posted as a new thread. - -As described in - cancel: [patch] Fix gdb.cp/gdb2495.exp regression with gcc-4.7 #4 [Re: [revert] Regression on PowerPC] - http://sourceware.org/ml/gdb-patches/2012-03/msg00322.html -just ON_STACK had some regressions. - -The expectations in that mail were wrong (at least that cleanup/fix is not -required for gdb.cp/gdb2495.exp). - -The problem is that the inferior call return pad breakpoint instruction is -never removed even after inferior call finishes. It is even still visible in -"maintenance info breakpoints". This does not matter much for AT_ENTRY_POINT -but for ON_STACK it just corrupts stack. - -No regressions on -{x86_64,x86_64-m32,i686}-fedora(15-rawhide)/rhel(5-6)-linux-gnu and for -gdbsever non-extended mode. - - -Thanks, -Jan - - -gdb/ -2012-03-09 Jan Kratochvil - - Remove momentary breakpoints for completed inferior calls. - * dummy-frame.c: Include gdbthread.h. - (pop_dummy_frame_bpt): New function. - (pop_dummy_frame): Initialie DUMMY earlier. Call pop_dummy_frame_bpt. - -gdb/testsuite/ -2012-03-09 Jan Kratochvil - - Remove momentary breakpoints for completed inferior calls. - * gdb.base/call-signal-resume.exp (maintenance print dummy-frames) - (maintenance info breakpoints): New tests. - -Index: gdb-7.4.50.20120602/gdb/dummy-frame.c -=================================================================== ---- gdb-7.4.50.20120602.orig/gdb/dummy-frame.c 2012-01-04 09:17:00.000000000 +0100 -+++ gdb-7.4.50.20120602/gdb/dummy-frame.c 2012-06-02 20:42:40.907720327 +0200 -@@ -29,6 +29,7 @@ - #include "gdbcmd.h" - #include "gdb_string.h" - #include "observer.h" -+#include "gdbthread.h" - - /* Dummy frame. This saves the processor state just prior to setting - up the inferior function call. Older targets save the registers -@@ -108,19 +109,36 @@ remove_dummy_frame (struct dummy_frame * - xfree (dummy); - } - -+/* Delete any breakpoint B which is a momentary breakpoint for return from -+ inferior call matching DUMMY_VOIDP. */ -+ -+static int -+pop_dummy_frame_bpt (struct breakpoint *b, void *dummy_voidp) -+{ -+ struct dummy_frame *dummy = dummy_voidp; -+ -+ if (b->disposition == disp_del && frame_id_eq (b->frame_id, dummy->id) -+ && b->thread == pid_to_thread_id (inferior_ptid)) -+ delete_breakpoint (b); -+ -+ /* Continue the traversal. */ -+ return 0; -+} -+ - /* Pop *DUMMY_PTR, restoring program state to that before the - frame was created. */ - - static void - pop_dummy_frame (struct dummy_frame **dummy_ptr) - { -- struct dummy_frame *dummy; -+ struct dummy_frame *dummy = *dummy_ptr; -+ -+ restore_infcall_suspend_state (dummy->caller_state); - -- restore_infcall_suspend_state ((*dummy_ptr)->caller_state); -+ iterate_over_breakpoints (pop_dummy_frame_bpt, dummy); - - /* restore_infcall_control_state frees inf_state, - all that remains is to pop *dummy_ptr. */ -- dummy = *dummy_ptr; - *dummy_ptr = dummy->next; - xfree (dummy); - -Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.base/call-signal-resume.exp -=================================================================== ---- gdb-7.4.50.20120602.orig/gdb/testsuite/gdb.base/call-signal-resume.exp 2012-01-23 18:11:50.000000000 +0100 -+++ gdb-7.4.50.20120602/gdb/testsuite/gdb.base/call-signal-resume.exp 2012-06-02 20:43:10.523709052 +0200 -@@ -101,6 +101,18 @@ gdb_test "frame $frame_number" ".*" - gdb_test_no_output "set confirm off" - gdb_test "return" "" - -+# Verify there are no remains of the dummy frame. -+gdb_test_no_output "maintenance print dummy-frames" -+set test "maintenance info breakpoints" -+gdb_test_multiple $test $test { -+ -re "call dummy.*\r\n$gdb_prompt $" { -+ fail $test -+ } -+ -re "\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+ - # Resume execution, the program should continue without any signal. - - gdb_test "break stop_two" "Breakpoint \[0-9\]* at .*" diff --git a/gdb-x86-onstack-2of2.patch b/gdb-x86-onstack-2of2.patch deleted file mode 100644 index a49904a..0000000 --- a/gdb-x86-onstack-2of2.patch +++ /dev/null @@ -1,166 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-03/msg00358.html -Subject: [patch 2/2] Fix gdb.cp/gdb2495.exp regression with gcc-4.7 #5 - -Hi, - -here is the ON_STACK code again, with fixed alignment for i386 SSE. - -It is generalized for all OSes on i386/amd64. I can move it to -{i386,amd64)-linux-tdep.c but I find this code much more lightweight than -i386_push_dummy_call which is already present in i386-tdep. - -No regressions on -{x86_64,x86_64-m32,i686}-fedora(15-rawhide)/rhel(5-6)-linux-gnu and for -gdbsever non-extended mode. - -For x86_64-fedora17-linux-gnu it fixes: --FAIL: gdb.cp/gdb2495.exp: Call a function that raises an exception without a handler. --FAIL: gdb.cp/gdb2495.exp: bt after returning from a popped frame -+PASS: gdb.cp/gdb2495.exp: Call a function that raises an exception without a handler. -+PASS: gdb.cp/gdb2495.exp: bt after returning from a popped frame - - -Thanks, -Jan - - -gdb/ -2012-03-09 Jan Kratochvil - - * amd64-dicos-tdep.c (amd64_dicos_push_dummy_code): Remove. - (amd64_dicos_init_abi): Remove its installment. - * dicos-tdep.c (dicos_init_abi): Remove the - set_gdbarch_call_dummy_location call. Update the comment here. - * i386-dicos-tdep.c (i386_dicos_push_dummy_code): Remove. - (i386_dicos_init_abi): Remove its installment. - * i386-tdep.c (i386_push_dummy_code): New function. - (i386_gdbarch_init): Call set_gdbarch_call_dummy_location, install - i386_push_dummy_code. - ---- a/gdb/amd64-dicos-tdep.c -+++ b/gdb/amd64-dicos-tdep.c -@@ -23,24 +23,6 @@ - #include "amd64-tdep.h" - #include "dicos-tdep.h" - --static CORE_ADDR --amd64_dicos_push_dummy_code (struct gdbarch *gdbarch, -- CORE_ADDR sp, CORE_ADDR funaddr, -- struct value **args, int nargs, -- struct type *value_type, -- CORE_ADDR *real_pc, CORE_ADDR *bp_addr, -- struct regcache *regcache) --{ -- int bplen; -- CORE_ADDR bppc = sp; -- -- gdbarch_breakpoint_from_pc (gdbarch, &bppc, &bplen); -- *bp_addr = sp - bplen; -- *real_pc = funaddr; -- -- return *bp_addr; --} -- - static void - amd64_dicos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - { -@@ -49,8 +31,6 @@ amd64_dicos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - amd64_init_abi (info, gdbarch); - - dicos_init_abi (gdbarch); -- -- set_gdbarch_push_dummy_code (gdbarch, amd64_dicos_push_dummy_code); - } - - static enum gdb_osabi ---- a/gdb/dicos-tdep.c -+++ b/gdb/dicos-tdep.c -@@ -43,8 +43,8 @@ dicos_init_abi (struct gdbarch *gdbarch) - - /* There's no (standard definition of) entry point or a guaranteed - text location with a symbol where to place the call dummy, so we -- put it on the stack. */ -- set_gdbarch_call_dummy_location (gdbarch, ON_STACK); -+ need it on the stack. Rely on i386_gdbarch_init used also for -+ amd64 to set up ON_STACK inferior calls. */ - - /* DICOS rewinds the PC itself. */ - set_gdbarch_decr_pc_after_break (gdbarch, 0); ---- a/gdb/i386-dicos-tdep.c -+++ b/gdb/i386-dicos-tdep.c -@@ -22,32 +22,12 @@ - #include "gdb_string.h" - #include "dicos-tdep.h" - --static CORE_ADDR --i386_dicos_push_dummy_code (struct gdbarch *gdbarch, -- CORE_ADDR sp, CORE_ADDR funaddr, -- struct value **args, int nargs, -- struct type *value_type, -- CORE_ADDR *real_pc, CORE_ADDR *bp_addr, -- struct regcache *regcache) --{ -- int bplen; -- CORE_ADDR bppc = sp; -- -- gdbarch_breakpoint_from_pc (gdbarch, &bppc, &bplen); -- *bp_addr = sp - bplen; -- *real_pc = funaddr; -- -- return *bp_addr; --} -- - static void - i386_dicos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - - dicos_init_abi (gdbarch); -- -- set_gdbarch_push_dummy_code (gdbarch, i386_dicos_push_dummy_code); - } - - static enum gdb_osabi ---- a/gdb/i386-tdep.c -+++ b/gdb/i386-tdep.c -@@ -2326,6 +2326,30 @@ i386_16_byte_align_p (struct type *type) - return 0; - } - -+/* Implementation for set_gdbarch_push_dummy_code. */ -+ -+static CORE_ADDR -+i386_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, -+ struct value **args, int nargs, struct type *value_type, -+ CORE_ADDR *real_pc, CORE_ADDR *bp_addr, -+ struct regcache *regcache) -+{ -+ int bplen; -+ CORE_ADDR bppc = sp; -+ -+ gdbarch_breakpoint_from_pc (gdbarch, &bppc, &bplen); -+ sp -= bplen; -+ -+ /* amd64_push_dummy_call does alignment on its own but i386_push_dummy_call -+ does not. ABI requires stack alignment for executables using SSE. */ -+ if (gdbarch_frame_align_p (gdbarch)) -+ sp = gdbarch_frame_align (gdbarch, sp); -+ -+ *bp_addr = sp; -+ *real_pc = funaddr; -+ return sp; -+} -+ - static CORE_ADDR - i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, - struct regcache *regcache, CORE_ADDR bp_addr, int nargs, -@@ -7372,6 +7396,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) - set_gdbarch_get_longjmp_target (gdbarch, i386_get_longjmp_target); - - /* Call dummy code. */ -+ set_gdbarch_call_dummy_location (gdbarch, ON_STACK); -+ set_gdbarch_push_dummy_code (gdbarch, i386_push_dummy_code); - set_gdbarch_push_dummy_call (gdbarch, i386_push_dummy_call); - set_gdbarch_frame_align (gdbarch, i386_frame_align); - - diff --git a/gdb.spec b/gdb.spec index 24b76c8..133ba22 100644 --- a/gdb.spec +++ b/gdb.spec @@ -30,12 +30,12 @@ Name: %{?scl_prefix}gdb # Set version to contents of gdb/version.in. # NOTE: the FSF gdb versions are numbered N.M for official releases, like 6.3 # and, since January 2005, X.Y.Z.date for daily snapshots, like 6.3.50.20050112 # (daily snapshot from mailine), or 6.3.0.20040112 (head of the release branch). -%global snap 20120603 +%global snap 20120703 Version: 7.4.50.%{snap} # 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: 7%{?dist} +Release: 8%{?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 @@ -481,8 +481,6 @@ Patch504: gdb-bz623749-gcore-relro.patch # Fix lost siginfo_t in linux-nat (BZ 592031). #=push -Patch510: gdb-bz592031-siginfo-lost-4of5.patch -#=push Patch511: gdb-bz592031-siginfo-lost-5of5.patch # Verify GDB Python built-in function gdb.solib_address exists (BZ # 634108). @@ -542,36 +540,22 @@ Patch653: gdb-attach-fail-reasons-5of5.patch #=fedora Patch657: gdb-attach-fail-reasons-5of5configure.patch -# Fix inferior calls, particularly uncaught thrown exceptions (BZ 799531). -#=push+work -Patch654: gdb-x86-onstack-1of2.patch -Patch658: gdb-x86-onstack-2of2.patch - # Workaround crashes from stale frame_info pointer (BZ 804256). -#=push+work +#=fedora Patch661: gdb-stale-frame_info.patch # Workaround PR libc/14166 for inferior calls of strstr. #=push+work: But push it to glibc. Patch690: gdb-glibc-strstr-workaround.patch -# Fix dejagnu-1.5-4.fc17 compatibility for Go (for BZ 635651). -#=fedoratest -Patch692: gdb-dejagnu-go.patch - -# Revert recent breakage of UNIX objfiles order for symbols lookup. -Patch693: gdb-objfile-order.patch - # Disable -lmcheck in the development builds. +#=fedora Patch694: gdb-disable-mcheck.patch # Fix assertion on some files as glibc-2.15.90-8.fc18 (Doug Evans). +#=push Patch695: gdb-index-assert.patch -# Support DW_OP_GNU_parameter_ref for -O2 -g inferiors (BZ 827375). -Patch696: gdb-parameterref-1of2.patch -Patch697: gdb-parameterref-2of2.patch - # Include testcase for `Unable to see a variable inside a module (XLF)' (BZ 823789). #=fedoratest #+ppc @@ -581,6 +565,10 @@ Patch698: gdb-rhel5.9-testcase-xlf-var-inside-mod.patch #=fedoratest Patch703: gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch +# Revert function returning pointer fix (PR 9514) regressing Fedora errno patch. +#=push +Patch715: gdb-errno-func-datatype-revert.patch + %if 0%{!?rhel:1} || 0%{?rhel} > 6 # RL_STATE_FEDORA_GDB would not be found for: # Patch642: gdb-readline62-ask-more-rh.patch @@ -651,8 +639,11 @@ BuildRequires: prelink %endif %endif %if 0%{!?rhel:1} +# Fedora arm does not yet have fpc built. +%ifnarch %{arm} BuildRequires: fpc %endif +%endif %if 0%{?el5:1} BuildRequires: gcc44 gcc44-gfortran %endif @@ -758,6 +749,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch2 -p1 %patch232 -p1 +%patch715 -p1 %patch349 -p1 %patch1 -p1 %patch3 -p1 @@ -847,7 +839,6 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch491 -p1 %patch496 -p1 %patch504 -p1 -%patch510 -p1 %patch511 -p1 %patch526 -p1 %patch542 -p1 @@ -861,16 +852,10 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch643 -p1 %patch653 -p1 %patch657 -p1 -%patch654 -p1 -%patch658 -p1 %patch661 -p1 %patch690 -p1 -%patch692 -p1 -%patch693 -p1 %patch694 -p1 %patch695 -p1 -%patch696 -p1 -%patch697 -p1 %patch698 -p1 %patch703 -p1 @@ -1362,6 +1347,12 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Tue Jul 3 2012 Jan Kratochvil - 7.4.50.20120703-8.fc18 +- Rebase to FSF GDB 7.4.50.20120703. +- [archer-tromey-dwz-multifile-rebase] Merge new branch (Tom Tromey). +- [arm] <--with testsuite>: Disable fpc BuildRequires as it is not yet built. +- Revert function returning pointer fix (PR 9514) regressing Fedora errno patch. + * Thu Jun 21 2012 Sergio Durigan Junior - 7.4.50.20120603-7.fc18 - Include testcase for BZ 818343. diff --git a/sources b/sources index fd83e6f..09fc654 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ 04e5c4b1b9e633422cc48990fe61958d libstdc++-v3-python-r155978.tar.bz2 -d6766c3ec4444f337cb0d7a0265130f9 gdb-7.4.50.20120603.tar.bz2 +91290d1034013db1fe035c081adde514 gdb-7.4.50.20120703.tar.bz2