diff --git a/gdb/symfile.c b/gdb/symfile.c index aea8c762ee6..d0a32d13231 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1656,6 +1656,9 @@ symbol_file_command (const char *args, int from_tty) /* Now it's safe to re-add the breakpoints. */ breakpoint_re_set (); + + /* Also, it's safe to re-add varobjs. */ + varobj_re_set (); } } diff --git a/gdb/varobj.c b/gdb/varobj.c index 0683af1991e..ecc53f2643d 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -2362,6 +2362,26 @@ all_root_varobjs (gdb::function_view func) static void varobj_invalidate_iter (struct varobj *var) +{ + /* global and floating var must be re-evaluated. */ + if (var->root->floating || var->root->global) + ; + else /* locals must be invalidated. */ + var->root->is_valid = false; +} + +/* 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="invalid". */ + +void +varobj_invalidate (void) +{ + all_root_varobjs (varobj_invalidate_iter); +} + +static void +varobj_re_set_iter (struct varobj *var) { /* global and floating var must be re-evaluated. */ if (var->root->floating || var->root->global) @@ -2387,18 +2407,12 @@ varobj_invalidate_iter (struct varobj *var) var->root->is_valid = false; } } - else /* locals must be invalidated. */ - var->root->is_valid = false; } -/* 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="invalid". */ - void -varobj_invalidate (void) +varobj_re_set (void) { - all_root_varobjs (varobj_invalidate_iter); + all_root_varobjs (varobj_re_set_iter); } /* Ensure that no varobj keep references to OBJFILE. */ diff --git a/gdb/varobj.h b/gdb/varobj.h index 073da60d772..f3cce8ebfbd 100644 --- a/gdb/varobj.h +++ b/gdb/varobj.h @@ -316,6 +316,8 @@ extern std::vector extern void varobj_invalidate (void); +extern void varobj_re_set (void); + extern bool varobj_editable_p (const struct varobj *var); extern bool varobj_floating_p (const struct varobj *var);