From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116770 invoked by alias); 29 Nov 2018 22:32:40 -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 116735 invoked by uid 89); 29 Nov 2018 22:32:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=BAYES_00,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=hate, Typical X-HELO: gateway22.websitewelcome.com Received: from gateway22.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.46.156) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 29 Nov 2018 22:32:34 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 8F5FD7F3F48 for ; Thu, 29 Nov 2018 16:32:33 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id SUrJgUCVtkBj6SUrJgQEc1; Thu, 29 Nov 2018 16:32:33 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lrablwXBBzufO/Lb06B2tGjlgpVvI0EY8hHo6eV7SSE=; b=Vg1+4E54EJ2Ud/eE4rr6AMuJEe YcS7Y4eqZPQSAbQZe9r64DWnCir3eiAKLbpDpKNRuKgibemSofgPdQv4AgWOICQe3SGbdRhjppBtJ sYwDdsVgH9WTRcOVaEpM/gZpL; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:33872 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gSUrJ-001uhk-9q; Thu, 29 Nov 2018 16:32:33 -0600 From: Tom Tromey To: Tom de Vries Cc: Simon Marchi , gdb-patches@sourceware.org, Phil Muldoon , Tom Tromey Subject: Re: [PATCH][gdb/python] Add interface to access minimal_symbols References: <20181004211115.GA31056@delia> <39c4336d-c749-6f79-5a29-0b764fc4935e@ericsson.com> <211c4746-389a-93b7-faf9-c8f9b6245541@suse.de> Date: Thu, 29 Nov 2018 22:32:00 -0000 In-Reply-To: <211c4746-389a-93b7-faf9-c8f9b6245541@suse.de> (Tom de Vries's message of "Wed, 31 Oct 2018 17:59:15 +0100") Message-ID: <878t1ba51b.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2018-11/txt/msg00555.txt.bz2 >>>>> "Tom" == Tom de Vries writes: Tom> This patch adds a new gdb.MinSymbol object to export the minimal_symbol Tom> interface. I hate to bikeshed the name to start with, but I'm going to anyway. Why the abbreviated name rather than gdb.MinimalSymbol? Or alternatively why not something less "gdb-ish", like gdb.LinkerSymbol? Tom> +Typical symbols like functions, variables, etc are represented by Tom> +@code{gdb.Symbol} objects in Python. Some symbols are defined with less Tom> +information associated with them, like linker script variables Tom> +or assembly labels. Python represents these minimal symbols in @value{GDBN} Tom> +with the @code{gdb.MinSymbol} object. I think this is mildly misleading and perhaps should also mention that linker symbols will generally end up in here. Tom> +@defvar MinSymbol.filename Tom> +The file name of the source file where the minimal symbol is defined. As mentioned elsewhere in the thread, I think this field is largely not useful. I feel like we once considered removing it from minsyms entirely. So, I tend to think this one should just be dropped, unless you have some specific need for it (which would be interesting to hear about). Tom> +@defvar MinSymbol.section_name Tom> +The name of the section in the object file containing this minimal symbol. Are there platforms where sections do not have names? What will happen to this on those? Tom> + return PyString_FromString (minsym->filename); I suspect filename can be NULL here. But see above. Tom> + if (section != NULL) Tom> + { Tom> + name = bfd_section_name (objfile->obfd, section->the_bfd_section); Tom> + if (name != NULL) Tom> + return PyString_FromString (name); Tom> + } Tom> + Tom> + Py_RETURN_NONE; Ok, I see the answer to my question here. This should be documented. Tom> + type = builtin_type (minsym_gdbarch (self))->builtin_func_ptr; Tom> + Tom> + if (minsym_type (self) == type) Tom> + Py_RETURN_TRUE; This seems kind of roundabout to me. Tom> + type = builtin_type (minsym_gdbarch (self))->builtin_data_ptr; Tom> + Tom> + if (minsym_type (self) == type) Tom> + Py_RETURN_TRUE; Same here. Tom> + minsym_object *minsym_obj = (minsym_object *)self; Space after the ")". Tom> +static void Tom> +set_symbol (minsym_object *obj, struct bound_minimal_symbol *bound) I think a const reference for "bound" would be more natural here. Tom> +static PyObject * Tom> +bound_minsym_to_minsym_object (struct bound_minimal_symbol *bound) Here too. Tom> + if (sfile_obj != NULL && sfile_obj != Py_None) Tom> + { Tom> + sfile_tmp = gdbpy_obj_to_string (sfile_obj); If this returns NULL then this function should early-return as well. Tom> + if (bound_minsym.minsym != NULL) Tom> + msym_obj = bound_minsym_to_minsym_object (&bound_minsym); If bound_minsym_to_minsym_object returns NULL, then an exception has been set, so this function must return NULL. But: Tom> + if (msym_obj != NULL) Tom> + return msym_obj; ... that isn't happening. So the logic needs a bit of reordering here. Tom> +/* Initialize gdb.MinSymbol. Return -1 on error, 0 on success. */ Tom> + Tom> +int Tom> +gdbpy_initialize_minsymbols (void) Don't need the "void" here any more. Tom> +/* Return struct objfile reference that is wrapped by the SELF object. */ Tom> + Tom> +struct objfile * Tom> +objectfile_object_to_objfile (PyObject *self) I think this should be named objfile_object_to_objfile instead. Tom> +++ b/gdb/testsuite/gdb.python/py-minsymbol.exp Some of the lines here are too long and can reasonably be split. I think it would also make sense to check for the minsym for "main" itself. Tom