From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11044 invoked by alias); 21 Sep 2011 15:54:32 -0000 Received: (qmail 11016 invoked by uid 22791); 21 Sep 2011 15:54:30 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from qmta06.emeryville.ca.mail.comcast.net (HELO qmta06.emeryville.ca.mail.comcast.net) (76.96.30.56) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Sep 2011 15:54:11 +0000 Received: from omta20.emeryville.ca.mail.comcast.net ([76.96.30.87]) by qmta06.emeryville.ca.mail.comcast.net with comcast id bPtl1h0021smiN4A6Tu5Ru; Wed, 21 Sep 2011 15:54:05 +0000 Received: from [10.127.238.91] ([65.206.2.68]) by omta20.emeryville.ca.mail.comcast.net with comcast id bTeV1h00J1U2a2h8gTeYd7; Wed, 21 Sep 2011 15:38:36 +0000 From: Paul Koning Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Python: fetch value when building gdb.Value object Date: Wed, 21 Sep 2011 16:17:00 -0000 Message-Id: <36B29E9D-F2B3-446F-AF8A-97254A3AAEE2@comcast.net> To: gdb-patches@sourceware.org Mime-Version: 1.0 (Apple Message framework v1084) 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: 2011-09/txt/msg00391.txt.bz2 GDB sometimes lazily evaluates operations on values, and py-value.c wasn't = taking that into account. The result was that assigning a Value object to = a Python variable could assign a lazy value, so that any errors in accessin= g the data would occur at a later time, and sometimes would not be handled = right. (For example, the "nonzero" operation would fail without a Python t= raceback.) The attached patch cures this by fetching any lazy values when the gdb.Valu= e object is built, and adds a test in the testcases to verify this. Ok to submit? paul ChangeLog: =09 2011-09-21 Paul Koning * python/py-value.c (valpy_get_address): Use Py_XINCREF. (value_to_value_object): Fetch value if it was lazy. testsuite/ChangeLog: =09 2011-09-21 Paul Koning * gdb.python/py-value.exp: Add test for null pointer reference assigned to a variable. Index: python/py-value.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/python/py-value.c,v retrieving revision 1.25 diff -u -r1.25 py-value.c --- python/py-value.c 27 Jun 2011 19:21:51 -0000 1.25 +++ python/py-value.c 21 Sep 2011 15:45:12 -0000 @@ -209,7 +209,7 @@ val_obj->address =3D value_to_value_object (res_val); } =20 - Py_INCREF (val_obj->address); + Py_XINCREF (val_obj->address); =20 return val_obj->address; } @@ -1045,7 +1045,15 @@ value_to_value_object (struct value *val) { value_object *val_obj; + volatile struct gdb_exception except; =20 + TRY_CATCH (except, RETURN_MASK_ALL) + { + if (value_lazy (val)) + value_fetch_lazy (val); + } + GDB_PY_HANDLE_EXCEPTION (except); +=20=20 val_obj =3D PyObject_New (value_object, &value_object_type); if (val_obj !=3D NULL) { Index: testsuite/gdb.python/py-value.exp =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/testsuite/gdb.python/py-value.exp,v retrieving revision 1.22 diff -u -r1.22 py-value.exp --- testsuite/gdb.python/py-value.exp 26 Jul 2011 18:38:55 -0000 1.22 +++ testsuite/gdb.python/py-value.exp 21 Sep 2011 15:45:13 -0000 @@ -218,6 +218,7 @@ =20 # Test memory error. gdb_test "python print gdb.parse_and_eval('*(int*)0')" "gdb.MemoryError:= Cannot access memory at address 0x0.*" + gdb_test "python inval =3D gdb.parse_and_eval('*(int*)0')" "gdb.MemoryEr= ror: Cannot access memory at address 0x0.*" =20 # Test string fetches, both partial and whole. gdb_test "print st" "\"divide et impera\""