From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17346 invoked by alias); 24 May 2009 17:07:23 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 17317 invoked by uid 9674); 24 May 2009 17:07:22 -0000 Date: Sun, 24 May 2009 17:07:00 -0000 Message-ID: <20090524170721.17302.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-jankratochvil-vla: Merge commit 'origin/archer-jankratochvil-type-refcount' into archer-jankratochvil-vla X-Git-Refname: refs/heads/archer-jankratochvil-vla X-Git-Reftype: branch X-Git-Oldrev: 80adfb8af20aaf46f5146fe510e80a0e76e9ad78 X-Git-Newrev: a6d985d5b2b265601a389b14938d15faec4de336 X-SW-Source: 2009-q2/txt/msg00077.txt.bz2 List-Id: The branch, archer-jankratochvil-vla has been updated via a6d985d5b2b265601a389b14938d15faec4de336 (commit) via 59c5ab041dce3d467a11922c38876f830cfc35a4 (commit) via 2334cc6ce2ccb55e9280e8dd877f4b3eb8ffc5b2 (commit) via 4797634711f280bb0e9d187b2d11f0d00d664a5c (commit) via 46a88eb14a8744005312fe48ee968dd230b87451 (commit) from 80adfb8af20aaf46f5146fe510e80a0e76e9ad78 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit a6d985d5b2b265601a389b14938d15faec4de336 Merge: 80adfb8af20aaf46f5146fe510e80a0e76e9ad78 59c5ab041dce3d467a11922c38876f830cfc35a4 Author: Jan Kratochvil Date: Sun May 24 19:04:03 2009 +0200 Merge commit 'origin/archer-jankratochvil-type-refcount' into archer-jankratochvil-vla Conflicts: gdb/gdbtypes.c commit 59c5ab041dce3d467a11922c38876f830cfc35a4 Author: Jan Kratochvil Date: Sun May 24 18:42:05 2009 +0200 Execute forgotten breakpoint_types_mark_used(). commit 2334cc6ce2ccb55e9280e8dd877f4b3eb8ffc5b2 Author: Jan Kratochvil Date: Sun May 24 18:38:54 2009 +0200 Introduce observer `mark_used'. commit 4797634711f280bb0e9d187b2d11f0d00d664a5c Author: Jan Kratochvil Date: Sun May 24 17:59:39 2009 +0200 Move to observers. Fixup clear_dangling_display_expressions. commit 46a88eb14a8744005312fe48ee968dd230b87451 Author: Jan Kratochvil Date: Sun May 24 16:07:12 2009 +0200 Remove excessive matching_objfiles. - If we are removing objfile we get invalidated both of its parts. - If we really remove just the one part, the other part can still get referenced. ----------------------------------------------------------------------- Summary of changes: gdb/breakpoint.c | 5 +- gdb/breakpoint.h | 2 - gdb/doc/observer.texi | 14 ++++++ gdb/gdbtypes.c | 20 +-------- gdb/objfiles.c | 26 +---------- gdb/objfiles.h | 2 - gdb/parse.c | 3 +- gdb/printcmd.c | 40 +++++------------ gdb/python/python-value.c | 14 ++++++ gdb/symfile.c | 11 +++-- gdb/value.c | 8 +++- gdb/value.h | 4 -- gdb/varobj.c | 104 +++++++++++++++++++++++++++------------------ gdb/varobj.h | 6 --- 14 files changed, 124 insertions(+), 135 deletions(-) First 500 lines of diff: diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 11cd1eb..8ce8896 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8551,8 +8551,8 @@ all_tracepoints () /* Call type_mark_used for any TYPEs referenced from this GDB source file. */ -void -brekpoint_types_mark_used (void) +static void +breakpoint_types_mark_used (void) { struct breakpoint *b; @@ -9070,4 +9070,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 5d5bae8..43c2f3f 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -816,8 +816,6 @@ extern void disable_display (int); extern void clear_displays (void); -extern void print_types_mark_used (void); - extern void disable_breakpoint (struct breakpoint *); extern void enable_breakpoint (struct breakpoint *); diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi index 4984f31..4bbbe4e 100644 --- a/gdb/doc/observer.texi +++ b/gdb/doc/observer.texi @@ -130,6 +130,15 @@ Called with @var{objfile} equal to @code{NULL} to indicate previously loaded symbol table data has now been invalidated. @end deftypefun +@deftypefun void objfile_unloading (struct objfile *@var{objfile}) +The file specified by @var{objfile} is going to be removed from @value{GDBN}. +@end deftypefun + +@deftypefun void objfile_unloaded (void) +Removal of @var{objfile} started by @code{objfile_unloading} finished and +@var{objfile} is no longer known to @value{GDBN}. +@end deftypefun + @deftypefun void new_thread (struct thread_info *@var{t}) The thread specified by @var{t} has been created. @end deftypefun @@ -206,6 +215,11 @@ Either @value{GDBN} detached from the inferior, or the inferior exited. The argument @var{pid} identifies the inferior. @end deftypefun +@deftypefun void mark_used (void) +Mark any possibly reclaimable objects as used during a mark-and-sweep garbage +collector pass. Currently only @code{type_mark_used} marker is supported. +@end deftypefun + @deftypefun void test_notification (int @var{somearg}) This observer is used for internal testing. Do not use. See testsuite/gdb.gdb/observer.exp. diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 018fd82..6c3d650 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -38,9 +38,7 @@ #include "cp-abi.h" #include "gdb_assert.h" #include "hashtab.h" -#include "varobj.h" -#include "breakpoint.h" -#include "python/python.h" +#include "observer.h" #include "dwarf2expr.h" #include "dwarf2loc.h" @@ -3693,17 +3691,6 @@ type_group_link_remove (void **slot, void *unused) return 1; } -/* Call type_mark_used for any TYPEs referenced by Python global variables. */ - -static void -python_types_mark_used (void) -{ - struct value *val; - - for (val = values_in_python; val != NULL; val = value_next (val)) - type_mark_used (value_type (val)); -} - /* Free all the reclaimable types that have been allocated and that have currently zero reference counter. @@ -3721,10 +3708,7 @@ free_all_types (void) type_group_link_check (); - value_types_mark_used (); - varobj_types_mark_used (); - print_types_mark_used (); - python_types_mark_used (); + observer_notify_mark_used (); htab_traverse (type_group_link_table, type_group_link_remove, NULL); } diff --git a/gdb/objfiles.c b/gdb/objfiles.c index fd3fd86..36a123c 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -50,7 +50,7 @@ #include "addrmap.h" #include "arch-utils.h" #include "exec.h" -#include "varobj.h" +#include "observer.h" /* Prototypes for local functions */ @@ -407,10 +407,8 @@ free_objfile (struct objfile *objfile) objfile->separate_debug_objfile_backlink->separate_debug_objfile = NULL; } - /* Remove any references to this objfile in the global value - lists. */ - preserve_values (objfile); - varobj_invalidate (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 @@ -893,21 +891,3 @@ objfile_data (struct objfile *objfile, const struct objfile_data *data) 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; -} diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 61d61a5..60d3143 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -497,8 +497,6 @@ 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. */ diff --git a/gdb/parse.c b/gdb/parse.c index de512bd..3a04e28 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -1460,7 +1460,7 @@ exp_uses_objfile_iter (struct objfile *exp_objfile, void *objfile_voidp) { struct objfile *objfile = objfile_voidp; - return matching_objfiles (exp_objfile, objfile); + return exp_objfile == objfile; } /* Return 1 if EXP uses OBJFILE (and will become dangling when OBJFILE @@ -1479,6 +1479,7 @@ exp_types_mark_used_iter (struct type *type, void *unused) { type_mark_used (type); + /* Continue the traversal. */ return 0; } diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 9aedb56..a05a46f 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1367,7 +1367,7 @@ x_command (char *exp, int from_tty) /* Call type_mark_used for any TYPEs referenced from this GDB source file. */ -void +static void print_types_mark_used (void) { struct display *d; @@ -1780,21 +1780,6 @@ disable_display_command (char *args, int from_tty) } } -/* Return 1 if D uses OBJFILE (and will become dangling when OBJFILE - is unloaded), otherwise return 0. */ - -static int -display_uses_objfile (const struct display *d, struct objfile *objfile) -{ - if (matching_objfiles (block_objfile (d->block), objfile)) - return 1; - - if (exp_uses_objfile (d->exp, objfile)) - return 1; - - return 0; -} - /* display_chain items point to blocks and expressions. Some expressions in turn may point to symbols. Both symbols and blocks are obstack_alloc'd on objfile_stack, and are @@ -1804,20 +1789,18 @@ display_uses_objfile (const struct display *d, struct objfile *objfile) an item by re-parsing .exp_string field in the new execution context. */ static void -clear_dangling_display_expressions (struct so_list *solib) +clear_dangling_display_expressions (struct objfile *objfile) { struct display *d; - struct objfile *objfile = NULL; - for (d = display_chain; d; d = d->next) - { - if (d->exp && display_uses_objfile (d, solib->objfile)) - { - xfree (d->exp); - d->exp = NULL; - d->block = NULL; - } - } + for (d = display_chain; d != NULL; d = d->next) + if (block_objfile (d->block) == objfile + || (d->exp && exp_uses_objfile (d->exp, objfile))) + { + xfree (d->exp); + d->exp = NULL; + d->block = NULL; + } } @@ -2535,7 +2518,7 @@ _initialize_printcmd (void) current_display_number = -1; - observer_attach_solib_unloaded (clear_dangling_display_expressions); + observer_attach_objfile_unloading (clear_dangling_display_expressions); add_info ("address", address_info, _("Describe where symbol SYM is stored.")); @@ -2702,4 +2685,5 @@ Show printing of source filename and line number with ."), NULL, examine_w_type = init_type (TYPE_CODE_INT, 4, 0, "examine_w_type", NULL); examine_g_type = init_type (TYPE_CODE_INT, 8, 0, "examine_g_type", NULL); + observer_attach_mark_used (print_types_mark_used); } diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c index 5faa281..3079928 100644 --- a/gdb/python/python-value.c +++ b/gdb/python/python-value.c @@ -25,6 +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 @@ -843,6 +844,17 @@ gdbpy_history (PyObject *self, PyObject *args) return value_to_value_object (res_val); } +/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ + +static void +python_types_mark_used (void) +{ + struct value *val; + + for (val = values_in_python; val != NULL; val = value_next (val)) + type_mark_used (value_type (val)); +} + void gdbpy_initialize_values (void) { @@ -853,6 +865,8 @@ gdbpy_initialize_values (void) PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type); values_in_python = NULL; + + observer_attach_mark_used (python_types_mark_used); } static PyGetSetDef value_object_getset[] = { diff --git a/gdb/symfile.c b/gdb/symfile.c index 5394597..0d7d6d8 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -51,7 +51,6 @@ #include "observer.h" #include "exec.h" #include "parser-defs.h" -#include "varobj.h" #include "elf-bfd.h" #include "solib.h" #include "remote.h" @@ -929,7 +928,8 @@ new_symfile_objfile (struct objfile *objfile, int mainline, int verbo) /* We're done reading the symbol file; finish off complaints. */ clear_complaints (&symfile_complaints, 0, verbo); - varobj_revalidate (); + /* We have finished unloading of OBJFILE. */ + observer_notify_objfile_unloaded (); } /* Process a symbol file, as either the main file or as a dynamically @@ -2343,8 +2343,7 @@ reread_symbols (void) /* Remove any references to this objfile in the global value lists. */ - preserve_values (objfile); - varobj_invalidate (objfile); + observer_notify_objfile_unloading (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 @@ -2441,7 +2440,9 @@ reread_symbols (void) frameless. */ reinit_frame_cache (); - varobj_revalidate (); + + /* We have finished reloading of OBJFILE. */ + observer_notify_objfile_unloaded (); /* Discard cleanups as symbol reading was successful. */ discard_cleanups (old_cleanups); diff --git a/gdb/value.c b/gdb/value.c index 7a89fc7..d56c502 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -38,6 +38,7 @@ #include "objfiles.h" #include "valprint.h" #include "cli/cli-decode.h" +#include "observer.h" #include "python/python.h" @@ -1145,7 +1146,7 @@ call_internal_function (struct value *func, int argc, struct value **argv) /* Call type_mark_used for any TYPEs referenced from this GDB source file. */ -void +static void value_types_mark_used (void) { struct internalvar *var; @@ -1224,7 +1225,7 @@ preserve_one_value (struct value *value, struct objfile *objfile, this objfile's types, and the convenience variables will be adjusted to use the new global types. */ -void +static void preserve_values (struct objfile *objfile) { htab_t copied_types; @@ -2098,4 +2099,7 @@ Placeholder command for showing help on convenience functions."), TYPE_NAME (internal_fn_type) = ""; make_final_cleanup (value_history_cleanup, NULL); + + observer_attach_objfile_unloading (preserve_values); + observer_attach_mark_used (value_types_mark_used); } diff --git a/gdb/value.h b/gdb/value.h index 7ad6f80..6cdb2ff 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -645,10 +645,6 @@ extern void typedef_print (struct type *type, struct symbol *news, extern char *internalvar_name (struct internalvar *var); -extern void preserve_values (struct objfile *); - -extern void value_types_mark_used (void); - /* From values.c */ extern struct value *value_copy (struct value *); diff --git a/gdb/varobj.c b/gdb/varobj.c index d7de3e6..0af591e 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -36,6 +36,7 @@ #include "vec.h" #include "gdbthread.h" #include "inferior.h" +#include "observer.h" /* Non-zero if we want to see trace of varobj level stuff. */ @@ -2760,7 +2761,7 @@ varobj_types_mark_used_iter (struct varobj *var, void *unused) /* Call type_mark_used for any TYPEs referenced from this GDB source file. */ -void +static void varobj_types_mark_used (void) { /* Check all the VAROBJs, even non-root ones. Child VAROBJs can reference @@ -2770,27 +2771,13 @@ varobj_types_mark_used (void) all_varobjs (varobj_types_mark_used_iter, NULL); } - -extern void _initialize_varobj (void); -void -_initialize_varobj (void) -{ - int sizeof_table = sizeof (struct vlist *) * VAROBJ_TABLE_SIZE; - varobj_table = xmalloc (sizeof_table); - memset (varobj_table, 0, sizeof_table); +/* Invalidate VAR if it is tied to the specified OBJFILE. Call this function + before you start removing OBJFILE. - add_setshow_zinteger_cmd ("debugvarobj", class_maintenance, - &varobjdebug, _("\ -Set varobj debugging."), _("\ -Show varobj debugging."), _("\ -When non-zero, varobj debugging is enabled."), - NULL, - show_varobjdebug, - &setlist, &showlist); -} + Call varobj_revalidate_iter after the OBJFILE update get finished. -/* Helper for varobj_invalidate. */ + Invalidated varobjs will be always printed in_scope="invalid". */ static void varobj_invalidate_iter (struct varobj *var, void *objfile_voidp) @@ -2805,8 +2792,7 @@ varobj_invalidate_iter (struct varobj *var, void *objfile_voidp) during varobj_update by varobj_get_type. */ if (var->root->is_valid - && matching_objfiles (block_objfile (var->root->valid_block), - objfile)) + && block_objfile (var->root->valid_block) == objfile) var->root->is_valid = 0; if (var->root->exp && exp_uses_objfile (var->root->exp, objfile)) @@ -2835,24 +2821,8 @@ varobj_invalidate_iter (struct varobj *var, void *objfile_voidp) } } -/* 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 (struct objfile *objfile) -{ - /* Check all the VAROBJs, even non-root ones. Child VAROBJs can reference - types from other OBJFILEs through TYPE_IS_OPAQUE resolutions by - check_typedef. */ - - all_varobjs (varobj_invalidate_iter, objfile); -} - -/* Helper for varobj_revalidate. */ +/* Recreate any global varobjs possibly previously invalidated. If the + expressions are no longer evaluatable set/keep the VAR invalid. */ static void varobj_revalidate_iter (struct varobj *var, void *unused) @@ -2877,11 +2847,61 @@ varobj_revalidate_iter (struct varobj *var, void *unused) } hooks/post-receive -- Repository for Project Archer.