From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15846 invoked by alias); 1 Oct 2011 09:29:16 -0000 Received: (qmail 15837 invoked by uid 22791); 1 Oct 2011 09:29:15 -0000 X-SWARE-Spam-Status: No, hits=-6.8 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; Sat, 01 Oct 2011 09:28:56 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p919StEx004947 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 1 Oct 2011 05:28:55 -0400 Received: from host1.jankratochvil.net (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p919SrCR019027 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 1 Oct 2011 05:28:55 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p919SqUh016162; Sat, 1 Oct 2011 11:28:52 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p919SqRW016161; Sat, 1 Oct 2011 11:28:52 +0200 Date: Sat, 01 Oct 2011 09:29:00 -0000 From: Jan Kratochvil To: Phil Muldoon Cc: Paul Koning , gdb-patches@sourceware.org Subject: Re: Python: fetch value when building gdb.Value object Message-ID: <20111001092852.GB11227@host1.jankratochvil.net> References: <36B29E9D-F2B3-446F-AF8A-97254A3AAEE2@comcast.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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-10/txt/msg00007.txt.bz2 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? I would prefer here a testcase more clearly showing the bug, attached below. I believe the patch is right, as Phil hasn't yet agreed posting it only. Thanks, Jan gdb/ 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/ 2011-09-21 Paul Koning Jan Kratochvil * gdb.python/py-value.exp (python inval = gdb.parse_and_eval('*(int*)0')) (python argc_lazy = gdb.parse_and_eval('argc'), sanity check argc) (set argc=2, python print argc_lazy): New tests. --- 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 = value_to_value_object (res_val); } - Py_INCREF (val_obj->address); + Py_XINCREF (val_obj->address); 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; + TRY_CATCH (except, RETURN_MASK_ALL) + { + if (value_lazy (val)) + value_fetch_lazy (val); + } + GDB_PY_HANDLE_EXCEPTION (except); + val_obj = PyObject_New (value_object, &value_object_type); if (val_obj != NULL) { --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -218,6 +218,11 @@ proc test_value_in_inferior {} { # 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.*" + gdb_test "python argc_lazy = gdb.parse_and_eval('argc')" + gdb_test "print argc" " = 1" "sanity check argc" + gdb_test_no_output "set argc=2" + gdb_test "python print argc_lazy" "\r\n1" # Test string fetches, both partial and whole. gdb_test "print st" "\"divide et impera\""