From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23153 invoked by alias); 1 Oct 2011 18:58:39 -0000 Received: (qmail 23140 invoked by uid 22791); 1 Oct 2011 18:58:38 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from qmta07.emeryville.ca.mail.comcast.net (HELO qmta07.emeryville.ca.mail.comcast.net) (76.96.30.64) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 01 Oct 2011 18:58:24 +0000 Received: from omta22.emeryville.ca.mail.comcast.net ([76.96.30.89]) by qmta07.emeryville.ca.mail.comcast.net with comcast id fVf61h0031vN32cA7WyJfX; Sat, 01 Oct 2011 18:58:18 +0000 Received: from [192.168.10.125] ([75.68.58.5]) by omta22.emeryville.ca.mail.comcast.net with comcast id fX0K1h00w06m2QB8iX0KiC; Sat, 01 Oct 2011 19:00:20 +0000 Subject: Re: Python: fetch value when building gdb.Value object [rediff] Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Paul Koning In-Reply-To: <20111001121642.GA29550@host1.jankratochvil.net> Date: Sat, 01 Oct 2011 18:58:00 -0000 Cc: Phil Muldoon , gdb-patches@sourceware.org Content-Transfer-Encoding: quoted-printable Message-Id: <786484A8-7FDA-449E-9D03-FACB65A02C7E@comcast.net> References: <36B29E9D-F2B3-446F-AF8A-97254A3AAEE2@comcast.net> <20111001092852.GB11227@host1.jankratochvil.net> <20111001121642.GA29550@host1.jankratochvil.net> To: Jan Kratochvil 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-10/txt/msg00013.txt.bz2 On Oct 1, 2011, at 8:16 AM, Jan Kratochvil wrote: > Updated for current HEAD: >=20 > On Sat, 01 Oct 2011 11:28:52 +0200, Jan Kratochvil wrote: > On Wed, 28 Sep 2011 21:24:45 +0200, Phil Muldoon wrote: >> What scenario will this test catch that the previous test won't? I'm >> not saying you are incorrect, I just don't understand. What >> error-trigger does the assignment to "inval" trigger? >=20 > I would prefer here a testcase more clearly showing the bug, attached bel= ow. Thanks, yes I agree that's a clearer and more complete testcase. paul >=20 > I believe the patch is right, as Phil hasn't yet agreed posting it only. >=20 >=20 > Thanks, > Jan >=20 >=20 > gdb/ > 2011-09-21 Paul Koning >=20 > * python/py-value.c (valpy_get_address): Use Py_XINCREF. > (value_to_value_object): Fetch value if it was lazy. >=20 > testsuite/ > 2011-09-21 Paul Koning > Jan Kratochvil >=20 > * gdb.python/py-value.exp > (python inval =3D gdb.parse_and_eval('*(int*)0')) > (python argc_lazy =3D gdb.parse_and_eval('argc'), sanity check argc) > (set argc=3D2, python print argc_lazy): New tests. >=20 > --- a/gdb/python/py-value.c > +++ b/gdb/python/py-value.c > @@ -209,7 +209,7 @@ valpy_get_address (PyObject *self, void *closure) > 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 @@ PyObject * > 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) > { > --- a/gdb/testsuite/gdb.python/py-value.exp > +++ b/gdb/testsuite/gdb.python/py-value.exp > @@ -236,6 +236,18 @@ proc test_value_in_inferior {} { > gdb_test "python print gdb.parse_and_eval('*(int*)0')" "gdb.MemoryErr= or: Cannot access memory at address 0x0.*" $test > } >=20 > + # Test Python values are not lazy. > + set test "memory error occurs even for possibly lazy values" > + if {$can_read_0} { > + untested $test > + } else { > + gdb_test "python inval =3D gdb.parse_and_eval('*(int*)0')" "gdb.Memo= ryError: Cannot access memory at address 0x0.*" $test > + } > + gdb_test "python argc_lazy =3D gdb.parse_and_eval('argc')" > + gdb_test "print argc" " =3D 1" "sanity check argc" > + gdb_test_no_output "set argc=3D2" > + gdb_test "python print argc_lazy" "\r\n1" > + > # Test string fetches, both partial and whole. > gdb_test "print st" "\"divide et impera\"" > gdb_py_test_silent_cmd "python st =3D gdb.history (0)" "get value from = history" 1