From: "Marc Khouzam" <marc.khouzam@ericsson.com>
To: <gdb-patches@sources.redhat.com>
Subject: [Patch] Fix for -var-update to use natural format to compare
Date: Tue, 22 Jan 2008 03:25:00 -0000 [thread overview]
Message-ID: <6D19CA8D71C89C43A057926FE0D4ADAA2DE0A5@ecamlmw720.eamcs.ericsson.se> (raw)
This patch addresses a discussion titled "-var-update using formatted value" from
the GDB mailing list.
It modifies the variable object code to always uses the natural format to compare
old and new values for the -var-update command (one line change).
It also renames the member print_value of varobj to natural_value.
### Eclipse Workspace Patch 1.0
#P gdb
Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.99
diff -u -r1.99 varobj.c
--- varobj.c 1 Jan 2008 22:53:13 -0000 1.99
+++ varobj.c 22 Jan 2008 03:19:28 -0000
@@ -139,8 +139,8 @@
/* Was this variable updated via a varobj_set_value operation */
int updated;
- /* Last print value. */
- char *print_value;
+ /* Last value in natural format. */
+ char *natural_value;
/* Is this variable frozen. Frozen variables are never implicitly
updated by -var-update *
@@ -966,7 +966,7 @@
int need_to_fetch;
int changed = 0;
int intentionally_not_fetched = 0;
- char *print_value = NULL;
+ char *natural_value = NULL;
/* We need to know the varobj's type to decide if the value should
be fetched or not. C++ fake children (public/protected/private) don't have
@@ -1025,11 +1025,15 @@
}
/* Below, we'll be comparing string rendering of old and new
- values. Don't get string rendering if the value is
+ values. We only use the natural format to make sure we
+ catch changes that may affect some but not all formats.
+ E.g, float 1.1 and 1.2 are the same in all format except
+ natural; we don't want to miss this.
+ Don't get string rendering if the value is
lazy -- if it is, the code above has decided that the value
should not be fetched. */
if (value && !value_lazy (value))
- print_value = value_get_print_value (value, var->format);
+ natural_value = value_get_print_value (value, FORMAT_NATURAL);
/* If the type is changeable, compare the old and the new values.
If this is the initial assignment, we don't have any old value
@@ -1069,8 +1073,8 @@
gdb_assert (!value_lazy (var->value));
gdb_assert (!value_lazy (value));
- gdb_assert (var->print_value != NULL && print_value != NULL);
- if (strcmp (var->print_value, print_value) != 0)
+ gdb_assert (var->natural_value != NULL && natural_value != NULL);
+ if (strcmp (var->natural_value, natural_value) != 0)
changed = 1;
}
}
@@ -1080,9 +1084,9 @@
if (var->value != NULL && var->value != value)
value_free (var->value);
var->value = value;
- if (var->print_value)
- xfree (var->print_value);
- var->print_value = print_value;
+ if (var->natural_value)
+ xfree (var->natural_value);
+ var->natural_value = natural_value;
if (value && value_lazy (value) && intentionally_not_fetched)
var->not_fetched = 1;
else
@@ -1489,7 +1493,7 @@
var->format = 0;
var->root = NULL;
var->updated = 0;
- var->print_value = NULL;
+ var->natural_value = NULL;
var->frozen = 0;
var->not_fetched = 0;
@@ -1526,7 +1530,7 @@
xfree (var->name);
xfree (var->obj_name);
- xfree (var->print_value);
+ xfree (var->natural_value);
xfree (var->path_expr);
xfree (var);
}
next reply other threads:[~2008-01-22 3:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-22 3:25 Marc Khouzam [this message]
2008-01-22 3:53 ` Daniel Jacobowitz
2008-01-22 14:43 ` Marc Khouzam
2008-01-22 15:03 ` Daniel Jacobowitz
2008-01-22 15:12 ` Marc Khouzam
2008-01-22 15:35 ` Vladimir Prus
2008-01-22 16:38 ` Marc Khouzam
2008-01-22 17:50 ` Vladimir Prus
2008-01-22 17:59 ` Daniel Jacobowitz
2008-01-23 0:33 ` Nick Roberts
2008-01-23 14:41 ` Marc Khouzam
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=6D19CA8D71C89C43A057926FE0D4ADAA2DE0A5@ecamlmw720.eamcs.ericsson.se \
--to=marc.khouzam@ericsson.com \
--cc=gdb-patches@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