From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8211 invoked by alias); 7 Oct 2011 20:41:45 -0000 Received: (qmail 8199 invoked by uid 22791); 7 Oct 2011 20:41:44 -0000 X-SWARE-Spam-Status: No, hits=-7.2 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; Fri, 07 Oct 2011 20:41:27 +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 p97KfQ1m029994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 7 Oct 2011 16:41:26 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p97KfQMG026879; Fri, 7 Oct 2011 16:41:26 -0400 Received: from barimba (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 p97KfOd1032608; Fri, 7 Oct 2011 16:41:25 -0400 From: Tom Tromey To: pmuldoon@redhat.com Cc: gdb-patches@sourceware.org Subject: Re: [python] [patch] PR python/12656 (API for special blocks) References: Date: Fri, 07 Oct 2011 20:41:00 -0000 In-Reply-To: (Phil Muldoon's message of "Fri, 07 Oct 2011 18:02:15 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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/msg00206.txt.bz2 >>>>> "Phil" == Phil Muldoon writes: Phil> This patch addresses PR python/12656. It allows the user to determine if Phil> a given gdb.Block is the static block, or the global block. Phil> Additionally I added two new APIs to actually get the global/static Phil> blocks on behalf of the user. Thanks. Phil> I also, because the global/static GDB fetch methods use const struct Phil> *block, changed the Python code to use consts. This required some minor Phil> refactoring both inside and outside the Python API code. Nice. Looks pretty good. Phil> +@defun Block.is_global () Phil> +@defun Block.is_static () Why are these methods rather than attributes? Phil> diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c Phil> index 08d4455..5ef7d2e 100644 Phil> --- a/gdb/python/py-block.c Phil> +++ b/gdb/python/py-block.c Phil> @@ -28,7 +28,7 @@ Phil> typedef struct blpy_block_object { Phil> PyObject_HEAD Phil> /* The GDB block structure that represents a frame's code block. */ Phil> - struct block *block; Phil> + const struct block *block; Phil> /* The backing object file. There is no direct relationship in GDB Phil> between a block and an object file. When a block is created also Phil> store a pointer to the object file for later use. */ Phil> @@ -50,7 +50,7 @@ typedef struct { Phil> /* Pointer back to the original source block object. Needed to Phil> check if the block is still valid, and has not been invalidated Phil> when an object file has been freed. */ Phil> - struct blpy_block_object *source; Phil> + const struct blpy_block_object *source; Why make this one const? It seems wrong given that we have to decref it when the iterator is destroyed. Phil> + Py_INCREF (Py_None); Phil> + return Py_None; I think it is more normal to use Py_RETURN_NONE here. Phil> gdb_test "python print block_iter.is_valid()" "False" \ Phil> "Check block validity" Phil> + Gratuitous newline addition. Phil> -extern struct value *value_of_variable (struct symbol *var, struct block *b); Phil> +extern struct value *value_of_variable (struct symbol *var, const struct block *b); This should probably wrap after the ",". Tom