* varobj.c (install_new_value): Always update print_value.
authorDaniel Jacobowitz <drow@false.org>
Mon, 8 Jan 2007 23:11:47 +0000 (23:11 +0000)
committerDaniel Jacobowitz <drow@false.org>
Mon, 8 Jan 2007 23:11:47 +0000 (23:11 +0000)
(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.

gdb/ChangeLog
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/mi-var-cmd.exp
gdb/testsuite/gdb.mi/mi2-var-cmd.exp
gdb/varobj.c

index 82dd082296a586f5f7e99a3363f7aedda71a7a51..15c98ddc5c0d72aa5f562310b32d868b3969de1b 100644 (file)
@@ -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
index b7120a3b4d459d520cbc2ce2da12bca41f62c1b0..dedbe26cc01b960edfe27184ff83dc33684fe31b 100644 (file)
@@ -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.
index 9dfcc52d1c434d1b79e5abbf2fe37fedea643166..3335b5e4e28c2ff09923723fcd880e8def0c8ac2 100644 (file)
@@ -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" \
index 79aeb08859006733c55be1df2d2414af86cf85b6..a97b549faaadd96cb00ce472f4f99aca43cc7569 100644 (file)
@@ -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" \
index e24bcd396d4c73141278f2b8075a4812586cea00..a73dfd66ccf5c78849dad079593a0b2cd1c2fd23 100644 (file)
@@ -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;
 }