Index: symfile.c =================================================================== --- symfile.c (revision 552) +++ symfile.c (working copy) @@ -52,6 +52,7 @@ #include "observer.h" #include "exec.h" #include "parser-defs.h" +#include "varobj.h" #include #include @@ -2585,6 +2586,10 @@ 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: varobj.c =================================================================== --- varobj.c (revision 552) +++ varobj.c (working copy) @@ -77,6 +77,10 @@ struct varobj_root /* Next root variable */ struct varobj_root *next; + + /* Flag that indicates validity: set to 0 when this varobj_root refers + to symbols that do not exist anymore. */ + int is_valid; }; /* Every variable in the system has a structure of this type defined @@ -912,6 +916,9 @@ varobj_update (struct varobj **varp, str /* Not a root var */ return -1; + if (!(*varp)->root->is_valid) + return -1; + /* Save the selected stack frame, since we will need to change it in order to evaluate expressions. */ old_fid = get_frame_id (deprecated_selected_frame); @@ -1361,6 +1368,7 @@ new_root_variable (void) var->root->frame = null_frame_id; var->root->use_selected_frame = 0; var->root->rootvar = NULL; + var->root->is_valid = 1; return var; } @@ -2569,3 +2577,45 @@ When non-zero, varobj debugging is enabl show_varobjdebug, &setlist, &showlist); } + +/* Invalidate the varobjs that are tied to locals and re-create the ones that + are defined on globals. + Invalidated varobjs will be always printed in_scope="false". */ +void +varobj_invalidate (void) +{ + struct varobj **all_rootvarobj; + struct varobj **varp; + + if (varobj_list (&all_rootvarobj) > 0) + { + varp = all_rootvarobj; + while (*varp != NULL) + { + /* 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 success we replace + the old varobj, othewize we invalidate it. */ + tmp_var = varobj_create (NULL, (*varp)->name, (CORE_ADDR) 0, USE_CURRENT_FRAME); + if (tmp_var != NULL) + { + tmp_var->obj_name = + savestring ((*varp)->obj_name, strlen ((*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++; + } + xfree (all_rootvarobj); + } + return; +} Index: varobj.h =================================================================== --- varobj.h (revision 552) +++ varobj.h (working copy) @@ -99,4 +99,6 @@ extern int varobj_list (struct varobj ** extern int varobj_update (struct varobj **varp, struct varobj ***changelist); +extern void varobj_invalidate (void); + #endif /* VAROBJ_H */