+2007-01-08 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * varobj.c (install_new_value): Always update print_value.
+ (value_get_print_value): Immediately return NULL for missing
+ values.
+
2007-01-08 Jim Blandy <jimb@codesourcery.com>
* configure.ac: Tighten pattern for extracting value of
+2007-01-08 Nick Roberts <nickrob@snap.net.nz>
+ Daniel Jacobowitz <dan@codesourcery.com>
+
+ * 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 <dan@codesourcery.com>
* gdb.threads/sigthread.c, gdb.threads/sigthread.exp: New.
# 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"
###
"\\^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" \
# 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"
###
"\\^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" \
/* 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
/* 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;
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);
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;
}