From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id gIyrOF4PO2JkDwAAWB0awg (envelope-from ) for ; Wed, 23 Mar 2022 08:15:26 -0400 Received: by simark.ca (Postfix, from userid 112) id D60691F3E2; Wed, 23 Mar 2022 08:15:26 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 531231F3B9 for ; Wed, 23 Mar 2022 08:15:26 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CECCE385E457 for ; Wed, 23 Mar 2022 12:15:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CECCE385E457 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1648037725; bh=UHZLzxj/EmH6yWvya4+hU6HAD0K99jWDRVTvOtQIrME=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=aqL20feeq2P2TiFu1XVQQTha7ywtnwabAnnCwrdJIhV7aBQaHbwpeZmNr0Be5CxOU BkBJEVrACrdeTxy1Ca6pAlVESaFImiRBoPAER3xOA0dg4YqbKVkazuHXUj/GOm/Wt1 M6ket3d++mWIq9skrFUaNNGNpLr392O97lSdWghk= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 33AF43858405 for ; Wed, 23 Mar 2022 12:15:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 33AF43858405 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 22NCExmP009777 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Mar 2022 08:15:04 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 22NCExmP009777 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 79DFA1F3B9; Wed, 23 Mar 2022 08:14:59 -0400 (EDT) Message-ID: Date: Wed, 23 Mar 2022 08:14:59 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCHv3] gdb/python: add gdb.format_address function Content-Language: en-US To: Andrew Burgess , gdb-patches@sourceware.org References: <20220304105031.2706582-1-aburgess@redhat.com> <20220307123317.3966024-1-aburgess@redhat.com> <87o81yruo9.fsf@redhat.com> In-Reply-To: <87o81yruo9.fsf@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 23 Mar 2022 12:14:59 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: Andrew Burgess Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 2022-03-22 09:19, Andrew Burgess wrote: > Simon Marchi via Gdb-patches writes: > >>> diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c >>> index 0f273b344e4..53906ce506e 100644 >>> --- a/gdb/python/py-arch.c >>> +++ b/gdb/python/py-arch.c >>> @@ -62,16 +62,25 @@ arch_object_data_init (struct gdbarch *gdbarch) >>> } >>> >>> /* Returns the struct gdbarch value corresponding to the given Python >>> - architecture object OBJ. */ >>> + architecture object OBJ, which must be a gdb.Architecture object. */ >>> >>> struct gdbarch * >>> arch_object_to_gdbarch (PyObject *obj) >>> { >>> - arch_object *py_arch = (arch_object *) obj; >>> + gdb_assert (PyObject_TypeCheck (obj, &arch_object_type)); >> >> Since we have a function for that, I'd do: >> >> gdb_assert (gdbpy_is_architecture (obj)); >> >>> diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c >>> index 1e01068c59b..f9f2a969e2b 100644 >>> --- a/gdb/python/py-progspace.c >>> +++ b/gdb/python/py-progspace.c >>> @@ -504,6 +504,23 @@ pspace_to_pspace_object (struct program_space *pspace) >>> return gdbpy_ref<>::new_reference (result); >>> } >>> >>> +/* See python-internal.h. */ >>> + >>> +struct program_space * >>> +progspace_object_to_program_space (PyObject *obj) >>> +{ >>> + gdb_assert (PyObject_TypeCheck (obj, &pspace_object_type)); >> >> Same here, use gdbpy_is_progspace. >> >> Otherwise, LGTM. > > Thanks, I made those changes and pushed this patch. > > Andrew > Hmm, I see these failures: 145 python print("Got: " + gdb.format_address(0x1129))^M 146 Got: 0x1129 ^M 147 (gdb) FAIL: gdb.python/py-format-address.exp: gdb.format_address for bar, while inferior 2 is selected 148 python print("Got: " + gdb.format_address(0x1129, inf2.progspace, inf2.architecture()))^M 149 Got: 0x1129 ^M 150 (gdb) FAIL: gdb.python/py-format-address.exp: gdb.format_address for bar, while inferior 2 is selected, pass progspace and architecture 151 inferior 1^M 152 [Switching to inferior 1 [process 1874961] (/home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.python/py-format-address/py-format-address-foo)]^M 153 [Switching to thread 1.1 (process 1874961)]^M 154 #0 main () at /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.python/py-format-address.c:31^M 155 31 return FUNCTION_NAME ();^M 156 (gdb) PASS: gdb.python/py-format-address.exp: inferior 1 157 python print("Got: " + gdb.format_address(0x1129, inf2.progspace, inf2.architecture()))^M 158 Got: 0x1129 ^M 159 (gdb) FAIL: gdb.python/py-format-address.exp: gdb.format_address for bar, while inferior 1 is selected, pass progspace and architecture Simon