From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8758 invoked by alias); 22 Jan 2008 03:25:04 -0000 Received: (qmail 8734 invoked by uid 22791); 22 Jan 2008 03:25:03 -0000 X-Spam-Check-By: sourceware.org Received: from imr1.ericy.com (HELO imr1.ericy.com) (198.24.6.9) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 22 Jan 2008 03:24:43 +0000 Received: from eusrcmw750.eamcs.ericsson.se (eusrcmw750.exu.ericsson.se [138.85.77.50]) by imr1.ericy.com (8.13.1/8.13.1) with ESMTP id m0M3OfAb002094 for ; Mon, 21 Jan 2008 21:24:41 -0600 Received: from ecamlmw720.eamcs.ericsson.se ([142.133.1.72]) by eusrcmw750.eamcs.ericsson.se with Microsoft SMTPSVC(6.0.3790.1830); Mon, 21 Jan 2008 21:24:41 -0600 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: [Patch] Fix for -var-update to use natural format to compare Date: Tue, 22 Jan 2008 03:25:00 -0000 Message-ID: <6D19CA8D71C89C43A057926FE0D4ADAA2DE0A5@ecamlmw720.eamcs.ericsson.se> From: "Marc Khouzam" To: Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-01/txt/msg00517.txt.bz2 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 c= ompare=20 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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; =20 - /* Last print value. */ - char *print_value; + /* Last value in natural format. */ + char *natural_value; =20 /* Is this variable frozen. Frozen variables are never implicitly updated by -var-update *=20 @@ -966,7 +966,7 @@ int need_to_fetch; int changed =3D 0; int intentionally_not_fetched =3D 0; - char *print_value =3D NULL; + char *natural_value =3D NULL; =20 /* 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 @@ } =20 /* 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 =3D value_get_print_value (value, var->format); + natural_value =3D value_get_print_value (value, FORMAT_NATURAL); =20 /* 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)); =20 - gdb_assert (var->print_value !=3D NULL && print_value !=3D NU= LL); - if (strcmp (var->print_value, print_value) !=3D 0) + gdb_assert (var->natural_value !=3D NULL && natural_value != =3D NULL); + if (strcmp (var->natural_value, natural_value) !=3D 0) changed =3D 1; } } @@ -1080,9 +1084,9 @@ if (var->value !=3D NULL && var->value !=3D value) value_free (var->value); var->value =3D value; - if (var->print_value) - xfree (var->print_value); - var->print_value =3D print_value; + if (var->natural_value) + xfree (var->natural_value); + var->natural_value =3D natural_value; if (value && value_lazy (value) && intentionally_not_fetched) var->not_fetched =3D 1; else @@ -1489,7 +1493,7 @@ var->format =3D 0; var->root =3D NULL; var->updated =3D 0; - var->print_value =3D NULL; + var->natural_value =3D NULL; var->frozen =3D 0; var->not_fetched =3D 0; =20 @@ -1526,7 +1530,7 @@ =20 xfree (var->name); xfree (var->obj_name); - xfree (var->print_value); + xfree (var->natural_value); xfree (var->path_expr); xfree (var); }