From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 94018 invoked by alias); 16 Sep 2018 03:10:04 -0000 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 Received: (qmail 93945 invoked by uid 89); 16 Sep 2018 03:10:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 16 Sep 2018 03:09:59 +0000 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 7A5791E186; Sat, 15 Sep 2018 23:09:57 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=simark.ca; s=mail; t=1537067397; bh=3vQ2iIDPTVdm2iQscy5e2U2KYxMjvhxwBIPjpvbcibY=; h=Subject:To:References:From:Date:In-Reply-To:From; b=r/3hQT76rMi0sMqjt5b1UttecmcxdOOxgpzeYpnc00Lc8+/5JLNY03S4QGvShfRJT pVrFb8VoPbrzjon7c5V5S1DIgTg1sS4ykKxnhJo9VpFBCzA/bdHvK37yQkEWOnSZJI P8YN3iP+0ag3KpDVAKApI54wN2QUgGubhZCvCzgQ= Subject: Re: [PATCH v3] Add more methods to gdb.Progspace To: Tom Tromey , gdb-patches@sourceware.org References: <20180913221627.13772-1-tom@tromey.com> From: Simon Marchi Message-ID: Date: Sun, 16 Sep 2018 03:10:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180913221627.13772-1-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-09/txt/msg00519.txt.bz2 LGTM, I just noted some minor comments. I wish there was more consistency in how the methods are documented (in the progspace_object_methods array), but that should be another patch. On 2018-09-13 6:16 p.m., Tom Tromey wrote: > diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi > index aca6ec858cf..34f42c0effe 100644 > --- a/gdb/doc/python.texi > +++ b/gdb/doc/python.texi > @@ -328,7 +328,9 @@ Return the @code{gdb.Symtab_and_line} object corresponding to the > @var{pc} value. @xref{Symbol Tables In Python}. If an invalid > value of @var{pc} is passed as an argument, then the @code{symtab} and > @code{line} attributes of the returned @code{gdb.Symtab_and_line} object > -will be @code{None} and 0 respectively. > +will be @code{None} and 0 respectively. This is identical to > +@code{current_progspace().find_pc_line(pc)} and is included for Perhaps this should say gdb.current_progspace().find_pc_line(pc) ? > +/* Implementation of solib_name (Long) -> String. > + Returns the name of the shared library holding a given address, or None. */ > + > +static PyObject * > +pspy_solib_name (PyObject *o, PyObject *args) > +{ > + char *soname; > + PyObject *str_obj; > + gdb_py_longest pc; > + pspace_object *self = (pspace_object *) o; > + > + PSPY_REQUIRE_VALID (self); > + > + if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc)) > + return NULL; > + > + soname = solib_name_from_address (self->pspace, pc); > + if (soname) > + str_obj = host_string_to_python_string (soname); > + else > + { > + str_obj = Py_None; > + Py_INCREF (Py_None); > + } I know this is pre-existing code, but it could use Py_RETURN_NONE, then we can get rid of the str_obj variable. Simon