diff --git a/fix-symread-crash.diff b/fix-symread-crash.diff deleted file mode 100644 index ac8a043..0000000 --- a/fix-symread-crash.diff +++ /dev/null @@ -1,28 +0,0 @@ -Index: gdb-6.8.50.20090302/gdb/symfile.c -=================================================================== ---- gdb-6.8.50.20090302.orig/gdb/symfile.c 2009-07-28 12:49:19.000000000 +0200 -+++ gdb-6.8.50.20090302/gdb/symfile.c 2009-07-28 13:44:06.000000000 +0200 -@@ -2342,8 +2342,14 @@ find_separate_debug_file (struct objfile - gdb_assert (i >= 0 && IS_DIR_SEPARATOR (dir[i])); - dir[i+1] = '\0'; - -+ canon_name = lrealpath (dir); -+ i = strlen (dir); -+ if (canon_name -+ && strlen (canon_name) > i) -+ i = strlen (canon_name); -+ - debugfile = xmalloc (strlen (debug_file_directory) + 1 -- + strlen (dir) -+ + i /* MAX (strlen (canon_name), strlen (dir)) */ - + strlen (DEBUG_SUBDIRECTORY) - + strlen ("/") - + strlen (basename) -@@ -2376,7 +2382,6 @@ find_separate_debug_file (struct objfile - - /* If the file is in the sysroot, try using its base path in the - global debugfile directory. */ -- canon_name = lrealpath (dir); - if (canon_name - && strncmp (canon_name, gdb_sysroot, strlen (gdb_sysroot)) == 0 - && IS_DIR_SEPARATOR (canon_name[strlen (gdb_sysroot)])) diff --git a/gdb-6.3-pie-20050110.patch b/gdb-6.3-pie-20050110.patch index ca1c664..ea42d95 100644 --- a/gdb-6.3-pie-20050110.patch +++ b/gdb-6.3-pie-20050110.patch @@ -26,10 +26,10 @@ Fix scan_dyntag() for binaries provided by valgrind (BZ 460319). -Index: gdb-6.8.50.20090803/gdb/amd64-tdep.c +Index: gdb-6.8.50.20090809/gdb/amd64-tdep.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/amd64-tdep.c 2009-08-03 21:39:38.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/amd64-tdep.c 2009-08-03 21:39:39.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/amd64-tdep.c 2009-08-10 00:50:30.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/amd64-tdep.c 2009-08-10 14:59:58.000000000 +0200 @@ -36,6 +36,7 @@ #include "regcache.h" #include "regset.h" @@ -138,10 +138,10 @@ Index: gdb-6.8.50.20090803/gdb/amd64-tdep.c return pc; } -Index: gdb-6.8.50.20090803/gdb/auxv.c +Index: gdb-6.8.50.20090809/gdb/auxv.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/auxv.c 2009-08-03 21:39:08.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/auxv.c 2009-08-03 21:39:39.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/auxv.c 2009-07-02 19:25:52.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/auxv.c 2009-08-10 14:59:58.000000000 +0200 @@ -78,7 +78,7 @@ procfs_xfer_auxv (struct target_ops *ops Return 1 if an entry was read into *TYPEP and *VALP. */ static int @@ -230,10 +230,10 @@ Index: gdb-6.8.50.20090803/gdb/auxv.c break; } -Index: gdb-6.8.50.20090803/gdb/auxv.h +Index: gdb-6.8.50.20090809/gdb/auxv.h =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/auxv.h 2009-08-03 21:39:08.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/auxv.h 2009-08-03 21:39:39.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/auxv.h 2009-06-07 21:07:08.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/auxv.h 2009-08-10 14:59:58.000000000 +0200 @@ -31,14 +31,14 @@ Return 1 if an entry was read into *TYPEP and *VALP. */ extern int target_auxv_parse (struct target_ops *ops, @@ -251,10 +251,10 @@ Index: gdb-6.8.50.20090803/gdb/auxv.h /* Print the contents of the target's AUXV on the specified file. */ extern int fprint_target_auxv (struct ui_file *file, struct target_ops *ops); -Index: gdb-6.8.50.20090803/gdb/dwarf2read.c +Index: gdb-6.8.50.20090809/gdb/dwarf2read.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/dwarf2read.c 2009-08-03 21:39:39.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/dwarf2read.c 2009-08-03 21:39:39.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/dwarf2read.c 2009-08-10 14:59:28.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/dwarf2read.c 2009-08-10 14:59:58.000000000 +0200 @@ -1659,7 +1659,7 @@ dwarf2_build_psymtabs (struct objfile *o dwarf2_read_section (objfile, &dwarf2_per_objfile->eh_frame); dwarf2_read_section (objfile, &dwarf2_per_objfile->frame); @@ -264,10 +264,10 @@ Index: gdb-6.8.50.20090803/gdb/dwarf2read.c || (objfile->global_psymbols.size == 0 && objfile->static_psymbols.size == 0)) { -Index: gdb-6.8.50.20090803/gdb/elfread.c +Index: gdb-6.8.50.20090809/gdb/elfread.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/elfread.c 2009-08-03 21:39:08.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/elfread.c 2009-08-03 21:39:39.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/elfread.c 2009-08-10 00:50:30.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/elfread.c 2009-08-10 14:59:58.000000000 +0200 @@ -681,7 +681,7 @@ elf_symfile_read (struct objfile *objfil /* If we are reinitializing, or if we have never loaded syms yet, set table to empty. MAINLINE is cleared so that *_read_psymtab @@ -277,10 +277,10 @@ Index: gdb-6.8.50.20090803/gdb/elfread.c { init_psymbol_list (objfile, 0); mainline = 0; -Index: gdb-6.8.50.20090803/gdb/infrun.c +Index: gdb-6.8.50.20090809/gdb/infrun.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/infrun.c 2009-08-03 21:39:38.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/infrun.c 2009-08-04 06:04:25.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/infrun.c 2009-08-10 00:50:30.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/infrun.c 2009-08-10 14:59:58.000000000 +0200 @@ -3531,6 +3531,10 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME ( #endif target_terminal_inferior (); @@ -292,10 +292,10 @@ Index: gdb-6.8.50.20090803/gdb/infrun.c /* If requested, stop when the dynamic linker notifies gdb of events. This allows the user to get control and place breakpoints in initializer routines for -Index: gdb-6.8.50.20090803/gdb/objfiles.c +Index: gdb-6.8.50.20090809/gdb/objfiles.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/objfiles.c 2009-08-03 21:39:08.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/objfiles.c 2009-08-03 21:39:39.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/objfiles.c 2009-08-10 00:50:30.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/objfiles.c 2009-08-10 14:59:58.000000000 +0200 @@ -52,6 +52,9 @@ #include "exec.h" #include "observer.h" @@ -324,7 +324,7 @@ Index: gdb-6.8.50.20090803/gdb/objfiles.c if (symfile_objfile == NULL) return 0; -@@ -475,6 +486,9 @@ free_objfile (struct objfile *objfile) +@@ -465,6 +476,9 @@ free_objfile (struct objfile *objfile) if (objfile == symfile_objfile) symfile_objfile = NULL; @@ -334,10 +334,10 @@ Index: gdb-6.8.50.20090803/gdb/objfiles.c /* Before the symbol table code was redone to make it easier to selectively load and remove information particular to a specific linkage unit, gdb used to do these things whenever the monolithic -Index: gdb-6.8.50.20090803/gdb/solib-svr4.c +Index: gdb-6.8.50.20090809/gdb/solib-svr4.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/solib-svr4.c 2009-08-03 21:39:38.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/solib-svr4.c 2009-08-03 21:41:49.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/solib-svr4.c 2009-08-10 14:56:11.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/solib-svr4.c 2009-08-10 14:59:58.000000000 +0200 @@ -47,6 +47,7 @@ #include "exec.h" #include "auxv.h" @@ -999,10 +999,10 @@ Index: gdb-6.8.50.20090803/gdb/solib-svr4.c + add_info ("linkmap", info_linkmap_command, + "Display the inferior's linkmap."); } -Index: gdb-6.8.50.20090803/gdb/solib.c +Index: gdb-6.8.50.20090809/gdb/solib.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/solib.c 2009-08-03 21:39:08.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/solib.c 2009-08-04 05:57:36.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/solib.c 2009-08-10 00:50:30.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/solib.c 2009-08-10 15:07:13.000000000 +0200 @@ -81,6 +81,8 @@ set_solib_ops (struct gdbarch *gdbarch, /* external data declarations */ @@ -1021,35 +1021,7 @@ Index: gdb-6.8.50.20090803/gdb/solib.c /* GLOBAL FUNCTION -@@ -428,10 +432,23 @@ free_so (struct so_list *so) - - if (so->abfd) - { -- bfd_filename = bfd_get_filename (so->abfd); -- if (! bfd_close (so->abfd)) -- warning (_("cannot close \"%s\": %s"), -- bfd_filename, bfd_errmsg (bfd_get_error ())); -+ struct objfile *objfile; -+ -+ ALL_OBJFILES (objfile) -+ if (objfile->obfd == so->abfd) -+ { -+ gdb_assert (objfile->flags & OBJF_KEEPBFD); -+ objfile->flags &= ~OBJF_KEEPBFD; -+ break; -+ } -+ -+ if (!objfile) -+ { -+ bfd_filename = bfd_get_filename (so->abfd); -+ if (! bfd_close (so->abfd)) -+ warning (_("cannot close \"%s\": %s"), -+ bfd_filename, bfd_errmsg (bfd_get_error ())); -+ } - } - - if (bfd_filename) -@@ -458,15 +475,40 @@ symbol_add_stub (struct so_list *so, int +@@ -453,14 +453,38 @@ symbol_add_stub (struct so_list *so, int /* Have we already loaded this shared object? */ ALL_OBJFILES (so->objfile) { @@ -1075,25 +1047,22 @@ Index: gdb-6.8.50.20090803/gdb/solib.c sap = build_section_addr_info_from_section_table (so->sections, so->sections_end); -- so->objfile = symbol_file_add_from_bfd (so->abfd, flags, -- sap, OBJF_SHARED | OBJF_KEEPBFD); +- so->objfile = symbol_file_add_from_bfd (so->abfd, flags, sap, OBJF_SHARED); + if (so->main) + { + if (debug_solib) + fprintf_unfiltered (gdb_stdlog, + "symbol_add_stub: adding symbols for main\n"); -+ so->objfile = symbol_file_add_from_bfd (so->abfd, (flags & ~SYMFILE_VERBOSE) | SYMFILE_MAINLINE, -+ sap, OBJF_KEEPBFD); ++ so->objfile = symbol_file_add_from_bfd (so->abfd, (flags & ~SYMFILE_VERBOSE) | SYMFILE_MAINLINE, sap, 0); + so->main_relocated = 1; + } + else -+ so->objfile = symbol_file_add_from_bfd (so->abfd, flags, -+ sap, OBJF_SHARED | OBJF_KEEPBFD); ++ so->objfile = symbol_file_add_from_bfd (so->abfd, flags, sap, OBJF_SHARED); + - free_section_addr_info (sap); - - return; -@@ -606,6 +648,10 @@ update_solib_list (int from_tty, struct + p_refcount = xmalloc (sizeof (*p_refcount)); + *p_refcount = 2; /* Both solib and objfile refer to this abfd. */ + bfd_usrdata (so->abfd) = p_refcount; +@@ -600,6 +628,10 @@ update_solib_list (int from_tty, struct } else { @@ -1104,7 +1073,7 @@ Index: gdb-6.8.50.20090803/gdb/solib.c if (! strcmp (gdb->so_original_name, i->so_original_name)) break; } -@@ -660,18 +706,7 @@ update_solib_list (int from_tty, struct +@@ -654,18 +686,7 @@ update_solib_list (int from_tty, struct /* Fill in the rest of each of the `struct so_list' nodes. */ for (i = inferior; i; i = i->next) { @@ -1124,7 +1093,7 @@ Index: gdb-6.8.50.20090803/gdb/solib.c /* Notify any observer that the shared object has been loaded now that we've added it to GDB's tables. */ -@@ -781,6 +816,32 @@ solib_add (char *pattern, int from_tty, +@@ -775,6 +796,32 @@ solib_add (char *pattern, int from_tty, } } @@ -1157,7 +1126,7 @@ Index: gdb-6.8.50.20090803/gdb/solib.c /* -@@ -1134,4 +1195,12 @@ This takes precedence over the environme +@@ -1128,4 +1175,12 @@ This takes precedence over the environme reload_shared_libraries, show_solib_search_path, &setlist, &showlist); @@ -1170,10 +1139,10 @@ Index: gdb-6.8.50.20090803/gdb/solib.c + NULL, NULL, + &setdebuglist, &showdebuglist); } -Index: gdb-6.8.50.20090803/gdb/solist.h +Index: gdb-6.8.50.20090809/gdb/solist.h =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/solist.h 2009-08-03 21:39:08.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/solist.h 2009-08-03 21:39:39.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/solist.h 2009-08-10 00:50:30.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/solist.h 2009-08-10 14:59:58.000000000 +0200 @@ -61,6 +61,8 @@ struct so_list bfd *abfd; char symbols_loaded; /* flag: symbols read in yet? */ @@ -1194,10 +1163,10 @@ Index: gdb-6.8.50.20090803/gdb/solist.h +extern int debug_solib; + #endif -Index: gdb-6.8.50.20090803/gdb/symfile-mem.c +Index: gdb-6.8.50.20090809/gdb/symfile-mem.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/symfile-mem.c 2009-08-03 21:39:38.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/symfile-mem.c 2009-08-03 21:39:39.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/symfile-mem.c 2009-08-10 00:50:30.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/symfile-mem.c 2009-08-10 14:59:58.000000000 +0200 @@ -115,7 +115,7 @@ symbol_file_add_from_memory (struct bfd ++i; } @@ -1207,10 +1176,10 @@ Index: gdb-6.8.50.20090803/gdb/symfile-mem.c sai, OBJF_SHARED); /* This might change our ideas about frames already looked at. */ -Index: gdb-6.8.50.20090803/gdb/symfile.c +Index: gdb-6.8.50.20090809/gdb/symfile.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/symfile.c 2009-08-03 21:39:38.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/symfile.c 2009-08-04 06:02:45.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/symfile.c 2009-08-10 14:59:28.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/symfile.c 2009-08-10 14:59:58.000000000 +0200 @@ -49,6 +49,7 @@ #include "readline/readline.h" #include "gdb_assert.h" @@ -1290,7 +1259,7 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c free_all_objfiles (); -@@ -3380,6 +3389,8 @@ reread_symbols (void) +@@ -3387,6 +3396,8 @@ reread_symbols (void) /* Discard cleanups as symbol reading was successful. */ discard_cleanups (old_cleanups); @@ -1299,10 +1268,10 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c /* If the mtime has changed between the time we set new_modtime and now, we *want* this to be out of date, so don't call stat again now. */ -Index: gdb-6.8.50.20090803/gdb/target.h +Index: gdb-6.8.50.20090809/gdb/target.h =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/target.h 2009-08-03 21:39:39.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/target.h 2009-08-03 21:39:39.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/target.h 2009-08-10 14:59:28.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/target.h 2009-08-10 14:59:58.000000000 +0200 @@ -524,7 +524,7 @@ struct target_ops Return -1 if there is insufficient buffer for a whole entry. Return 1 if an entry was read into *TYPEP and *VALP. */ @@ -1312,10 +1281,10 @@ Index: gdb-6.8.50.20090803/gdb/target.h /* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the sequence of bytes in PATTERN with length PATTERN_LEN. -Index: gdb-6.8.50.20090803/gdb/symfile.h +Index: gdb-6.8.50.20090809/gdb/symfile.h =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/symfile.h 2009-08-03 21:39:38.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/symfile.h 2009-08-03 21:39:39.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/symfile.h 2009-08-10 14:59:28.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/symfile.h 2009-08-10 14:59:58.000000000 +0200 @@ -229,7 +229,13 @@ enum symfile_add_flags SYMFILE_MAINLINE = 1 << 2, diff --git a/gdb-6.5-bz216711-clone-is-outermost.patch b/gdb-6.5-bz216711-clone-is-outermost.patch index 4fb8a3d..1554f7b 100644 --- a/gdb-6.5-bz216711-clone-is-outermost.patch +++ b/gdb-6.5-bz216711-clone-is-outermost.patch @@ -138,28 +138,24 @@ Index: gdb-6.8.50.20090802/gdb/amd64-tdep.c (*this_id) = frame_id_build (cache->base + 16, cache->pc); } -Index: gdb-6.8.50.20090802/gdb/i386-tdep.c -=================================================================== ---- gdb-6.8.50.20090802.orig/gdb/i386-tdep.c 2009-07-12 19:46:21.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/i386-tdep.c 2009-08-03 15:50:08.000000000 +0200 -@@ -5307,6 +5307,9 @@ i386_gdbarch_init (struct gdbarch_info i +--- gdb-6.8.50.20090811/gdb/i386-tdep.c.orig 2009-08-10 05:02:39.000000000 +0200 ++++ gdb-6.8.50.20090811/gdb/i386-tdep.c 2009-08-11 16:33:51.000000000 +0200 +@@ -5432,6 +5432,9 @@ i386_gdbarch_init (struct gdbarch_info i tdep->sc_pc_offset = -1; tdep->sc_sp_offset = -1; + /* Unwinding stops on i386 automatically. */ + tdep->outermost_frame_p = NULL; + + tdep->record_regmap = i386_record_regmap; + /* The format used for `long double' on almost all i386 targets is - the i387 extended floating-point format. In fact, of all targets - in the GCC 2.95 tree, only OSF/1 does it different, and insists -Index: gdb-6.8.50.20090802/gdb/i386-tdep.h -=================================================================== ---- gdb-6.8.50.20090802.orig/gdb/i386-tdep.h 2009-07-02 19:25:54.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/i386-tdep.h 2009-08-03 15:50:29.000000000 +0200 -@@ -115,6 +115,9 @@ struct gdbarch_tdep - int (*i386_intx80_record) (struct regcache *regcache); - /* Parse sysenter args. */ +--- gdb-6.8.50.20090811/gdb/i386-tdep.h.orig 2009-08-10 05:02:39.000000000 +0200 ++++ gdb-6.8.50.20090811/gdb/i386-tdep.h 2009-08-11 16:34:08.000000000 +0200 +@@ -120,6 +120,9 @@ struct gdbarch_tdep int (*i386_sysenter_record) (struct regcache *regcache); + /* Parse syscall args. */ + int (*i386_syscall_record) (struct regcache *regcache); + + /* Detect OS dependent outermost frames; such as `clone'. */ + int (*outermost_frame_p) (struct frame_info *this_frame); diff --git a/gdb-6.6-buildid-locate.patch b/gdb-6.6-buildid-locate.patch index fe7bed2..e373c95 100644 --- a/gdb-6.6-buildid-locate.patch +++ b/gdb-6.6-buildid-locate.patch @@ -1,7 +1,7 @@ -Index: gdb-6.8.50.20090803/gdb/corelow.c +Index: gdb-6.8.50.20090809/gdb/corelow.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/corelow.c 2009-07-31 17:25:21.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/corelow.c 2009-08-04 06:32:12.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/corelow.c 2009-07-31 17:25:21.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/corelow.c 2009-08-10 14:56:11.000000000 +0200 @@ -45,6 +45,10 @@ #include "exceptions.h" #include "solib.h" @@ -89,10 +89,10 @@ Index: gdb-6.8.50.20090803/gdb/corelow.c + NULL, NULL, NULL, + &setlist, &showlist); } -Index: gdb-6.8.50.20090803/gdb/doc/gdb.texinfo +Index: gdb-6.8.50.20090809/gdb/doc/gdb.texinfo =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/doc/gdb.texinfo 2009-08-04 06:31:59.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/doc/gdb.texinfo 2009-08-04 06:32:12.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/doc/gdb.texinfo 2009-08-10 00:50:30.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/doc/gdb.texinfo 2009-08-10 14:56:11.000000000 +0200 @@ -13733,6 +13733,27 @@ information files. @end table @@ -121,10 +121,10 @@ Index: gdb-6.8.50.20090803/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-6.8.50.20090803/gdb/solib-svr4.c +Index: gdb-6.8.50.20090809/gdb/solib-svr4.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/solib-svr4.c 2009-08-04 06:29:47.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/solib-svr4.c 2009-08-04 06:32:12.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/solib-svr4.c 2009-08-10 00:50:30.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/solib-svr4.c 2009-08-10 14:56:11.000000000 +0200 @@ -1101,9 +1101,33 @@ svr4_current_sos (void) safe_strerror (errcode)); else @@ -162,10 +162,10 @@ Index: gdb-6.8.50.20090803/gdb/solib-svr4.c } xfree (buffer); -Index: gdb-6.8.50.20090803/gdb/symfile.c +Index: gdb-6.8.50.20090809/gdb/symfile.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/symfile.c 2009-08-04 06:31:58.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/symfile.c 2009-08-04 06:32:12.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/symfile.c 2009-08-10 00:50:30.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/symfile.c 2009-08-10 14:58:53.000000000 +0200 @@ -55,6 +55,7 @@ #include "elf-bfd.h" #include "solib.h" @@ -174,7 +174,7 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c #include #include -@@ -1193,16 +1194,65 @@ symbol_file_clear (int from_tty) +@@ -1195,16 +1196,65 @@ symbol_file_clear (int from_tty) printf_unfiltered (_("No symbol file now.\n")); } @@ -242,7 +242,7 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c { struct build_id *retval; -@@ -1218,6 +1268,348 @@ build_id_bfd_get (bfd *abfd) +@@ -1220,6 +1270,348 @@ build_id_bfd_get (bfd *abfd) return retval; } @@ -591,7 +591,7 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c /* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */ static int -@@ -1235,7 +1627,7 @@ build_id_verify (const char *filename, s +@@ -1237,7 +1629,7 @@ build_id_verify (const char *filename, s if (abfd == NULL) return 0; @@ -600,7 +600,7 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c if (found == NULL) warning (_("File \"%s\" has no build-id, file skipped"), filename); -@@ -1254,8 +1646,9 @@ build_id_verify (const char *filename, s +@@ -1256,8 +1648,9 @@ build_id_verify (const char *filename, s return retval; } @@ -612,7 +612,7 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c { char *link, *s, *retval = NULL; gdb_byte *data = build_id->data; -@@ -1263,7 +1656,9 @@ build_id_to_debug_filename (struct build +@@ -1265,7 +1658,9 @@ build_id_to_debug_filename (struct build /* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */ link = xmalloc (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1 @@ -623,7 +623,7 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c s = link + sprintf (link, "%s/.build-id/", debug_file_directory); if (size > 0) { -@@ -1274,12 +1669,14 @@ build_id_to_debug_filename (struct build +@@ -1276,12 +1671,14 @@ build_id_to_debug_filename (struct build *s++ = '/'; while (size-- > 0) s += sprintf (s, "%02x", (unsigned) *data++); @@ -640,7 +640,7 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c if (retval != NULL && !build_id_verify (retval, build_id)) { -@@ -1287,9 +1684,150 @@ build_id_to_debug_filename (struct build +@@ -1289,9 +1686,150 @@ build_id_to_debug_filename (struct build retval = NULL; } @@ -649,9 +649,9 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c + else + xfree (link); + -+ return retval; -+} -+ + return retval; + } + +/* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages + Try to install the hash file ... + avoidance. */ @@ -674,9 +674,9 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c + + retval = obstack_alloc (&missing_filepair_obstack, size); + memset (retval, 0, size); - return retval; - } - ++ return retval; ++} ++ +static hashval_t +missing_filepair_hash_func (const struct missing_filepair *elem) +{ @@ -791,7 +791,7 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c static char * get_debug_link_info (struct objfile *objfile, unsigned long *crc32_out) { -@@ -1372,32 +1910,36 @@ static char * +@@ -1374,32 +1912,36 @@ static char * find_separate_debug_file (struct objfile *objfile) { asection *sect; @@ -836,7 +836,7 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c } basename = get_debug_link_info (objfile, &crc32); -@@ -1405,7 +1947,7 @@ find_separate_debug_file (struct objfile +@@ -1407,7 +1949,7 @@ find_separate_debug_file (struct objfile if (basename == NULL) /* There's no separate debug info, hence there's no way we could load it => no warning. */ @@ -845,18 +845,18 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c dir = xstrdup (objfile->name); -@@ -1421,23 +1963,19 @@ find_separate_debug_file (struct objfile - gdb_assert (i >= 0 && IS_DIR_SEPARATOR (dir[i])); - dir[i+1] = '\0'; +@@ -1429,24 +1971,19 @@ find_separate_debug_file (struct objfile + if (canon_name && strlen (canon_name) > i) + i = strlen (canon_name); - debugfile = alloca (strlen (debug_file_directory) + 1 -- + strlen (dir) +- + i - + strlen (DEBUG_SUBDIRECTORY) - + strlen ("/") - + strlen (basename) - + 1); + debugfile = xmalloc (strlen (debug_file_directory) + 1 -+ + strlen (dir) ++ + i + + strlen (DEBUG_SUBDIRECTORY) + + strlen ("/") + + strlen (basename) @@ -870,39 +870,42 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c - { - xfree (basename); - xfree (dir); +- xfree (canon_name); - return xstrdup (debugfile); - } + goto cleanup_return_debugfile; /* Then try in the subdirectory named DEBUG_SUBDIRECTORY. */ strcpy (debugfile, dir); -@@ -1446,11 +1984,7 @@ find_separate_debug_file (struct objfile +@@ -1455,12 +1992,7 @@ find_separate_debug_file (struct objfile strcat (debugfile, basename); if (separate_debug_file_exists (debugfile, crc32, objfile->name)) - { - xfree (basename); - xfree (dir); +- xfree (canon_name); - return xstrdup (debugfile); - } + goto cleanup_return_debugfile; /* Then try in the global debugfile directory. */ strcpy (debugfile, debug_file_directory); -@@ -1459,11 +1993,7 @@ find_separate_debug_file (struct objfile +@@ -1469,12 +2001,7 @@ find_separate_debug_file (struct objfile strcat (debugfile, basename); if (separate_debug_file_exists (debugfile, crc32, objfile->name)) - { - xfree (basename); - xfree (dir); +- xfree (canon_name); - return xstrdup (debugfile); - } + goto cleanup_return_debugfile; /* If the file is in the sysroot, try using its base path in the global debugfile directory. */ -@@ -1478,20 +2008,18 @@ find_separate_debug_file (struct objfile +@@ -1488,21 +2015,18 @@ find_separate_debug_file (struct objfile strcat (debugfile, basename); if (separate_debug_file_exists (debugfile, crc32, objfile->name)) @@ -910,17 +913,17 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c - xfree (canon_name); - xfree (basename); - xfree (dir); +- xfree (canon_name); - return xstrdup (debugfile); - } -+ goto cleanup_return_debugfile; ++ goto cleanup_return_debugfile; } -- + - if (canon_name) - xfree (canon_name); - + debugfile = NULL; + debug_print_missing (objfile->name, build_id_filename); -+ + +cleanup_return_debugfile: + xfree (build_id_filename); + xfree (canon_name); @@ -931,7 +934,7 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c } -@@ -4243,4 +4771,16 @@ Show printing of symbol loading messages +@@ -4254,4 +4778,16 @@ Show printing of symbol loading messages NULL, NULL, &setprintlist, &showprintlist); @@ -948,10 +951,10 @@ Index: gdb-6.8.50.20090803/gdb/symfile.c + + observer_attach_executable_changed (debug_print_executable_changed); } -Index: gdb-6.8.50.20090803/gdb/symfile.h +Index: gdb-6.8.50.20090809/gdb/symfile.h =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/symfile.h 2009-08-04 06:29:47.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/symfile.h 2009-08-04 06:32:12.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/symfile.h 2009-08-10 00:50:30.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/symfile.h 2009-08-10 14:56:11.000000000 +0200 @@ -388,6 +388,13 @@ extern int symfile_map_offsets_to_segmen struct symfile_segment_data *get_symfile_segment_data (bfd *abfd); void free_symfile_segment_data (struct symfile_segment_data *data); @@ -966,10 +969,10 @@ Index: gdb-6.8.50.20090803/gdb/symfile.h /* From dwarf2read.c */ extern int dwarf2_has_info (struct objfile *); -Index: gdb-6.8.50.20090803/gdb/testsuite/lib/gdb.exp +Index: gdb-6.8.50.20090809/gdb/testsuite/lib/gdb.exp =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/testsuite/lib/gdb.exp 2009-08-04 06:29:47.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/testsuite/lib/gdb.exp 2009-08-04 06:32:12.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/testsuite/lib/gdb.exp 2009-08-10 00:50:30.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/testsuite/lib/gdb.exp 2009-08-10 14:56:11.000000000 +0200 @@ -1248,6 +1248,16 @@ proc default_gdb_start { } { warning "Couldn't set the width to 0." } @@ -987,10 +990,10 @@ Index: gdb-6.8.50.20090803/gdb/testsuite/lib/gdb.exp return 0; } -Index: gdb-6.8.50.20090803/gdb/testsuite/lib/mi-support.exp +Index: gdb-6.8.50.20090809/gdb/testsuite/lib/mi-support.exp =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/testsuite/lib/mi-support.exp 2009-08-04 06:29:47.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/testsuite/lib/mi-support.exp 2009-08-04 06:32:12.000000000 +0200 +--- gdb-6.8.50.20090809.orig/gdb/testsuite/lib/mi-support.exp 2009-08-10 00:50:30.000000000 +0200 ++++ gdb-6.8.50.20090809/gdb/testsuite/lib/mi-support.exp 2009-08-10 14:56:11.000000000 +0200 @@ -221,6 +221,16 @@ proc default_mi_gdb_start { args } { } } diff --git a/gdb-6.8.50.20090803.tar.bz2 b/gdb-6.8.50.20090803.tar.bz2 deleted file mode 100644 index 1c96c01..0000000 --- a/gdb-6.8.50.20090803.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e630a9433f9b72ed6ba6651a32d44e4867c42645e7706ffc128c54448efd0c8d -size 18144505 diff --git a/gdb-6.8.50.20090811.tar.bz2 b/gdb-6.8.50.20090811.tar.bz2 new file mode 100644 index 0000000..c1c565c --- /dev/null +++ b/gdb-6.8.50.20090811.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:03dec5c2840b0edb1cbca5ad2946327fab075e5c896f9afd830250fad3767a25 +size 18139711 diff --git a/gdb-archer.patch b/gdb-archer.patch index a0bff94..781f192 100644 --- a/gdb-archer.patch +++ b/gdb-archer.patch @@ -2,7 +2,7 @@ http://sourceware.org/gdb/wiki/ProjectArcher http://sourceware.org/gdb/wiki/ArcherBranchManagement GIT snapshot: -commit 0222cb1f4ddd1eda32965e464cb60b1e44e110b2 +commit 93f5e942bdcdcc376ece452c309bedabae71def9 branch `archer' - the merge of branches: archer-tromey-call-frame-cfa @@ -10,10 +10,8 @@ archer-tromey-delayed-symfile archer-tromey-dw-op-value archer-jankratochvil-vla archer-jankratochvil-misc -archer-jankratochvil-expr-cumulative - archer-keiths-expr-cumulative -archer-jankratochvil-python - archer-tromey-python +archer-keiths-expr-cumulative +archer-tromey-python diff --git a/gdb/Makefile.in b/gdb/Makefile.in @@ -195,7 +193,7 @@ index ccc4db8..496c9f2 100644 # Dependency tracking. Most of this is conditional on GNU Make being # found by configure; if GNU Make is not found, we fall back to a diff --git a/gdb/NEWS b/gdb/NEWS -index 970f4df..e8de474 100644 +index 0b8e3af..446246f 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -425,6 +425,13 @@ x86/x86_64 Darwin i[34567]86-*-darwin* @@ -340,7 +338,7 @@ index 53e7371..8290adc 100644 + #endif /* BLOCK_H */ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c -index 2e598e4..38fdf8a 100644 +index f3940e1..70222a4 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -59,6 +59,7 @@ @@ -351,8 +349,8 @@ index 2e598e4..38fdf8a 100644 /* readline include files */ #include "readline/readline.h" -@@ -564,6 +565,53 @@ get_number_or_range (char **pp) - +@@ -578,6 +579,53 @@ get_breakpoint (int num) + } +/* Set break condition of breakpoint B to EXP. */ @@ -405,7 +403,7 @@ index 2e598e4..38fdf8a 100644 /* condition N EXP -- set break condition of breakpoint N to EXP. */ static void -@@ -584,42 +632,7 @@ condition_command (char *arg, int from_tty) +@@ -598,42 +646,7 @@ condition_command (char *arg, int from_tty) ALL_BREAKPOINTS (b) if (b->number == bnum) { @@ -449,7 +447,7 @@ index 2e598e4..38fdf8a 100644 return; } -@@ -8821,6 +8834,22 @@ all_tracepoints () +@@ -8843,6 +8856,22 @@ all_tracepoints () return tp_vec; } @@ -472,17 +470,17 @@ index 2e598e4..38fdf8a 100644 /* This help string is used for the break, hbreak, tbreak and thbreak commands. It is defined as a macro to prevent duplication. -@@ -9323,4 +9352,5 @@ inferior in all-stop mode, gdb behaves as if always-inserted mode is off."), +@@ -9345,4 +9374,5 @@ inferior in all-stop mode, gdb behaves as if always-inserted mode is off."), automatic_hardware_breakpoints = 1; observer_attach_about_to_proceed (breakpoint_about_to_proceed); + observer_attach_mark_used (breakpoint_types_mark_used); } diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h -index d8fe047..3a929b5 100644 +index d93c6b6..a555c16 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h -@@ -913,6 +913,9 @@ extern void breakpoint_retire_moribund (void); +@@ -918,6 +918,9 @@ extern void breakpoint_retire_moribund (void); /* Tell a breakpoint to be quiet. */ extern void make_breakpoint_silent (struct breakpoint *); @@ -1720,7 +1718,7 @@ index 62800b8..97d587b 100644 { $$ = $1.comp; if ($2) $$ = fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, $$, $2); } diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c -index d2d8f2e..3166818 100644 +index d2d8f2e..cc259e7 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -35,15 +35,7 @@ @@ -1819,7 +1817,7 @@ index d2d8f2e..3166818 100644 xfree (using); return retval; -@@ -261,12 +270,30 @@ cp_copy_usings (struct using_direct *using, +@@ -261,12 +270,42 @@ cp_copy_usings (struct using_direct *using, struct symbol * cp_lookup_symbol_nonlocal (const char *name, @@ -1829,31 +1827,43 @@ index d2d8f2e..3166818 100644 { - return lookup_namespace_scope (name, linkage_name, block, domain, - block_scope (block), 0); -+ struct symbol* sym = NULL; -+ const struct block *global_block = block_global_block (block); -+ const char* scope = block_scope(block); -+ /* Check if either no block is specified or it's a global block. */ ++ struct symbol *sym; ++ const char* scope = block_scope (block); + -+ while (block != global_block) -+ while (block != global_block) -+ { -+ sym = lookup_namespace_scope(name, block, domain, scope, 0, 0); -+ -+ if (sym != NULL) -+ return sym; -+ -+ block = BLOCK_SUPERBLOCK (block); -+ } -+ -+ -+ if (sym != NULL) ++ sym = lookup_namespace_scope (name, block, domain, scope , 0, 0); ++ if ( sym != NULL) + return sym; + -+ return lookup_symbol_file(name, block, domain, 0); ++ return cp_lookup_symbol_namespace_incremental(scope, name, block, domain); ++} ++ ++struct symbol* ++cp_lookup_symbol_namespace_incremental (const char *scope, ++ const char *name, ++ const struct block *block, ++ const domain_enum domain) ++{ ++ struct symbol *sym; ++ ++ sym = cp_lookup_symbol_namespace (scope, name, block, domain, 0); ++ if ( sym != NULL) ++ return sym; ++ ++ while (block != NULL) ++ { ++ sym = cp_lookup_symbol_imports(scope, name, block, domain,0); ++ ++ if (sym) ++ return sym; ++ ++ block = BLOCK_SUPERBLOCK(block); ++ } ++ ++ return NULL; } /* Lookup NAME at namespace scope (or, in C terms, in static and -@@ -284,13 +311,13 @@ cp_lookup_symbol_nonlocal (const char *name, +@@ -284,13 +323,13 @@ cp_lookup_symbol_nonlocal (const char *name, "A::x", and if that call fails, then the first call looks for "x". */ @@ -1870,7 +1880,7 @@ index d2d8f2e..3166818 100644 { char *namespace; -@@ -308,8 +335,8 @@ lookup_namespace_scope (const char *name, +@@ -308,8 +347,8 @@ lookup_namespace_scope (const char *name, new_scope_len += 2; } new_scope_len += cp_find_first_component (scope + new_scope_len); @@ -1881,54 +1891,20 @@ index d2d8f2e..3166818 100644 if (sym != NULL) return sym; } -@@ -320,10 +347,44 @@ lookup_namespace_scope (const char *name, +@@ -320,25 +359,50 @@ lookup_namespace_scope (const char *name, namespace = alloca (scope_len + 1); strncpy (namespace, scope, scope_len); namespace[scope_len] = '\0'; - return cp_lookup_symbol_namespace (namespace, name, linkage_name, - block, domain); -+ return cp_lookup_symbol_namespace (namespace, name, block, domain, -+ declaration_only); ++ return cp_lookup_symbol_namespace (namespace, name, block, domain, declaration_only); } -+/* Searches the for the given NAME in the given NAMESPACE, using import -+ statements implied by the given BLOCK, *and its' parents*. */ -+struct symbol * -+cp_lookup_symbol_namespace_incremental (const char *namespace, -+ const char *name, -+ const struct block *block, -+ const domain_enum domain, -+ int declaration_only) -+{ -+ struct symbol *sym; -+ const struct block *global_block = block_global_block (block); -+ -+ /* Check if either no block is specified or it's a global block. */ -+ -+ if (global_block == NULL) -+ return NULL; -+ -+ while (block != global_block) -+ { -+ sym = cp_lookup_symbol_namespace (namespace, name, block, domain, -+ declaration_only); -+ -+ if (sym != NULL) -+ return sym; -+ -+ block = BLOCK_SUPERBLOCK (block); -+ } -+ -+ /* We've reached the global block without finding a result. */ -+ -+ return NULL; -+} -+ -+ - /* Look up NAME in the C++ namespace NAMESPACE, applying the using - directives that are active in BLOCK. Other arguments are as in +-/* Look up NAME in the C++ namespace NAMESPACE, applying the using +- directives that are active in BLOCK. Other arguments are as in ++/* Look up NAME in the C++ namespace NAMESPACE. Other arguments are as in cp_lookup_symbol_nonlocal. */ -@@ -331,12 +392,12 @@ lookup_namespace_scope (const char *name, + struct symbol * cp_lookup_symbol_namespace (const char *namespace, const char *name, @@ -1937,21 +1913,53 @@ index d2d8f2e..3166818 100644 - const domain_enum domain) + const domain_enum domain, + int declaration_only) ++{ ++ ++ if (namespace[0] == '\0') ++ { ++ return lookup_symbol_file (name, block,domain, 0); ++ } ++ else ++ { ++ char *concatenated_name ++ = alloca (strlen (namespace) + 2 + strlen (name) + 1); ++ strcpy (concatenated_name, namespace); ++ strcat (concatenated_name, "::"); ++ strcat (concatenated_name, name); ++ return lookup_symbol_file (concatenated_name, block, domain, ++ cp_is_anonymous (namespace)); ++ } ++} ++ ++/* Search for NAME by applying all import statements belonging ++ to BLOCK which are applicable in SCOPE. */ ++ ++struct symbol * ++cp_lookup_symbol_imports (const char *scope, ++ const char *name, ++ const struct block *block, ++ const domain_enum domain, ++ int declaration_only) { const struct using_direct *current; - struct symbol *sym; + struct symbol *sym = NULL; - /* First, go through the using directives. If any of them add new +- /* First, go through the using directives. If any of them add new ++ /* Go through the using directives. If any of them add new names to the namespace we're searching in, see if we can find a -@@ -346,15 +407,60 @@ cp_lookup_symbol_namespace (const char *namespace, + match by applying them. */ + +@@ -346,39 +410,65 @@ cp_lookup_symbol_namespace (const char *namespace, current != NULL; current = current->next) { - if (strcmp (namespace, current->import_dest) == 0) + int current_line = find_pc_line (get_frame_pc (get_current_frame ()), 0).line; + -+ if (strcmp (namespace, current->import_dest) == 0 && current->line_number < current_line) ++ /* If the import destination is the current scope or one of its ancestors then ++ it is applicable. */ ++ if (strncmp (scope, current->import_dest, strlen(current->import_dest)) == 0 && current->line_number < current_line ) { - sym = cp_lookup_symbol_namespace (current->import_src, - name, @@ -1959,7 +1967,6 @@ index d2d8f2e..3166818 100644 - block, - domain); - if (sym != NULL) -+ + /* If there is an import of a single declaration, compare the imported + declaration with the sought out name. If there is a match pass + current->import_src as NAMESPACE to direct the search towards the @@ -1991,7 +1998,7 @@ index d2d8f2e..3166818 100644 + sought name. Pass current->inner as the NAME to direct the + search towards the aliased namespace */ + { -+ sym = cp_lookup_symbol_namespace (namespace, ++ sym = cp_lookup_symbol_namespace (scope, + current->import_src, + block, + domain, @@ -2012,32 +2019,32 @@ index d2d8f2e..3166818 100644 } } -@@ -362,10 +468,11 @@ cp_lookup_symbol_namespace (const char *namespace, - that are still applicable; so let's see if we've got a match - using the current namespace. */ - +- /* We didn't find anything by applying any of the using directives +- that are still applicable; so let's see if we've got a match +- using the current namespace. */ +- - if (namespace[0] == '\0') -+ if (namespace[0] == '\0' && !declaration_only) - { +- { - return lookup_symbol_file (name, linkage_name, block, - domain, 0); -+ sym = lookup_symbol_file (name, block, domain, -+ cp_is_anonymous (namespace)); -+ return sym; - } - else - { -@@ -374,8 +481,7 @@ cp_lookup_symbol_namespace (const char *namespace, - strcpy (concatenated_name, namespace); - strcat (concatenated_name, "::"); - strcat (concatenated_name, name); +- } +- else +- { +- char *concatenated_name +- = alloca (strlen (namespace) + 2 + strlen (name) + 1); +- strcpy (concatenated_name, namespace); +- strcat (concatenated_name, "::"); +- strcat (concatenated_name, name); - sym = lookup_symbol_file (concatenated_name, linkage_name, - block, domain, -+ sym = lookup_symbol_file (concatenated_name, block, domain, - cp_is_anonymous (namespace)); - return sym; - } -@@ -388,14 +494,13 @@ cp_lookup_symbol_namespace (const char *namespace, +- cp_is_anonymous (namespace)); +- return sym; +- } ++ return NULL; + } + + /* Look up NAME in BLOCK's static block and in global blocks. If +@@ -388,17 +478,15 @@ cp_lookup_symbol_namespace (const char *namespace, static struct symbol * lookup_symbol_file (const char *name, @@ -2052,8 +2059,11 @@ index d2d8f2e..3166818 100644 + sym = lookup_symbol_static (name, block, domain); if (sym != NULL) return sym; - -@@ -408,12 +513,11 @@ lookup_symbol_file (const char *name, +- + if (anonymous_namespace) + { + /* Symbols defined in anonymous namespaces have external linkage +@@ -408,12 +496,11 @@ lookup_symbol_file (const char *name, const struct block *global_block = block_global_block (block); if (global_block != NULL) @@ -2068,7 +2078,15 @@ index d2d8f2e..3166818 100644 } if (sym != NULL) -@@ -463,9 +567,8 @@ cp_lookup_nested_type (struct type *parent_type, +@@ -434,6 +521,7 @@ lookup_symbol_file (const char *name, + sym = lookup_possible_namespace_symbol (name); + if (sym != NULL) + return sym; ++ + } + + return NULL; +@@ -463,9 +551,8 @@ cp_lookup_nested_type (struct type *parent_type, const char *parent_name = TYPE_TAG_NAME (parent_type); struct symbol *sym = cp_lookup_symbol_namespace (parent_name, nested_name, @@ -2079,7 +2097,7 @@ index d2d8f2e..3166818 100644 if (sym == NULL || SYMBOL_CLASS (sym) != LOC_TYPEDEF) return NULL; else -@@ -709,7 +812,7 @@ check_one_possible_namespace_symbol (const char *name, int len, +@@ -709,7 +796,7 @@ check_one_possible_namespace_symbol (const char *name, int len, memcpy (name_copy, name, len); name_copy[len] = '\0'; @@ -2088,7 +2106,7 @@ index d2d8f2e..3166818 100644 if (sym == NULL) { -@@ -749,7 +852,7 @@ lookup_possible_namespace_symbol (const char *name) +@@ -749,7 +836,7 @@ lookup_possible_namespace_symbol (const char *name) struct symbol *sym; sym = lookup_block_symbol (get_possible_namespace_block (objfile), @@ -2219,7 +2237,7 @@ index f12d785..ca10007 100644 _initialize_cp_support (void) { diff --git a/gdb/cp-support.h b/gdb/cp-support.h -index b5a5c5f..0381686 100644 +index b5a5c5f..f126bed 100644 --- a/gdb/cp-support.h +++ b/gdb/cp-support.h @@ -38,14 +38,29 @@ struct demangle_component; @@ -2288,7 +2306,7 @@ index b5a5c5f..0381686 100644 struct using_direct *next); extern void cp_initialize_namespace (void); -@@ -97,15 +121,27 @@ extern void cp_set_block_scope (const struct symbol *symbol, +@@ -97,15 +121,32 @@ extern void cp_set_block_scope (const struct symbol *symbol, extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol); extern struct symbol *cp_lookup_symbol_nonlocal (const char *name, @@ -2303,11 +2321,16 @@ index b5a5c5f..0381686 100644 + int scope_len, + int declaration_only); + -+extern struct symbol *cp_lookup_symbol_namespace_incremental (const char *namespace, -+ const char *name, -+ const struct block *block, -+ const domain_enum domain, -+ int declaration_only); ++extern struct symbol* cp_lookup_symbol_namespace_incremental (const char *scope, ++ const char *name, ++ const struct block *block, ++ const domain_enum domain); ++ ++struct symbol *cp_lookup_symbol_imports (const char *scope, ++ const char *name, ++ const struct block *block, ++ const domain_enum domain, ++ int declaration_only); + extern struct symbol *cp_lookup_symbol_namespace (const char *namespace, - const char *name, @@ -2334,7 +2357,7 @@ index 7cb016d..bb9e35a 100644 default_symfile_offsets, /* sym_offsets: parse user's offsets to internal form */ diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo -index fab05fc..44cc1f2 100644 +index 4016acc..1042303 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -958,8 +958,10 @@ Connect to process ID @var{number}, as with the @code{attach} command. @@ -2367,7 +2390,7 @@ index fab05fc..44cc1f2 100644 @c resolve the situation of these eventually @item -tui @cindex @code{--tui} -@@ -18427,7 +18439,7 @@ command: +@@ -18465,7 +18477,7 @@ command: @table @code @kindex source @cindex execute commands from a file @@ -2376,7 +2399,7 @@ index fab05fc..44cc1f2 100644 Execute the command file @var{filename}. @end table -@@ -18444,6 +18456,11 @@ If @code{-v}, for verbose mode, is given then @value{GDBN} displays +@@ -18482,6 +18494,11 @@ If @code{-v}, for verbose mode, is given then @value{GDBN} displays each command as it is executed. The option must be given before @var{filename}, and is interpreted as part of the filename anywhere else. @@ -2388,7 +2411,7 @@ index fab05fc..44cc1f2 100644 Commands that would ask for confirmation if used interactively proceed without asking when used in a command file. Many @value{GDBN} commands that normally print messages to say what they are doing omit the messages -@@ -18705,8 +18722,6 @@ containing @code{end}. For example: +@@ -18743,8 +18760,6 @@ containing @code{end}. For example: @smallexample (@value{GDBP}) python @@ -2397,7 +2420,7 @@ index fab05fc..44cc1f2 100644 >print 23 >end 23 -@@ -18719,6 +18734,14 @@ in a Python script. This can be controlled using @code{maint set +@@ -18757,6 +18772,14 @@ in a Python script. This can be controlled using @code{maint set python print-stack}: if @code{on}, the default, then Python stack printing is enabled; if @code{off}, then Python stack printing is disabled. @@ -2412,7 +2435,7 @@ index fab05fc..44cc1f2 100644 @end table @node Python API -@@ -18726,6 +18749,14 @@ disabled. +@@ -18764,6 +18787,14 @@ disabled. @cindex python api @cindex programming in python @@ -2427,7 +2450,7 @@ index fab05fc..44cc1f2 100644 @cindex python stdout @cindex python pagination At startup, @value{GDBN} overrides Python's @code{sys.stdout} and -@@ -18738,13 +18769,17 @@ situation, a Python @code{KeyboardInterrupt} exception is thrown. +@@ -18776,13 +18807,17 @@ situation, a Python @code{KeyboardInterrupt} exception is thrown. * Basic Python:: Basic Python Functions. * Exception Handling:: * Auto-loading:: Automatically loading Python code. @@ -2446,7 +2469,7 @@ index fab05fc..44cc1f2 100644 * Frames In Python:: Acessing inferior stack frames from Python. @end menu -@@ -18771,6 +18806,12 @@ command as having originated from the user invoking it interactively. +@@ -18809,6 +18844,12 @@ command as having originated from the user invoking it interactively. It must be a boolean value. If omitted, it defaults to @code{False}. @end defun @@ -2459,7 +2482,7 @@ index fab05fc..44cc1f2 100644 @findex gdb.parameter @defun parameter parameter Return the value of a @value{GDBN} parameter. @var{parameter} is a -@@ -18787,6 +18828,7 @@ a Python value of the appropriate type, and returned. +@@ -18825,6 +18866,7 @@ a Python value of the appropriate type, and returned. @defun history number Return a value from @value{GDBN}'s value history (@pxref{Value History}). @var{number} indicates which history element to return. @@ -2467,7 +2490,7 @@ index fab05fc..44cc1f2 100644 If @var{number} is negative, then @value{GDBN} will take its absolute value and count backward from the last element (i.e., the most recent element) to find the value to return. If @var{number} is zero, then @value{GDBN} will -@@ -18798,6 +18840,28 @@ If no exception is raised, the return value is always an instance of +@@ -18836,6 +18878,28 @@ If no exception is raised, the return value is always an instance of @code{gdb.Value} (@pxref{Values From Inferior}). @end defun @@ -2496,7 +2519,7 @@ index fab05fc..44cc1f2 100644 @findex gdb.write @defun write string Print a string to @value{GDBN}'s paginated standard output stream. -@@ -18812,6 +18876,11 @@ Flush @value{GDBN}'s paginated standard output stream. Flushing +@@ -18850,6 +18914,11 @@ Flush @value{GDBN}'s paginated standard output stream. Flushing function. @end defun @@ -2508,7 +2531,7 @@ index fab05fc..44cc1f2 100644 @node Exception Handling @subsubsection Exception Handling @cindex python exceptions -@@ -18948,6 +19017,13 @@ The type of this @code{gdb.Value}. The value of this attribute is a +@@ -18986,6 +19055,13 @@ The type of this @code{gdb.Value}. The value of this attribute is a The following methods are provided: @table @code @@ -2522,7 +2545,7 @@ index fab05fc..44cc1f2 100644 @defmethod Value dereference For pointer data types, this method returns a new @code{gdb.Value} object whose contents is the object pointed to by the pointer. For example, if -@@ -19019,6 +19095,9 @@ module: +@@ -19057,6 +19133,9 @@ module: This function looks up a type by name. @var{name} is the name of the type to look up. It must be a string. @@ -2532,7 +2555,7 @@ index fab05fc..44cc1f2 100644 Ordinarily, this function will return an instance of @code{gdb.Type}. If the named type cannot be found, it will throw an exception. @end defun -@@ -19071,6 +19150,12 @@ This is @code{True} if the field is artificial, usually meaning that +@@ -19109,6 +19188,12 @@ This is @code{True} if the field is artificial, usually meaning that it was provided by the compiler and not the user. This attribute is always provided, and is @code{False} if the field is not artificial. @@ -2545,7 +2568,7 @@ index fab05fc..44cc1f2 100644 @item bitsize If the field is packed, or is a bitfield, then this will have a non-zero value, which is the size of the field in bits. Otherwise, -@@ -19123,7 +19208,7 @@ If the type does not have a target, this method will throw an +@@ -19161,7 +19246,7 @@ If the type does not have a target, this method will throw an exception. @end defmethod @@ -2554,7 +2577,7 @@ index fab05fc..44cc1f2 100644 If this @code{gdb.Type} is an instantiation of a template, this will return a new @code{gdb.Type} which represents the type of the @var{n}th template argument. -@@ -19131,7 +19216,8 @@ return a new @code{gdb.Type} which represents the type of the +@@ -19169,7 +19254,8 @@ return a new @code{gdb.Type} which represents the type of the If this @code{gdb.Type} is not a template type, this will throw an exception. Ordinarily, only C@t{++} code will have template types. @@ -2564,7 +2587,7 @@ index fab05fc..44cc1f2 100644 @end defmethod @end table -@@ -19485,6 +19571,121 @@ import gdb.libstdcxx.v6 +@@ -19523,6 +19609,121 @@ import gdb.libstdcxx.v6 gdb.libstdcxx.v6.register_printers (gdb.current_objfile ()) @end smallexample @@ -2686,7 +2709,7 @@ index fab05fc..44cc1f2 100644 @node Commands In Python @subsubsection Commands In Python -@@ -19737,6 +19938,135 @@ registration of the command with @value{GDBN}. Depending on how the +@@ -19775,6 +19976,135 @@ registration of the command with @value{GDBN}. Depending on how the Python code is read into @value{GDBN}, you may need to import the @code{gdb} module explicitly. @@ -2822,7 +2845,7 @@ index fab05fc..44cc1f2 100644 @node Functions In Python @subsubsection Writing new convenience functions -@@ -19841,6 +20171,82 @@ which is used to format the value. @xref{Pretty Printing}, for more +@@ -19879,6 +20209,82 @@ which is used to format the value. @xref{Pretty Printing}, for more information. @end defivar @@ -2905,7 +2928,7 @@ index fab05fc..44cc1f2 100644 @node Frames In Python @subsubsection Acessing inferior stack frames from Python. -@@ -19905,6 +20311,14 @@ function to a string. +@@ -19943,6 +20349,14 @@ function to a string. Returns the frame's resume address. @end defmethod @@ -2920,7 +2943,7 @@ index fab05fc..44cc1f2 100644 @defmethod Frame older Return the frame that called this frame. @end defmethod -@@ -19913,10 +20327,18 @@ Return the frame that called this frame. +@@ -19951,10 +20365,18 @@ Return the frame that called this frame. Return the frame called by this frame. @end defmethod @@ -2939,7 +2962,7 @@ index fab05fc..44cc1f2 100644 @end table @node Interpreters -@@ -23238,6 +23660,8 @@ access this functionality: +@@ -23306,6 +23728,8 @@ access this functionality: @item @strong{Operation} @tab @strong{Description} @@ -2948,7 +2971,16 @@ index fab05fc..44cc1f2 100644 @item @code{-var-create} @tab create a variable object @item @code{-var-delete} -@@ -23273,6 +23697,23 @@ how it can be used. +@@ -23334,6 +23758,8 @@ access this functionality: + @tab update the variable and its children + @item @code{-var-set-frozen} + @tab set frozeness attribute ++@item @code{-var-set-update-range} ++@tab set range of children to display on update + @end multitable + + In the next subsection we describe each operation in detail and suggest +@@ -23341,6 +23767,23 @@ how it can be used. @subheading Description And Use of Operations on Variable Objects @@ -2972,7 +3004,7 @@ index fab05fc..44cc1f2 100644 @subheading The @code{-var-create} Command @findex -var-create -@@ -23405,7 +23846,7 @@ Returns the number of children of a variable object @var{name}: +@@ -23473,7 +23916,7 @@ Returns the number of children of a variable object @var{name}: @subsubheading Synopsis @smallexample @@ -2981,7 +3013,7 @@ index fab05fc..44cc1f2 100644 @end smallexample @anchor{-var-list-children} -@@ -23418,6 +23859,14 @@ values; and if it is 2 or @code{--simple-values} print the name and +@@ -23486,6 +23929,12 @@ values; and if it is 2 or @code{--simple-values} print the name and value for simple data types and just the name for arrays, structures and unions. @@ -2989,24 +3021,69 @@ index fab05fc..44cc1f2 100644 +to report. If @var{from} or @var{to} is less than zero, the range is +reset and all children will be reported. Otherwise, children starting +at @var{from} (zero-based) and ending just before @var{to} will be -+reported. The selected range is sticky; future calls to -+@code{-var-update} or @code{-var-list-children} will use any -+previously set range. ++reported. + For each child the following results are returned: @table @var -@@ -23449,6 +23898,10 @@ Otherwise this result is not present. - - @item frozen +@@ -23519,6 +23968,14 @@ Otherwise this result is not present. If the variable object is frozen, this variable will be present with a value of 1. + @end table + ++The result may have its own attributes: + ++@table @var +@item has_more +This is an integer attribute which is nonzero if there are children +remaining after the end of the selected range. - @end table - ++@end table ++ @subsubheading Example + + @smallexample +@@ -23700,6 +24157,9 @@ With the @samp{*} parameter, if a variable object is bound to a + currently running thread, it will not be updated, without any + diagnostic. + ++If @code{-var-set-update-range} was previously used on a varobj, then ++only the selected range of children will be reported. ++ + @subsubheading Example + + @smallexample +@@ -23767,6 +24227,32 @@ Unfreezing a variable does not update it, only subsequent + (gdb) + @end smallexample + ++@subheading The @code{-var-set-update-range} command ++@findex -var-set-update-range ++@anchor{-var-set-update-range} ++ ++@subsubheading Synopsis ++ ++@smallexample ++ -var-set-update-range @var{name} @var{from} @var{to} ++@end smallexample ++ ++Set the range of children to be returned by future invocations of ++@code{-var-update}. ++ ++@var{from} and @var{to} indicate the range of children to report. If ++@var{from} or @var{to} is less than zero, the range is reset and all ++children will be reported. Otherwise, children starting at @var{from} ++(zero-based) and ending just before @var{to} will be reported. ++ ++@subsubheading Example ++ ++@smallexample ++(gdb) ++-var-set-update-range V 1 2 ++^done ++@end smallexample ++ + @subheading The @code{-var-set-visualizer} command + @findex -var-set-visualizer + @anchor{-var-set-visualizer} diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo index b1c0452..da24b98 100644 --- a/gdb/doc/gdbint.texinfo @@ -3169,7 +3246,7 @@ index 4984f31..4bbbe4e 100644 This observer is used for internal testing. Do not use. See testsuite/gdb.gdb/observer.exp. diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c -index c620067..6c4faf1 100644 +index 0f6da40..fc70309 100644 --- a/gdb/dwarf2-frame.c +++ b/gdb/dwarf2-frame.c @@ -38,6 +38,7 @@ @@ -3180,7 +3257,7 @@ index c620067..6c4faf1 100644 struct comp_unit; -@@ -305,6 +306,13 @@ no_get_frame_base (void *baton, gdb_byte **start, size_t *length) +@@ -310,6 +311,13 @@ no_get_frame_base (void *baton, gdb_byte **start, size_t *length) } static CORE_ADDR @@ -3194,7 +3271,18 @@ index c620067..6c4faf1 100644 no_get_tls_address (void *baton, CORE_ADDR offset) { internal_error (__FILE__, __LINE__, -@@ -355,14 +363,16 @@ execute_stack_op (gdb_byte *exp, ULONGEST len, int addr_size, +@@ -352,24 +360,29 @@ execute_stack_op (gdb_byte *exp, ULONGEST len, int addr_size, + { + struct dwarf_expr_context *ctx; + CORE_ADDR result; ++ struct cleanup *old_chain; + + ctx = new_dwarf_expr_context (); ++ old_chain = make_cleanup_free_dwarf_expr_context (ctx); ++ + ctx->gdbarch = get_frame_arch (this_frame); + ctx->addr_size = addr_size; + ctx->baton = this_frame; ctx->read_reg = read_reg; ctx->read_mem = read_mem; ctx->get_frame_base = no_get_frame_base; @@ -3210,9 +3298,12 @@ index c620067..6c4faf1 100644 result = read_reg (this_frame, result); + /* FIXME */ - free_dwarf_expr_context (ctx); +- free_dwarf_expr_context (ctx); ++ do_cleanups (old_chain); -@@ -1242,6 +1252,14 @@ dwarf2_frame_base_sniffer (struct frame_info *this_frame) + return result; + } +@@ -1247,6 +1260,14 @@ dwarf2_frame_base_sniffer (struct frame_info *this_frame) return NULL; } @@ -3220,16 +3311,16 @@ index c620067..6c4faf1 100644 +CORE_ADDR +dwarf2_frame_cfa (struct frame_info *this_frame) +{ -+ if (! frame_base_is (this_frame, &dwarf2_frame_base)) ++ if (! frame_unwinder_is (this_frame, &dwarf2_frame_unwind)) + error (_("can't compute CFA for this frame")); -+ return get_frame_base_address (this_frame); ++ return get_frame_base (this_frame); +} const struct objfile_data *dwarf2_frame_objfile_data; -@@ -1504,6 +1522,14 @@ dwarf2_frame_find_fde (CORE_ADDR *pc) - struct dwarf2_fde *fde; +@@ -1536,6 +1557,14 @@ dwarf2_frame_find_fde (CORE_ADDR *pc) CORE_ADDR offset; + CORE_ADDR seek_pc; + if (objfile->quick_addrmap) + { @@ -3239,8 +3330,8 @@ index c620067..6c4faf1 100644 + /* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info? */ + require_partial_symbols (objfile); + - fde = objfile_data (objfile, dwarf2_frame_objfile_data); - if (fde == NULL) + fde_table = objfile_data (objfile, dwarf2_frame_objfile_data); + if (fde_table == NULL) continue; diff --git a/gdb/dwarf2-frame.h b/gdb/dwarf2-frame.h index b203661..dd03d59 100644 @@ -3256,10 +3347,33 @@ index b203661..dd03d59 100644 + #endif /* dwarf2-frame.h */ diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c -index 8dbf976..aec7b92 100644 +index 8dbf976..228eae7 100644 --- a/gdb/dwarf2expr.c +++ b/gdb/dwarf2expr.c -@@ -109,8 +109,7 @@ dwarf_expr_fetch (struct dwarf_expr_context *ctx, int n) +@@ -61,6 +61,22 @@ free_dwarf_expr_context (struct dwarf_expr_context *ctx) + xfree (ctx); + } + ++/* Helper for make_cleanup_free_dwarf_expr_context. */ ++ ++static void ++free_dwarf_expr_context_cleanup (void *arg) ++{ ++ free_dwarf_expr_context (arg); ++} ++ ++/* Return a cleanup that calls free_dwarf_expr_context. */ ++ ++struct cleanup * ++make_cleanup_free_dwarf_expr_context (struct dwarf_expr_context *ctx) ++{ ++ return make_cleanup (free_dwarf_expr_context_cleanup, ctx); ++} ++ + /* Expand the memory allocated to CTX's stack to contain at least + NEED more elements than are currently used. */ + +@@ -109,8 +125,7 @@ dwarf_expr_fetch (struct dwarf_expr_context *ctx, int n) /* Add a new piece to CTX's piece list. */ static void @@ -3269,7 +3383,7 @@ index 8dbf976..aec7b92 100644 { struct dwarf_expr_piece *p; -@@ -125,9 +124,15 @@ add_piece (struct dwarf_expr_context *ctx, +@@ -125,9 +140,15 @@ add_piece (struct dwarf_expr_context *ctx, * sizeof (struct dwarf_expr_piece)); p = &ctx->pieces[ctx->num_pieces - 1]; @@ -3287,7 +3401,7 @@ index 8dbf976..aec7b92 100644 } /* Evaluate the expression at ADDR (LEN bytes long) using the context -@@ -271,6 +276,21 @@ signed_address_type (struct gdbarch *gdbarch, int addr_size) +@@ -271,6 +292,21 @@ signed_address_type (struct gdbarch *gdbarch, int addr_size) } } @@ -3309,7 +3423,7 @@ index 8dbf976..aec7b92 100644 /* The engine for the expression evaluator. Using the context in CTX, evaluate the expression between OP_PTR and OP_END. */ -@@ -279,8 +299,7 @@ execute_stack_op (struct dwarf_expr_context *ctx, +@@ -279,8 +315,7 @@ execute_stack_op (struct dwarf_expr_context *ctx, gdb_byte *op_ptr, gdb_byte *op_end) { enum bfd_endian byte_order = gdbarch_byte_order (ctx->gdbarch); @@ -3319,7 +3433,7 @@ index 8dbf976..aec7b92 100644 ctx->initialized = 1; /* Default is initialized. */ if (ctx->recursion_depth > ctx->max_recursion_depth) -@@ -420,20 +439,36 @@ execute_stack_op (struct dwarf_expr_context *ctx, +@@ -420,20 +455,36 @@ execute_stack_op (struct dwarf_expr_context *ctx, "used either alone or in conjuction with DW_OP_piece.")); result = op - DW_OP_reg0; @@ -3362,7 +3476,7 @@ index 8dbf976..aec7b92 100644 case DW_OP_breg0: case DW_OP_breg1: case DW_OP_breg2: -@@ -498,11 +533,12 @@ execute_stack_op (struct dwarf_expr_context *ctx, +@@ -498,11 +549,12 @@ execute_stack_op (struct dwarf_expr_context *ctx, (ctx->get_frame_base) (ctx->baton, &datastart, &datalen); dwarf_expr_eval (ctx, datastart, datalen); result = dwarf_expr_fetch (ctx, 0); @@ -3377,7 +3491,7 @@ index 8dbf976..aec7b92 100644 } break; case DW_OP_dup: -@@ -700,6 +736,10 @@ execute_stack_op (struct dwarf_expr_context *ctx, +@@ -700,6 +752,10 @@ execute_stack_op (struct dwarf_expr_context *ctx, } break; @@ -3388,7 +3502,7 @@ index 8dbf976..aec7b92 100644 case DW_OP_GNU_push_tls_address: /* Variable is at a constant offset in the thread-local storage block into the objfile for the current thread and -@@ -738,12 +778,13 @@ execute_stack_op (struct dwarf_expr_context *ctx, +@@ -738,12 +794,13 @@ execute_stack_op (struct dwarf_expr_context *ctx, /* Record the piece. */ op_ptr = read_uleb128 (op_ptr, op_end, &size); @@ -3407,7 +3521,7 @@ index 8dbf976..aec7b92 100644 } goto no_push; -@@ -755,6 +796,13 @@ execute_stack_op (struct dwarf_expr_context *ctx, +@@ -755,6 +812,13 @@ execute_stack_op (struct dwarf_expr_context *ctx, ctx->initialized = 0; goto no_push; @@ -3422,7 +3536,7 @@ index 8dbf976..aec7b92 100644 error (_("Unhandled dwarf expression opcode 0x%x"), op); } diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h -index 7047922..232208d 100644 +index 7047922..597c2de 100644 --- a/gdb/dwarf2expr.h +++ b/gdb/dwarf2expr.h @@ -23,6 +23,19 @@ @@ -3544,8 +3658,17 @@ index 7047922..232208d 100644 /* The length of the piece, in bytes. */ ULONGEST size; +@@ -131,6 +159,8 @@ struct dwarf_expr_piece + + struct dwarf_expr_context *new_dwarf_expr_context (void); + void free_dwarf_expr_context (struct dwarf_expr_context *ctx); ++struct cleanup * ++ make_cleanup_free_dwarf_expr_context (struct dwarf_expr_context *ctx); + + void dwarf_expr_push (struct dwarf_expr_context *ctx, CORE_ADDR value); + void dwarf_expr_pop (struct dwarf_expr_context *ctx); diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c -index 071b5ac..07bb8ba 100644 +index 071b5ac..7b2e488 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -36,6 +36,7 @@ @@ -3927,7 +4050,20 @@ index 071b5ac..07bb8ba 100644 /* Thread-local accesses do require a frame. */ static CORE_ADDR needs_frame_tls_address (void *baton, CORE_ADDR offset) -@@ -356,11 +567,12 @@ dwarf2_loc_desc_needs_frame (gdb_byte *data, unsigned short size, +@@ -346,21 +557,25 @@ dwarf2_loc_desc_needs_frame (gdb_byte *data, unsigned short size, + struct needs_frame_baton baton; + struct dwarf_expr_context *ctx; + int in_reg; ++ struct cleanup *old_chain; + + baton.needs_frame = 0; + + ctx = new_dwarf_expr_context (); ++ old_chain = make_cleanup_free_dwarf_expr_context (ctx); ++ + ctx->gdbarch = get_objfile_arch (dwarf2_per_cu_objfile (per_cu)); + ctx->addr_size = dwarf2_per_cu_addr_size (per_cu); + ctx->baton = &baton; ctx->read_reg = needs_frame_read_reg; ctx->read_mem = needs_frame_read_mem; ctx->get_frame_base = needs_frame_frame_base; @@ -3941,7 +4077,7 @@ index 071b5ac..07bb8ba 100644 if (ctx->num_pieces > 0) { -@@ -369,7 +581,7 @@ dwarf2_loc_desc_needs_frame (gdb_byte *data, unsigned short size, +@@ -369,11 +584,11 @@ dwarf2_loc_desc_needs_frame (gdb_byte *data, unsigned short size, /* If the location has several pieces, and any of them are in registers, then we will need a frame to fetch them from. */ for (i = 0; i < ctx->num_pieces; i++) @@ -3950,7 +4086,12 @@ index 071b5ac..07bb8ba 100644 in_reg = 1; } -@@ -601,7 +813,7 @@ static int +- free_dwarf_expr_context (ctx); ++ do_cleanups (old_chain); + + return baton.needs_frame || in_reg; + } +@@ -601,7 +816,7 @@ static int loclist_describe_location (struct symbol *symbol, struct ui_file *stream) { /* FIXME: Could print the entire list of locations. */ @@ -3959,7 +4100,7 @@ index 071b5ac..07bb8ba 100644 return 1; } -@@ -617,16 +829,56 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, +@@ -617,16 +832,56 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, data = find_location_expression (dlbaton, &size, ax->scope); if (data == NULL) @@ -4036,7 +4177,7 @@ index 0bfcfca..01018d6 100644 #endif /* dwarf2loc.h */ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c -index 445bab8..be2dc2a 100644 +index 445bab8..65556c9 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1,8 +1,7 @@ @@ -4178,23 +4319,17 @@ index 445bab8..be2dc2a 100644 static void read_module (struct die_info *die, struct dwarf2_cu *cu); static void read_import_statement (struct die_info *die, struct dwarf2_cu *); -@@ -1078,7 +1101,14 @@ static int is_ref_attr (struct attribute *); +@@ -1078,7 +1101,8 @@ static int is_ref_attr (struct attribute *); static unsigned int dwarf2_get_ref_die_offset (struct attribute *); -static int dwarf2_get_attr_constant_value (struct attribute *, int); -+enum get_attr_constant_value -+ { -+ dwarf2_attr_unknown, -+ dwarf2_attr_const, -+ dwarf2_attr_block -+ }; -+static enum get_attr_constant_value get_attr_constant_value -+ (struct attribute *attr, int *val_return); ++static CORE_ADDR dwarf2_get_attr_constant_value (struct attribute *, CORE_ADDR, ++ struct dwarf2_cu *); static struct die_info *follow_die_ref_or_sig (struct die_info *, struct attribute *, -@@ -1150,6 +1180,9 @@ static void age_cached_comp_units (void); +@@ -1150,6 +1174,9 @@ static void age_cached_comp_units (void); static void free_one_cached_comp_unit (void *); @@ -4204,7 +4339,7 @@ index 445bab8..be2dc2a 100644 static struct type *set_die_type (struct die_info *, struct type *, struct dwarf2_cu *); -@@ -1169,22 +1202,31 @@ static void dwarf2_clear_marks (struct dwarf2_per_cu_data *); +@@ -1169,22 +1196,31 @@ static void dwarf2_clear_marks (struct dwarf2_per_cu_data *); static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu); @@ -4245,7 +4380,7 @@ index 445bab8..be2dc2a 100644 } /* When loading sections, we can either look for ".", or for -@@ -1277,10 +1319,13 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr) +@@ -1277,10 +1313,13 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr) } /* Decompress a section that was compressed using zlib. Store the @@ -4261,7 +4396,7 @@ index 445bab8..be2dc2a 100644 gdb_byte **outbuf, bfd_size_type *outsize) { bfd *abfd = objfile->obfd; -@@ -1297,6 +1342,7 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, +@@ -1297,6 +1336,7 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, z_stream strm; int rc; int header_size = 12; @@ -4269,7 +4404,7 @@ index 445bab8..be2dc2a 100644 if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0 || bfd_bread (compressed_buffer, compressed_size, abfd) != compressed_size) -@@ -1326,8 +1372,13 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, +@@ -1326,8 +1366,13 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, strm.avail_in = compressed_size - header_size; strm.next_in = (Bytef*) compressed_buffer + header_size; strm.avail_out = uncompressed_size; @@ -4285,7 +4420,7 @@ index 445bab8..be2dc2a 100644 rc = inflateInit (&strm); while (strm.avail_in > 0) { -@@ -1348,26 +1399,136 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, +@@ -1348,26 +1393,136 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, error (_("Dwarf Error: concluding DWARF uncompression in '%s': %d"), bfd_get_filename (abfd), rc); @@ -4427,7 +4562,7 @@ index 445bab8..be2dc2a 100644 if (info->asection == NULL || info->size == 0) return; -@@ -1380,7 +1541,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1380,7 +1535,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) /* Upon decompression, update the buffer and its size. */ if (strncmp (header, "ZLIB", sizeof (header)) == 0) { @@ -4436,7 +4571,7 @@ index 445bab8..be2dc2a 100644 &info->size); return; } -@@ -1403,7 +1564,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1403,7 +1558,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) if (retbuf != MAP_FAILED) { @@ -4445,7 +4580,7 @@ index 445bab8..be2dc2a 100644 info->buffer = retbuf + (sectp->filepos & (pagesize - 1)) ; return; } -@@ -1411,8 +1572,15 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1411,8 +1566,15 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) #endif /* If we get here, we are a normal, not-compressed section. */ @@ -4463,7 +4598,7 @@ index 445bab8..be2dc2a 100644 /* When debugging .o files, we may need to apply relocations; see http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html . -@@ -1421,6 +1589,8 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1421,6 +1583,8 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) retbuf = symfile_relocate_debug_section (abfd, sectp, buf); if (retbuf != NULL) { @@ -4472,7 +4607,7 @@ index 445bab8..be2dc2a 100644 info->buffer = retbuf; return; } -@@ -1429,6 +1599,19 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1429,6 +1593,19 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) || bfd_bread (buf, info->size, abfd) != info->size) error (_("Dwarf Error: Can't read DWARF data from '%s'"), bfd_get_filename (abfd)); @@ -4492,7 +4627,7 @@ index 445bab8..be2dc2a 100644 } /* Fill in SECTP, BUFP and SIZEP with section info, given OBJFILE and -@@ -1666,11 +1849,7 @@ dwarf2_create_include_psymtab (char *name, struct partial_symtab *pst, +@@ -1666,11 +1843,7 @@ dwarf2_create_include_psymtab (char *name, struct partial_symtab *pst, /* Read the Line Number Program data and extract the list of files included by the source file represented by PST. Build an include @@ -4505,8 +4640,8 @@ index 445bab8..be2dc2a 100644 static void dwarf2_build_include_psymtabs (struct dwarf2_cu *cu, -@@ -1690,6 +1869,37 @@ dwarf2_build_include_psymtabs (struct dwarf2_cu *cu, - free_line_header (lh); +@@ -1812,6 +1985,37 @@ lookup_signatured_type (struct objfile *objfile, ULONGEST sig) + return entry; } +/* Find the base address of the compilation unit for range lists and @@ -4540,20 +4675,10 @@ index 445bab8..be2dc2a 100644 + } +} + - static hashval_t - hash_type_signature (const void *item) - { -@@ -1812,8 +2022,7 @@ lookup_signatured_type (struct objfile *objfile, ULONGEST sig) - return entry; - } - --/* Subroutine of process_type_comp_unit and dwarf2_build_psymtabs_hard -- to combine the common parts. -+/* Subroutine of dwarf2_build_psymtabs_hard to simplify it. + /* Subroutine of process_type_comp_unit and dwarf2_build_psymtabs_hard + to combine the common parts. Process a compilation unit for a psymtab. - BUFFER is a pointer to the beginning of the dwarf section buffer, - either .debug_info or debug_types. -@@ -1878,7 +2087,7 @@ process_psymtab_comp_unit (struct objfile *objfile, +@@ -1878,7 +2082,7 @@ process_psymtab_comp_unit (struct objfile *objfile, } /* Set the language we're debugging. */ @@ -4562,7 +4687,7 @@ index 445bab8..be2dc2a 100644 /* Allocate a new partial symbol table structure. */ pst = start_psymtab_common (objfile, objfile->section_offsets, -@@ -1929,8 +2138,8 @@ process_psymtab_comp_unit (struct objfile *objfile, +@@ -1929,8 +2133,8 @@ process_psymtab_comp_unit (struct objfile *objfile, } else if (comp_unit_die.has_pc_info && comp_unit_die.lowpc < comp_unit_die.highpc) @@ -4573,7 +4698,7 @@ index 445bab8..be2dc2a 100644 addrmap_set_empty (objfile->psymtabs_addrmap, comp_unit_die.lowpc + baseaddr, comp_unit_die.highpc + baseaddr - 1, pst); -@@ -2361,7 +2570,7 @@ partial_die_parent_scope (struct partial_die_info *pdi, +@@ -2361,7 +2565,7 @@ partial_die_parent_scope (struct partial_die_info *pdi, ignoring them. */ complaint (&symfile_complaints, _("unhandled containing DIE tag %d for DIE at %d"), @@ -4582,7 +4707,7 @@ index 445bab8..be2dc2a 100644 parent->scope = grandparent_scope; } -@@ -2376,12 +2585,22 @@ partial_die_full_name (struct partial_die_info *pdi, +@@ -2376,12 +2580,22 @@ partial_die_full_name (struct partial_die_info *pdi, struct dwarf2_cu *cu) { char *parent_scope; @@ -4609,7 +4734,7 @@ index 445bab8..be2dc2a 100644 } static void -@@ -2397,12 +2616,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) +@@ -2397,12 +2611,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); @@ -4625,7 +4750,7 @@ index 445bab8..be2dc2a 100644 if (actual_name == NULL) actual_name = pdi->name; -@@ -2534,22 +2750,6 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) +@@ -2534,22 +2745,6 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) break; } @@ -4648,7 +4773,7 @@ index 445bab8..be2dc2a 100644 if (built_actual_name) xfree (actual_name); } -@@ -2559,9 +2759,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) +@@ -2559,9 +2754,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) name listed in the die. */ static int @@ -4660,7 +4785,7 @@ index 445bab8..be2dc2a 100644 { case DW_TAG_namespace: case DW_TAG_typedef: -@@ -2571,7 +2771,23 @@ pdi_needs_namespace (enum dwarf_tag tag) +@@ -2571,7 +2766,23 @@ pdi_needs_namespace (enum dwarf_tag tag) case DW_TAG_union_type: case DW_TAG_enumeration_type: case DW_TAG_enumerator: @@ -4684,7 +4809,7 @@ index 445bab8..be2dc2a 100644 default: return 0; } -@@ -2700,27 +2916,6 @@ guess_structure_name (struct partial_die_info *struct_pdi, +@@ -2700,27 +2911,6 @@ guess_structure_name (struct partial_die_info *struct_pdi, if (real_pdi->die_parent != NULL) return; @@ -4712,7 +4837,7 @@ index 445bab8..be2dc2a 100644 } } -@@ -3170,7 +3365,6 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu) +@@ -3170,7 +3360,6 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu) CORE_ADDR lowpc, highpc; struct symtab *symtab; struct cleanup *back_to; @@ -4720,7 +4845,7 @@ index 445bab8..be2dc2a 100644 CORE_ADDR baseaddr; baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); -@@ -3180,30 +3374,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu) +@@ -3180,30 +3369,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu) cu->list_in_scope = &file_symbols; @@ -4752,7 +4877,7 @@ index 445bab8..be2dc2a 100644 /* Do line number decoding in read_file_scope () */ process_die (cu->dies, cu); -@@ -3234,6 +3405,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu) +@@ -3234,6 +3400,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu) static void process_die (struct die_info *die, struct dwarf2_cu *cu) { @@ -4760,7 +4885,7 @@ index 445bab8..be2dc2a 100644 switch (die->tag) { case DW_TAG_padding: -@@ -3312,42 +3484,69 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) +@@ -3312,42 +3479,69 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) /* Return the fully qualified name of DIE, based on its DW_AT_name. If scope qualifiers are appropriate they will be added. The result will be allocated on the objfile_obstack, or NULL if the DIE does @@ -4852,7 +4977,7 @@ index 445bab8..be2dc2a 100644 static void read_import_statement (struct die_info *die, struct dwarf2_cu *cu) -@@ -3356,9 +3555,15 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) +@@ -3356,9 +3550,15 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) struct die_info *imported_die; const char *imported_name; const char *imported_name_prefix; @@ -4870,7 +4995,7 @@ index 445bab8..be2dc2a 100644 import_attr = dwarf2_attr (die, DW_AT_import, cu); if (import_attr == NULL) { -@@ -3406,29 +3611,45 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) +@@ -3406,29 +3606,45 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) return; } @@ -4929,101 +5054,31 @@ index 445bab8..be2dc2a 100644 } static void -@@ -3677,6 +3898,93 @@ unsigned_int_compar (const void *ap, const void *bp) +@@ -3676,7 +3892,7 @@ unsigned_int_compar (const void *ap, const void *bp) + return (a > b) - (b > a); } - -+static void explore_abstract_origin(struct die_info *die, struct dwarf2_cu *cu, unsigned* die_children_p){ -+ struct attribute *attr; -+ unsigned die_children = *die_children_p; -+ struct die_info *child_die; -+ -+ attr = dwarf2_attr (die, DW_AT_abstract_origin, cu); -+ -+ /* GCC currently uses DW_AT_specification to indicate die inheritence -+ in the case of import statements. The following is to accommodate that */ -+ if(!attr){ -+ attr = dwarf2_attr (die, DW_AT_specification, cu); -+ } -+ -+ if (attr) -+ { -+ /* For the list of CHILD_DIEs. */ -+ unsigned *offsets; -+ unsigned *offsets_end, *offsetp; -+ struct die_info *origin_die, *origin_child_die; -+ struct cleanup *cleanups; -+ -+ origin_die = follow_die_ref (die, attr, &cu); -+ if (die->tag != origin_die->tag) -+ complaint (&symfile_complaints, -+ _("DIE 0x%x and its abstract origin 0x%x have different " -+ "tags"), -+ die->offset, origin_die->offset); -+ -+ offsets = xmalloc (sizeof (*offsets) * die_children); -+ cleanups = make_cleanup (xfree, offsets); -+ -+ offsets_end = offsets; -+ child_die = die->child; -+ while (child_die && child_die->tag) -+ { -+ attr = dwarf2_attr (child_die, DW_AT_abstract_origin, cu); -+ if (!attr) -+ complaint (&symfile_complaints, -+ _("Child DIE 0x%x of DIE 0x%x has missing " -+ "DW_AT_abstract_origin"), -+ child_die->offset, die->offset); -+ else -+ { -+ struct die_info *child_origin_die; -+ -+ child_origin_die = follow_die_ref (child_die, attr, &cu); -+ if (child_die->tag != child_origin_die->tag) -+ complaint (&symfile_complaints, -+ _("Child DIE 0x%x and its abstract origin 0x%x have " -+ "different tags"), -+ child_die->offset, child_origin_die->offset); -+ *offsets_end++ = child_origin_die->offset; -+ } -+ child_die = sibling_die (child_die); -+ } -+ qsort (offsets, offsets_end - offsets, sizeof (*offsets), -+ unsigned_int_compar); -+ /* Disabled as excessively expensive - check if we may ever complain. */ -+ if (0) -+ { -+ for (offsetp = offsets + 1; offsetp < offsets_end; offsetp++) -+ if (offsetp[-1] == *offsetp) -+ complaint (&symfile_complaints, -+ _("Child DIEs of DIE 0x%x duplicitly abstract-origin " -+ "referenced DIE 0x%x"), -+ die->offset, *offsetp); -+ } -+ -+ offsetp = offsets; -+ origin_child_die = origin_die->child; -+ while (origin_child_die && origin_child_die->tag) -+ { -+ /* Is origin_child_die referenced by any of the DIE children? */ -+ while (offsetp < offsets_end && *offsetp < origin_child_die->offset) -+ offsetp++; -+ if (offsetp >= offsets_end || *offsetp > origin_child_die->offset) -+ { -+ /* Found that origin_child_die is really not referenced. */ -+ process_die (origin_child_die, cu); -+ } -+ origin_child_die = sibling_die (origin_child_die); -+ } -+ -+ do_cleanups (cleanups); -+ } -+} +- + /* DW_AT_abstract_origin inherits whole DIEs (not just their attributes). Inherit only the children of the DW_AT_abstract_origin DIE not being already referenced by DW_AT_abstract_origin from the children of the current DIE. */ -@@ -3795,6 +4103,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -3697,6 +3913,14 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) + struct attribute *attr; + + attr = dwarf2_attr (die, DW_AT_abstract_origin, cu); ++ ++ /* GCC 4.3 incorrectly uses DW_AT_specification to indicate die inheritence ++ in the case of import statements. The following is to accommodate ++ that. */ ++ if(!attr){ ++ attr = dwarf2_attr (die, DW_AT_specification, cu); ++ } ++ + if (!attr) + return; + +@@ -3795,6 +4019,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) char *name; CORE_ADDR baseaddr; struct block *block; @@ -5031,7 +5086,7 @@ index 445bab8..be2dc2a 100644 int inlined_func = (die->tag == DW_TAG_inlined_subroutine); if (inlined_func) -@@ -3813,13 +4122,23 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -3813,13 +4038,23 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); @@ -5050,7 +5105,7 @@ index 445bab8..be2dc2a 100644 + child_die = sibling_die (child_die); + die_children++; + } -+ explore_abstract_origin(die, cu, &die_children); ++ inherit_abstract_dies(die, cu); return; - + } @@ -5058,7 +5113,7 @@ index 445bab8..be2dc2a 100644 lowpc += baseaddr; highpc += baseaddr; -@@ -3846,16 +4165,15 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -3846,14 +4081,12 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) cu->list_in_scope = &local_symbols; @@ -5077,11 +5132,8 @@ index 445bab8..be2dc2a 100644 + die_children++; } -+ explore_abstract_origin(die, cu, &die_children); inherit_abstract_dies (die, cu); - - new = pop_context (); -@@ -3905,7 +4223,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -3905,7 +4138,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) as multiple lexical blocks? Handling children in a sane way would be nasty. Might be easier to properly extend generic blocks to describe ranges. */ @@ -5090,16 +5142,16 @@ index 445bab8..be2dc2a 100644 return; lowpc += baseaddr; highpc += baseaddr; -@@ -3922,7 +4240,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -3922,7 +4155,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) } new = pop_context (); - if (local_symbols != NULL) -+ if (local_symbols != NULL || using_directives!= NULL ) ++ if (local_symbols != NULL || using_directives != NULL) { struct block *block = finish_block (0, &local_symbols, new->old_blocks, new->start_addr, -@@ -4077,7 +4395,8 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return, +@@ -4077,7 +4310,8 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return, discontinuous, i.e. derived from DW_AT_ranges information. */ static int dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, @@ -5109,7 +5161,7 @@ index 445bab8..be2dc2a 100644 { struct attribute *attr; CORE_ADDR low = 0; -@@ -4105,7 +4424,7 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, +@@ -4105,7 +4339,7 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, { /* Value of the DW_AT_ranges attribute is the offset in the .debug_ranges section. */ @@ -5118,7 +5170,7 @@ index 445bab8..be2dc2a 100644 return 0; /* Found discontinuous range of addresses. */ ret = -1; -@@ -4144,7 +4463,7 @@ dwarf2_get_subprogram_pc_bounds (struct die_info *die, +@@ -4144,7 +4378,7 @@ dwarf2_get_subprogram_pc_bounds (struct die_info *die, CORE_ADDR low, high; struct die_info *child = die->child; @@ -5127,7 +5179,7 @@ index 445bab8..be2dc2a 100644 { *lowpc = min (*lowpc, low); *highpc = max (*highpc, high); -@@ -4181,7 +4500,7 @@ get_scope_pc_bounds (struct die_info *die, +@@ -4181,7 +4415,7 @@ get_scope_pc_bounds (struct die_info *die, CORE_ADDR best_high = (CORE_ADDR) 0; CORE_ADDR current_low, current_high; @@ -5136,21 +5188,31 @@ index 445bab8..be2dc2a 100644 { best_low = current_low; best_high = current_high; -@@ -4393,7 +4712,12 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, - byte_offset = 0; - } - else if (attr_form_is_constant (attr)) +@@ -4384,21 +4618,8 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, + /* Get bit offset of field. */ + attr = dwarf2_attr (die, DW_AT_data_member_location, cu); + if (attr) +- { +- int byte_offset; +- +- if (attr_form_is_section_offset (attr)) +- { +- dwarf2_complex_location_expr_complaint (); +- byte_offset = 0; +- } +- else if (attr_form_is_constant (attr)) - byte_offset = dwarf2_get_attr_constant_value (attr, 0); -+ { -+ enum get_attr_constant_value type; -+ -+ type = get_attr_constant_value (attr, &byte_offset); -+ gdb_assert (type == dwarf2_attr_const); -+ } - else - byte_offset = decode_locdesc (DW_BLOCK (attr), cu); - -@@ -4476,7 +4800,11 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, +- else +- byte_offset = decode_locdesc (DW_BLOCK (attr), cu); +- +- SET_FIELD_BITPOS (*fp, byte_offset * bits_per_byte); +- } ++ SET_FIELD_BITPOS (*fp, dwarf2_get_attr_constant_value (attr, 0, cu) ++ * bits_per_byte); + attr = dwarf2_attr (die, DW_AT_bit_offset, cu); + if (attr) + { +@@ -4476,7 +4697,11 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, if (fieldname == NULL) return; @@ -5163,7 +5225,16 @@ index 445bab8..be2dc2a 100644 physname = dwarf2_linkage_name (die, cu); /* The name is already allocated along with this objfile, so we don't -@@ -4607,7 +4935,11 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, +@@ -4490,7 +4715,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, + /* C++ base class field. */ + attr = dwarf2_attr (die, DW_AT_data_member_location, cu); + if (attr) +- SET_FIELD_BITPOS (*fp, decode_locdesc (DW_BLOCK (attr), cu) ++ SET_FIELD_BITPOS (*fp, dwarf2_get_attr_constant_value (attr, 0, cu) + * bits_per_byte); + FIELD_BITSIZE (*fp) = 0; + FIELD_TYPE (*fp) = die_type (die, cu); +@@ -4607,7 +4832,11 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, if (fieldname == NULL) return; @@ -5176,7 +5247,7 @@ index 445bab8..be2dc2a 100644 physname = dwarf2_linkage_name (die, cu); /* Look up member function name in fieldlist. */ -@@ -4652,7 +4984,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, +@@ -4652,7 +4881,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, /* The name is already allocated along with this objfile, so we don't need to duplicate it for the type. */ fnp->physname = physname ? physname : ""; @@ -5185,7 +5256,31 @@ index 445bab8..be2dc2a 100644 this_type = read_type_die (die, cu); if (this_type && TYPE_CODE (this_type) == TYPE_CODE_FUNC) { -@@ -4836,7 +5168,7 @@ quirk_gcc_member_function_pointer (struct die_info *die, struct dwarf2_cu *cu) +@@ -4709,22 +4938,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, + /* Get index in virtual function table if it is a virtual member function. */ + attr = dwarf2_attr (die, DW_AT_vtable_elem_location, cu); + if (attr) +- { +- /* Support the .debug_loc offsets */ +- if (attr_form_is_block (attr)) +- { +- fnp->voffset = decode_locdesc (DW_BLOCK (attr), cu) + 2; +- } +- else if (attr_form_is_section_offset (attr)) +- { +- dwarf2_complex_location_expr_complaint (); +- } +- else +- { +- dwarf2_invalid_attrib_class_complaint ("DW_AT_vtable_elem_location", +- fieldname); +- } +- } ++ fnp->voffset = dwarf2_get_attr_constant_value (attr, -2, cu) + 2; + } + + /* Create the vector of member function fields, and attach it to the type. */ +@@ -4836,7 +5050,7 @@ quirk_gcc_member_function_pointer (struct die_info *die, struct dwarf2_cu *cu) return NULL; domain_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (pfn_type, 0)); @@ -5194,7 +5289,7 @@ index 445bab8..be2dc2a 100644 smash_to_method_type (type, domain_type, TYPE_TARGET_TYPE (pfn_type), TYPE_FIELDS (pfn_type), TYPE_NFIELDS (pfn_type), TYPE_VARARGS (pfn_type)); -@@ -4889,7 +5221,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -4889,7 +5103,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) return set_die_type (die, type, cu); } @@ -5203,7 +5298,7 @@ index 445bab8..be2dc2a 100644 INIT_CPLUS_SPECIFIC (type); name = dwarf2_name (die, cu); -@@ -4898,14 +5230,18 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -4898,14 +5112,18 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) if (cu->language == language_cplus || cu->language == language_java) { @@ -5225,7 +5320,7 @@ index 445bab8..be2dc2a 100644 } } -@@ -5115,7 +5451,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5115,7 +5333,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) return set_die_type (die, type, cu); } @@ -5234,7 +5329,7 @@ index 445bab8..be2dc2a 100644 TYPE_CODE (type) = TYPE_CODE_ENUM; name = dwarf2_full_name (die, cu); -@@ -5143,51 +5479,6 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5143,51 +5361,6 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) return set_die_type (die, type, cu); } @@ -5286,7 +5381,7 @@ index 445bab8..be2dc2a 100644 /* Given a pointer to a die which begins an enumeration, process all the dies that define the members of the enumeration, and create the symbol for the enumeration type. -@@ -5265,6 +5556,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -5265,6 +5438,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) new_symbol (die, this_type, cu); } @@ -5316,7 +5411,7 @@ index 445bab8..be2dc2a 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. */ -@@ -5278,7 +5592,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5278,7 +5474,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; @@ -5325,7 +5420,7 @@ index 445bab8..be2dc2a 100644 struct cleanup *back_to; char *name; -@@ -5325,16 +5639,11 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5325,16 +5521,11 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) type = element_type; if (read_array_order (die, cu) == DW_ORD_col_major) @@ -5347,7 +5442,7 @@ index 445bab8..be2dc2a 100644 /* Understand Dwarf2 support for vector types (like they occur on the PowerPC w/ AltiVec). Gcc just adds another attribute to the -@@ -5401,12 +5710,14 @@ read_set_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5401,49 +5592,83 @@ read_set_type (struct die_info *die, struct dwarf2_cu *cu) return set_die_type (die, set_type, cu); } @@ -5364,8 +5459,26 @@ index 445bab8..be2dc2a 100644 struct attribute *attr; struct symbol *sym; CORE_ADDR base = (CORE_ADDR) 0; -@@ -5431,10 +5742,40 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) - } + + attr = dwarf2_attr (die, DW_AT_location, cu); + if (attr) +- { +- /* Support the .debug_loc offsets */ +- if (attr_form_is_block (attr)) +- { +- base = decode_locdesc (DW_BLOCK (attr), cu); +- } +- else if (attr_form_is_section_offset (attr)) +- { +- dwarf2_complex_location_expr_complaint (); +- } +- else +- { +- dwarf2_invalid_attrib_class_complaint ("DW_AT_location", +- "common block member"); +- } +- } ++ base = dwarf2_get_attr_constant_value (attr, 0, cu); if (die->child != NULL) { + struct objfile *objfile = cu->objfile; @@ -5405,8 +5518,9 @@ index 445bab8..be2dc2a 100644 attr = dwarf2_attr (child_die, DW_AT_data_member_location, cu); if (attr) { -@@ -5442,8 +5783,25 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) - base + decode_locdesc (DW_BLOCK (attr), cu); + SYMBOL_VALUE_ADDRESS (sym) = +- base + decode_locdesc (DW_BLOCK (attr), cu); ++ base + dwarf2_get_attr_constant_value (attr, 0, cu); add_symbol_to_list (sym, &global_symbols); } + @@ -5431,7 +5545,7 @@ index 445bab8..be2dc2a 100644 } } -@@ -5511,7 +5869,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) +@@ -5511,7 +5736,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) if (is_anonymous) { const char *previous_prefix = determine_prefix (die, cu); @@ -5440,7 +5554,7 @@ index 445bab8..be2dc2a 100644 } } -@@ -5705,29 +6063,95 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5705,29 +5930,93 @@ 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; @@ -5461,92 +5575,86 @@ index 445bab8..be2dc2a 100644 - if (attr) - { - length = DW_UNSND (attr); -- } -- else -- { -- /* check for the DW_AT_byte_size attribute */ -+ switch (get_attr_constant_value (attr, &length)) ++ if (attr && attr_form_is_block (attr)) + { -+ case dwarf2_attr_const: -+ /* We currently do not support a constant address where the location -+ should be read from - DWARF2_ATTR_BLOCK is expected instead. See -+ DWARF for the DW_AT_STRING_LENGTH vs. DW_AT_BYTE_SIZE difference. */ -+ /* PASSTHRU */ -+ case dwarf2_attr_unknown: ++ /* Security check for a size overflow. */ ++ if (DW_BLOCK (attr)->size + 2 < DW_BLOCK (attr)->size) ++ TYPE_HIGH_BOUND (range_type) = 1; ++ /* Extend the DWARF block by a new DW_OP_deref/DW_OP_deref_size ++ instruction as DW_AT_string_length specifies the length location, not ++ its value. */ ++ else ++ { ++ struct dwarf2_locexpr_baton *length_baton; ++ struct attribute *size_attr; ++ ++ length_baton = obstack_alloc (&cu->comp_unit_obstack, ++ sizeof (*length_baton)); ++ length_baton->per_cu = cu->per_cu; ++ length_baton->data = obstack_alloc (&cu->comp_unit_obstack, ++ DW_BLOCK (attr)->size + 2); ++ memcpy (length_baton->data, DW_BLOCK (attr)->data, ++ DW_BLOCK (attr)->size); ++ ++ /* DW_AT_BYTE_SIZE existing together with DW_AT_STRING_LENGTH ++ specifies the size of an integer to fetch. */ ++ ++ size_attr = dwarf2_attr (die, DW_AT_byte_size, cu); ++ if (size_attr) ++ { ++ length_baton->size = DW_BLOCK (attr)->size + 2; ++ length_baton->data[DW_BLOCK (attr)->size] = DW_OP_deref_size; ++ length_baton->data[DW_BLOCK (attr)->size + 1] ++ = DW_UNSND (size_attr); ++ if (length_baton->data[DW_BLOCK (attr)->size + 1] ++ != DW_UNSND (size_attr)) ++ complaint (&symfile_complaints, ++ _("DW_AT_string_length's DW_AT_byte_size integer " ++ "exceeds the byte size storage")); ++ } ++ else ++ { ++ length_baton->size = DW_BLOCK (attr)->size + 1; ++ length_baton->data[DW_BLOCK (attr)->size] = DW_OP_deref; ++ } ++ ++ TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 1); ++ TYPE_FIELD_DWARF_BLOCK (range_type, 1) = length_baton; ++ TYPE_DYNAMIC (range_type) = 1; ++ } + } + else + { +- /* check for the DW_AT_byte_size attribute */ ++ if (attr && attr_form_is_constant (attr)) ++ { ++ /* We currently do not support a constant address where the location ++ should be read from - attr_form_is_block is expected instead. See ++ DWARF for the DW_AT_STRING_LENGTH vs. DW_AT_BYTE_SIZE difference. ++ */ ++ /* PASSTHRU */ ++ } ++ attr = dwarf2_attr (die, DW_AT_byte_size, cu); - if (attr) - { - length = DW_UNSND (attr); - } -- else -- { -- length = 1; -- } -+ switch (get_attr_constant_value (attr, &length)) ++ if (attr && attr_form_is_block (attr)) + { -+ case dwarf2_attr_unknown: -+ length = 1; -+ /* PASSTHRU */ -+ case dwarf2_attr_const: -+ TYPE_HIGH_BOUND (range_type) = length; -+ break; -+ case dwarf2_attr_block: + TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 1); + TYPE_FIELD_DWARF_BLOCK (range_type, 1) = + dwarf2_attr_to_locexpr_baton (attr, cu); + TYPE_DYNAMIC (range_type) = 1; -+ break; + } -+ break; -+ case dwarf2_attr_block: -+ /* Security check for a size overflow. */ -+ if (DW_BLOCK (attr)->size + 2 < DW_BLOCK (attr)->size) -+ { -+ TYPE_HIGH_BOUND (range_type) = 1; -+ break; -+ } -+ /* Extend the DWARF block by a new DW_OP_deref/DW_OP_deref_size -+ instruction as DW_AT_string_length specifies the length location, not -+ its value. */ -+ { -+ struct dwarf2_locexpr_baton *length_baton; -+ struct attribute *size_attr; -+ -+ length_baton = obstack_alloc (&cu->comp_unit_obstack, -+ sizeof (*length_baton)); -+ length_baton->per_cu = cu->per_cu; -+ length_baton->data = obstack_alloc (&cu->comp_unit_obstack, -+ DW_BLOCK (attr)->size + 2); -+ memcpy (length_baton->data, DW_BLOCK (attr)->data, -+ DW_BLOCK (attr)->size); -+ -+ /* DW_AT_BYTE_SIZE existing together with DW_AT_STRING_LENGTH specifies -+ the size of an integer to fetch. */ -+ -+ size_attr = dwarf2_attr (die, DW_AT_byte_size, cu); -+ if (size_attr) -+ { -+ length_baton->size = DW_BLOCK (attr)->size + 2; -+ length_baton->data[DW_BLOCK (attr)->size] = DW_OP_deref_size; -+ length_baton->data[DW_BLOCK (attr)->size + 1] -+ = DW_UNSND (size_attr); -+ if (length_baton->data[DW_BLOCK (attr)->size + 1] -+ != DW_UNSND (size_attr)) -+ complaint (&symfile_complaints, -+ _("DW_AT_string_length's DW_AT_byte_size integer " -+ "exceeds the byte size storage")); -+ } -+ else -+ { -+ length_baton->size = DW_BLOCK (attr)->size + 1; -+ length_baton->data[DW_BLOCK (attr)->size] = DW_OP_deref; -+ } -+ -+ TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 1); -+ TYPE_FIELD_DWARF_BLOCK (range_type, 1) = length_baton; -+ TYPE_DYNAMIC (range_type) = 1; -+ } -+ break; ++ else if (attr && attr_form_is_constant (attr)) ++ TYPE_HIGH_BOUND (range_type) = dwarf2_get_attr_constant_value (attr, 0, ++ cu); + else +- { +- length = 1; +- } ++ TYPE_HIGH_BOUND (range_type) = 1; } - index_type = objfile_type (objfile)->builtin_int; @@ -5554,7 +5662,7 @@ index 445bab8..be2dc2a 100644 char_type = language_string_char_type (cu->language_defn, gdbarch); type = create_string_type (NULL, char_type, range_type); -@@ -5822,7 +6246,6 @@ static struct type * +@@ -5822,7 +6111,6 @@ static struct type * read_typedef (struct die_info *die, struct dwarf2_cu *cu) { struct objfile *objfile = cu->objfile; @@ -5562,18 +5670,17 @@ index 445bab8..be2dc2a 100644 const char *name = NULL; struct type *this_type; -@@ -5930,8 +6353,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5930,8 +6218,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) struct type *base_type; struct type *range_type; struct attribute *attr; - int low = 0; - int high = -1; -+ int low, high, byte_stride_int; -+ enum get_attr_constant_value high_type; ++ int low; char *name; base_type = die_type (die, cu); -@@ -5944,42 +6367,90 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5944,42 +6231,91 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) 0, NULL, cu->objfile); } @@ -5591,34 +5698,36 @@ index 445bab8..be2dc2a 100644 attr = dwarf2_attr (die, DW_AT_lower_bound, cu); - if (attr) - low = dwarf2_get_attr_constant_value (attr, 0); -+ switch (get_attr_constant_value (attr, &low)) ++ if (attr && attr_form_is_block (attr)) + { -+ case dwarf2_attr_unknown: -+ if (cu->language == language_fortran) -+ { -+ /* FORTRAN implies a lower bound of 1, if not given. */ -+ low = 1; -+ } -+ else -+ { -+ /* According to DWARF we should assume the value 0 only for -+ LANGUAGE_C and LANGUAGE_CPLUS. */ -+ low = 0; -+ } -+ /* PASSTHRU */ -+ case dwarf2_attr_const: -+ TYPE_LOW_BOUND (range_type) = low; -+ if (low >= 0) -+ TYPE_UNSIGNED (range_type) = 1; -+ break; -+ case dwarf2_attr_block: + TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 0); + TYPE_FIELD_DWARF_BLOCK (range_type, 0) = dwarf2_attr_to_locexpr_baton + (attr, cu); + TYPE_DYNAMIC (range_type) = 1; + /* For setting a default if DW_AT_UPPER_BOUND would be missing. */ + low = 0; -+ break; ++ } ++ else ++ { ++ if (attr && attr_form_is_constant (attr)) ++ low = dwarf2_get_attr_constant_value (attr, 0, cu); ++ else ++ { ++ if (cu->language == language_fortran) ++ { ++ /* FORTRAN implies a lower bound of 1, if not given. */ ++ low = 1; ++ } ++ else ++ { ++ /* According to DWARF we should assume the value 0 only for ++ LANGUAGE_C and LANGUAGE_CPLUS. */ ++ low = 0; ++ } ++ } ++ TYPE_LOW_BOUND (range_type) = low; ++ if (low >= 0) ++ TYPE_UNSIGNED (range_type) = 1; + } attr = dwarf2_attr (die, DW_AT_upper_bound, cu); @@ -5639,62 +5748,60 @@ index 445bab8..be2dc2a 100644 - the lower bound we've computed above. */ - high = low - 1; - } -- else -- high = dwarf2_get_attr_constant_value (attr, 1); -+ high_type = get_attr_constant_value (attr, &high); -+ if (high_type == dwarf2_attr_unknown) ++ if (!attr || (!attr_form_is_block (attr) && !attr_form_is_constant (attr))) + { + attr = dwarf2_attr (die, DW_AT_count, cu); -+ high_type = get_attr_constant_value (attr, &high); + /* It does not hurt but it is needlessly ineffective in check_typedef. */ -+ if (high_type != dwarf2_attr_unknown) ++ if (attr && (attr_form_is_block (attr) || attr_form_is_constant (attr))) + { + TYPE_RANGE_HIGH_BOUND_IS_COUNT (range_type) = 1; + TYPE_DYNAMIC (range_type) = 1; + } + /* Pass it now as the regular DW_AT_upper_bound. */ + } -+ switch (high_type) ++ ++ if (attr && attr_form_is_block (attr)) + { -+ case dwarf2_attr_unknown: -+ TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED (range_type) = 1; -+ high = low - 1; -+ /* PASSTHRU */ -+ case dwarf2_attr_const: -+ TYPE_HIGH_BOUND (range_type) = high; -+ break; -+ case dwarf2_attr_block: + TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 1); + TYPE_FIELD_DWARF_BLOCK (range_type, 1) = dwarf2_attr_to_locexpr_baton + (attr, cu); + TYPE_DYNAMIC (range_type) = 1; -+ break; ++ } ++ else ++ { ++ if (attr && attr_form_is_constant (attr)) ++ TYPE_HIGH_BOUND (range_type) = dwarf2_get_attr_constant_value (attr, 0, ++ cu); + else +- high = dwarf2_get_attr_constant_value (attr, 1); ++ { ++ TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED (range_type) = 1; ++ TYPE_HIGH_BOUND (range_type) = low - 1; ++ } } - range_type = create_range_type (NULL, base_type, low, high); + /* DW_AT_bit_stride is currently unsupported as we count in bytes. */ + attr = dwarf2_attr (die, DW_AT_byte_stride, cu); -+ switch (get_attr_constant_value (attr, &byte_stride_int)) ++ if (attr && attr_form_is_block (attr)) + { -+ case dwarf2_attr_unknown: -+ break; -+ case dwarf2_attr_const: -+ if (byte_stride_int == 0) -+ complaint (&symfile_complaints, -+ _("Found DW_AT_byte_stride with unsupported value 0")); -+ TYPE_BYTE_STRIDE (range_type) = byte_stride_int; -+ break; -+ case dwarf2_attr_block: + TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 2); + TYPE_FIELD_DWARF_BLOCK (range_type, 2) = dwarf2_attr_to_locexpr_baton + (attr, cu); + TYPE_DYNAMIC (range_type) = 1; -+ break; ++ } ++ else if (attr && attr_form_is_constant (attr)) ++ { ++ TYPE_BYTE_STRIDE (range_type) = dwarf2_get_attr_constant_value (attr, 0, ++ cu); ++ if (TYPE_BYTE_STRIDE (range_type) == 0) ++ complaint (&symfile_complaints, ++ _("Found DW_AT_byte_stride with unsupported value 0")); + } name = dwarf2_name (die, cu); if (name) -@@ -6670,9 +7141,6 @@ read_partial_die (struct partial_die_info *part_die, +@@ -6670,9 +7006,6 @@ read_partial_die (struct partial_die_info *part_die, if (part_die->dirname == NULL) part_die->dirname = DW_STRING (&attr); break; @@ -5704,7 +5811,7 @@ index 445bab8..be2dc2a 100644 case DW_AT_low_pc: has_low_pc_attr = 1; part_die->lowpc = DW_ADDR (&attr); -@@ -6744,10 +7212,10 @@ read_partial_die (struct partial_die_info *part_die, +@@ -6744,10 +7077,10 @@ read_partial_die (struct partial_die_info *part_die, else part_die->sibling = buffer + dwarf2_get_ref_die_offset (&attr); break; @@ -5719,7 +5826,7 @@ index 445bab8..be2dc2a 100644 case DW_AT_byte_size: part_die->has_byte_size = 1; break; -@@ -6789,13 +7257,6 @@ read_partial_die (struct partial_die_info *part_die, +@@ -6789,13 +7122,6 @@ read_partial_die (struct partial_die_info *part_die, || dwarf2_per_objfile->has_section_at_zero)) part_die->has_pc_info = 1; @@ -5733,7 +5840,7 @@ index 445bab8..be2dc2a 100644 return info_ptr; } -@@ -6904,7 +7365,8 @@ fixup_partial_die (struct partial_die_info *part_die, +@@ -6904,7 +7230,8 @@ fixup_partial_die (struct partial_die_info *part_die, /* If we found a reference attribute and the DIE has no name, try to find a name in the referred to DIE. */ @@ -5743,7 +5850,7 @@ index 445bab8..be2dc2a 100644 { struct partial_die_info *spec_die; -@@ -8244,10 +8706,12 @@ var_decode_location (struct attribute *attr, struct symbol *sym, +@@ -8244,10 +8571,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 @@ -5758,7 +5865,7 @@ index 445bab8..be2dc2a 100644 } /* Given a pointer to a DWARF information entry, figure out if we need -@@ -8269,21 +8733,24 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8269,21 +8598,24 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); @@ -5790,7 +5897,7 @@ index 445bab8..be2dc2a 100644 /* Default assumptions. Use the passed type or decode it from the die. */ -@@ -8381,7 +8848,15 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8381,7 +8713,15 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) if (attr) { var_decode_location (attr, sym, cu); @@ -5806,7 +5913,7 @@ index 445bab8..be2dc2a 100644 if (attr2 && (DW_UNSND (attr2) != 0)) add_symbol_to_list (sym, &global_symbols); else -@@ -8513,7 +8988,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8513,7 +8853,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) add_symbol_to_list (sym, cu->list_in_scope); break; case DW_TAG_enumerator: @@ -5815,7 +5922,7 @@ index 445bab8..be2dc2a 100644 attr = dwarf2_attr (die, DW_AT_const_value, cu); if (attr) { -@@ -8537,6 +9012,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8537,6 +8877,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) SYMBOL_CLASS (sym) = LOC_TYPEDEF; add_symbol_to_list (sym, &global_symbols); break; @@ -5827,7 +5934,7 @@ index 445bab8..be2dc2a 100644 default: /* Not a tag we recognize. Hopefully we aren't processing trash data, but since we must specifically ignore things -@@ -8550,8 +9030,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8550,8 +8895,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) /* For the benefit of old versions of GCC, check for anonymous namespaces based on the demangled name. */ if (!processing_has_namespace_info @@ -5837,7 +5944,7 @@ index 445bab8..be2dc2a 100644 cp_scan_for_anonymous_namespaces (sym); } return (sym); -@@ -8808,6 +9287,9 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu) +@@ -8808,6 +9152,9 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu) break; } @@ -5847,7 +5954,7 @@ index 445bab8..be2dc2a 100644 return this_type; } -@@ -8889,10 +9371,97 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) +@@ -8889,10 +9236,97 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) So it does not need a prefix. */ return ""; default: @@ -5946,14 +6053,18 @@ index 445bab8..be2dc2a 100644 /* Return a newly-allocated string formed by concatenating PREFIX and SUFFIX with appropriate separator. If PREFIX or SUFFIX is NULL or empty, then simply copy the SUFFIX or PREFIX, respectively. If OBS is non-null, -@@ -8948,14 +9517,75 @@ static char * +@@ -8948,14 +9382,75 @@ static char * dwarf2_linkage_name (struct die_info *die, struct dwarf2_cu *cu) { struct attribute *attr; + char *name; + + name = dwarf2_name (die, cu); -+ + +- attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu); +- if (attr && DW_STRING (attr)) +- return DW_STRING (attr); +- return dwarf2_name (die, cu); + /* These are the only languages we know how to qualify names in. */ + if (cu->language != language_cplus + && cu->language != language_java) @@ -6014,11 +6125,7 @@ index 445bab8..be2dc2a 100644 + name = cname; + } + } - -- attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu); -- if (attr && DW_STRING (attr)) -- return DW_STRING (attr); -- return dwarf2_name (die, cu); ++ + return name; } @@ -6027,58 +6134,32 @@ index 445bab8..be2dc2a 100644 static char * dwarf2_canonicalize_name (char *name, struct dwarf2_cu *cu, -@@ -10181,26 +10811,35 @@ dwarf2_get_ref_die_offset (struct attribute *attr) +@@ -10181,11 +10676,12 @@ dwarf2_get_ref_die_offset (struct attribute *attr) return 0; } -/* Return the constant value held by the given attribute. Return -1 -- if the value held by the attribute is not constant. */ -+/* (*val_return) is filled only if returning dwarf2_attr_const. */ ++/* Return the constant value held by the given attribute. Return DEFAULT_VALUE + if the value held by the attribute is not constant. */ -static int -dwarf2_get_attr_constant_value (struct attribute *attr, int default_value) -+static enum get_attr_constant_value -+get_attr_constant_value (struct attribute *attr, int *val_return) ++static CORE_ADDR ++dwarf2_get_attr_constant_value (struct attribute *attr, CORE_ADDR default_value, ++ struct dwarf2_cu *cu) { -+ if (attr == NULL) -+ return dwarf2_attr_unknown; if (attr->form == DW_FORM_sdata) -- return DW_SND (attr); -- else if (attr->form == DW_FORM_udata -- || attr->form == DW_FORM_data1 -- || attr->form == DW_FORM_data2 -- || attr->form == DW_FORM_data4 -- || attr->form == DW_FORM_data8) -- return DW_UNSND (attr); -- else + return DW_SND (attr); +@@ -10195,6 +10691,8 @@ dwarf2_get_attr_constant_value (struct attribute *attr, int default_value) + || attr->form == DW_FORM_data4 + || attr->form == DW_FORM_data8) + return DW_UNSND (attr); ++ else if (attr_form_is_block (attr)) ++ return decode_locdesc (DW_BLOCK (attr), cu); + else { -- complaint (&symfile_complaints, _("Attribute value is not a constant (%s)"), -- dwarf_form_name (attr->form)); -- return default_value; -+ *val_return = DW_SND (attr); -+ return dwarf2_attr_const; - } -+ if (attr->form == DW_FORM_udata -+ || attr->form == DW_FORM_data1 -+ || attr->form == DW_FORM_data2 -+ || attr->form == DW_FORM_data4 -+ || attr->form == DW_FORM_data8) -+ { -+ *val_return = DW_UNSND (attr); -+ return dwarf2_attr_const; -+ } -+ if (attr->form == DW_FORM_block -+ || attr->form == DW_FORM_block1 -+ || attr->form == DW_FORM_block2 -+ || attr->form == DW_FORM_block4) -+ return dwarf2_attr_block; -+ complaint (&symfile_complaints, _("Attribute value is not a constant (%s)"), -+ dwarf_form_name (attr->form)); -+ return dwarf2_attr_unknown; - } - - /* THIS_CU has a reference to PER_CU. If necessary, load the new compilation -@@ -10990,8 +11629,6 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, + complaint (&symfile_complaints, _("Attribute value is not a constant (%s)"), +@@ -10990,8 +11488,6 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, { gdb_byte *mac_ptr, *mac_end; struct macro_source_file *current_file = 0; @@ -6087,7 +6168,7 @@ index 445bab8..be2dc2a 100644 if (dwarf2_per_objfile->macinfo.buffer == NULL) { -@@ -10999,29 +11636,19 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, +@@ -10999,29 +11495,19 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, return; } @@ -6122,7 +6203,7 @@ index 445bab8..be2dc2a 100644 } macinfo_type = read_1_byte (abfd, mac_ptr); -@@ -11032,92 +11659,7 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, +@@ -11032,92 +11518,7 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, /* A zero macinfo type indicates the end of the macro information. */ case 0: @@ -6216,7 +6297,7 @@ index 445bab8..be2dc2a 100644 case DW_MACINFO_define: case DW_MACINFO_undef: -@@ -11132,31 +11674,19 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, +@@ -11132,31 +11533,19 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, mac_ptr += bytes_read; if (! current_file) @@ -6259,7 +6340,7 @@ index 445bab8..be2dc2a 100644 } break; -@@ -11170,22 +11700,9 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, +@@ -11170,22 +11559,9 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); mac_ptr += bytes_read; @@ -6285,7 +6366,7 @@ index 445bab8..be2dc2a 100644 } break; -@@ -11239,7 +11756,7 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, +@@ -11239,7 +11615,7 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, } break; } @@ -6294,16 +6375,7 @@ index 445bab8..be2dc2a 100644 } /* Check if the attribute's form is a DW_FORM_block* -@@ -11272,7 +11789,7 @@ attr_form_is_section_offset (struct attribute *attr) - - /* Return non-zero if ATTR's value falls in the 'constant' class, or - zero otherwise. When this function returns true, you can apply -- dwarf2_get_attr_constant_value to it. -+ get_attr_constant_value to it. - - However, note that for some attributes you must check - attr_form_is_section_offset before using this test. DW_FORM_data4 -@@ -11299,6 +11816,34 @@ attr_form_is_constant (struct attribute *attr) +@@ -11299,6 +11675,34 @@ attr_form_is_constant (struct attribute *attr) } } @@ -6338,7 +6410,7 @@ index 445bab8..be2dc2a 100644 static void dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, struct dwarf2_cu *cu) -@@ -11328,35 +11873,25 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, +@@ -11328,35 +11732,25 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, SYMBOL_COMPUTED_OPS (sym) = &dwarf2_loclist_funcs; SYMBOL_LOCATION_BATON (sym) = baton; } @@ -6389,7 +6461,7 @@ index 445bab8..be2dc2a 100644 } } -@@ -11644,6 +12179,31 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs) +@@ -11644,6 +12038,31 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs) return ofs_lhs->offset == ofs_rhs->offset; } @@ -6421,7 +6493,7 @@ index 445bab8..be2dc2a 100644 /* Set the type associated with DIE to TYPE. Save it in CU's hash table if necessary. For convenience, return TYPE. */ -@@ -11652,6 +12212,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -11652,6 +12071,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) { struct dwarf2_offset_and_type **slot, ofs; @@ -6430,7 +6502,7 @@ index 445bab8..be2dc2a 100644 if (cu->type_hash == NULL) { gdb_assert (cu->per_cu != NULL); -@@ -11794,23 +12356,13 @@ show_dwarf2_cmd (char *args, int from_tty) +@@ -11794,23 +12215,13 @@ show_dwarf2_cmd (char *args, int from_tty) cmd_show_list (show_dwarf2_cmdlist, from_tty, ""); } @@ -6458,7 +6530,7 @@ index 445bab8..be2dc2a 100644 } /* munmap debug sections for OBJFILE, if necessary. */ -@@ -11819,15 +12371,15 @@ static void +@@ -11819,15 +12230,15 @@ static void dwarf2_per_objfile_cleanup (struct objfile *objfile, void *d) { struct dwarf2_per_objfile *data = d; @@ -6483,7 +6555,7 @@ index 445bab8..be2dc2a 100644 } void _initialize_dwarf2_read (void); -@@ -11835,6 +12387,7 @@ void _initialize_dwarf2_read (void); +@@ -11835,6 +12246,7 @@ void _initialize_dwarf2_read (void); void _initialize_dwarf2_read (void) { @@ -8242,7 +8314,7 @@ index 8c027c9..d201f76 100644 else { diff --git a/gdb/frame.c b/gdb/frame.c -index 67e0607..1eb7f9d 100644 +index 67e0607..49c3013 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1109,6 +1109,14 @@ has_stack_frames (void) @@ -8260,7 +8332,7 @@ index 67e0607..1eb7f9d 100644 /* Don't try to read from a dead thread. */ if (is_exited (inferior_ptid)) return 0; -@@ -1843,6 +1851,17 @@ get_frame_args_address (struct frame_info *fi) +@@ -1843,6 +1851,15 @@ get_frame_args_address (struct frame_info *fi) return fi->base->this_args (fi, &fi->base_cache); } @@ -8268,28 +8340,27 @@ index 67e0607..1eb7f9d 100644 + otherwise. */ + +int -+frame_base_is (struct frame_info *fi, const struct frame_base *base) ++frame_unwinder_is (struct frame_info *fi, const struct frame_unwind *unwinder) +{ -+ if (fi->base == NULL) -+ fi->base = frame_base_find_by_frame (fi); -+ return fi->base == base; ++ return fi->unwind == unwinder; +} + /* Level of the selected frame: 0 for innermost, 1 for its caller, ... or -1 for a NULL frame. */ diff --git a/gdb/frame.h b/gdb/frame.h -index febef5c..09bf628 100644 +index febef5c..611c6d3 100644 --- a/gdb/frame.h +++ b/gdb/frame.h -@@ -696,4 +696,9 @@ extern struct frame_info *deprecated_safe_get_selected_frame (void); +@@ -696,4 +696,10 @@ extern struct frame_info *deprecated_safe_get_selected_frame (void); extern struct frame_info *create_new_frame (CORE_ADDR base, CORE_ADDR pc); -+/* Return true if the frame base for frame FI is BASE; false ++/* Return true if the frame unwinder for frame FI is UNWINDER; false + otherwise. */ + -+extern int frame_base_is (struct frame_info *fi, const struct frame_base *base); ++extern int frame_unwinder_is (struct frame_info *fi, ++ const struct frame_unwind *unwinder); + #endif /* !defined (FRAME_H) */ diff --git a/gdb/gdbinit.in b/gdb/gdbinit.in @@ -8733,7 +8804,7 @@ index 79d33fe..aecd820 100644 once for each known thread. */ typedef int (*thread_callback_func) (struct thread_info *, void *); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c -index 2f77dca..09f15dc 100644 +index 2f77dca..8146175 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -38,6 +38,9 @@ @@ -9324,7 +9395,7 @@ index 2f77dca..09f15dc 100644 /* Make a copy of the given TYPE, except that the pointer & reference types are not preserved. -@@ -2973,6 +3227,219 @@ copy_type (const struct type *type) +@@ -2973,6 +3227,217 @@ copy_type (const struct type *type) return new_type; } @@ -9485,6 +9556,21 @@ index 2f77dca..09f15dc 100644 + main_type_crawl (type, type_mark_used_crawl, NULL); +} + ++/* Increment the reference count for TYPE. */ ++ ++void ++type_incref (struct type *type) ++{ ++} ++ ++/* Decrement the reference count for TYPE. If TYPE has no more ++ references, delete it. */ ++ ++void ++type_decref (struct type *type) ++{ ++} ++ +/* A traverse callback for type_discardable_table which removes any + type_discardable whose reference count is now zero (unused link). */ + @@ -9523,28 +9609,11 @@ index 2f77dca..09f15dc 100644 + observer_notify_mark_used (); + + htab_traverse (type_discardable_table, type_discardable_remove, NULL); -+} -+ -+/* Increment the reference count for TYPE. */ -+/* We'll be replacing this with type GC soon. */ -+ -+void -+type_incref (struct type *type) -+{ -+} -+ -+/* Decrement the reference count for TYPE. If TYPE has no more -+ references, delete it. */ -+/* We'll be replacing this with type GC soon. */ -+ -+void -+type_decref (struct type *type) -+{ +} /* Helper functions to initialize architecture-specific types. */ -@@ -3463,6 +3930,11 @@ void +@@ -3463,6 +3928,11 @@ void _initialize_gdbtypes (void) { gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init); @@ -10196,10 +10265,10 @@ index aac82e9..626292c 100644 TYPE_CPLUS_SPECIFIC (t) = (struct cplus_struct_type *) &cplus_struct_default; return t; diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c -index 0cf03d9..89936d2 100644 +index 0cf03d9..1913c49 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c -@@ -369,28 +369,39 @@ mi_cmd_var_list_children (char *command, char **argv, int argc) +@@ -369,24 +369,35 @@ mi_cmd_var_list_children (char *command, char **argv, int argc) struct varobj *var; VEC(varobj_p) *children; struct varobj *child; @@ -10222,29 +10291,26 @@ index 0cf03d9..89936d2 100644 else var = varobj_get_handle (argv[1]); +- children = varobj_list_children (var); + if (argc > 2) + { + from = atoi (argv[argc - 2]); + to = atoi (argv[argc - 1]); -+ varobj_set_child_range (var, from, to); ++ } ++ else ++ { ++ from = -1; ++ to = -1; + } + - children = varobj_list_children (var); ++ children = varobj_list_children (var, &from, &to); ui_out_field_int (uiout, "numchild", VEC_length (varobj_p, children)); - if (argc == 2) + if (argc == 2 || argc == 4) print_values = mi_parse_values_option (argv[0]); else print_values = PRINT_NO_VALUES; - -+ /* Re-fetch the child range, because varobj_get_child_range computes -+ the real start and end indices for us. */ -+ varobj_get_child_range (var, children, &from, &to); -+ - display_hint = varobj_get_display_hint (var); - if (display_hint) - { -@@ -398,21 +409,29 @@ mi_cmd_var_list_children (char *command, char **argv, int argc) +@@ -398,21 +409,28 @@ mi_cmd_var_list_children (char *command, char **argv, int argc) xfree (display_hint); } @@ -10282,12 +10348,11 @@ index 0cf03d9..89936d2 100644 } - do_cleanups (cleanup_children); + -+ ui_out_field_int (uiout, "has_more", -+ VEC_length (varobj_p, children) > to); ++ ui_out_field_int (uiout, "has_more", varobj_has_more (var, to)); } void -@@ -644,7 +663,6 @@ mi_cmd_var_update (char *command, char **argv, int argc) +@@ -644,7 +662,6 @@ mi_cmd_var_update (char *command, char **argv, int argc) } else { @@ -10295,37 +10360,63 @@ index 0cf03d9..89936d2 100644 struct varobj *var = varobj_get_handle (name); varobj_update_one (var, print_values, 1 /* explicit */); -@@ -714,14 +732,17 @@ varobj_update_one (struct varobj *var, enum print_values print_values, +@@ -699,11 +716,11 @@ varobj_update_one (struct varobj *var, enum print_values print_values, + } + + if (r->type_changed) +- { +- ui_out_field_string (uiout, "new_type", varobj_get_type (r->varobj)); +- ui_out_field_int (uiout, "new_num_children", +- varobj_get_num_children (r->varobj)); +- } ++ ui_out_field_string (uiout, "new_type", varobj_get_type (r->varobj)); ++ ++ if (r->type_changed || r->children_changed) ++ ui_out_field_int (uiout, "new_num_children", ++ varobj_get_num_children (r->varobj)); + + display_hint = varobj_get_display_hint (var); + if (display_hint) +@@ -714,26 +731,58 @@ varobj_update_one (struct varobj *var, enum print_values print_values, if (r->children_changed) { - int ix; -+ int ix, from, to; - struct varobj *child; - struct cleanup *cleanup = - make_cleanup_ui_out_list_begin_end (uiout, "children"); +- struct varobj *child; +- struct cleanup *cleanup = +- make_cleanup_ui_out_list_begin_end (uiout, "children"); ++ int from, to; ++ varobj_get_child_range (r->varobj, &from, &to); ++ ui_out_field_int (uiout, "has_more", ++ varobj_has_more (r->varobj, to)); ++ } - VEC (varobj_p)* children = varobj_list_children (r->varobj); -+ varobj_get_child_range (r->varobj, children, &from, &to); +- VEC (varobj_p)* children = varobj_list_children (r->varobj); ++ if (r->new) ++ { ++ int j; ++ varobj_p child; ++ struct cleanup *cleanup; - for (ix = 0; VEC_iterate (varobj_p, children, ix, child); ++ix) -+ for (ix = from; -+ ix < to && VEC_iterate (varobj_p, children, ix, child); -+ ++ix) ++ cleanup = make_cleanup_ui_out_list_begin_end (uiout, "new_children"); ++ for (j = 0; VEC_iterate (varobj_p, r->new, j, child); ++j) { struct cleanup *cleanup_child; cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); -@@ -730,6 +751,9 @@ varobj_update_one (struct varobj *var, enum print_values print_values, +- print_varobj (child, print_values, 1 /* print expression */); ++ print_varobj (child, print_values, 1 /* print_expression */); + do_cleanups (cleanup_child); } do_cleanups (cleanup); -+ -+ ui_out_field_int (uiout, "has_more", -+ VEC_length (varobj_p, children) > to); ++ VEC_free (varobj_p, r->new); ++ r->new = NULL; /* Paranoia. */ } - +- ++ if (mi_version (uiout) > 1) -@@ -737,3 +761,11 @@ varobj_update_one (struct varobj *var, enum print_values print_values, + do_cleanups (cleanup); } VEC_free (varobj_update_result, changes); } @@ -10337,11 +10428,27 @@ index 0cf03d9..89936d2 100644 + error (_("mi_cmd_enable_pretty_printing: no arguments allowed")); + varobj_enable_pretty_printing (); +} ++ ++void ++mi_cmd_var_set_update_range (char *command, char **argv, int argc) ++{ ++ struct varobj *var; ++ int from, to; ++ ++ if (argc != 3) ++ error (_("mi_cmd_var_set_update_range: Usage: VAROBJ FROM TO")); ++ ++ var = varobj_get_handle (argv[0]); ++ from = atoi (argv[1]); ++ to = atoi (argv[2]); ++ ++ varobj_set_child_range (var, from, to); ++} diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c -index 4911146..772566e 100644 +index dd3d803..8ba086c 100644 --- a/gdb/mi/mi-cmds.c +++ b/gdb/mi/mi-cmds.c -@@ -51,6 +51,7 @@ struct mi_cmd mi_cmds[] = +@@ -52,6 +52,7 @@ struct mi_cmd mi_cmds[] = { "data-write-memory", { NULL, 0 }, mi_cmd_data_write_memory}, { "data-write-register-values", { NULL, 0 }, mi_cmd_data_write_register_values}, { "enable-timings", { NULL, 0 }, mi_cmd_enable_timings}, @@ -10349,15 +10456,24 @@ index 4911146..772566e 100644 { "environment-cd", { NULL, 0 }, mi_cmd_env_cd}, { "environment-directory", { NULL, 0 }, mi_cmd_env_dir}, { "environment-path", { NULL, 0 }, mi_cmd_env_path}, +@@ -112,6 +113,7 @@ struct mi_cmd mi_cmds[] = + { "var-list-children", { NULL, 0 }, mi_cmd_var_list_children}, + { "var-set-format", { NULL, 0 }, mi_cmd_var_set_format}, + { "var-set-frozen", { NULL, 0 }, mi_cmd_var_set_frozen}, ++ { "var-set-update-range", { NULL, 0 }, mi_cmd_var_set_update_range }, + { "var-set-visualizer", { NULL, 0 }, mi_cmd_var_set_visualizer}, + { "var-show-attributes", { NULL, 0 }, mi_cmd_var_show_attributes}, + { "var-show-format", { NULL, 0 }, mi_cmd_var_show_format}, diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h -index afcba1e..79798ef 100644 +index 85ad0c4..dfab411 100644 --- a/gdb/mi/mi-cmds.h +++ b/gdb/mi/mi-cmds.h -@@ -98,6 +98,7 @@ extern mi_cmd_argv_ftype mi_cmd_var_set_visualizer; +@@ -99,6 +99,8 @@ extern mi_cmd_argv_ftype mi_cmd_var_set_visualizer; extern mi_cmd_argv_ftype mi_cmd_var_show_attributes; extern mi_cmd_argv_ftype mi_cmd_var_show_format; extern mi_cmd_argv_ftype mi_cmd_var_update; +extern mi_cmd_argv_ftype mi_cmd_enable_pretty_printing; ++extern mi_cmd_argv_ftype mi_cmd_var_set_update_range; /* Description of a single command. */ @@ -10397,22 +10513,31 @@ index a84003f..924c1c5 100644 default_symfile_offsets, /* sym_offsets: dummy FIXME til implem sym reloc */ default_symfile_segments, /* sym_segments: Get segment information from diff --git a/gdb/objfiles.c b/gdb/objfiles.c -index c983b11..2ac1bd1 100644 +index 586f5d0..a4bf719 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c -@@ -433,9 +433,8 @@ free_objfile (struct objfile *objfile) +@@ -432,10 +432,9 @@ free_objfile (struct objfile *objfile) + doesn't reference it. */ objfile->separate_debug_objfile_backlink->separate_debug_objfile = NULL; } - +- - /* Remove any references to this objfile in the global value - lists. */ - preserve_values (objfile); ++ + /* Remove any references to this objfile in the global value lists. */ + observer_notify_objfile_unloading (objfile); /* First do any symbol file specific actions required when we are finished with a particular symbol file. Note that if the objfile -@@ -473,6 +472,9 @@ free_objfile (struct objfile *objfile) +@@ -458,12 +457,14 @@ free_objfile (struct objfile *objfile) + + unlink_objfile (objfile); + +- /* If we are going to free the runtime common objfile, mark it +- as unallocated. */ ++ /* If we are going to free any existing OBJFILE reference, clear it. */ + if (objfile == rt_common_objfile) rt_common_objfile = NULL; @@ -10422,7 +10547,7 @@ index c983b11..2ac1bd1 100644 /* Before the symbol table code was redone to make it easier to selectively load and remove information particular to a specific linkage unit, gdb used to do these things whenever the monolithic -@@ -723,6 +725,20 @@ have_partial_symbols (void) +@@ -714,6 +715,20 @@ have_partial_symbols (void) return 1; } } @@ -10443,30 +10568,8 @@ index c983b11..2ac1bd1 100644 return 0; } -@@ -1020,3 +1036,21 @@ objfiles_changed (void) - { - objfiles_changed_p = 1; /* Rebuild section map next time we need it. */ - } -+ -+/* Return non-zero if A and B point to the same OBJFILE, ignoring any binary -+ vs. debuginfo variants of the pointers. If either A or B is NULL return -+ zero as not a match. */ -+ -+int -+matching_objfiles (struct objfile *a, struct objfile *b) -+{ -+ if (a == NULL || b == NULL) -+ return 0; -+ -+ if (a->separate_debug_objfile_backlink) -+ a = a->separate_debug_objfile_backlink; -+ if (b->separate_debug_objfile_backlink) -+ b = b->separate_debug_objfile_backlink; -+ -+ return a == b; -+} diff --git a/gdb/objfiles.h b/gdb/objfiles.h -index 1857260..e421232 100644 +index aecf8d8..9a7d635 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -212,6 +212,11 @@ struct objfile @@ -10481,9 +10584,9 @@ index 1857260..e421232 100644 /* Map addresses to the entries of PSYMTABS. It would be more efficient to have a map per the whole process but ADDRMAP cannot selectively remove its items during FREE_OBJFILE. This mapping is already present even for -@@ -420,6 +425,15 @@ struct objfile - #define OBJF_KEEPBFD (1 << 4) /* Do not delete bfd */ +@@ -414,6 +419,15 @@ struct objfile + #define OBJF_USERLOADED (1 << 3) /* User loaded */ +/* Set if we have tried to read partial symtabs for this objfile. + This is used to allow lazy reading of partial symtabs. */ @@ -10497,16 +10600,7 @@ index 1857260..e421232 100644 /* The object file that the main symbol table was loaded from (e.g. the argument to the "symbol-file" or "file" command). */ -@@ -499,6 +513,8 @@ extern struct obj_section *find_pc_section (CORE_ADDR pc); - - extern int in_plt_section (CORE_ADDR, char *); - -+extern int matching_objfiles (struct objfile *a, struct objfile *b); -+ - /* Keep a registry of per-objfile data-pointers required by other GDB - modules. */ - -@@ -558,6 +574,13 @@ extern void *objfile_data (struct objfile *objfile, +@@ -554,6 +568,13 @@ extern void gdb_bfd_unref (struct bfd *abfd); ALL_OBJFILES (objfile) \ ALL_OBJFILE_PSYMTABS (objfile, p) @@ -16408,27 +16502,27 @@ index 49c0437..84a476e 100644 + return 1; +} diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c -index dd3c919..fb9dab2 100644 +index dd3c919..dc76692 100644 --- a/gdb/python/python-value.c +++ b/gdb/python/python-value.c -@@ -25,6 +25,7 @@ +@@ -25,15 +25,7 @@ #include "language.h" #include "dfp.h" #include "valprint.h" -+#include "observer.h" - - /* List of all values which are currently exposed to Python. It is - maintained so that when an objfile is discarded, preserve_values -@@ -33,7 +34,7 @@ - generic code. */ - /* This variable is unnecessarily initialized to NULL in order to - work around a linker bug on MacOS. */ +- +-/* List of all values which are currently exposed to Python. It is +- maintained so that when an objfile is discarded, preserve_values +- can copy the values' types if needed. This is declared +- unconditionally to reduce the number of uses of HAVE_PYTHON in the +- generic code. */ +-/* This variable is unnecessarily initialized to NULL in order to +- work around a linker bug on MacOS. */ -struct value *values_in_python = NULL; -+static struct value_object *values_in_python = NULL; ++#include "observer.h" #ifdef HAVE_PYTHON -@@ -52,17 +53,23 @@ struct value *values_in_python = NULL; +@@ -52,26 +44,43 @@ struct value *values_in_python = NULL; /* Python's long type corresponds to C's long long type. */ #define builtin_type_pylong builtin_type (python_gdbarch)->builtin_long_long @@ -16445,67 +16539,100 @@ index dd3c919..fb9dab2 100644 -typedef struct { +typedef struct value_object { PyObject_HEAD ++ struct value_object *next; struct value *value; PyObject *address; PyObject *type; -+ struct value_object *next; -+ struct value_object *prev; } value_object; ++/* List of all values which are currently exposed to Python. It is ++ maintained so that when an objfile is discarded, preserve_values ++ can copy the values' types if needed. */ ++/* This variable is unnecessarily initialized to NULL in order to ++ work around a linker bug on MacOS. */ ++static value_object *values_in_python = NULL; ++ /* Called by the Python interpreter when deallocating a value object. */ -@@ -71,7 +78,12 @@ valpy_dealloc (PyObject *obj) + static void + valpy_dealloc (PyObject *obj) { value_object *self = (value_object *) obj; ++ value_object **iter; - value_remove_from_list (&values_in_python, self->value); -+ if (self == values_in_python) -+ values_in_python = self->next; -+ if (self->prev) -+ self->prev->next = self->next; -+ if (self->next) -+ self->next->prev = self->prev; ++ /* Remove OBJ from the global list. */ ++ iter = &values_in_python; ++ while (*iter != self) ++ iter = &(*iter)->next; ++ *iter = (*iter)->next; value_free (self->value); -@@ -122,7 +134,17 @@ valpy_new (PyTypeObject *subtype, PyObject *args, PyObject *keywords) +@@ -122,11 +131,23 @@ valpy_new (PyTypeObject *subtype, PyObject *args, PyObject *keywords) value_obj->address = NULL; value_obj->type = NULL; release_value (value); - value_prepend_to_list (&values_in_python, value); -+ -+ /* New FSF GDB reference counting no longer considers release_value as one -+ incref. FIXME: We are now leaking here if VALUE was already -+ release_value-d before. */ -+ value_incref (value); -+ + value_obj->next = values_in_python; + values_in_python = value_obj; -+ if (value_obj->next) -+ value_obj->next->prev = value_obj; -+ value_obj->prev = NULL; return (PyObject *) value_obj; } -@@ -803,7 +825,17 @@ value_to_value_object (struct value *val) + ++/* Iterate over all the Value objects, calling preserve_one_value on ++ each. */ ++void ++preserve_python_values (struct objfile *objfile, htab_t copied_types) ++{ ++ value_object *iter; ++ ++ for (iter = values_in_python; iter; iter = iter->next) ++ preserve_one_value (iter->value, objfile, copied_types); ++} ++ + /* Given a value of a pointer type, apply the C unary * operator to it. */ + static PyObject * + valpy_dereference (PyObject *self, PyObject *args) +@@ -543,9 +564,7 @@ valpy_negative (PyObject *self) + static PyObject * + valpy_positive (PyObject *self) + { +- struct value *copy = value_copy (((value_object *) self)->value); +- +- return value_to_value_object (copy); ++ return value_to_value_object (((value_object *) self)->value); + } + + static PyObject * +@@ -803,13 +822,15 @@ value_to_value_object (struct value *val) val_obj->address = NULL; val_obj->type = NULL; release_value (val); - value_prepend_to_list (&values_in_python, val); -+ -+ /* New FSF GDB reference counting no longer considers release_value as one -+ incref. FIXME: We are now leaking here if VALUE was already -+ release_value-d before. */ -+ value_incref (val); -+ + val_obj->next = values_in_python; + values_in_python = val_obj; -+ if (val_obj->next) -+ val_obj->next->prev = val_obj; -+ val_obj->prev = NULL; } return (PyObject *) val_obj; -@@ -853,7 +885,34 @@ convert_value_from_python (PyObject *obj) + } + +-/* Returns value structure corresponding to the given value object. */ ++/* Returns a borrowed reference to the struct value corresponding to ++ the given value object. */ + struct value * + value_object_to_value (PyObject *self) + { +@@ -821,7 +842,8 @@ value_object_to_value (PyObject *self) + } + + /* Try to convert a Python value to a gdb value. If the value cannot +- be converted, set a Python exception and return NULL. */ ++ be converted, set a Python exception and return NULL. Returns a ++ borrowed reference to the resulting struct value. */ + + struct value * + convert_value_from_python (PyObject *obj) +@@ -853,7 +875,34 @@ convert_value_from_python (PyObject *obj) { LONGEST l = PyLong_AsLongLong (obj); @@ -16541,7 +16668,21 @@ index dd3c919..fb9dab2 100644 value = value_from_longest (builtin_type_pylong, l); } else if (PyFloat_Check (obj)) -@@ -912,6 +971,34 @@ gdbpy_history (PyObject *self, PyObject *args) +@@ -876,7 +925,12 @@ convert_value_from_python (PyObject *obj) + } + } + else if (PyObject_TypeCheck (obj, &value_object_type)) +- value = value_copy (((value_object *) obj)->value); ++ { ++ /* This lets callers freely decref the Value wrapper object ++ and not worry about whether or not the value will ++ disappear. */ ++ value = value_copy (((value_object *) obj)->value); ++ } + else + PyErr_Format (PyExc_TypeError, _("Could not convert Python object: %s"), + PyString_AsString (PyObject_Str (obj))); +@@ -912,6 +966,25 @@ gdbpy_history (PyObject *self, PyObject *args) return value_to_value_object (res_val); } @@ -16550,19 +16691,10 @@ index dd3c919..fb9dab2 100644 +static void +python_types_mark_used (void) +{ -+ value_object *val_obj; ++ value_object *iter; + -+ for (val_obj = values_in_python; val_obj != NULL; val_obj = val_obj->next) -+ type_mark_used (value_type (val_obj->value)); -+} -+ -+void -+preserve_python_values (struct objfile *objfile, htab_t copied_types) -+{ -+ value_object *val_obj; -+ -+ for (val_obj = values_in_python; val_obj != NULL; val_obj = val_obj->next) -+ preserve_one_value (val_obj->value, objfile, copied_types); ++ for (iter = values_in_python; iter; iter = iter->next) ++ type_mark_used (value_type (iter->value)); +} + +/* Returns 1 in OBJ is a gdb.Value object, 0 otherwise. */ @@ -16576,7 +16708,7 @@ index dd3c919..fb9dab2 100644 void gdbpy_initialize_values (void) { -@@ -922,6 +1009,8 @@ gdbpy_initialize_values (void) +@@ -922,6 +995,8 @@ gdbpy_initialize_values (void) PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type); values_in_python = NULL; @@ -16585,20 +16717,32 @@ index dd3c919..fb9dab2 100644 } +@@ -1019,4 +1094,12 @@ PyTypeObject value_object_type = { + valpy_new /* tp_new */ + }; + ++#else ++ ++void ++preserve_python_values (struct objfile *objfile, htab_t copied_types) ++{ ++ /* Nothing. */ ++} ++ + #endif /* HAVE_PYTHON */ diff --git a/gdb/python/python.c b/gdb/python/python.c -index 254bd28..7cd2b3a 100644 +index 254bd28..5a2a9ae 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c -@@ -27,6 +27,8 @@ +@@ -27,6 +27,7 @@ #include "observer.h" #include "value.h" #include "language.h" +#include "event-loop.h" -+#include "valprint.h" #include -@@ -45,11 +47,18 @@ static int gdbpy_auto_load = 1; +@@ -45,11 +46,18 @@ static int gdbpy_auto_load = 1; #include "cli/cli-decode.h" #include "charset.h" #include "top.h" @@ -16617,7 +16761,7 @@ index 254bd28..7cd2b3a 100644 static PyMethodDef GdbMethods[]; -@@ -197,10 +206,10 @@ python_command (char *arg, int from_tty) +@@ -197,10 +205,10 @@ python_command (char *arg, int from_tty) NULL (and set a Python exception) on error. Helper function for get_parameter. */ @@ -16631,7 +16775,7 @@ index 254bd28..7cd2b3a 100644 { case var_string: case var_string_noescape: -@@ -208,7 +217,7 @@ parameter_to_python (struct cmd_list_element *cmd) +@@ -208,7 +216,7 @@ parameter_to_python (struct cmd_list_element *cmd) case var_filename: case var_enum: { @@ -16640,7 +16784,7 @@ index 254bd28..7cd2b3a 100644 if (! str) str = ""; return PyString_Decode (str, strlen (str), host_charset (), NULL); -@@ -216,7 +225,7 @@ parameter_to_python (struct cmd_list_element *cmd) +@@ -216,7 +224,7 @@ parameter_to_python (struct cmd_list_element *cmd) case var_boolean: { @@ -16649,7 +16793,7 @@ index 254bd28..7cd2b3a 100644 Py_RETURN_TRUE; else Py_RETURN_FALSE; -@@ -224,7 +233,7 @@ parameter_to_python (struct cmd_list_element *cmd) +@@ -224,7 +232,7 @@ parameter_to_python (struct cmd_list_element *cmd) case var_auto_boolean: { @@ -16658,7 +16802,7 @@ index 254bd28..7cd2b3a 100644 if (ab == AUTO_BOOLEAN_TRUE) Py_RETURN_TRUE; else if (ab == AUTO_BOOLEAN_FALSE) -@@ -234,15 +243,15 @@ parameter_to_python (struct cmd_list_element *cmd) +@@ -234,15 +242,15 @@ parameter_to_python (struct cmd_list_element *cmd) } case var_integer: @@ -16677,7 +16821,7 @@ index 254bd28..7cd2b3a 100644 if (val == UINT_MAX) Py_RETURN_NONE; return PyLong_FromUnsignedLong (val); -@@ -280,7 +289,7 @@ gdbpy_parameter (PyObject *self, PyObject *args) +@@ -280,7 +288,7 @@ gdbpy_parameter (PyObject *self, PyObject *args) if (! cmd->var) return PyErr_Format (PyExc_RuntimeError, "`%s' is not a parameter", arg); @@ -16686,7 +16830,7 @@ index 254bd28..7cd2b3a 100644 } /* A Python function which evaluates a string using the gdb CLI. */ -@@ -319,6 +328,233 @@ execute_gdb_command (PyObject *self, PyObject *args) +@@ -319,6 +327,233 @@ execute_gdb_command (PyObject *self, PyObject *args) Py_RETURN_NONE; } @@ -16920,7 +17064,7 @@ index 254bd28..7cd2b3a 100644 /* Printing. */ -@@ -357,6 +593,69 @@ gdbpy_print_stack (void) +@@ -357,6 +592,69 @@ gdbpy_print_stack (void) @@ -16990,152 +17134,7 @@ index 254bd28..7cd2b3a 100644 /* The "current" objfile. This is set when gdb detects that a new objfile has been loaded. It is only set for the duration of a call to gdbpy_new_objfile; it is NULL at other times. */ -@@ -475,6 +774,144 @@ gdbpy_objfiles (PyObject *unused1, PyObject *unused2) - return list; - } - -+ -+ -+/* Helper function for find_pretty_printer which iterates over a -+ list, calls each function and inspects output. */ -+static PyObject * -+search_pp_list (PyObject *list, PyObject *value) -+{ -+ Py_ssize_t pp_list_size, list_index; -+ PyObject *function, *printer = NULL; -+ -+ pp_list_size = PyList_Size (list); -+ for (list_index = 0; list_index < pp_list_size; list_index++) -+ { -+ function = PyList_GetItem (list, list_index); -+ if (! function) -+ return NULL; -+ -+ /* gdbpy_instantiate_printer can return three possible return -+ values: NULL on error; Py_None if the pretty-printer -+ in the list cannot print the value; or a printer instance if -+ the printer can print the value. */ -+ printer = gdbpy_instantiate_printer (function, value); -+ if (! printer) -+ return NULL; -+ else if (printer != Py_None) -+ return printer; -+ -+ Py_DECREF (printer); -+ } -+ -+ Py_RETURN_NONE; -+} -+ -+/* Find the pretty-printing constructor function for TYPE. If no -+ pretty-printer exists, return NULL. If one exists, return a new -+ reference. */ -+static PyObject * -+find_pretty_printer (PyObject *value) -+{ -+ PyObject *pp_list = NULL; -+ PyObject *function = NULL; -+ struct objfile *obj; -+ volatile struct gdb_exception except; -+ -+ /* Look at the pretty-printer dictionary for each objfile. */ -+ ALL_OBJFILES (obj) -+ { -+ PyObject *objf = objfile_to_objfile_object (obj); -+ if (!objf) -+ continue; -+ -+ pp_list = objfpy_get_printers (objf, NULL); -+ function = search_pp_list (pp_list, value); -+ -+ /* If there is an error in any objfile list, abort the search and -+ exit. */ -+ if (! function) -+ { -+ Py_XDECREF (pp_list); -+ return NULL; -+ } -+ -+ if (function != Py_None) -+ goto done; -+ -+ /* In this loop, if function is not an instantiation of a -+ pretty-printer, and it is not null, then it is a return of -+ Py_RETURN_NONE, which must be decremented. */ -+ Py_DECREF (function); -+ Py_XDECREF (pp_list); -+ } -+ -+ pp_list = NULL; -+ /* Fetch the global pretty printer dictionary. */ -+ if (! PyObject_HasAttrString (gdb_module, "pretty_printers")) -+ goto done; -+ pp_list = PyObject_GetAttrString (gdb_module, "pretty_printers"); -+ if (! pp_list) -+ goto done; -+ if (! PyList_Check (pp_list)) -+ goto done; -+ -+ function = search_pp_list (pp_list, value); -+ -+ done: -+ Py_XDECREF (pp_list); -+ -+ return function; -+} -+ -+/* Pretty-print a single value, via the printer object PRINTER. If -+ the function returns a string, an xmalloc()d copy is returned. -+ Otherwise, if the function returns a value, a *OUT_VALUE is set to -+ the value, and NULL is returned. On error, *OUT_VALUE is set to -+ NULL and NULL is returned. */ -+static char * -+pretty_print_one_value (PyObject *printer, struct value **out_value) -+{ -+ char *output = NULL; -+ volatile struct gdb_exception except; -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ PyObject *result; -+ -+ result = PyObject_CallMethodObjArgs (printer, gdbpy_to_string_cst, NULL); -+ if (result) -+ { -+ if (gdbpy_is_string (result)) -+ output = python_string_to_host_string (result); -+ else if (PyObject_TypeCheck (result, &value_object_type)) -+ { -+ /* If we just call convert_value_from_python for this -+ type, we won't know who owns the result. For this -+ one case we need to copy the resulting value. */ -+ struct value *v = value_object_to_value (result); -+ *out_value = value_copy (v); -+ } -+ else -+ *out_value = convert_value_from_python (result); -+ Py_DECREF (result); -+ } -+ } -+ -+ return output; -+} -+ -+/* Instantiate a pretty-printer given a constructor, CONS, and a -+ value, VAL. Return NULL on error. Ownership of the object -+ instance is transferred to the reciever */ -+PyObject * -+gdbpy_instantiate_printer (PyObject *cons, PyObject *value) -+{ -+ PyObject *result; -+ result = PyObject_CallFunctionObjArgs (cons, value, NULL); -+ return result; -+} -+ - #else /* HAVE_PYTHON */ - - /* Dummy implementation of the gdb "python" command. */ -@@ -501,6 +938,13 @@ eval_python_from_control_command (struct command_line *cmd) +@@ -501,6 +799,13 @@ eval_python_from_control_command (struct command_line *cmd) error (_("Python scripting is not supported in this copy of GDB.")); } @@ -17149,7 +17148,7 @@ index 254bd28..7cd2b3a 100644 #endif /* HAVE_PYTHON */ -@@ -592,13 +1036,27 @@ Enables or disables auto-loading of Python code when an object is opened."), +@@ -592,13 +897,27 @@ Enables or disables auto-loading of Python code when an object is opened."), PyModule_AddStringConstant (gdb_module, "VERSION", (char*) version); PyModule_AddStringConstant (gdb_module, "HOST_CONFIG", (char*) host_name); PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG", (char*) target_name); @@ -17177,7 +17176,7 @@ index 254bd28..7cd2b3a 100644 PyRun_SimpleString ("import gdb"); PyRun_SimpleString ("gdb.pretty_printers = []"); -@@ -634,6 +1092,15 @@ class GdbOutputFile:\n\ +@@ -634,6 +953,15 @@ class GdbOutputFile:\n\ \n\ sys.stderr = GdbOutputFile()\n\ sys.stdout = GdbOutputFile()\n\ @@ -17193,7 +17192,7 @@ index 254bd28..7cd2b3a 100644 "); /* Release the GIL while gdb runs. */ -@@ -653,9 +1120,14 @@ static PyMethodDef GdbMethods[] = +@@ -653,9 +981,14 @@ static PyMethodDef GdbMethods[] = "Get a value from history" }, { "execute", execute_gdb_command, METH_VARARGS, "Execute a gdb command" }, @@ -17208,7 +17207,7 @@ index 254bd28..7cd2b3a 100644 { "default_visualizer", gdbpy_default_visualizer, METH_VARARGS, "Find the default visualizer for a Value." }, -@@ -676,6 +1148,37 @@ Return a string explaining unwind stop reason." }, +@@ -676,6 +1009,37 @@ Return a string explaining unwind stop reason." }, "lookup_type (name [, block]) -> type\n\ Return a Type corresponding to the given name." }, @@ -17247,16 +17246,15 @@ index 254bd28..7cd2b3a 100644 "Write a string using gdb's filtered stream." }, { "flush", gdbpy_flush, METH_NOARGS, diff --git a/gdb/python/python.h b/gdb/python/python.h -index 33b0437..b761a65 100644 +index 33b0437..bbb6184 100644 --- a/gdb/python/python.h +++ b/gdb/python/python.h -@@ -22,10 +22,14 @@ +@@ -22,14 +22,18 @@ #include "value.h" -extern struct value *values_in_python; -+void preserve_python_values (struct objfile *objfile, htab_t copied_types); - +- void eval_python_from_control_command (struct command_line *); +void source_python_script (FILE *stream, char *file); @@ -17266,6 +17264,12 @@ index 33b0437..b761a65 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, + const struct value_print_options *options, + const struct language_defn *language); + ++void preserve_python_values (struct objfile *objfile, htab_t copied_types); ++ + #endif /* GDB_PYTHON_H */ diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c index de34894..07518b0 100644 --- a/gdb/scm-lang.c @@ -17295,10 +17299,10 @@ index cc3319a..d0d4702 100644 if ((gdb_output_sym == NULL) || (gdb_output_len_sym == NULL)) ret = -1; diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c -index 97cc29c..f655956 100644 +index 8b96a6f..9428d92 100644 --- a/gdb/solib-darwin.c +++ b/gdb/solib-darwin.c -@@ -401,7 +401,6 @@ darwin_relocate_section_addresses (struct so_list *so, +@@ -389,7 +389,6 @@ darwin_relocate_section_addresses (struct so_list *so, static struct symbol * darwin_lookup_lib_symbol (const struct objfile *objfile, const char *name, @@ -17351,10 +17355,10 @@ index 6cfaa85..68aadc0 100644 extern initialize_file_ftype _initialize_svr4_solib; /* -Wmissing-prototypes */ diff --git a/gdb/solib.c b/gdb/solib.c -index 157aaba..4c1b0fb 100644 +index aad2d59..def02f8 100644 --- a/gdb/solib.c +++ b/gdb/solib.c -@@ -1072,13 +1072,12 @@ show_auto_solib_add (struct ui_file *file, int from_tty, +@@ -1066,13 +1066,12 @@ show_auto_solib_add (struct ui_file *file, int from_tty, struct symbol * solib_global_lookup (const struct objfile *objfile, const char *name, @@ -17493,7 +17497,7 @@ index 1c37801..594eb16 100644 print_variable_and_value (NULL, sym, frame, stream, 4 * num_tabs); break; diff --git a/gdb/symfile.c b/gdb/symfile.c -index 36480c1..4dea8d7 100644 +index c182faa..8b971fb 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -52,7 +52,6 @@ @@ -17576,7 +17580,18 @@ index 36480c1..4dea8d7 100644 { wrap_here (""); printf_unfiltered (_("(no debugging symbols found)")); -@@ -2337,7 +2358,7 @@ reread_symbols (void) +@@ -1166,7 +1187,9 @@ symbol_file_clear (int from_tty) + descriptors as well. */ + no_shared_libraries (NULL, from_tty); + +- symfile_objfile = NULL; ++ /* free_objfile should have cleared it. */ ++ gdb_assert (symfile_objfile == NULL); ++ + if (from_tty) + printf_unfiltered (_("No symbol file now.\n")); + } +@@ -2349,7 +2372,7 @@ reread_symbols (void) /* Remove any references to this objfile in the global value lists. */ @@ -17585,7 +17600,7 @@ index 36480c1..4dea8d7 100644 /* Nuke all the state that we will re-read. Much of the following code which sets things to NULL really is necessary to tell -@@ -2425,13 +2446,15 @@ reread_symbols (void) +@@ -2437,13 +2460,15 @@ reread_symbols (void) zero is OK since dbxread.c also does what it needs to do if objfile->global_psymbols.size is 0. */ (*objfile->sf->sym_read) (objfile, 0); @@ -17602,7 +17617,7 @@ index 36480c1..4dea8d7 100644 /* We're done reading the symbol file; finish off complaints. */ clear_complaints (&symfile_complaints, 0, 1); -@@ -2440,6 +2463,9 @@ reread_symbols (void) +@@ -2452,6 +2477,9 @@ reread_symbols (void) reinit_frame_cache (); @@ -17612,7 +17627,7 @@ index 36480c1..4dea8d7 100644 /* Discard cleanups as symbol reading was successful. */ discard_cleanups (old_cleanups); -@@ -2729,7 +2755,7 @@ allocate_symtab (char *filename, struct objfile *objfile) +@@ -2741,7 +2769,7 @@ allocate_symtab (char *filename, struct objfile *objfile) } struct partial_symtab * @@ -17621,7 +17636,7 @@ index 36480c1..4dea8d7 100644 { struct partial_symtab *psymtab; -@@ -2820,10 +2846,6 @@ clear_symtab_users (void) +@@ -2832,10 +2860,6 @@ clear_symtab_users (void) between expressions and which ought to be reset each time. */ expression_context_block = NULL; innermost_block = NULL; @@ -17632,7 +17647,7 @@ index 36480c1..4dea8d7 100644 } static void -@@ -3043,7 +3065,8 @@ again2: +@@ -3055,7 +3079,8 @@ again2: struct partial_symtab * start_psymtab_common (struct objfile *objfile, @@ -17709,7 +17724,7 @@ index eb35369..dfd8c8c 100644 { printf_filtered ("Global symbol `"); diff --git a/gdb/symtab.c b/gdb/symtab.c -index c88156a..567fa07 100644 +index c88156a..b269491 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -42,6 +42,7 @@ @@ -17949,7 +17964,7 @@ index c88156a..567fa07 100644 if (sym != NULL) return sym; -@@ -1364,30 +1352,79 @@ lookup_symbol_aux (const char *name, const char *linkage_name, +@@ -1364,30 +1352,81 @@ lookup_symbol_aux (const char *name, const char *linkage_name, Don't search STATIC_BLOCK or GLOBAL_BLOCK. */ static struct symbol * @@ -17967,7 +17982,6 @@ index c88156a..567fa07 100644 + const struct language_defn *langdef; + + langdef = language_def (language); -+ /* Check if either no block is specified or it's a global block. */ @@ -17991,8 +18005,8 @@ index c88156a..567fa07 100644 + + if (language == language_cplus ) + { -+ sym = lookup_namespace_scope(name, block,domain, -+ block_scope (block_iterator), 0, 1); ++ sym = cp_lookup_symbol_imports (block_scope (block_iterator), name, ++ block_iterator, domain, 1); + + if (sym != NULL) + return sym; @@ -18033,6 +18047,9 @@ index c88156a..567fa07 100644 + } + } + ++ if (BLOCK_FUNCTION (block_iterator) != NULL && block_inlined_p (block_iterator)) ++ break; ++ + block_iterator = BLOCK_SUPERBLOCK (block_iterator); } @@ -18041,7 +18058,7 @@ index c88156a..567fa07 100644 return NULL; } -@@ -1416,13 +1453,12 @@ lookup_objfile_from_block (const struct block *block) +@@ -1416,13 +1455,12 @@ lookup_objfile_from_block (const struct block *block) block_found appropriately. */ struct symbol * @@ -18057,7 +18074,7 @@ index c88156a..567fa07 100644 if (sym) { block_found = block; -@@ -1438,7 +1474,6 @@ lookup_symbol_aux_block (const char *name, const char *linkage_name, +@@ -1438,7 +1476,6 @@ lookup_symbol_aux_block (const char *name, const char *linkage_name, struct symbol * lookup_global_symbol_from_objfile (const struct objfile *objfile, const char *name, @@ -18065,7 +18082,7 @@ index c88156a..567fa07 100644 const domain_enum domain) { struct symbol *sym; -@@ -1452,7 +1487,7 @@ lookup_global_symbol_from_objfile (const struct objfile *objfile, +@@ -1452,7 +1489,7 @@ lookup_global_symbol_from_objfile (const struct objfile *objfile, { bv = BLOCKVECTOR (s); block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); @@ -18074,7 +18091,7 @@ index c88156a..567fa07 100644 if (sym) { block_found = block; -@@ -1461,23 +1496,23 @@ lookup_global_symbol_from_objfile (const struct objfile *objfile, +@@ -1461,23 +1498,23 @@ lookup_global_symbol_from_objfile (const struct objfile *objfile, } /* Now go through psymtabs. */ @@ -18102,7 +18119,7 @@ index c88156a..567fa07 100644 return NULL; } -@@ -1488,8 +1523,7 @@ lookup_global_symbol_from_objfile (const struct objfile *objfile, +@@ -1488,8 +1525,7 @@ lookup_global_symbol_from_objfile (const struct objfile *objfile, static symbols. */ static struct symbol * @@ -18112,7 +18129,7 @@ index c88156a..567fa07 100644 const domain_enum domain) { struct symbol *sym; -@@ -1502,7 +1536,7 @@ lookup_symbol_aux_symtabs (int block_index, +@@ -1502,7 +1538,7 @@ lookup_symbol_aux_symtabs (int block_index, { bv = BLOCKVECTOR (s); block = BLOCKVECTOR_BLOCK (bv, block_index); @@ -18121,7 +18138,7 @@ index c88156a..567fa07 100644 if (sym) { block_found = block; -@@ -1520,7 +1554,6 @@ lookup_symbol_aux_symtabs (int block_index, +@@ -1520,7 +1556,6 @@ lookup_symbol_aux_symtabs (int block_index, static struct symbol * lookup_symbol_aux_psymtabs (int block_index, const char *name, @@ -18129,7 +18146,7 @@ index c88156a..567fa07 100644 const domain_enum domain) { struct symbol *sym; -@@ -1531,16 +1564,15 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name, +@@ -1531,16 +1566,15 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name, struct symtab *s; const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0); @@ -18149,7 +18166,7 @@ index c88156a..567fa07 100644 if (!sym) { /* This shouldn't be necessary, but as a last resort try -@@ -1557,7 +1589,7 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name, +@@ -1557,7 +1591,7 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name, block = BLOCKVECTOR_BLOCK (bv, block_index == GLOBAL_BLOCK ? STATIC_BLOCK : GLOBAL_BLOCK); @@ -18158,7 +18175,7 @@ index c88156a..567fa07 100644 if (!sym) error (_("Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n%s may be an inlined function, or may be a template function\n(if a template, try specifying an instantiation: %s)."), block_index == GLOBAL_BLOCK ? "global" : "static", -@@ -1576,7 +1608,6 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name, +@@ -1576,7 +1610,6 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name, struct symbol * basic_lookup_symbol_nonlocal (const char *name, @@ -18166,7 +18183,7 @@ index c88156a..567fa07 100644 const struct block *block, const domain_enum domain) { -@@ -1610,11 +1641,11 @@ basic_lookup_symbol_nonlocal (const char *name, +@@ -1610,11 +1643,11 @@ basic_lookup_symbol_nonlocal (const char *name, than that one, so I don't think we should worry about that for now. */ @@ -18180,7 +18197,7 @@ index c88156a..567fa07 100644 } /* Lookup a symbol in the static block associated to BLOCK, if there -@@ -1622,14 +1653,13 @@ basic_lookup_symbol_nonlocal (const char *name, +@@ -1622,14 +1655,13 @@ basic_lookup_symbol_nonlocal (const char *name, struct symbol * lookup_symbol_static (const char *name, @@ -18196,7 +18213,7 @@ index c88156a..567fa07 100644 else return NULL; } -@@ -1639,7 +1669,6 @@ lookup_symbol_static (const char *name, +@@ -1639,7 +1671,6 @@ lookup_symbol_static (const char *name, struct symbol * lookup_symbol_global (const char *name, @@ -18204,7 +18221,7 @@ index c88156a..567fa07 100644 const struct block *block, const domain_enum domain) { -@@ -1649,15 +1678,15 @@ lookup_symbol_global (const char *name, +@@ -1649,15 +1680,15 @@ lookup_symbol_global (const char *name, /* Call library-specific lookup procedure. */ objfile = lookup_objfile_from_block (block); if (objfile != NULL) @@ -18223,7 +18240,7 @@ index c88156a..567fa07 100644 } int -@@ -1681,14 +1710,11 @@ symbol_matches_domain (enum language symbol_language, +@@ -1681,14 +1712,11 @@ symbol_matches_domain (enum language symbol_language, } /* Look, in partial_symtab PST, for symbol whose natural name is NAME. @@ -18240,7 +18257,7 @@ index c88156a..567fa07 100644 { struct partial_symbol *temp; struct partial_symbol **start, **psym; -@@ -1740,9 +1766,7 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, +@@ -1740,9 +1768,7 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, internal_error (__FILE__, __LINE__, _("failed internal consistency check")); while (top <= real_top @@ -18251,7 +18268,7 @@ index c88156a..567fa07 100644 { if (symbol_matches_domain (SYMBOL_LANGUAGE (*top), SYMBOL_DOMAIN (*top), domain)) -@@ -1759,15 +1783,9 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, +@@ -1759,15 +1785,9 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, for (psym = start; psym < start + length; psym++) { if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym), @@ -18270,7 +18287,7 @@ index c88156a..567fa07 100644 } } -@@ -1809,22 +1827,25 @@ basic_lookup_transparent_type (const char *name) +@@ -1809,22 +1829,25 @@ basic_lookup_transparent_type (const char *name) { bv = BLOCKVECTOR (s); block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); @@ -18301,7 +18318,7 @@ index c88156a..567fa07 100644 if (!sym) { /* This shouldn't be necessary, but as a last resort -@@ -1833,7 +1854,7 @@ basic_lookup_transparent_type (const char *name) +@@ -1833,7 +1856,7 @@ basic_lookup_transparent_type (const char *name) * the psymtab gets it wrong in some cases. */ block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); @@ -18310,7 +18327,7 @@ index c88156a..567fa07 100644 if (!sym) error (_("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\ %s may be an inlined function, or may be a template function\n\ -@@ -1857,21 +1878,26 @@ basic_lookup_transparent_type (const char *name) +@@ -1857,21 +1880,26 @@ basic_lookup_transparent_type (const char *name) { bv = BLOCKVECTOR (s); block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); @@ -18341,7 +18358,7 @@ index c88156a..567fa07 100644 if (!sym) { /* This shouldn't be necessary, but as a last resort -@@ -1880,7 +1906,7 @@ basic_lookup_transparent_type (const char *name) +@@ -1880,7 +1908,7 @@ basic_lookup_transparent_type (const char *name) * the psymtab gets it wrong in some cases. */ block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); @@ -18350,7 +18367,7 @@ index c88156a..567fa07 100644 if (!sym) error (_("Internal: static symbol `%s' found in %s psymtab but not in symtab.\n\ %s may be an inlined function, or may be a template function\n\ -@@ -1905,9 +1931,23 @@ find_main_psymtab (void) +@@ -1905,9 +1933,23 @@ find_main_psymtab (void) struct partial_symtab *pst; struct objfile *objfile; @@ -18376,7 +18393,7 @@ index c88156a..567fa07 100644 { return (pst); } -@@ -1925,14 +1965,10 @@ find_main_psymtab (void) +@@ -1925,14 +1967,10 @@ find_main_psymtab (void) search on the symbols. Each symbol which is marked as being a ObjC/C++ symbol (language_cplus or language_objc set) has both the encoded and non-encoded names tested for a match. @@ -18391,7 +18408,7 @@ index c88156a..567fa07 100644 const domain_enum domain) { struct dict_iterator iter; -@@ -1945,9 +1981,7 @@ lookup_block_symbol (const struct block *block, const char *name, +@@ -1945,9 +1983,7 @@ lookup_block_symbol (const struct block *block, const char *name, sym = dict_iter_name_next (name, &iter)) { if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), @@ -18402,7 +18419,7 @@ index c88156a..567fa07 100644 return sym; } return NULL; -@@ -1967,9 +2001,7 @@ lookup_block_symbol (const struct block *block, const char *name, +@@ -1967,9 +2003,7 @@ lookup_block_symbol (const struct block *block, const char *name, sym = dict_iter_name_next (name, &iter)) { if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), @@ -18413,7 +18430,7 @@ index c88156a..567fa07 100644 { sym_found = sym; if (!SYMBOL_IS_ARGUMENT (sym)) -@@ -3172,7 +3204,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[], +@@ -3172,7 +3206,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[], matching the regexp. That way we don't have to reproduce all of the machinery below. */ @@ -18552,10 +18569,10 @@ index 2c743e9..ef29610 100644 /* Stuff that should be shared among the various remote targets. */ diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog -index d1e38f3..c7511cc 100644 +index 7993ac5..181b752 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog -@@ -1252,6 +1252,103 @@ +@@ -1263,6 +1263,103 @@ gdb_start_cmd. Use runto_main before any test that requires execution. @@ -19465,7 +19482,7 @@ index 0000000..b809c4e +#endif diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp new file mode 100644 -index 0000000..534120a +index 0000000..b05411e --- /dev/null +++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp @@ -0,0 +1,64 @@ @@ -19523,10 +19540,10 @@ index 0000000..534120a + +gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array" + -+gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\1'" -+gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\2'" -+gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\3'" -+gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\4'" ++gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'" ++gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'" ++gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'" ++gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'" + +gdb_continue_to_breakpoint "break_here" + @@ -20988,6 +21005,88 @@ index 0000000..e508103 +gdb_test "print _a" "= 11" +gdb_test "print ab" "= 22" +gdb_test "print abc" "= 33" +diff --git a/gdb/testsuite/gdb.cp/namespace-recursive.cc b/gdb/testsuite/gdb.cp/namespace-recursive.cc +new file mode 100644 +index 0000000..cb712fa +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/namespace-recursive.cc +@@ -0,0 +1,16 @@ ++namespace A{ ++ int ax = 9; ++} ++ ++namespace B{ ++ using namespace A; ++} ++ ++namespace C{ ++ using namespace B; ++} ++ ++int main(){ ++ using namespace C; ++ return ax; ++} +\ No newline at end of file +diff --git a/gdb/testsuite/gdb.cp/namespace-recursive.exp b/gdb/testsuite/gdb.cp/namespace-recursive.exp +new file mode 100644 +index 0000000..4e6ad20 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/namespace-recursive.exp +@@ -0,0 +1,53 @@ ++# Copyright 2008 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 . ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set prms_id 0 ++set bug_id 0 ++ ++set testfile namespace-recursive ++set srcfile ${testfile}.cc ++set binfile ${objdir}/${subdir}/${testfile} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++if [get_compiler_info ${binfile}] { ++ return -1; ++} ++ ++ ++# Get things started. ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++############################################ ++# test printing of namespace imported within ++# the function. ++ ++if ![runto_main] then { ++ perror "couldn't run to breakpoint main" ++ continue ++} ++ ++setup_xfail *-*-* ++gdb_test "print ax" "= 9" diff --git a/gdb/testsuite/gdb.cp/namespace-using.cc b/gdb/testsuite/gdb.cp/namespace-using.cc index 4786fd5..8ff5622 100644 --- a/gdb/testsuite/gdb.cp/namespace-using.cc @@ -21154,10 +21253,22 @@ index 4786fd5..8ff5622 100644 + return marker1 (); } diff --git a/gdb/testsuite/gdb.cp/namespace-using.exp b/gdb/testsuite/gdb.cp/namespace-using.exp -index f24973f..fa6b669 100644 +index f24973f..c015ef7 100644 --- a/gdb/testsuite/gdb.cp/namespace-using.exp +++ b/gdb/testsuite/gdb.cp/namespace-using.exp -@@ -46,15 +46,61 @@ if ![runto_main] then { +@@ -28,6 +28,11 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb + return -1 + } + ++if [get_compiler_info ${binfile}] { ++ return -1; ++} ++ ++ + # Get things started. + + gdb_exit +@@ -46,15 +51,61 @@ if ![runto_main] then { gdb_test "print _a" "= 1" @@ -21219,7 +21330,7 @@ index f24973f..fa6b669 100644 ############################################ # Test printing of namespace aliases -@@ -64,14 +110,24 @@ if ![runto marker2] then { +@@ -64,16 +115,32 @@ if ![runto marker2] then { continue } @@ -21245,9 +21356,18 @@ index f24973f..fa6b669 100644 + perror "couldn't run to breakpoint marker3" +} - gdb_test "print _a" "No symbol \"_a\" in current context." "Print a without import" +-gdb_test "print _a" "No symbol \"_a\" in current context." "Print a without import" ++# gcc-4-3 puts import statements for aliases in ++# the global scope instead of the corresponding ++# function scope. These wrong import statements throw ++# this test off. This is fixed in gcc-4-4. ++if [test_compiler_info gcc-4-3-*] then { setup_xfail *-*-* } ++ ++gdb_test "print _a" "No symbol \"_a\" in current context." "Print _a without import" -@@ -84,4 +140,57 @@ if ![runto marker4] then { + ############################################ + # Test printing of individually imported elements +@@ -84,4 +151,57 @@ if ![runto marker4] then { continue } @@ -21257,8 +21377,8 @@ index f24973f..fa6b669 100644 +############################################ +# Test printing of namespace aliases + -+if ![runto marker6] then { -+ perror "couldn't run to breakpoint marker6" ++if ![runto marker5] then { ++ perror "couldn't run to marker5" + continue +} + @@ -21471,10 +21591,10 @@ index 8a6b795..9997a45 100644 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r diff --git a/gdb/testsuite/gdb.cp/shadowing.cc b/gdb/testsuite/gdb.cp/shadowing.cc new file mode 100644 -index 0000000..1651510 +index 0000000..6d9c2f1 --- /dev/null +++ b/gdb/testsuite/gdb.cp/shadowing.cc -@@ -0,0 +1,45 @@ +@@ -0,0 +1,48 @@ +namespace A +{ + int x = 11; @@ -21492,22 +21612,25 @@ index 0000000..1651510 + func() + { + x = 33; -+ y++; // marker1 ++ y+=x; // marker1 + + { + int x = 44; -+ y++; // marker2 ++ y+=x; // marker2 + + { + int x = 55; -+ y++; // marker3 ++ y+=x; // marker3 + + { ++ int z = x; //prevent gcc from optimizing away this scope + using namespace A; -+ y++; // marker4 ++ y+=x; // marker4 + + using A::x; -+ y++; // marker5 ++ y+=x; // marker5 ++ ++ return this->x; + } + } + } @@ -21522,10 +21645,10 @@ index 0000000..1651510 +} diff --git a/gdb/testsuite/gdb.cp/shadowing.exp b/gdb/testsuite/gdb.cp/shadowing.exp new file mode 100644 -index 0000000..fcbf680 +index 0000000..6922eed --- /dev/null +++ b/gdb/testsuite/gdb.cp/shadowing.exp -@@ -0,0 +1,85 @@ +@@ -0,0 +1,91 @@ +# Copyright 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -21556,6 +21679,10 @@ index 0000000..fcbf680 + return -1 +} + ++if [get_compiler_info ${binfile}] { ++ return -1; ++} ++ +# Get things started. + +gdb_exit @@ -21610,7 +21737,385 @@ index 0000000..fcbf680 +gdb_breakpoint [gdb_get_line_number "marker5"] +gdb_continue_to_breakpoint "marker5" + ++if [test_compiler_info gcc-4-3-*] then { setup_xfail *-*-* } ++ +gdb_test "print x" "= 11" "Print imported namespace x" +diff --git a/gdb/testsuite/gdb.dwarf2/callframecfa.S b/gdb/testsuite/gdb.dwarf2/callframecfa.S +new file mode 100644 +index 0000000..6d0421a +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/callframecfa.S +@@ -0,0 +1,309 @@ ++/* ++ Copyright 2009 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 was compiled from a trivial program just to test the ++ DW_OP_call_frame_cfa operator: ++ ++ int func (int arg) { ++ return arg + 23; ++ } ++ ++ int main(int argc, char *argv[]) { ++ func (77); ++ } ++*/ ++ ++ .file "q.c" ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .text ++.Ltext0: ++.globl func ++ .type func, @function ++func: ++.LFB0: ++ .file 1 "q.c" ++ .loc 1 2 0 ++ .cfi_startproc ++ pushl %ebp ++ .cfi_def_cfa_offset 8 ++ movl %esp, %ebp ++ .cfi_offset 5, -8 ++ .cfi_def_cfa_register 5 ++ .loc 1 3 0 ++ movl 8(%ebp), %eax ++ addl $23, %eax ++ .loc 1 4 0 ++ popl %ebp ++ .cfi_restore 5 ++ .cfi_def_cfa 4, 4 ++ ret ++ .cfi_endproc ++.LFE0: ++ .size func, .-func ++.globl _start ++ .type _start, @function ++_start: ++.LFB1: ++ .loc 1 6 0 ++ .cfi_startproc ++ pushl %ebp ++ .cfi_def_cfa_offset 8 ++ movl %esp, %ebp ++ .cfi_offset 5, -8 ++ .cfi_def_cfa_register 5 ++ subl $4, %esp ++ .loc 1 7 0 ++ movl $77, (%esp) ++ call func ++ .loc 1 8 0 ++ leave ++ .cfi_restore 5 ++ .cfi_def_cfa 4, 4 ++ ret ++ .cfi_endproc ++.LFE1: ++ .size _start, .-_start ++.Letext0: ++ .section .debug_info ++ .long 0x9e ++ .value 0x3 ++ .long .Ldebug_abbrev0 ++ .byte 0x4 ++ .uleb128 0x1 ++ .long .LASF5 ++ .byte 0x1 ++ .string "q.c" ++ .long .LASF6 ++ .long .Ltext0 ++ .long .Letext0 ++ .long .Ldebug_line0 ++ .uleb128 0x2 ++ .byte 0x1 ++ .long .LASF0 ++ .byte 0x1 ++ .byte 0x1 ++ .byte 0x1 ++ .long 0x4f ++ .long .LFB0 ++ .long .LFE0 ++ .byte 0x1 ++ .byte 0x9c ++ .long 0x4f ++ .uleb128 0x3 ++ .string "arg" ++ .byte 0x1 ++ .byte 0x1 ++ .long 0x4f ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 0 ++ .byte 0x0 ++ .uleb128 0x4 ++ .byte 0x4 ++ .byte 0x5 ++ .string "int" ++ .uleb128 0x2 ++ .byte 0x1 ++ .long .LASF1 ++ .byte 0x1 ++ .byte 0x6 ++ .byte 0x1 ++ .long 0x4f ++ .long .LFB1 ++ .long .LFE1 ++ .byte 0x1 ++ .byte 0x9c ++ .long 0x8e ++ .uleb128 0x5 ++ .long .LASF2 ++ .byte 0x1 ++ .byte 0x6 ++ .long 0x4f ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 0 ++ .uleb128 0x5 ++ .long .LASF3 ++ .byte 0x1 ++ .byte 0x6 ++ .long 0x8e ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 4 ++ .byte 0x0 ++ .uleb128 0x6 ++ .byte 0x4 ++ .long 0x94 ++ .uleb128 0x6 ++ .byte 0x4 ++ .long 0x9a ++ .uleb128 0x7 ++ .byte 0x1 ++ .byte 0x6 ++ .long .LASF4 ++ .byte 0x0 ++ .section .debug_abbrev ++ .uleb128 0x1 ++ .uleb128 0x11 ++ .byte 0x1 ++ .uleb128 0x25 ++ .uleb128 0xe ++ .uleb128 0x13 ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x1b ++ .uleb128 0xe ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x10 ++ .uleb128 0x6 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 ++ .uleb128 0x2e ++ .byte 0x1 ++ .uleb128 0x3f ++ .uleb128 0xc ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x27 ++ .uleb128 0xc ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x40 ++ .uleb128 0xa ++ .uleb128 0x1 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x5 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x4 ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x5 ++ .uleb128 0x5 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x6 ++ .uleb128 0xf ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x7 ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_pubnames,"",@progbits ++ .long 0x20 ++ .value 0x2 ++ .long .Ldebug_info0 ++ .long 0xa2 ++ .long 0x25 ++ .string "func" ++ .long 0x56 ++ .string "main" ++ .long 0x0 ++ .section .debug_aranges,"",@progbits ++ .long 0x1c ++ .value 0x2 ++ .long .Ldebug_info0 ++ .byte 0x4 ++ .byte 0x0 ++ .value 0x0 ++ .value 0x0 ++ .long .Ltext0 ++ .long .Letext0-.Ltext0 ++ .long 0x0 ++ .long 0x0 ++ .section .debug_str,"MS",@progbits,1 ++.LASF5: ++ .string "GNU C 4.5.0 20090810 (experimental) [trunk revision 150633]" ++.LASF2: ++ .string "argc" ++.LASF6: ++ .string "/tmp" ++.LASF0: ++ .string "func" ++.LASF3: ++ .string "argv" ++.LASF1: ++ .string "main" ++.LASF4: ++ .string "char" ++ .ident "GCC: (GNU) 4.5.0 20090810 (experimental) [trunk revision 150633]" ++ .section .note.GNU-stack,"",@progbits +diff --git a/gdb/testsuite/gdb.dwarf2/callframecfa.exp b/gdb/testsuite/gdb.dwarf2/callframecfa.exp +new file mode 100644 +index 0000000..00d67fc +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/callframecfa.exp +@@ -0,0 +1,55 @@ ++# Copyright 2009 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 . ++ ++# Test DW_OP_call_frame_cfa. ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++# This test can only be run on x86 targets. ++if {![istarget i?86-*]} { ++ return 0 ++} ++ ++set testfile "callframecfa" ++set srcfile ${testfile}.S ++set binfile ${objdir}/${subdir}/${testfile}.x ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \ ++ [list {additional_flags=-nostdlib}]] != "" } { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++gdb_test "break *func" "Breakpoint 1.*" "set breakpoint for call-frame-cfa" ++gdb_test "run" "" "run for call-frame-cfa" ++gdb_test "display arg" "arg = 77" "set display for call-frame-cfa" ++ ++# We know how many instructions are in the function. Note that we ++# can't handle the "ret" instruction due to the epilogue unwinder. ++for {set i 1} {$i < 5} {incr i} { ++ gdb_test "si" "arg = 77" "step $i for call-frame-cfa" ++} diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c new file mode 100644 index 0000000..1f02d90 @@ -23339,10 +23844,10 @@ index 0000000..d444554 +gdb_test "python print t0" "\\" "verify InferiorThread object" +gdb_test "python print 'result =', t0.num" " = \[0-9\]+" "test Inferior.num" diff --git a/gdb/testsuite/gdb.python/python-mi.exp b/gdb/testsuite/gdb.python/python-mi.exp -index 3258810..e7bfe54 100644 +index 3258810..095ee78 100644 --- a/gdb/testsuite/gdb.python/python-mi.exp +++ b/gdb/testsuite/gdb.python/python-mi.exp -@@ -48,7 +48,21 @@ mi_gdb_test "python execfile ('${srcdir}/${subdir}/${testfile}.py')" "" +@@ -48,23 +48,42 @@ mi_gdb_test "python execfile ('${srcdir}/${subdir}/${testfile}.py')" "" mi_continue_to_line [gdb_get_line_number {MI breakpoint here} ${testfile}.c] \ "step to breakpoint" @@ -23365,24 +23870,111 @@ index 3258810..e7bfe54 100644 mi_list_varobj_children container { } "examine container children=0" -@@ -92,6 +106,15 @@ mi_varobj_update_dynamic container { - { {container.\[1\]} {\[1\]} 0 int } - } "varobj update after choosing via expression" + mi_next "next over update 1" + +-mi_varobj_update_dynamic container { +- { {container.\[0\]} {\[0\]} 0 int } +-} "varobj update 1" ++mi_varobj_update_dynamic container "varobj update 1" { ++ type_changed false new_num_children 1 has_more 0 ++} { ++} { ++ { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 } ++} + + mi_next "next over update 2" + +-mi_varobj_update_dynamic container { +- { {container.\[0\]} {\[0\]} 0 int } +- { {container.\[1\]} {\[1\]} 0 int } +-} "varobj update 2" ++mi_varobj_update_dynamic container "varobj update 2" { ++ type_changed false new_num_children 2 has_more 0 ++} { ++} { ++ { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 } ++} + + mi_gdb_test "-var-set-visualizer container None" \ + "\\^done" \ +@@ -78,19 +97,68 @@ mi_gdb_test "-var-set-visualizer container gdb.default_visualizer" \ + "\\^done" \ + "choose default visualizer" + +-mi_varobj_update_dynamic container { +- { {container.\[0\]} {\[0\]} 0 int } +- { {container.\[1\]} {\[1\]} 0 int } +-} "varobj update after choosing default" ++mi_varobj_update_dynamic container "varobj update after choosing default" { ++ type_changed false new_num_children 2 has_more 0 ++} { ++} { ++ { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 } ++ { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 } ++} + + mi_gdb_test "-var-set-visualizer container ContainerPrinter" \ + "\\^done" \ + "choose visualizer using expression" + +-mi_varobj_update_dynamic container { ++mi_varobj_update_dynamic container \ ++ "varobj update after choosing via expression" { ++ type_changed false new_num_children 2 has_more 0 ++ } { ++ } { ++ { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 } ++ { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 } ++ } ++ +mi_list_varobj_children_range container 1 2 2 { + { {container.\[1\]} {\[1\]} 0 int } +} "list varobj children after selecting child range" + +mi_list_varobj_children_range container -1 -1 2 { -+ { {container.\[0\]} {\[0\]} 0 int } -+ { {container.\[1\]} {\[1\]} 0 int } + { {container.\[0\]} {\[0\]} 0 int } + { {container.\[1\]} {\[1\]} 0 int } +-} "varobj update after choosing via expression" +} "list varobj children after resetting child range" + ++mi_next "next over update 3" ++ ++mi_gdb_test "-var-set-update-range container 0 1" \ ++ "\\^done" \ ++ "set update range" ++ ++# This should truncate the list. ++mi_list_varobj_children container { ++ { {container.\[0\]} {\[0\]} 0 int } ++} "list children after setting update range" ++ ++# This should return just the items in [1,2). ++mi_list_varobj_children_range container 1 2 2 { ++ { {container.\[1\]} {\[1\]} 0 int } ++} "list selected children after setting range" ++ ++# This should not be affected by the previous list-children request. ++mi_list_varobj_children container { ++ { {container.\[0\]} {\[0\]} 0 int } ++} "list children after listing selected range" ++ ++mi_next "next over update 4" ++ ++# This should only show the first child, because the update range has ++# been set. ++mi_varobj_update_dynamic container \ ++ "update after next with restricted range" { ++ type_changed false new_num_children 1 has_more 1 ++ } { ++ { name {container.\[0\]} in_scope true type_changed false } ++ } { ++ } + mi_continue_to_line \ [gdb_get_line_number {Another MI breakpoint} ${testfile}.c] \ - "step to second breakpoint" diff --git a/gdb/testsuite/gdb.python/python-prettyprint.c b/gdb/testsuite/gdb.python/python-prettyprint.c -index 3cafc48..5cc35be 100644 +index 3cafc48..6bbbf1d 100644 --- a/gdb/testsuite/gdb.python/python-prettyprint.c +++ b/gdb/testsuite/gdb.python/python-prettyprint.c @@ -15,6 +15,8 @@ @@ -23420,6 +24012,16 @@ index 3cafc48..5cc35be 100644 struct ns ns; ns.null_str = "embedded\0null\0string"; +@@ -193,6 +203,9 @@ main () + add_item (&c, 72); + + #ifdef MI ++ add_item (&c, 1011); ++ c.elements[0] = 1023; ++ + do_nothing (); + #endif + diff --git a/gdb/testsuite/gdb.python/python-prettyprint.exp b/gdb/testsuite/gdb.python/python-prettyprint.exp index 01d4a06..b2dc85d 100644 --- a/gdb/testsuite/gdb.python/python-prettyprint.exp @@ -23699,19 +24301,92 @@ index 0c93a73..d0c3493 100644 global GDB diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp -index 9b4c464..33f277a 100644 +index e691232..64bc28e 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp -@@ -1258,7 +1258,7 @@ proc mi_varobj_update_dynamic {name children testname} { - set er "\\^done,changelist=\\\[" +@@ -1201,7 +1201,7 @@ proc mi_create_varobj { name expression testname } { - append er "{name=\"$name\",in_scope=\"true\",type_changed=\"false\"" + proc mi_create_floating_varobj { name expression testname } { + mi_gdb_test "-var-create $name @ $expression" \ +- "\\^done,name=\"$name\",numchild=\"\[0-9\]+\",value=\".*\",type=.*" \ ++ "\\^done,name=\"$name\",numchild=\"\(-1\|\[0-9\]+\)\",value=\".*\",type=.*" \ + $testname + } + +@@ -1250,16 +1250,64 @@ proc mi_varobj_update_with_type_change { name new_type new_children testname } { + mi_gdb_test "-var-update $name" $er $testname + } + +-# Update a dynamic varobj named NAME. CHILDREN is a list of children, +-# in the same form as mi_list_varobj_children. TESTNAME is the name +-# of the test. +-proc mi_varobj_update_dynamic {name children testname} { +- set children_exp_j [mi_child_regexp $children 0] ++# A helper that turns a key/value list into a regular expression ++# matching some MI output. ++proc mi_varobj_update_kv_helper {list} { ++ set first 1 ++ set rx "" ++ foreach {key value} $list { ++ if {!$first} { ++ append rx , ++ } ++ set first 0 ++ if {$key == "new_children"} { ++ append rx "$key=\\\[$value\\\]" ++ } else { ++ append rx "$key=\"$value\"" ++ } ++ } ++ return $rx ++} ++ ++# A helper for mi_varobj_update_dynamic that computes a match ++# expression given a child list. ++proc mi_varobj_update_dynamic_helper {children} { ++ set crx "" + +- set er "\\^done,changelist=\\\[" ++ set first 1 ++ foreach child $children { ++ if {!$first} { ++ append crx , ++ } ++ set first 0 ++ append crx "{" ++ append crx [mi_varobj_update_kv_helper $child] ++ append crx "}" ++ } ++ ++ return $crx ++} ++ ++# Update a dynamic varobj named NAME. CHILDREN is a list of children ++# that have been updated; NEW_CHILDREN is a list of children that were ++# added to the primary varobj. Each child is a list of key/value ++# pairs that are expected. SELF is a key/value list holding ++# information about the varobj itself. TESTNAME is the name of the ++# test. ++proc mi_varobj_update_dynamic {name testname self children new_children} { ++ if {[llength $new_children]} { ++ set newrx [mi_varobj_update_dynamic_helper $new_children] ++ lappend self new_children $newrx ++ } ++ set selfrx [mi_varobj_update_kv_helper $self] ++ set crx [mi_varobj_update_dynamic_helper $children] + +- append er "{name=\"$name\",in_scope=\"true\",type_changed=\"false\"" - append er ",children=\\\[$children_exp_j.*\\\]}\\\]" -+ append er ",children=\\\[$children_exp_j.*\\\],has_more=\".\"}\\\]" ++ set er "\\^done,changelist=\\\[\{name=\"$name\",in_scope=\"true\"" ++ append er ",$selfrx\}" ++ if {"$crx" != ""} { ++ append er ",$crx" ++ } ++ append er "\\\]" verbose -log "Expecting: $er" mi_gdb_test "-var-update $name" $er $testname -@@ -1328,14 +1328,13 @@ proc mi_child_regexp {children add_child} { +@@ -1329,14 +1377,13 @@ proc mi_child_regexp {children add_child} { # have no value. # proc mi_list_varobj_children { varname children testname } { @@ -23730,7 +24405,7 @@ index 9b4c464..33f277a 100644 set options "" if {[llength $varname] == 2} { set options [lindex $varname 1] -@@ -1351,9 +1350,18 @@ proc mi_list_varobj_children_range {varname numchildren children testname} { +@@ -1352,9 +1399,18 @@ proc mi_list_varobj_children_range {varname numchildren children testname} { set expected "\\^done,numchild=\"0\"" } @@ -24008,7 +24683,7 @@ index 1562d5a..d86a7eb 100644 extern long ui_file_read (struct ui_file *file, char *buf, long length_buf); diff --git a/gdb/utils.c b/gdb/utils.c -index eb75f2e..1e246b8 100644 +index a266b02..3d953e3 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2605,7 +2605,10 @@ fprintf_symbol_filtered (struct ui_file *stream, char *name, @@ -24123,7 +24798,7 @@ index a9c875d..12f6f07 100644 } diff --git a/gdb/valops.c b/gdb/valops.c -index 5e5c4ed..59c9018 100644 +index 5e5c4ed..446a4d1 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -38,6 +38,7 @@ @@ -24477,18 +25152,15 @@ index 5e5c4ed..59c9018 100644 if (TYPE_FN_FIELD_STATIC_P (f, j)) { -@@ -2752,9 +2932,9 @@ value_maybe_namespace_elt (const struct type *curtype, +@@ -2752,7 +2932,7 @@ value_maybe_namespace_elt (const struct type *curtype, struct symbol *sym; struct value *result; - sym = cp_lookup_symbol_namespace (namespace_name, name, NULL, -+ sym = cp_lookup_symbol_namespace_incremental (namespace_name, name, ++ sym = cp_lookup_symbol_namespace_incremental(namespace_name, name, get_selected_block (0), -- VAR_DOMAIN); -+ VAR_DOMAIN, 0); + VAR_DOMAIN); - if (sym == NULL) - return NULL; @@ -2896,7 +3076,7 @@ value_of_local (const char *name, int complain) /* Calling lookup_block_symbol is necessary to get the LOC_REGISTER @@ -24529,7 +25201,7 @@ index cbb5d94..cf35bf0 100644 ++reps; ++rep1; diff --git a/gdb/value.c b/gdb/value.c -index 65a5aa9..007e4b0 100644 +index 65a5aa9..c943781 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -37,8 +37,10 @@ @@ -24543,7 +25215,22 @@ index 65a5aa9..007e4b0 100644 #include "python/python.h" -@@ -257,7 +259,9 @@ allocate_value_lazy (struct type *type) +@@ -170,6 +172,14 @@ struct value + taken off this list. */ + struct value *next; + ++ /* The reference count. A value that is still on the `all_values' ++ list will have a reference count of 0. A call to `release_value' ++ will increment the reference count (and remove the value from the ++ list, the first time). A call to `value_free' will decrement the ++ reference count, and will free the value when there are no more ++ references. */ ++ int refcount; ++ + /* Register number if the value is from a register. */ + short regnum; + +@@ -257,7 +267,9 @@ allocate_value_lazy (struct type *type) val->next = all_values; all_values = val; val->type = type; @@ -24553,7 +25240,7 @@ index 65a5aa9..007e4b0 100644 VALUE_LVAL (val) = not_lval; val->location.address = 0; VALUE_FRAME_ID (val) = null_frame_id; -@@ -367,6 +371,8 @@ value_type (struct value *value) +@@ -367,6 +379,8 @@ value_type (struct value *value) void deprecated_set_value_type (struct value *value, struct type *type) { @@ -24562,27 +25249,91 @@ index 65a5aa9..007e4b0 100644 value->type = type; } -@@ -623,6 +629,9 @@ value_free (struct value *val) +@@ -623,27 +637,28 @@ value_free (struct value *val) { if (val) { -+ type_decref (val->type); -+ type_decref (val->enclosing_type); -+ - gdb_assert (val->reference_count > 0); - val->reference_count--; - if (val->reference_count > 0) -@@ -642,8 +651,8 @@ value_free (struct value *val) - } +- gdb_assert (val->reference_count > 0); +- val->reference_count--; +- if (val->reference_count > 0) +- return; ++ /* If the count was already 0, then the value was on the ++ all_values list, and we must be freeing back to some ++ point. */ ++ if (val->refcount <= 1) ++ { ++ type_decref (val->type); ++ type_decref (val->enclosing_type); - xfree (val->contents); -+ xfree (val); +- /* If there's an associated parent value, drop our reference to +- it. */ +- if (val->parent != NULL) +- value_free (val->parent); ++ if (VALUE_LVAL (val) == lval_computed) ++ { ++ struct lval_funcs *funcs = val->location.computed.funcs; + +- if (VALUE_LVAL (val) == lval_computed) +- { +- struct lval_funcs *funcs = val->location.computed.funcs; ++ if (funcs->free_closure) ++ funcs->free_closure (val); ++ } + +- if (funcs->free_closure) +- funcs->free_closure (val); ++ xfree (val->contents); ++ xfree (val); + } +- +- xfree (val->contents); ++ else ++ --val->refcount; } - xfree (val); } /* Free all values allocated since MARK was obtained by value_mark -@@ -736,6 +745,9 @@ value_copy (struct value *arg) +@@ -686,22 +701,26 @@ free_all_values (void) + void + release_value (struct value *val) + { +- struct value *v; +- +- if (all_values == val) +- { +- all_values = val->next; +- return; +- } +- +- for (v = all_values; v; v = v->next) ++ /* If the reference count is nonzero, then we have already removed ++ the item from the list, so there is no reason to do it again. */ ++ if (val->refcount == 0) + { +- if (v->next == val) ++ if (all_values == val) ++ all_values = val->next; ++ else + { +- v->next = val->next; +- break; ++ struct value *v; ++ for (v = all_values; v; v = v->next) ++ { ++ if (v->next == val) ++ { ++ v->next = val->next; ++ break; ++ } ++ } + } + } ++ ++val->refcount; + } + + /* Release all values up to mark */ +@@ -736,6 +755,9 @@ value_copy (struct value *arg) val = allocate_value_lazy (encl_type); else val = allocate_value (encl_type); @@ -24592,7 +25343,7 @@ index 65a5aa9..007e4b0 100644 val->type = arg->type; VALUE_LVAL (val) = VALUE_LVAL (arg); val->location = arg->location; -@@ -771,12 +783,15 @@ value_copy (struct value *arg) +@@ -771,12 +793,15 @@ value_copy (struct value *arg) void set_value_component_location (struct value *component, struct value *whole) { @@ -24608,7 +25359,7 @@ index 65a5aa9..007e4b0 100644 if (VALUE_LVAL (whole) == lval_computed) { struct lval_funcs *funcs = whole->location.computed.funcs; -@@ -784,6 +799,10 @@ set_value_component_location (struct value *component, struct value *whole) +@@ -784,6 +809,10 @@ set_value_component_location (struct value *component, struct value *whole) if (funcs->copy_closure) component->location.computed.closure = funcs->copy_closure (whole); } @@ -24619,7 +25370,7 @@ index 65a5aa9..007e4b0 100644 } -@@ -914,6 +933,29 @@ show_values (char *num_exp, int from_tty) +@@ -914,6 +943,29 @@ show_values (char *num_exp, int from_tty) num_exp[1] = '\0'; } } @@ -24649,7 +25400,7 @@ index 65a5aa9..007e4b0 100644 /* Internal variables. These are variables within the debugger that hold values assigned by debugger commands. -@@ -1388,6 +1430,37 @@ call_internal_function (struct gdbarch *gdbarch, +@@ -1388,6 +1440,37 @@ call_internal_function (struct gdbarch *gdbarch, return (*ifn->handler) (gdbarch, language, ifn->cookie, argc, argv); } @@ -24687,7 +25438,7 @@ index 65a5aa9..007e4b0 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 -@@ -1430,17 +1503,26 @@ add_internal_function (const char *name, const char *doc, +@@ -1430,16 +1513,15 @@ add_internal_function (const char *name, const char *doc, /* Update VALUE before discarding OBJFILE. COPIED_TYPES is used to prevent cycles / duplicates. */ @@ -24698,27 +25449,15 @@ index 65a5aa9..007e4b0 100644 { if (TYPE_OBJFILE (value->type) == objfile) - value->type = copy_type_recursive (objfile, value->type, copied_types); -+ { -+ /* No need to decref the old type here, since we know it has no -+ reference count. */ -+ value->type = copy_type_recursive (value->type, copied_types); -+ type_incref (value->type); -+ } ++ value->type = copy_type_recursive (value->type, copied_types); if (TYPE_OBJFILE (value->enclosing_type) == objfile) - value->enclosing_type = copy_type_recursive (objfile, - value->enclosing_type, -- copied_types); -+ { -+ /* No need to decref the old type here, since we know it has no -+ reference count. */ -+ value->enclosing_type = copy_type_recursive (value->enclosing_type, -+ copied_types); -+ type_incref (value->enclosing_type); -+ } ++ value->enclosing_type = copy_type_recursive (value->enclosing_type, + copied_types); } - /* Likewise for internal variable VAR. */ @@ -1454,7 +1536,7 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile, case INTERNALVAR_SCALAR: if (var->u.scalar.type && TYPE_OBJFILE (var->u.scalar.type) == objfile) @@ -24839,7 +25578,7 @@ index 65a5aa9..007e4b0 100644 + observer_attach_mark_used (value_types_mark_used); } diff --git a/gdb/value.h b/gdb/value.h -index 29ad783..bc96309 100644 +index 29ad783..ee8440b 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -344,11 +344,16 @@ extern LONGEST unpack_field_as_long (struct type *type, @@ -24867,7 +25606,7 @@ index 29ad783..bc96309 100644 int want_address, enum noside noside); -@@ -658,12 +664,13 @@ extern void typedef_print (struct type *type, struct symbol *news, +@@ -658,12 +664,12 @@ extern void typedef_print (struct type *type, struct symbol *news, extern char *internalvar_name (struct internalvar *var); @@ -24877,13 +25616,12 @@ index 29ad783..bc96309 100644 extern struct value *value_copy (struct value *); -+extern void preserve_one_value (struct value *value, struct objfile *objfile, -+ htab_t copied_types); ++extern void preserve_one_value (struct value *, struct objfile *, htab_t); + /* From valops.c */ extern struct value *varying_to_slice (struct value *); -@@ -681,7 +688,7 @@ extern struct value *value_allocate_space_in_inferior (int); +@@ -681,7 +687,7 @@ extern struct value *value_allocate_space_in_inferior (int); extern struct value *value_of_local (const char *name, int complain); extern struct value *value_subscripted_rvalue (struct value *array, @@ -24893,10 +25631,15 @@ index 29ad783..bc96309 100644 /* User function handler. */ diff --git a/gdb/varobj.c b/gdb/varobj.c -index 4a94988..9bfc130 100644 +index 4a94988..34333fb 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c -@@ -29,11 +29,14 @@ +@@ -26,14 +26,18 @@ + #include "gdbcmd.h" + #include "block.h" + #include "valprint.h" ++#include "objfiles.h" ++#include "parser-defs.h" #include "gdb_assert.h" #include "gdb_string.h" @@ -24907,11 +25650,10 @@ index 4a94988..9bfc130 100644 #include "gdbthread.h" #include "inferior.h" +#include "observer.h" -+#include "parser-defs.h" #if HAVE_PYTHON #include "python/python.h" -@@ -59,6 +62,15 @@ char *varobj_format_string[] = +@@ -59,6 +63,15 @@ char *varobj_format_string[] = /* String representations of gdb's known languages */ char *varobj_language_string[] = { "unknown", "C", "C++", "Java" }; @@ -24927,7 +25669,7 @@ index 4a94988..9bfc130 100644 /* Data structures */ /* Every root variable has one of these structures saved in its -@@ -173,6 +185,17 @@ struct varobj +@@ -173,9 +186,31 @@ struct varobj frozen. */ int not_fetched; @@ -24945,7 +25687,21 @@ index 4a94988..9bfc130 100644 /* The pretty-printer that has been constructed. If NULL, then a new printer object is needed, and one will be constructed. */ PyObject *pretty_printer; -@@ -221,6 +244,8 @@ static void free_variable (struct varobj *var); ++ ++ /* The iterator returned by the printer's 'children' method, or NULL ++ if not available. */ ++ PyObject *child_iter; ++ ++ /* We request one extra item from the iterator, so that we can ++ report to the caller whether there are more items than we have ++ already reported. However, we don't want to install this value ++ when we read it, because that will mess up future updates. So, ++ we stash it here instead. */ ++ PyObject *saved_item; + }; + + struct cpstack +@@ -221,6 +256,8 @@ static void free_variable (struct varobj *var); static struct cleanup *make_cleanup_free_variable (struct varobj *var); @@ -24954,7 +25710,7 @@ index 4a94988..9bfc130 100644 static struct type *get_type (struct varobj *var); static struct type *get_value_type (struct varobj *var); -@@ -236,8 +261,6 @@ static char *cppop (struct cpstack **pstack); +@@ -236,8 +273,6 @@ static char *cppop (struct cpstack **pstack); static int install_new_value (struct varobj *var, struct value *value, int initial); @@ -24963,7 +25719,16 @@ index 4a94988..9bfc130 100644 /* Language-specific routines. */ static enum varobj_languages variable_language (struct varobj *var); -@@ -614,9 +637,9 @@ varobj_create (char *objname, +@@ -450,6 +485,8 @@ is_root_p (struct varobj *var) + struct cleanup * + varobj_ensure_python_env (struct varobj *var) + { ++ gdb_assert (var->root->is_valid); ++ + return ensure_python_env (var->root->exp->gdbarch, + var->root->exp->language_defn); + } +@@ -614,9 +651,9 @@ varobj_create (char *objname, do_cleanups (old_chain); return NULL; } @@ -24974,18 +25739,339 @@ index 4a94988..9bfc130 100644 discard_cleanups (old_chain); return var; } -@@ -884,7 +907,9 @@ update_dynamic_varobj_children (struct varobj *var, +@@ -731,15 +768,8 @@ instantiate_pretty_printer (PyObject *constructor, struct value *value) + #if HAVE_PYTHON + PyObject *val_obj = NULL; + PyObject *printer; +- volatile struct gdb_exception except; + +- TRY_CATCH (except, RETURN_MASK_ALL) +- { +- value = value_copy (value); +- } +- GDB_PY_HANDLE_EXCEPTION (except); + val_obj = value_to_value_object (value); +- + if (! val_obj) + return NULL; + +@@ -792,7 +822,12 @@ varobj_get_display_hint (struct varobj *var) + char *result = NULL; + + #if HAVE_PYTHON +- struct cleanup *back_to = varobj_ensure_python_env (var); ++ struct cleanup *back_to; ++ ++ if (!var->root->is_valid) ++ return NULL; ++ ++ back_to = varobj_ensure_python_env (var); + + if (var->pretty_printer) + result = gdbpy_get_display_hint (var->pretty_printer); +@@ -803,6 +838,17 @@ varobj_get_display_hint (struct varobj *var) + return result; + } + ++/* Return true if the varobj has items after TO, false otherwise. */ ++ ++int ++varobj_has_more (struct varobj *var, int to) ++{ ++ if (VEC_length (varobj_p, var->children) > to) ++ return 1; ++ return (VEC_length (varobj_p, var->children) == to ++ && var->saved_item != NULL); ++} ++ + /* If the variable object is bound to a specific thread, that + is its evaluation can always be done in context of a frame + inside that thread, returns GDB id of the thread -- which +@@ -835,22 +881,73 @@ varobj_get_frozen (struct varobj *var) + return var->frozen; + } + ++/* A helper function that restricts a range to what is actually ++ available in a VEC. This follows the usual rules for the meaning ++ of FROM and TO -- if either is negative, the entire range is ++ used. */ ++ ++static void ++restrict_range (VEC (varobj_p) *children, int *from, int *to) ++{ ++ if (*from < 0 || *to < 0) ++ { ++ *from = 0; ++ *to = VEC_length (varobj_p, children); ++ } ++ else ++ { ++ if (*from > VEC_length (varobj_p, children)) ++ *from = VEC_length (varobj_p, children); ++ if (*to > VEC_length (varobj_p, children)) ++ *to = VEC_length (varobj_p, children); ++ if (*from > *to) ++ *from = *to; ++ } ++} ++ ++/* A helper for update_dynamic_varobj_children that installs a new ++ child when needed. */ ++ ++static void ++install_dynamic_child (struct varobj *var, ++ VEC (varobj_p) **changed, ++ VEC (varobj_p) **new, ++ int *cchanged, ++ int index, ++ const char *name, ++ struct value *value) ++{ ++ if (VEC_length (varobj_p, var->children) < index + 1) ++ { ++ /* There's no child yet. */ ++ struct varobj *child = varobj_add_child (var, name, value); ++ if (new) ++ VEC_safe_push (varobj_p, *new, child); ++ *cchanged = 1; ++ } ++ else ++ { ++ varobj_p existing = VEC_index (varobj_p, var->children, index); ++ if (install_new_value (existing, value, 0)) ++ { ++ if (changed) ++ VEC_safe_push (varobj_p, *changed, existing); ++ } ++ } ++} ++ + static int + update_dynamic_varobj_children (struct varobj *var, + VEC (varobj_p) **changed, +- VEC (varobj_p) **new_and_unchanged, +- int *cchanged) +- ++ VEC (varobj_p) **new, ++ int *cchanged, ++ int update_children, ++ int to) + { + #if HAVE_PYTHON +- /* FIXME: we *might* want to provide this functionality as +- a standalone function, so that other interested parties +- than varobj code can benefit for this. */ + struct cleanup *back_to; + PyObject *children; +- PyObject *iterator; + int i; +- int children_changed = 0; + PyObject *printer = var->pretty_printer; + + back_to = varobj_ensure_python_env (var); +@@ -862,96 +959,103 @@ update_dynamic_varobj_children (struct varobj *var, + return 0; } - make_cleanup_py_decref (iterator); + +- children = PyObject_CallMethodObjArgs (printer, gdbpy_children_cst, +- NULL); +- +- if (!children) ++ if (update_children || !var->child_iter) + { +- gdbpy_print_stack (); +- error (_("Null value returned for children")); +- } ++ children = PyObject_CallMethodObjArgs (printer, gdbpy_children_cst, ++ NULL); + +- make_cleanup_py_decref (children); ++ if (!children) ++ { ++ gdbpy_print_stack (); ++ error (_("Null value returned for children")); ++ } + +- if (!PyIter_Check (children)) +- error (_("Returned value is not iterable")); ++ make_cleanup_py_decref (children); + +- iterator = PyObject_GetIter (children); +- if (!iterator) +- { +- gdbpy_print_stack (); +- error (_("Could not get children iterator")); ++ if (!PyIter_Check (children)) ++ error (_("Returned value is not iterable")); ++ ++ Py_XDECREF (var->child_iter); ++ var->child_iter = PyObject_GetIter (children); ++ if (!var->child_iter) ++ { ++ gdbpy_print_stack (); ++ error (_("Could not get children iterator")); ++ } ++ ++ Py_XDECREF (var->saved_item); ++ var->saved_item = NULL; ++ ++ i = 0; + } +- make_cleanup_py_decref (iterator); ++ else ++ i = VEC_length (varobj_p, var->children); - for (i = 0; ; ++i) + /* We ask for one extra child, so that MI can report whether there + are more children. */ -+ for (i = 0; var->to < 0 || i < var->to + 1; ++i) ++ for (; to < 0 || i < to + 1; ++i) { - PyObject *item = PyIter_Next (iterator); - PyObject *py_v; -@@ -1015,7 +1040,6 @@ varobj_list_children (struct varobj *var) +- PyObject *item = PyIter_Next (iterator); +- PyObject *py_v; +- struct value *v; +- char *name; +- struct cleanup *inner; +- +- if (!item) +- break; +- inner = make_cleanup_py_decref (item); ++ PyObject *item; + +- if (!PyArg_ParseTuple (item, "sO", &name, &py_v)) +- error (_("Invalid item from the child list")); +- +- if (PyObject_TypeCheck (py_v, &value_object_type)) ++ /* See if there was a leftover from last time. */ ++ if (var->saved_item) + { +- /* If we just call convert_value_from_python for this type, +- we won't know who owns the result. For this one case we +- need to copy the resulting value. */ +- v = value_object_to_value (py_v); +- v = value_copy (v); ++ item = var->saved_item; ++ var->saved_item = NULL; + } + else +- v = convert_value_from_python (py_v); ++ item = PyIter_Next (var->child_iter); + +- /* TODO: This assume the name of the i-th child never changes. */ ++ if (!item) ++ break; + +- /* Now see what to do here. */ +- if (VEC_length (varobj_p, var->children) < i + 1) ++ /* We don't want to push the extra child on any report list. */ ++ if (to < 0 || i < to) + { +- /* There's no child yet. */ +- struct varobj *child = varobj_add_child (var, name, v); +- if (new_and_unchanged) +- VEC_safe_push (varobj_p, *new_and_unchanged, child); +- children_changed = 1; ++ PyObject *py_v; ++ char *name; ++ struct value *v; ++ struct cleanup *inner; ++ ++ inner = make_cleanup_py_decref (item); ++ ++ if (!PyArg_ParseTuple (item, "sO", &name, &py_v)) ++ error (_("Invalid item from the child list")); ++ ++ v = convert_value_from_python (py_v); ++ install_dynamic_child (var, changed, new, ++ cchanged, i, name, v); ++ do_cleanups (inner); + } +- else ++ else + { +- varobj_p existing = VEC_index (varobj_p, var->children, i); +- if (install_new_value (existing, v, 0) && changed) +- { +- if (changed) +- VEC_safe_push (varobj_p, *changed, existing); +- } +- else +- { +- if (new_and_unchanged) +- VEC_safe_push (varobj_p, *new_and_unchanged, existing); +- } +- } ++ Py_XDECREF (var->saved_item); ++ var->saved_item = item; + +- do_cleanups (inner); ++ /* We want to truncate the child list just before this ++ element. */ ++ break; ++ } + } + + if (i < VEC_length (varobj_p, var->children)) + { +- int i; +- children_changed = 1; +- for (i = 0; i < VEC_length (varobj_p, var->children); ++i) +- varobj_delete (VEC_index (varobj_p, var->children, i), NULL, 0); ++ int j; ++ *cchanged = 1; ++ for (j = i; j < VEC_length (varobj_p, var->children); ++j) ++ varobj_delete (VEC_index (varobj_p, var->children, j), NULL, 0); ++ VEC_truncate (varobj_p, var->children, i); + } +- VEC_truncate (varobj_p, var->children, i); ++ ++ /* If there are fewer children than requested, note that the list of ++ children changed. */ ++ if (to >= 0 && VEC_length (varobj_p, var->children) < to) ++ *cchanged = 1; ++ + var->num_children = VEC_length (varobj_p, var->children); + + do_cleanups (back_to); + +- *cchanged = children_changed; + return 1; + #else + gdb_assert (0 && "should never be called if Python is not enabled"); +@@ -964,8 +1068,7 @@ varobj_get_num_children (struct varobj *var) + if (var->num_children == -1) + { + int changed; +- if (!var->pretty_printer +- || !update_dynamic_varobj_children (var, NULL, NULL, &changed)) ++ if (!var->pretty_printer) + var->num_children = number_of_children (var); + } + +@@ -976,7 +1079,7 @@ varobj_get_num_children (struct varobj *var) + the return code is the number of such children or -1 on error */ + + VEC (varobj_p)* +-varobj_list_children (struct varobj *var) ++varobj_list_children (struct varobj *var, int *from, int *to) + { + struct varobj *child; + char *name; +@@ -988,8 +1091,12 @@ varobj_list_children (struct varobj *var) + /* This, in theory, can result in the number of children changing without + frontend noticing. But well, calling -var-list-children on the same + varobj twice is not something a sane frontend would do. */ +- && update_dynamic_varobj_children (var, NULL, NULL, &children_changed)) +- return var->children; ++ && update_dynamic_varobj_children (var, NULL, NULL, &children_changed, ++ 0, *to)) ++ { ++ restrict_range (var->children, from, to); ++ return var->children; ++ } + + if (var->num_children == -1) + var->num_children = number_of_children (var); +@@ -1015,10 +1122,10 @@ varobj_list_children (struct varobj *var) name = name_of_child (var, i); existing = create_child (var, i, name); VEC_replace (varobj_p, var->children, i, existing); @@ -24993,7 +26079,11 @@ index 4a94988..9bfc130 100644 } } -@@ -1029,7 +1053,6 @@ varobj_add_child (struct varobj *var, const char *name, struct value *value) ++ restrict_range (var->children, from, to); + return var->children; + } + +@@ -1029,7 +1136,6 @@ varobj_add_child (struct varobj *var, const char *name, struct value *value) VEC_length (varobj_p, var->children), name, value); VEC_safe_push (varobj_p, var->children, v); @@ -25001,7 +26091,7 @@ index 4a94988..9bfc130 100644 return v; } -@@ -1168,6 +1191,112 @@ varobj_set_value (struct varobj *var, char *expression) +@@ -1168,6 +1274,115 @@ varobj_set_value (struct varobj *var, char *expression) return 1; } @@ -25019,6 +26109,9 @@ index 4a94988..9bfc130 100644 + + Py_XDECREF (var->pretty_printer); + var->pretty_printer = visualizer; ++ ++ Py_XDECREF (var->child_iter); ++ var->child_iter = NULL; +} + +/* Install the default visualizer for VAR. */ @@ -25114,7 +26207,7 @@ index 4a94988..9bfc130 100644 /* Assign a new value to a variable object. If INITIAL is non-zero, this is the first assignement after the variable object was just created, or changed type. In that case, just assign the value -@@ -1274,7 +1403,7 @@ install_new_value (struct varobj *var, struct value *value, int initial) +@@ -1274,7 +1489,7 @@ install_new_value (struct varobj *var, struct value *value, int initial) { changed = 1; } @@ -25123,7 +26216,7 @@ index 4a94988..9bfc130 100644 { /* Try to compare the values. That requires that both values are non-lazy. */ -@@ -1328,65 +1457,47 @@ install_new_value (struct varobj *var, struct value *value, int initial) +@@ -1328,65 +1543,32 @@ install_new_value (struct varobj *var, struct value *value, int initial) var->not_fetched = 0; var->updated = 0; @@ -25136,7 +26229,13 @@ index 4a94988..9bfc130 100644 -static void -install_visualizer (struct varobj *var, PyObject *visualizer) --{ ++/* Return the requested range for a varobj. VAR is the varobj. FROM ++ and TO are out parameters; *FROM and *TO will be set to the ++ selected sub-range of VAR. If no range was selected using ++ -var-set-update-range, then both will be -1. */ ++void ++varobj_get_child_range (struct varobj *var, int *from, int *to) + { -#if HAVE_PYTHON - /* If there are any children now, wipe them. */ - varobj_delete (var, NULL, 1 /* children only */); @@ -25156,19 +26255,17 @@ index 4a94988..9bfc130 100644 -#else - error (_("Python support required")); -#endif --} -- ++ *from = var->from; ++ *to = var->to; + } + -static void -install_default_visualizer (struct varobj *var) -+/* Return the effective requested range for a varobj. VAR is the -+ varobj. CHILDREN is the computed list of children. FROM and TO -+ are out parameters. If VAR has no bounds selected, *FROM and *TO -+ will be set to the full range of CHILDREN. Otherwise, *FROM and -+ *TO will be set to the selected sub-range of VAR, clipped to be in -+ range of CHILDREN. */ ++/* Set the selected sub-range of children of VAR to start at index ++ FROM and end at index TO. If either FROM or TO is less than zero, ++ this is interpreted as a request for all children. */ +void -+varobj_get_child_range (struct varobj *var, VEC (varobj_p) *children, -+ int *from, int *to) ++varobj_set_child_range (struct varobj *var, int from, int to) { -#if HAVE_PYTHON - struct cleanup *cleanup; @@ -25177,50 +26274,32 @@ index 4a94988..9bfc130 100644 - cleanup = varobj_ensure_python_env (var); - - if (var->value) -+ if (var->from < 0 || var->to < 0) - { +- { - pretty_printer = gdbpy_get_varobj_pretty_printer (var->value); - if (! pretty_printer) - { - gdbpy_print_stack (); - error (_("Cannot instantiate printer for default visualizer")); - } -+ *from = 0; -+ *to = VEC_length (varobj_p, children); - } +- } - - if (pretty_printer == Py_None) -+ else - { +- { - Py_DECREF (pretty_printer); - pretty_printer = NULL; -+ *from = var->from; -+ if (*from > VEC_length (varobj_p, children)) -+ *from = VEC_length (varobj_p, children); -+ *to = var->to; -+ if (*to > VEC_length (varobj_p, children)) -+ *to = VEC_length (varobj_p, children); - } +- } - - install_visualizer (var, pretty_printer); - do_cleanups (cleanup); -#else - /* No error is right as this function is inserted just as a hook. */ -#endif -+} -+ -+/* Set the selected sub-range of children of VAR to start at index -+ FROM and end at index TO. If either FROM or TO is less than zero, -+ this is interpreted as a request for all children. */ -+void -+varobj_set_child_range (struct varobj *var, int from, int to) -+{ + var->from = from; + var->to = to; } void -@@ -1404,31 +1515,19 @@ varobj_set_visualizer (struct varobj *var, const char *visualizer) +@@ -1404,31 +1586,19 @@ varobj_set_visualizer (struct varobj *var, const char *visualizer) make_cleanup_py_decref (globals); constructor = PyRun_String (visualizer, Py_eval_input, globals, globals); @@ -25233,9 +26312,9 @@ index 4a94988..9bfc130 100644 - } - else - pretty_printer = instantiate_pretty_printer (constructor, var->value); - -- Py_XDECREF (constructor); - +- Py_XDECREF (constructor); + - if (! pretty_printer) + if (! constructor) { @@ -25258,7 +26337,57 @@ index 4a94988..9bfc130 100644 do_cleanups (back_to); #else -@@ -1864,6 +1963,9 @@ new_variable (void) +@@ -1543,7 +1713,7 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit) + UI, so we need not bother getting it. */ + if (v->pretty_printer) + { +- VEC (varobj_p) *changed = 0, *new_and_unchanged = 0; ++ VEC (varobj_p) *changed = 0, *new = 0; + int i, children_changed; + varobj_p tmp; + +@@ -1555,28 +1725,28 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit) + + /* If update_dynamic_varobj_children returns 0, then we have + a non-conforming pretty-printer, so we skip it. */ +- if (update_dynamic_varobj_children (v, &changed, &new_and_unchanged, +- &children_changed)) ++ if (update_dynamic_varobj_children (v, &changed, &new, ++ &children_changed, 1, v->to)) + { +- if (children_changed) +- r.children_changed = 1; +- for (i = 0; VEC_iterate (varobj_p, changed, i, tmp); ++i) ++ if (children_changed || new) + { +- varobj_update_result r = {tmp}; +- r.changed = 1; +- r.value_installed = 1; +- VEC_safe_push (varobj_update_result, stack, &r); ++ r.children_changed = 1; ++ r.new = new; + } +- for (i = 0; +- VEC_iterate (varobj_p, new_and_unchanged, i, tmp); +- ++i) ++ for (i = 0; VEC_iterate (varobj_p, changed, i, tmp); ++i) + { + varobj_update_result r = {tmp}; ++ r.changed = 1; + r.value_installed = 1; + VEC_safe_push (varobj_update_result, stack, &r); + } + if (r.changed || r.children_changed) + VEC_safe_push (varobj_update_result, result, &r); ++ ++ /* Free CHANGED, but not NEW, because NEW has been put ++ into the result vector. */ ++ VEC_free (varobj_p, changed); ++ + continue; + } + } +@@ -1864,7 +2034,12 @@ new_variable (void) var->frozen = 0; var->not_fetched = 0; var->children_requested = 0; @@ -25266,9 +26395,24 @@ index 4a94988..9bfc130 100644 + var->to = -1; + var->constructor = 0; var->pretty_printer = 0; ++ var->child_iter = 0; ++ var->saved_item = 0; return var; -@@ -1927,6 +2029,18 @@ make_cleanup_free_variable (struct varobj *var) + } +@@ -1894,7 +2069,10 @@ free_variable (struct varobj *var) + if (var->pretty_printer) + { + struct cleanup *cleanup = varobj_ensure_python_env (var); +- Py_DECREF (var->pretty_printer); ++ Py_XDECREF (var->constructor); ++ Py_XDECREF (var->pretty_printer); ++ Py_XDECREF (var->child_iter); ++ Py_XDECREF (var->saved_item); + do_cleanups (cleanup); + } + #endif +@@ -1927,6 +2105,18 @@ make_cleanup_free_variable (struct varobj *var) return make_cleanup (do_free_variable_cleanup, var); } @@ -25287,16 +26431,16 @@ index 4a94988..9bfc130 100644 /* This returns the type of the variable. It also skips past typedefs to return the real type of the variable. -@@ -2187,7 +2301,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format, - long dummy; - struct ui_file *stb; - struct cleanup *old_chain; -- gdb_byte *thevalue = NULL; -+ char *thevalue = NULL; - struct value_print_options opts; - int len = 0; +@@ -2141,6 +2331,8 @@ value_of_root (struct varobj **var_handle, int *type_changed) + else + { + tmp_var->obj_name = xstrdup (var->obj_name); ++ tmp_var->from = var->from; ++ tmp_var->to = var->to; + varobj_delete (var, NULL, 0); -@@ -3173,6 +3287,19 @@ java_value_of_variable (struct varobj *var, enum varobj_display_formats format) + install_variable (tmp_var); +@@ -3173,6 +3365,19 @@ java_value_of_variable (struct varobj *var, enum varobj_display_formats format) return cplus_value_of_variable (var, format); } @@ -25316,7 +26460,7 @@ index 4a94988..9bfc130 100644 /* Iterate all the existing _root_ VAROBJs and call the FUNC callback for them with an arbitrary caller supplied DATA pointer. */ -@@ -3190,48 +3317,110 @@ all_root_varobjs (void (*func) (struct varobj *var, void *data), void *data) +@@ -3190,48 +3395,110 @@ all_root_varobjs (void (*func) (struct varobj *var, void *data), void *data) (*func) (var_root->rootvar, data); } } @@ -25454,8 +26598,12 @@ index 4a94988..9bfc130 100644 tmp_var->obj_name = xstrdup (var->obj_name); varobj_delete (var, NULL, 0); install_variable (tmp_var); -@@ -3243,12 +3432,61 @@ varobj_invalidate_iter (struct varobj *var, void *unused) - var->root->is_valid = 0; +@@ -3239,16 +3506,64 @@ varobj_invalidate_iter (struct varobj *var, void *unused) + else + var->root->is_valid = 0; + } +- else /* locals must be invalidated. */ +- var->root->is_valid = 0; } -/* Invalidate the varobjs that are tied to locals and re-create the ones that @@ -25467,8 +26615,7 @@ index 4a94988..9bfc130 100644 -varobj_invalidate (void) +static void +varobj_invalidate (struct objfile *objfile) - { -- all_root_varobjs (varobj_invalidate_iter, NULL); ++{ + /* Check all the VAROBJs, even non-root ones. Child VAROBJs can reference + types from other OBJFILEs through TYPE_IS_OPAQUE resolutions by + check_typedef. */ @@ -25495,7 +26642,8 @@ index 4a94988..9bfc130 100644 + +static void +varobj_revalidate_for_objfile (struct objfile *objfile) -+{ + { +- all_root_varobjs (varobj_invalidate_iter, NULL); + varobj_revalidate (); +} + @@ -25517,29 +26665,58 @@ index 4a94988..9bfc130 100644 + show_varobjdebug, + &setlist, &showlist); + ++ + observer_attach_objfile_unloading (varobj_invalidate ); + observer_attach_objfile_unloaded (varobj_revalidate); + observer_attach_new_objfile (varobj_revalidate_for_objfile); + observer_attach_mark_used (varobj_types_mark_used); } diff --git a/gdb/varobj.h b/gdb/varobj.h -index 7297243..aabd743 100644 +index 7297243..fbe2f2f 100644 --- a/gdb/varobj.h +++ b/gdb/varobj.h -@@ -112,6 +112,12 @@ extern void varobj_set_frozen (struct varobj *var, int frozen); +@@ -78,6 +78,12 @@ typedef struct varobj_update_result_t + new value of varobj is already computed and installed, or has to + be yet installed. Don't use this outside varobj.c */ + int value_installed; ++ ++ /* This will be non-NULL when new children were added to the varobj. ++ It lists the new children (which must necessarily come at the end ++ of the child list) added during an update. The caller is ++ responsible for freeing this vector. */ ++ VEC (varobj_p) *new; + } varobj_update_result; + + DEF_VEC_O (varobj_update_result); +@@ -112,13 +118,24 @@ extern void varobj_set_frozen (struct varobj *var, int frozen); extern int varobj_get_frozen (struct varobj *var); -+extern void varobj_get_child_range (struct varobj *var, -+ VEC (varobj_p) *children, -+ int *from, int *to); ++extern void varobj_get_child_range (struct varobj *var, int *from, int *to); + +extern void varobj_set_child_range (struct varobj *var, int from, int to); + extern char *varobj_get_display_hint (struct varobj *var); extern int varobj_get_num_children (struct varobj *var); -@@ -143,12 +149,13 @@ extern void all_root_varobjs (void (*func) (struct varobj *var, void *data), + +-/* Return the list of children of VAR. The returned vector +- should not be modified in any way. */ +-extern VEC (varobj_p)* varobj_list_children (struct varobj *var); ++/* Return the list of children of VAR. The returned vector should not ++ be modified in any way. FROM and TO are in/out parameters ++ indicating the range of children to return. If either *FROM or *TO ++ is less than zero on entry, then all children will be returned. On ++ return, *FROM and *TO will be updated to indicate the real range ++ that was returned. The resulting VEC will contain at least the ++ children from *FROM to just before *TO; it might contain more ++ children, depending on whether any more were available. */ ++extern VEC (varobj_p)* varobj_list_children (struct varobj *var, ++ int *from, int *to); + + extern char *varobj_get_type (struct varobj *var); + +@@ -143,12 +160,15 @@ extern void all_root_varobjs (void (*func) (struct varobj *var, void *data), extern VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit); @@ -25554,6 +26731,8 @@ index 7297243..aabd743 100644 +varobj_set_visualizer (struct varobj *var, const char *visualizer); + +extern void varobj_enable_pretty_printing (void); ++ ++extern int varobj_has_more (struct varobj *var, int to); #endif /* VAROBJ_H */ diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c diff --git a/gdb.changes b/gdb.changes index 2356e5f..da55165 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Aug 17 14:04:46 CEST 2009 - rguenther@suse.de + +- Merge from gdb-6.8.50.20090811-2.fc12.src.rpm. + ------------------------------------------------------------------- Tue Aug 11 17:32:38 CEST 2009 - rguenther@suse.de diff --git a/gdb.spec b/gdb.spec index 5a1f83e..976f0f5 100644 --- a/gdb.spec +++ b/gdb.spec @@ -1,5 +1,5 @@ # -# spec file for package gdb (Version 6.8.50.20090803) +# spec file for package gdb (Version 6.8.50.20090811) # # Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -22,13 +22,13 @@ Name: 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). -Version: 6.8.50.20090803 +Version: 6.8.50.20090811 Release: 1 # The release always contains a leading reserved number, start it at 1. # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing. License: GPLv3+ Group: Development/Debuggers -Source: ftp://sourceware.org/pub/gdb/releases/gdb-%{version}.tar.bz2 +Source: ftp://sourceware.org/pub/gdb/snapshots/current/gdb-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-build Url: http://gnu.org/software/gdb/ # For our convenience @@ -264,7 +264,6 @@ Patch375: gdb-readline-6.0.patch Patch1000: readline-5.1-random.patch Patch1002: gdb-6.6-buildid-locate-rpm-suse.patch Patch1007: fix-gdb-backtrace.diff -Patch1008: fix-symread-crash.diff BuildRequires: bison flex gettext glibc-devel ncurses-devel texinfo zlib-devel %if %{suse_version} < 1020 BuildRequires: expat @@ -439,7 +438,6 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch1000 %patch1002 -p1 %patch1007 -%patch1008 -p1 find -name "*.orig" | xargs rm -f ! find -name "*.rej" # Should not happen. %endif # 0%{!?_with_upstream:1}