From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 761 invoked by alias); 28 Sep 2011 19:25:04 -0000 Received: (qmail 730 invoked by uid 22791); 28 Sep 2011 19:25:01 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 28 Sep 2011 19:24:48 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8SJOlgs009823 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Sep 2011 15:24:47 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p8SJOjAs019755; Wed, 28 Sep 2011 15:24:46 -0400 From: Phil Muldoon To: Paul Koning Cc: gdb-patches@sourceware.org Subject: Re: Python: fetch value when building gdb.Value object References: <36B29E9D-F2B3-446F-AF8A-97254A3AAEE2@comcast.net> Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Wed, 28 Sep 2011 19:29:00 -0000 In-Reply-To: <36B29E9D-F2B3-446F-AF8A-97254A3AAEE2@comcast.net> (Paul Koning's message of "Wed, 21 Sep 2011 11:54:01 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes 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/msg00473.txt.bz2 Paul Koning writes: > 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 accessing 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 traceback.) > > The attached patch cures this by fetching any lazy values when the gdb.Value object is built, and adds a test in the testcases to verify this. > > Ok to submit? > > paul > > ChangeLog: > > 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: > > 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 > =================================================================== > 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 = value_to_value_object (res_val); > } > > - Py_INCREF (val_obj->address); > + Py_XINCREF (val_obj->address); > > return val_obj->address; > } This seems an unrelated change? > @@ -1045,7 +1045,15 @@ > value_to_value_object (struct value *val) > { > value_object *val_obj; > + volatile struct gdb_exception except; > > + TRY_CATCH (except, RETURN_MASK_ALL) > + { Something that Jan pointed out a few weeks ago, is our exception net is too wide, and asked me to review usage of REVIEW_MASK_ALL. In this case, this should probably be RETURN_MASK_ERROR. I understand there are many many usages of RETURN_MASK_ALL used incorrectly already. > # 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 = gdb.parse_and_eval('*(int*)0')" "gdb.MemoryError: Cannot access memory at address 0x0.*" 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? Cheers, Phil