aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2007-01-08 23:11:47 +0000
committerDaniel Jacobowitz <drow@false.org>2007-01-08 23:11:47 +0000
commit57e66780712e5e26bd6857c0f56b537013cd17dc (patch)
treea1dd7db3641ea8d1c242c00c44e22d3df5fb5c39 /gdb
parent822b7cb4a1db8a522bcd40990687d53a99567378 (diff)
downloadfsf-binutils-gdb-57e66780712e5e26bd6857c0f56b537013cd17dc.zip
fsf-binutils-gdb-57e66780712e5e26bd6857c0f56b537013cd17dc.tar.gz
fsf-binutils-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')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-cmd.exp11
-rw-r--r--gdb/testsuite/gdb.mi/mi2-var-cmd.exp11
-rw-r--r--gdb/varobj.c28
5 files changed, 51 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 82dd082..15c98dd 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index b7120a3..dedbe26 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+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.
diff --git a/gdb/testsuite/gdb.mi/mi-var-cmd.exp b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
index 9dfcc52..3335b5e 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 79aeb08..a97b549 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 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;
}