- Fix crashes due to (missing) varobj revalidation, for VLA (for BZ

377541).
This commit is contained in:
Jan Kratochvil 2009-05-11 21:25:16 +00:00
parent 47ac9de45c
commit 426ff34819
4 changed files with 462 additions and 39 deletions

View File

@ -28,8 +28,8 @@
Index: gdb-6.8.50.20090302/gdb/amd64-tdep.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/amd64-tdep.c 2009-03-07 00:30:09.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/amd64-tdep.c 2009-03-07 00:30:12.000000000 +0100
--- gdb-6.8.50.20090302.orig/gdb/amd64-tdep.c 2009-05-10 21:36:29.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/amd64-tdep.c 2009-05-10 21:41:23.000000000 +0200
@@ -36,6 +36,7 @@
#include "regcache.h"
#include "regset.h"
@ -134,8 +134,8 @@ Index: gdb-6.8.50.20090302/gdb/amd64-tdep.c
Index: gdb-6.8.50.20090302/gdb/auxv.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/auxv.c 2009-03-07 00:30:06.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/auxv.c 2009-03-07 00:30:12.000000000 +0100
--- gdb-6.8.50.20090302.orig/gdb/auxv.c 2009-05-10 21:36:27.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/auxv.c 2009-05-10 21:41:23.000000000 +0200
@@ -81,7 +81,7 @@ procfs_xfer_auxv (struct target_ops *ops
Return 1 if an entry was read into *TYPEP and *VALP. */
static int
@ -206,7 +206,7 @@ Index: gdb-6.8.50.20090302/gdb/auxv.c
{
#define TAG(tag, text, kind) \
case tag: name = #tag; description = text; flavor = kind; break
@@ -232,7 +234,7 @@ fprint_target_auxv (struct ui_file *file
@@ -233,7 +235,7 @@ fprint_target_auxv (struct ui_file *file
}
fprintf_filtered (file, "%-4s %-20s %-30s ",
@ -215,7 +215,7 @@ Index: gdb-6.8.50.20090302/gdb/auxv.c
switch (flavor)
{
case dec:
@@ -254,7 +256,7 @@ fprint_target_auxv (struct ui_file *file
@@ -255,7 +257,7 @@ fprint_target_auxv (struct ui_file *file
break;
}
++ents;
@ -227,7 +227,7 @@ Index: gdb-6.8.50.20090302/gdb/auxv.c
Index: gdb-6.8.50.20090302/gdb/auxv.h
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/auxv.h 2009-01-03 06:57:50.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/auxv.h 2009-03-07 00:30:12.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/auxv.h 2009-05-10 21:41:23.000000000 +0200
@@ -36,14 +36,14 @@ struct target_ops; /* Forward declarati
Return 1 if an entry was read into *TYPEP and *VALP. */
extern int target_auxv_parse (struct target_ops *ops,
@ -247,8 +247,8 @@ Index: gdb-6.8.50.20090302/gdb/auxv.h
extern int fprint_target_auxv (struct ui_file *file, struct target_ops *ops);
Index: gdb-6.8.50.20090302/gdb/breakpoint.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/breakpoint.c 2009-03-07 00:30:10.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/breakpoint.c 2009-03-07 00:30:12.000000000 +0100
--- gdb-6.8.50.20090302.orig/gdb/breakpoint.c 2009-05-10 21:36:30.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/breakpoint.c 2009-05-10 21:41:23.000000000 +0200
@@ -3920,7 +3920,8 @@ describe_other_breakpoints (CORE_ADDR pc
printf_filtered (" (thread %d)", b->thread);
printf_filtered ("%s%s ",
@ -259,7 +259,7 @@ Index: gdb-6.8.50.20090302/gdb/breakpoint.c
? " (disabled)"
: b->enable_state == bp_permanent
? " (permanent)"
@@ -5008,6 +5009,61 @@ create_catchpoint (int tempflag, char *c
@@ -5009,6 +5010,61 @@ create_catchpoint (int tempflag, char *c
return b;
}
@ -323,8 +323,8 @@ Index: gdb-6.8.50.20090302/gdb/breakpoint.c
struct breakpoint_ops *ops)
Index: gdb-6.8.50.20090302/gdb/breakpoint.h
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/breakpoint.h 2009-03-07 00:30:06.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/breakpoint.h 2009-03-07 00:30:12.000000000 +0100
--- gdb-6.8.50.20090302.orig/gdb/breakpoint.h 2009-05-10 21:36:27.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/breakpoint.h 2009-05-10 21:41:23.000000000 +0200
@@ -127,6 +127,7 @@ enum enable_state
automatically enabled and reset when the call
"lands" (either completes, or stops at another
@ -346,9 +346,9 @@ Index: gdb-6.8.50.20090302/gdb/breakpoint.h
Index: gdb-6.8.50.20090302/gdb/dwarf2read.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/dwarf2read.c 2009-03-07 00:30:10.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/dwarf2read.c 2009-03-07 00:30:12.000000000 +0100
@@ -1413,7 +1413,7 @@ dwarf2_build_psymtabs (struct objfile *o
--- gdb-6.8.50.20090302.orig/gdb/dwarf2read.c 2009-05-10 21:36:30.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/dwarf2read.c 2009-05-10 21:41:23.000000000 +0200
@@ -1438,7 +1438,7 @@ dwarf2_build_psymtabs (struct objfile *o
else
dwarf2_per_objfile->loc_buffer = NULL;
@ -359,8 +359,8 @@ Index: gdb-6.8.50.20090302/gdb/dwarf2read.c
{
Index: gdb-6.8.50.20090302/gdb/elfread.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/elfread.c 2009-03-07 00:30:06.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/elfread.c 2009-03-07 00:30:12.000000000 +0100
--- gdb-6.8.50.20090302.orig/gdb/elfread.c 2009-05-10 21:36:27.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/elfread.c 2009-05-10 21:41:23.000000000 +0200
@@ -680,7 +680,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
@ -372,8 +372,8 @@ Index: gdb-6.8.50.20090302/gdb/elfread.c
mainline = 0;
Index: gdb-6.8.50.20090302/gdb/infrun.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/infrun.c 2009-03-07 00:30:10.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/infrun.c 2009-03-07 00:30:12.000000000 +0100
--- gdb-6.8.50.20090302.orig/gdb/infrun.c 2009-05-10 21:36:30.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/infrun.c 2009-05-10 21:41:23.000000000 +0200
@@ -3354,6 +3354,11 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
#endif
target_terminal_inferior ();
@ -388,11 +388,11 @@ Index: gdb-6.8.50.20090302/gdb/infrun.c
and place breakpoints in initializer routines for
Index: gdb-6.8.50.20090302/gdb/objfiles.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/objfiles.c 2009-03-07 00:30:06.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/objfiles.c 2009-03-07 00:30:12.000000000 +0100
@@ -51,6 +51,9 @@
#include "arch-utils.h"
--- gdb-6.8.50.20090302.orig/gdb/objfiles.c 2009-05-10 21:36:42.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/objfiles.c 2009-05-10 21:41:36.000000000 +0200
@@ -52,6 +52,9 @@
#include "exec.h"
#include "varobj.h"
+#include "auxv.h"
+#include "elf/common.h"
@ -400,7 +400,7 @@ Index: gdb-6.8.50.20090302/gdb/objfiles.c
/* Prototypes for local functions */
static void objfile_alloc_data (struct objfile *objfile);
@@ -271,7 +274,19 @@ init_entry_point_info (struct objfile *o
@@ -272,7 +275,19 @@ init_entry_point_info (struct objfile *o
CORE_ADDR
entry_point_address (void)
{
@ -421,7 +421,7 @@ Index: gdb-6.8.50.20090302/gdb/objfiles.c
}
/* Create the terminating entry of OBJFILE's minimal symbol table.
@@ -443,6 +458,9 @@ free_objfile (struct objfile *objfile)
@@ -445,6 +460,9 @@ free_objfile (struct objfile *objfile)
if (objfile == rt_common_objfile)
rt_common_objfile = NULL;
@ -433,8 +433,8 @@ Index: gdb-6.8.50.20090302/gdb/objfiles.c
linkage unit, gdb used to do these things whenever the monolithic
Index: gdb-6.8.50.20090302/gdb/solib-svr4.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/solib-svr4.c 2009-03-07 00:30:09.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/solib-svr4.c 2009-03-07 00:30:12.000000000 +0100
--- gdb-6.8.50.20090302.orig/gdb/solib-svr4.c 2009-05-10 21:36:29.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/solib-svr4.c 2009-05-10 21:41:23.000000000 +0200
@@ -45,6 +45,7 @@
#include "exec.h"
#include "auxv.h"
@ -1119,7 +1119,7 @@ Index: gdb-6.8.50.20090302/gdb/solib-svr4.c
Index: gdb-6.8.50.20090302/gdb/solib.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/solib.c 2009-02-21 17:14:49.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/solib.c 2009-03-07 00:30:12.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/solib.c 2009-05-10 21:41:23.000000000 +0200
@@ -81,6 +81,8 @@ set_solib_ops (struct gdbarch *gdbarch,
/* external data declarations */
@ -1309,7 +1309,7 @@ Index: gdb-6.8.50.20090302/gdb/solib.c
Index: gdb-6.8.50.20090302/gdb/solist.h
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/solist.h 2009-02-04 09:42:11.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/solist.h 2009-03-07 00:30:12.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/solist.h 2009-05-10 21:41:23.000000000 +0200
@@ -61,6 +61,8 @@ struct so_list
bfd *abfd;
char symbols_loaded; /* flag: symbols read in yet? */
@ -1332,8 +1332,8 @@ Index: gdb-6.8.50.20090302/gdb/solist.h
#endif
Index: gdb-6.8.50.20090302/gdb/symfile-mem.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/symfile-mem.c 2009-03-07 00:30:08.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/symfile-mem.c 2009-03-07 00:30:12.000000000 +0100
--- gdb-6.8.50.20090302.orig/gdb/symfile-mem.c 2009-05-10 21:36:28.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/symfile-mem.c 2009-05-10 21:41:23.000000000 +0200
@@ -116,7 +116,7 @@ symbol_file_add_from_memory (struct bfd
}
@ -1345,8 +1345,8 @@ Index: gdb-6.8.50.20090302/gdb/symfile-mem.c
reinit_frame_cache ();
Index: gdb-6.8.50.20090302/gdb/symfile.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/symfile.c 2009-03-07 00:30:09.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/symfile.c 2009-03-07 00:31:24.000000000 +0100
--- gdb-6.8.50.20090302.orig/gdb/symfile.c 2009-05-10 21:37:51.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/symfile.c 2009-05-10 21:41:23.000000000 +0200
@@ -47,6 +47,7 @@
#include "readline/readline.h"
#include "gdb_assert.h"
@ -1397,7 +1397,7 @@ Index: gdb-6.8.50.20090302/gdb/symfile.c
/* We're done reading the symbol file; finish off complaints. */
clear_complaints (&symfile_complaints, 0, verbo);
@@ -980,7 +985,7 @@ symbol_file_add_with_addrs_or_offsets (b
@@ -982,7 +987,7 @@ symbol_file_add_with_addrs_or_offsets (b
/* Give user a chance to burp if we'd be
interactively wiping out any existing symbols. */
@ -1406,7 +1406,7 @@ Index: gdb-6.8.50.20090302/gdb/symfile.c
&& from_tty
&& (have_full_symbols () || have_partial_symbols ())
&& !query (_("Load new symbol table from \"%s\"? "), name))
@@ -1175,6 +1180,10 @@ symbol_file_clear (int from_tty)
@@ -1178,6 +1183,10 @@ symbol_file_clear (int from_tty)
symfile_objfile->name)
: !query (_("Discard symbol table? "))))
error (_("Not confirmed."));
@ -1417,7 +1417,7 @@ Index: gdb-6.8.50.20090302/gdb/symfile.c
free_all_objfiles ();
/* solib descriptors may have handles to objfiles. Since their
@@ -3275,6 +3284,8 @@ reread_symbols (void)
@@ -3367,6 +3376,8 @@ reread_symbols (void)
/* Discard cleanups as symbol reading was successful. */
discard_cleanups (old_cleanups);
@ -1428,8 +1428,8 @@ Index: gdb-6.8.50.20090302/gdb/symfile.c
again now. */
Index: gdb-6.8.50.20090302/gdb/target.h
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/target.h 2009-03-07 00:30:09.000000000 +0100
+++ gdb-6.8.50.20090302/gdb/target.h 2009-03-07 00:30:12.000000000 +0100
--- gdb-6.8.50.20090302.orig/gdb/target.h 2009-05-10 21:36:29.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/target.h 2009-05-10 21:41:23.000000000 +0200
@@ -542,7 +542,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. */

View File

@ -0,0 +1,328 @@
Re: [patch] [4/5] Types reference counting [varobj-validation]
http://sourceware.org/ml/gdb-patches/2009-04/msg00610.html
gdb/
2009-04-22 Jan Kratochvil <jan.kratochvil@redhat.com>
Split varobj_invalidate into a two-phased operation.
* objfiles.c: Include varobj.h
(free_objfile): Call varobj_invalidate.
* parser-defs.h (exp_uses_objfile): New prototype.
* printcmd.c (display_uses_objfile): Move the EXP checking part to ...
* parse.c (exp_uses_objfile): ... a new function here.
* symfile.c (new_symfile_objfile): Call varobj_revalidate.
(reread_symbols): Call varobj_invalidate and varobj_revalidate.
(clear_symtab_users): No longer call varobj_invalidate.
* varobj.c: New includes objfiles.h and parser-defs.h.
(varobj_invalidate): New parameter `objfile', comment it.
New variable `var'. Invalidate any varobj related to `objfile'.
Remove unconditional invalidation of local varobjs. Move global
varobjs revalidation to ...
(varobj_revalidate): ... a new function.
* varobj.h (varobj_invalidate): Update the prototype.
(varobj_revalidate): New prototype.
[ Cut the printcmd.c simplification/change. ]
Index: gdb-6.8.50.20090302/gdb/objfiles.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/objfiles.c 2009-05-10 21:36:30.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/objfiles.c 2009-05-10 21:36:42.000000000 +0200
@@ -50,6 +50,7 @@
#include "addrmap.h"
#include "arch-utils.h"
#include "exec.h"
+#include "varobj.h"
/* Prototypes for local functions */
@@ -409,6 +410,7 @@ free_objfile (struct objfile *objfile)
/* Remove any references to this objfile in the global value
lists. */
preserve_values (objfile);
+ varobj_invalidate (objfile);
/* First do any symbol file specific actions required when we are
finished with a particular symbol file. Note that if the objfile
Index: gdb-6.8.50.20090302/gdb/parse.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/parse.c 2009-05-10 21:36:29.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/parse.c 2009-05-10 21:36:42.000000000 +0200
@@ -1373,6 +1373,45 @@ parser_fprintf (FILE *x, const char *y,
va_end (args);
}
+/* Return 1 if EXP uses OBJFILE (and will become dangling when OBJFILE
+ is unloaded), otherwise return 0. */
+
+int
+exp_uses_objfile (struct expression *exp, struct objfile *objfile)
+{
+ int endpos;
+ const union exp_element *const elts = exp->elts;
+
+ for (endpos = exp->nelts; endpos > 0; )
+ {
+ int i, args, oplen = 0;
+
+ exp->language_defn->la_exp_desc->operator_length (exp, endpos,
+ &oplen, &args);
+ gdb_assert (oplen > 0);
+
+ i = endpos - oplen;
+ if (elts[i].opcode == OP_VAR_VALUE)
+ {
+ const struct block *const block = elts[i + 1].block;
+ const struct symbol *const symbol = elts[i + 2].symbol;
+ const struct obj_section *const section =
+ SYMBOL_OBJ_SECTION (symbol);
+
+ /* Check objfile where is placed the code touching the variable. */
+ if (matching_objfiles (block_objfile (block), objfile))
+ return 1;
+
+ /* Check objfile where the variable itself is placed. */
+ if (section && section->objfile == objfile)
+ return 1;
+ }
+ endpos -= oplen;
+ }
+
+ return 0;
+}
+
void
_initialize_parse (void)
{
Index: gdb-6.8.50.20090302/gdb/parser-defs.h
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/parser-defs.h 2009-05-10 21:36:27.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/parser-defs.h 2009-05-10 21:36:42.000000000 +0200
@@ -299,4 +299,6 @@ extern void print_subexp_standard (struc
extern void parser_fprintf (FILE *, const char *, ...) ATTR_FORMAT (printf, 2 ,3);
+extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
+
#endif /* PARSER_DEFS_H */
Index: gdb-6.8.50.20090302/gdb/symfile.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/symfile.c 2009-05-10 21:36:29.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/symfile.c 2009-05-10 21:37:51.000000000 +0200
@@ -931,6 +931,8 @@ new_symfile_objfile (struct objfile *obj
/* We're done reading the symbol file; finish off complaints. */
clear_complaints (&symfile_complaints, 0, verbo);
+
+ varobj_revalidate ();
}
/* A helper function which returns true if OBJFILE has any debug
@@ -3261,6 +3263,7 @@ reread_symbols (void)
/* Remove any references to this objfile in the global
value lists. */
preserve_values (objfile);
+ varobj_invalidate (objfile);
/* Nuke all the state that we will re-read. Much of the following
code which sets things to NULL really is necessary to tell
@@ -3359,6 +3362,7 @@ reread_symbols (void)
frameless. */
reinit_frame_cache ();
+ varobj_revalidate ();
/* Discard cleanups as symbol reading was successful. */
discard_cleanups (old_cleanups);
@@ -3739,10 +3743,6 @@ clear_symtab_users (void)
between expressions and which ought to be reset each time. */
expression_context_block = NULL;
innermost_block = NULL;
-
- /* Varobj may refer to old symbols, perform a cleanup. */
- varobj_invalidate ();
-
}
static void
Index: gdb-6.8.50.20090302/gdb/varobj.c
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/varobj.c 2009-05-10 21:36:27.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/varobj.c 2009-05-10 21:40:55.000000000 +0200
@@ -26,6 +26,8 @@
#include "gdbcmd.h"
#include "block.h"
#include "valprint.h"
+#include "objfiles.h"
+#include "parser-defs.h"
#include "gdb_assert.h"
#include "gdb_string.h"
@@ -3272,48 +3274,117 @@ When non-zero, varobj debugging is enabl
&setlist, &showlist);
}
-/* Invalidate the varobjs that are tied to locals and re-create the ones that
- are defined on globals.
+/* Invalidate the varobjs that are tied to the specified OBJFILE. Call this
+ function before you start removing OBJFILE.
+
+ Call varobj_revalidate after the OBJFILEs updates get finished.
+
Invalidated varobjs will be always printed in_scope="invalid". */
+
void
-varobj_invalidate (void)
+varobj_invalidate (struct objfile *objfile)
{
struct varobj **all_rootvarobj;
struct varobj **varp;
if (varobj_list (&all_rootvarobj) > 0)
- {
- varp = all_rootvarobj;
- while (*varp != NULL)
- {
- /* Floating varobjs are reparsed on each stop, so we don't care if
- the presently parsed expression refers to something that's gone. */
- if ((*varp)->root->floating)
- continue;
-
- /* global var must be re-evaluated. */
- if ((*varp)->root->valid_block == NULL)
- {
- struct varobj *tmp_var;
-
- /* Try to create a varobj with same expression. If we succeed replace
- the old varobj, otherwise invalidate it. */
- tmp_var = varobj_create (NULL, (*varp)->name, (CORE_ADDR) 0, USE_CURRENT_FRAME);
- if (tmp_var != NULL)
- {
- tmp_var->obj_name = xstrdup ((*varp)->obj_name);
- varobj_delete (*varp, NULL, 0);
- install_variable (tmp_var);
- }
- else
- (*varp)->root->is_valid = 0;
- }
- else /* locals must be invalidated. */
- (*varp)->root->is_valid = 0;
+ {
+ varp = all_rootvarobj;
+ while (*varp != NULL)
+ {
+ struct varobj *var = *varp;
- varp++;
- }
- }
+ /* Floating varobjs are reparsed on each stop, so we don't care if
+ the presently parsed expression refers to something that's gone.
+ */
+ if (var->root->floating)
+ continue;
+
+ if (var->root->is_valid
+ && matching_objfiles (block_objfile (var->root->valid_block),
+ objfile))
+ var->root->is_valid = 0;
+
+ if (var->root->is_valid
+ && exp_uses_objfile (var->root->exp, objfile))
+ {
+ var->root->is_valid = 0;
+
+ /* No one touches EXP for !IS_VALID varobj. */
+ xfree (var->root->exp);
+ var->root->exp = NULL;
+ }
+
+ if (var->type && TYPE_OBJFILE (var->type) == objfile)
+ {
+ if (!var->root->valid_block)
+ var->root->is_valid = 0;
+ else
+ gdb_assert (!var->root->is_valid);
+
+ var->type = NULL;
+ }
+
+ if (var->value
+ && TYPE_OBJFILE (value_type (var->value)) == objfile)
+ {
+ if (!var->root->valid_block)
+ var->root->is_valid = 0;
+ else
+ gdb_assert (!var->root->is_valid);
+
+ value_free (var->value);
+ var->value = NULL;
+ }
+
+ varp++;
+ }
+ }
+ xfree (all_rootvarobj);
+}
+
+/* Recreate any global varobjs possibly previously invalidated. If the
+ expressions are no longer evaluatable set/keep the varobj invalid. */
+
+void
+varobj_revalidate (void)
+{
+ struct varobj **all_rootvarobj;
+ struct varobj **varp;
+
+ if (varobj_list (&all_rootvarobj) > 0)
+ {
+ varp = all_rootvarobj;
+ while (*varp != NULL)
+ {
+ struct varobj *var = *varp;
+
+ /* Floating varobjs are reparsed on each stop, so we don't care if
+ the presently parsed expression refers to something that's gone.
+ */
+ if (var->root->floating)
+ continue;
+
+ /* global var must be re-evaluated. */
+ if (var->root->valid_block == NULL)
+ {
+ struct varobj *tmp_var;
+
+ /* Try to create a varobj with same expression. If we succeed
+ replace the old varobj, otherwise invalidate it. */
+ tmp_var = varobj_create (NULL, var->name, 0, USE_CURRENT_FRAME);
+ if (tmp_var != NULL)
+ {
+ tmp_var->obj_name = xstrdup (var->obj_name);
+ varobj_delete (var, NULL, 0);
+ install_variable (tmp_var);
+ }
+ else
+ var->root->is_valid = 0;
+ }
+
+ varp++;
+ }
+ }
xfree (all_rootvarobj);
- return;
}
Index: gdb-6.8.50.20090302/gdb/varobj.h
===================================================================
--- gdb-6.8.50.20090302.orig/gdb/varobj.h 2009-05-10 21:36:27.000000000 +0200
+++ gdb-6.8.50.20090302/gdb/varobj.h 2009-05-10 21:36:42.000000000 +0200
@@ -148,7 +148,9 @@ extern int varobj_list (struct varobj **
extern VEC(varobj_update_result) *varobj_update (struct varobj **varp,
int explicit);
-extern void varobj_invalidate (void);
+extern void varobj_invalidate (struct objfile *objfile);
+
+extern void varobj_revalidate (void);
extern int varobj_editable_p (struct varobj *var);

View File

@ -0,0 +1,86 @@
Re: [patch] Make a function for block->objfile lookups
http://sourceware.org/ml/gdb-patches/2009-04/msg00609.html
gdb/
2009-04-22 Jan Kratochvil <jan.kratochvil@redhat.com>
* block.c (block_objfile): New function.
* block.h (block_objfile): New prototype.
* objfiles.c (matching_objfiles): New function.
* objfiles.h (matching_objfiles): New prototype.
* printcmd.c: Remove include solib.h.
(display_uses_solib_p): Rename to ...
(display_uses_objfile): ... a new function name. Change the SOLIB
parameter to OBJFILE parameter. Use now a matching_objfiles call.
(clear_dangling_display_expressions): Update the caller.
[ Cut the printcmd.c simplification/change. ]
--- ./gdb/block.c 3 Jan 2009 05:57:50 -0000 1.18
+++ ./gdb/block.c 22 Apr 2009 19:51:40 -0000
@@ -309,3 +309,21 @@ allocate_block (struct obstack *obstack)
return bl;
}
+
+/* Return OBJFILE in which BLOCK is located or NULL if we cannot find it for
+ whatever reason. */
+
+struct objfile *
+block_objfile (const struct block *block)
+{
+ struct symbol *func;
+
+ if (block == NULL)
+ return NULL;
+
+ func = block_linkage_function (block);
+ if (func == NULL)
+ return NULL;
+
+ return SYMBOL_SYMTAB (func)->objfile;
+}
--- ./gdb/block.h 3 Jan 2009 05:57:50 -0000 1.19
+++ ./gdb/block.h 22 Apr 2009 19:51:40 -0000
@@ -164,4 +164,6 @@ extern const struct block *block_global_
extern struct block *allocate_block (struct obstack *obstack);
+extern struct objfile *block_objfile (const struct block *block);
+
#endif /* BLOCK_H */
--- ./gdb/objfiles.c 11 Mar 2009 20:26:02 -0000 1.82
+++ ./gdb/objfiles.c 22 Apr 2009 19:51:40 -0000
@@ -891,3 +891,21 @@ objfile_data (struct objfile *objfile, c
gdb_assert (data->index < objfile->num_data);
return objfile->data[data->index];
}
+
+/* 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;
+}
--- ./gdb/objfiles.h 15 Jan 2009 16:35:22 -0000 1.59
+++ ./gdb/objfiles.h 22 Apr 2009 19:51:40 -0000
@@ -497,6 +497,8 @@ extern struct obj_section *find_pc_secti
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. */

View File

@ -13,7 +13,7 @@ Version: 6.8.50.20090302
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 22%{?_with_upstream:.upstream}%{?dist}
Release: 23%{?_with_upstream:.upstream}%{?dist}
License: GPLv3+
Group: Development/Debuggers
@ -381,6 +381,10 @@ Patch357: gdb-c_get_string-xfree.patch
# Fix crash in the charset support.
Patch359: gdb-charset-crash.patch
# Fix crashes due to (missing) varobj revalidation, for VLA (for BZ 377541).
Patch369: gdb-varobj-revalidate-prep.patch
Patch370: gdb-varobj-revalidate-core.patch
BuildRequires: ncurses-devel texinfo gettext flex bison expat-devel
Requires: readline
BuildRequires: readline-devel
@ -577,6 +581,8 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch352 -p1
%patch357 -p1
%patch359 -p1
%patch369 -p1
%patch370 -p1
%patch124 -p1
find -name "*.orig" | xargs rm -f
@ -859,6 +865,9 @@ fi
%endif
%changelog
* Mon May 11 2009 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.8.50.20090302-23
- Fix crashes due to (missing) varobj revalidation, for VLA (for BZ 377541).
* Sun May 10 2009 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.8.50.20090302-22
- Archer update to the snapshot: e2812eadef2c15baeccd003e11fdf3fbc0b90dc2
- Archer backport: 58dcda94ac5d6398f47382505e9d3d9d866d79bf