diff options
author | Daniel Jacobowitz <drow@false.org> | 2007-01-08 23:11:47 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2007-01-08 23:11:47 +0000 |
commit | 57e66780712e5e26bd6857c0f56b537013cd17dc (patch) | |
tree | a1dd7db3641ea8d1c242c00c44e22d3df5fb5c39 /gdb/varobj.c | |
parent | 822b7cb4a1db8a522bcd40990687d53a99567378 (diff) | |
download | gdb-57e66780712e5e26bd6857c0f56b537013cd17dc.zip gdb-57e66780712e5e26bd6857c0f56b537013cd17dc.tar.gz gdb-57e66780712e5e26bd6857c0f56b537013cd17dc.tar.bz2 |
* 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.
Diffstat (limited to 'gdb/varobj.c')
-rw-r--r-- | gdb/varobj.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/gdb/varobj.c b/gdb/varobj.c index e24bcd3..a73dfd6 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; } |