Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Vladimir Prus <ghost@cs.msu.su>
To: gdb@sources.redhat.com
Subject: RE:  RE: -var-update using formatted value
Date: Tue, 15 Jan 2008 20:32:00 -0000	[thread overview]
Message-ID: <fmj58f$i78$1@ger.gmane.org> (raw)
In-Reply-To: <6D19CA8D71C89C43A057926FE0D4ADAA04290E35@ecamlmw720.eamcs.ericsson.se>

[-- Attachment #1: Type: text/plain, Size: 2598 bytes --]

Marc Khouzam wrote:

> 
>> > However, in my case, where we work with embedded systems and we want to
>> > minimize the requests to the (potentially very slow) back-end, I was
>> > hoping to share the same variable
>> > object and to cache the value of each format.
>> > 
>> I don't understand the above. Changing format of a variable object is not
>> supposed to refetch if from the target, so caching string representation
>> on frontend side is not necessary.
> 
> I'm not sure what you mean.
> If I have a varObject displaying 0x1 in hex and then I want to show the
> value in binary, I will need to go to the target.

No. GDB keeps the raw value inside the variable object, and changing format
only changed the way gdb converts that raw value into string.

>> >     -var-create - * z   (print value is remembered to be 11)
>> >     -var-set-format var1 hex
>> >     -var-evaluate-expression var1 => Oxb
>> >     -exec-step
>> >     -var-update var1              => will show var1 to have changed
>> 
>> As I've said before, it's a bug -- -var-set-format should recompute the
>> stored value.
> 
> This one may not really be a true bug.  The real bug is is not showing a
> change
> when there is one in evaluate-expression.  In this case, it is
> superfluous... The code has a comment about var-update being an
> approximation (in the case of a double var-assign, where this can also
> happen):
> 
>   /* If the value has changed, record it, so that next -var-update can
>      report this change.  If a variable had a value of '1', we've set it
>      to '333' and then set again to '1', when -var-update will report this
>      variable as changed -- because the first assignment has set the
>      'updated' flag.  There's no need to optimize that, because return
>      value
>      of -var-update should be considered an approximation.  */
> (from varobj.c)
> 
> 
>> 1. Make -var-evaluate-expression directly return stored printed value
>> 2. Make -var-set-format recompute the stored printed value.
> 
> Sounds good.
> Although the second change would have an interesting impact; if a
> front-end sends a var-set-format but does not follow it by a
> var-evaluate-expression. The front-end would not know about the latest
> printed value, but var-update would not show a change from the last
> var-evaluate-expression (the one of the old format and that the frontend
> does know about.) But this could be considered a bug in the frontend.

True. I attach a patch that's supposed to implement this idea. No regressions,
and seems to fix your original problem.

OK to commit?

- Volodya






[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: print_value.diff --]
[-- Type: text/x-diff; name="print_value.diff", Size: 1084 bytes --]

commit 67da794ce92c9af5fc9bc22721a942af27ade3d7
Author: Vladimir Prus <vladimir@codesourcery.com>
Date:   Tue Jan 15 23:29:36 2008 +0300

    Update stored value when format changes.
    
    	* varobj.c (varobj_set_display_format): Recomputed
    	print_value.
    	(c_value_of_variable): Return print_value.

diff --git a/gdb/varobj.c b/gdb/varobj.c
index d078bef..b0eb11a 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -677,6 +677,13 @@ varobj_set_display_format (struct varobj *var,
       var->format = variable_default_display (var);
     }
 
+  if (varobj_value_is_changeable_p (var) 
+      && var->value && !value_lazy (var->value))
+    {
+      free (var->print_value);
+      var->print_value = value_get_print_value (var->value, var->format);
+    }
+
   return var->format;
 }
 
@@ -2260,7 +2267,7 @@ c_value_of_variable (struct varobj *var)
 
 	    gdb_assert (varobj_value_is_changeable_p (var));
 	    gdb_assert (!value_lazy (var->value));
-	    return value_get_print_value (var->value, var->format);
+	    return strdup (var->print_value);
 	  }
       }
     }


  reply	other threads:[~2008-01-15 20:32 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-11 15:13 Marc Khouzam
2008-01-11 17:40 ` Vladimir Prus
2008-01-11 18:31   ` Marc Khouzam
2008-01-11 19:40     ` Marc Khouzam
2008-01-11 22:26     ` Nick Roberts
2008-01-11 22:53       ` Andreas Schwab
2008-01-11 22:59         ` Daniel Jacobowitz
2008-01-11 23:40           ` Nick Roberts
2008-01-11 23:52             ` Daniel Jacobowitz
2008-01-12  3:41               ` Marc Khouzam
2008-01-12  3:49                 ` Daniel Jacobowitz
2008-01-14  2:36                   ` Marc Khouzam
2008-01-15 18:43                     ` Vladimir Prus
2008-01-15 19:36                       ` Marc Khouzam
2008-01-15 20:32                         ` Vladimir Prus [this message]
2008-01-17 14:57                           ` Marc Khouzam
2008-01-17 18:05                             ` Vladimir Prus
2008-01-18  1:35                             ` Nick Roberts
2008-01-18 15:31                               ` Marc Khouzam
2008-01-18 15:41                                 ` Daniel Jacobowitz
2008-01-18 17:17                                   ` Marc Khouzam
2008-01-18 17:53                                     ` Daniel Jacobowitz
2008-01-18 19:26                                       ` Marc Khouzam
2008-01-18 21:10                                 ` Nick Roberts
2008-01-18 22:21                                   ` Marc Khouzam
2008-01-19  0:31                                     ` Nick Roberts
2008-01-19  1:46                                       ` Marc Khouzam
2008-01-19  8:27                                         ` Nick Roberts
2008-01-19 11:17                                         ` Vladimir Prus
2008-01-21 15:47                                       ` Marc Khouzam
2008-01-21 21:44                                         ` Nick Roberts
2008-01-17 23:10                           ` Nick Roberts
2008-01-19 11:06                             ` Vladimir Prus
2008-01-19 22:02                               ` Nick Roberts
2008-01-20 10:04                                 ` Vladimir Prus
2008-01-20 20:16                                   ` Nick Roberts
2008-01-20 20:28                                     ` Vladimir Prus
2008-01-21 15:15                                       ` Marc Khouzam
2008-01-21 22:35                                         ` Nick Roberts
2008-01-29 21:20                           ` Daniel Jacobowitz
2008-02-03 22:21                             ` Nick Roberts
2008-02-04  6:15                               ` Vladimir Prus
2008-01-18  0:53                     ` Nick Roberts
2008-01-18  2:13                       ` Marc Khouzam
2008-01-18 21:00                         ` Nick Roberts
2008-01-18 22:04                           ` Marc Khouzam
2008-01-14  6:34               ` Nick Roberts
2008-01-29 21:26                 ` Daniel Jacobowitz
2008-01-29 23:49                   ` Nick Roberts
2008-01-30  0:04                     ` Daniel Jacobowitz
2008-01-30  4:25                       ` Nick Roberts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='fmj58f$i78$1@ger.gmane.org' \
    --to=ghost@cs.msu.su \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox