From: Daniel Jacobowitz Date: Mon, 8 Jan 2007 23:11:47 +0000 (+0000) Subject: * varobj.c (install_new_value): Always update print_value. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=57e66780712e5e26bd6857c0f56b537013cd17dc;p=binutils-gdb.git * varobj.c (install_new_value): Always update print_value. (value_get_print_value): Immediately return NULL for missing values. * gdb.mi/mi-var-cmd.exp: Expect lpcharacter to update when lcharacter or linteger change. Correct duplicated test name. * gdb.mi/mi2-var-cmd.exp: Likewise. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 82dd082296a..15c98ddc5c0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2007-01-08 Daniel Jacobowitz + + * varobj.c (install_new_value): Always update print_value. + (value_get_print_value): Immediately return NULL for missing + values. + 2007-01-08 Jim Blandy * configure.ac: Tighten pattern for extracting value of diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index b7120a3b4d4..dedbe26cc01 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2007-01-08 Nick Roberts + Daniel Jacobowitz + + * gdb.mi/mi-var-cmd.exp: Expect lpcharacter to update when + lcharacter or linteger change. Correct duplicated test name. + * gdb.mi/mi2-var-cmd.exp: Likewise. + 2007-01-08 Daniel Jacobowitz * gdb.threads/sigthread.c, gdb.threads/sigthread.exp: New. diff --git a/gdb/testsuite/gdb.mi/mi-var-cmd.exp b/gdb/testsuite/gdb.mi/mi-var-cmd.exp index 9dfcc52d1c4..3335b5e4e28 100644 --- a/gdb/testsuite/gdb.mi/mi-var-cmd.exp +++ b/gdb/testsuite/gdb.mi/mi-var-cmd.exp @@ -261,8 +261,8 @@ mi_execute_to "exec-step 8" "end-stepping-range" "do_locals_tests" "" \ # Note: this test also checks that lpsimple->integer and lsimple.integer have # changed (they are the same) mi_gdb_test "-var-update *" \ - "\\^done,changelist=\\\[\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"ldouble\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lfloat\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ - "update all vars: func and lpsimple changed" + "\\^done,changelist=\\\[\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"ldouble\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lfloat\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: lsimple and others changed" ### @@ -278,8 +278,13 @@ mi_gdb_test "-var-assign linteger 3333" \ "\\^done,value=\"3333\"" \ "assign to linteger" +# Allow lpcharacter to update, optionally. Because it points to a +# char variable instead of a zero-terminated string, if linteger is +# directly after it in memory the printed characters may appear to +# change. +set lpchar_update "\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\}," mi_gdb_test "-var-update *" \ - "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "\\^done,changelist=\\\[($lpchar_update)?\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ "update all vars: linteger changed after assign" mi_gdb_test "-var-assign linteger 3333" \ diff --git a/gdb/testsuite/gdb.mi/mi2-var-cmd.exp b/gdb/testsuite/gdb.mi/mi2-var-cmd.exp index 79aeb088590..a97b549faaa 100644 --- a/gdb/testsuite/gdb.mi/mi2-var-cmd.exp +++ b/gdb/testsuite/gdb.mi/mi2-var-cmd.exp @@ -261,8 +261,8 @@ mi_execute_to "exec-step 8" "end-stepping-range" "do_locals_tests" "" \ # Note: this test also checks that lpsimple->integer and lsimple.integer have # changed (they are the same) mi_gdb_test "-var-update *" \ - "\\^done,changelist=\\\[\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"ldouble\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lfloat\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ - "update all vars: func and lpsimple changed" + "\\^done,changelist=\\\[\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"ldouble\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lfloat\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars: lsimple and others changed" ### @@ -278,8 +278,13 @@ mi_gdb_test "-var-assign linteger 3333" \ "\\^done,value=\"3333\"" \ "assign to linteger" +# Allow lpcharacter to update, optionally. Because it points to a +# char variable instead of a zero-terminated string, if linteger is +# directly after it in memory the printed characters may appear to +# change. +set lpchar_update "\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\}," mi_gdb_test "-var-update *" \ - "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "\\^done,changelist=\\\[($lpchar_update)?\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ "update all vars: linteger changed after assign" mi_gdb_test "-var-assign linteger 3333" \ diff --git a/gdb/varobj.c b/gdb/varobj.c index e24bcd396d4..a73dfd66ccf 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -966,9 +966,13 @@ install_new_value (struct varobj *var, struct value *value, int initial) /* If the value of the varobj was changed by -var-set-value, then the value in the varobj and in the target is the same. However, that value is different from the value that the varobj had after the previous - -var-update. So need to the varobj as changed. */ + -var-update. So need to the varobj as changed. */ if (var->updated) - changed = 1; + { + xfree (var->print_value); + var->print_value = value_get_print_value (value, var->format); + changed = 1; + } else { /* Try to compare the values. That requires that both @@ -979,7 +983,11 @@ install_new_value (struct varobj *var, struct value *value, int initial) /* Equal. */ ; else if (var->value == NULL || value == NULL) - changed = 1; + { + xfree (var->print_value); + var->print_value = value_get_print_value (value, var->format); + changed = 1; + } else { char *print_value; @@ -987,6 +995,7 @@ install_new_value (struct varobj *var, struct value *value, int initial) gdb_assert (!value_lazy (value)); print_value = value_get_print_value (value, var->format); + gdb_assert (var->print_value != NULL && print_value != NULL); if (strcmp (var->print_value, print_value) != 0) { xfree (var->print_value); @@ -1687,12 +1696,19 @@ static char * value_get_print_value (struct value *value, enum varobj_display_formats format) { long dummy; - struct ui_file *stb = mem_fileopen (); - struct cleanup *old_chain = make_cleanup_ui_file_delete (stb); + struct ui_file *stb; + struct cleanup *old_chain; char *thevalue; - + + if (value == NULL) + return NULL; + + stb = mem_fileopen (); + old_chain = make_cleanup_ui_file_delete (stb); + common_val_print (value, stb, format_code[(int) format], 1, 0, 0); thevalue = ui_file_xstrdup (stb, &dummy); + do_cleanups (old_chain); return thevalue; }