From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3000 invoked by alias); 20 Jul 2010 22:17:47 -0000 Received: (qmail 2983 invoked by uid 22791); 20 Jul 2010 22:17:47 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD 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; Tue, 20 Jul 2010 22:17:41 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6KMHevI022787 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 Jul 2010 18:17:40 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6KMHdmx024364; Tue, 20 Jul 2010 18:17:40 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o6KMHd7m017187; Tue, 20 Jul 2010 18:17:39 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id F1DC93797F2; Tue, 20 Jul 2010 16:17:38 -0600 (MDT) From: Tom Tromey To: Phil Muldoon Cc: gdb-patches ml Subject: Re: [patch] Allow gdb.Values to become callable if appropriate. References: <4C442BAA.2020300@redhat.com> Date: Tue, 20 Jul 2010 22:17:00 -0000 In-Reply-To: <4C442BAA.2020300@redhat.com> (Phil Muldoon's message of "Mon, 19 Jul 2010 11:40:42 +0100") 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 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: 2010-07/txt/msg00325.txt.bz2 >>>>> "Phil" == Phil Muldoon writes: Phil> Here is a little patch that allows gdb.Values to become "callable". Phil> In this patch, I have limited the ability to call only values where Phil> the type == TYPE_CODE_FUNC. It is the responsibility of the user to Phil> cast or dereference appropriately before attempting a call. If the Phil> type does not resolve to TYPE_CODE_FUNC, then the call will be Phil> abandoned. There's not too much checking I can do in the function Phil> beyond what call_function_by_hand already does. If any errors occur Phil> in the conversion of the arguments, the call will be abandoned. Phil> Comments? Looks good. Phil> +A @code{gdb.Value} that represents a function or a function pointer is a Phil> +callable Python object. >From what I can see, your patch explicitly excludes function pointers. This may be a bit too strict. I think it would be reasonably safe and easy to accept references (via coerce_ref) and also function pointers (doing a single dereference inside the new function). Alternatively, update the documentation. Phil> + args_count = PyTuple_Size (args); Phil> + if (args_count > 0) Phil> + { Phil> + int i; Phil> + Phil> + vargs = alloca (sizeof (struct value *) * args_count); Extra space after the "=". Phil> - 0, /*tp_call*/ Phil> + (ternaryfunc) valpy_call, /*tp_call*/ I don't think this cast is necessary. Tom