diff options
author | Andrew Burgess <aburgess@broadcom.com> | 2012-07-30 12:10:23 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@broadcom.com> | 2012-07-30 12:10:23 +0000 |
commit | 4e969b4f01286290f5d06e41dd8e8a2c738d7650 (patch) | |
tree | 32109ff24285ce772a7c45c07f23254981ddd93d | |
parent | a6dc81d2ab37bd09527e0a00d82c4670f22a1a27 (diff) | |
download | gdb-4e969b4f01286290f5d06e41dd8e8a2c738d7650.zip gdb-4e969b4f01286290f5d06e41dd8e8a2c738d7650.tar.gz gdb-4e969b4f01286290f5d06e41dd8e8a2c738d7650.tar.bz2 |
http://sourceware.org/ml/gdb-patches/2012-07/msg00551.html
Re-evaluate floating variables as part of variable invalidate to remove
references to type structures that might have been freed.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-var-invalidate.exp | 9 | ||||
-rw-r--r-- | gdb/varobj.c | 15 |
4 files changed, 27 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a89362b..4e83c25 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2012-07-30 Andrew Burgess <aburgess@broadcom.com> + + * varobj.c (varobj_invalidate_iter): All varobj must be marked as + invalid or reevaluated to prevent prevent references to possibly + delete'd type objects being left in the varobj. + 2012-07-27 Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 137c2e7..42ae5c8 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-07-30 Andrew Burgess <aburgess@broadcom.com> + + * gdb.mi/mi-var-invalidate.exp: Create a floating variable and + change its format immediately after reloading the binary. + 2012-07-27 Jan Kratochvil <jan.kratochvil@redhat.com> Fix testsuite regression after --use-deprecated-index-sections removal. diff --git a/gdb/testsuite/gdb.mi/mi-var-invalidate.exp b/gdb/testsuite/gdb.mi/mi-var-invalidate.exp index 3ecbbdf..1f16f88 100644 --- a/gdb/testsuite/gdb.mi/mi-var-invalidate.exp +++ b/gdb/testsuite/gdb.mi/mi-var-invalidate.exp @@ -61,6 +61,9 @@ mi_runto do_locals_tests # Desc: create local variables mi_create_varobj linteger linteger "create local variable linteger" +# Desc: create floating variable +mi_create_floating_varobj float_simple array "create floating variable" + # # Reload the same binary. # Global variable should remain, local should be invalidated. @@ -69,6 +72,12 @@ mi_delete_breakpoints mi_gdb_load ${binfile_bis} mi_runto main +# Change format of floating variable immediately after reload reveals a +# bug where gdb still uses a free'd pointer. +mi_gdb_test "-var-set-format float_simple hexadecimal" \ + "\\^done,format=\"hexadecimal\",value=\"\\\[-1\\\]\"" \ + "set format variable float_simple" + # Check local variable is "invalid". mi_gdb_test "-var-update linteger" \ "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"invalid\",has_more=\"0\"\}\\\]" \ diff --git a/gdb/varobj.c b/gdb/varobj.c index 99b158e..a75a40d 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -4186,18 +4186,17 @@ _initialize_varobj (void) } /* Invalidate varobj VAR if it is tied to locals and re-create it if it is - defined on globals. It is a helper for varobj_invalidate. */ + defined on globals. It is a helper for varobj_invalidate. + + This function is called after changing the symbol file, in this case the + pointers to "struct type" stored by the varobj are no longer valid. All + varobj must be either re-evaluated, or marked as invalid here. */ static void varobj_invalidate_iter (struct varobj *var, void *unused) { - /* 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) - return; - - /* global var must be re-evaluated. */ - if (var->root->valid_block == NULL) + /* global and floating var must be re-evaluated. */ + if (var->root->floating || var->root->valid_block == NULL) { struct varobj *tmp_var; |