From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iflTGRYMLGRX7yIAWB0awg (envelope-from ) for ; Tue, 04 Apr 2023 07:37:58 -0400 Received: by simark.ca (Postfix, from userid 112) id 611911E15D; Tue, 4 Apr 2023 07:37:58 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=yxdtN1XP; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.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 170131E0D3 for ; Tue, 4 Apr 2023 07:37:58 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BC9B93858C36 for ; Tue, 4 Apr 2023 11:37:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC9B93858C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680608277; bh=R9+MfnD8xVLuirLVZu2FQiVGos5TSrEqx7TG157pd4U=; h=Date:To:Cc:In-Reply-To:Subject:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=yxdtN1XPmLKJjWe/eoQRhRu22S6IajN9oXskvolveg9A6E79QWoS2MfrKeomPTHBt 1OYnZEy65XD0W2LL4k82Gixuf1Ex+PzGTsWzcFJnLBZG2yuVF6O4XXIKEiqoMJK+zS PFMNYMWshlwP9hrho9H0tXlLv+JBgDMgxN3oDVgU= Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id B5CDD3858D1E for ; Tue, 4 Apr 2023 11:37:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B5CDD3858D1E Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pjeyo-0003LY-9i; Tue, 04 Apr 2023 07:37:38 -0400 Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pjeyl-0007xY-N9; Tue, 04 Apr 2023 07:37:37 -0400 Date: Tue, 04 Apr 2023 14:38:00 +0300 Message-Id: <83wn2rubc7.fsf@gnu.org> To: Andrew Burgess Cc: gdb-patches@sourceware.org In-Reply-To: <05065dd898c6efc263bde5697e0c11130b99c902.1680596378.git.aburgess@redhat.com> (message from Andrew Burgess via Gdb-patches on Tue, 4 Apr 2023 09:21:06 +0100) Subject: Re: [PATCH 4/5] gdb/python: rework how the disassembler API reads the result object References: <05065dd898c6efc263bde5697e0c11130b99c902.1680596378.git.aburgess@redhat.com> 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: Eli Zaretskii via Gdb-patches Reply-To: Eli Zaretskii Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" > Cc: Andrew Burgess > Date: Tue, 4 Apr 2023 09:21:06 +0100 > From: Andrew Burgess via Gdb-patches > > This commit is a refactor ahead of the next change which will make > disassembler styling available through the Python API. > > Unfortunately, in order to make the styling support available, I think > the easiest solution is to make a very small change to the existing > API. > > The current API relies on returning a DisassemblerResult object to > represent each disassembled instruction. Currently GDB allows the > DisassemblerResult class to be sub-classed, which could mean that a > user tries to override the various attributes that exist on the > DisassemblerResult object. > > This commit removes this ability, effectively making the > DisassemblerResult class final. > > Though this is a change to the existing API, I'm hoping this isn't > going to cause too many issues: > > - The Python disassembler API was only added in the previous release > of GDB, so I don't expect it to be widely used yet, and > > - It's not clear to me why a user would need to sub-class the > DisassemblerResult type, I allowed it in the original patch > because at the time I couldn't see any reason to NOT allow it. > > Having prevented sub-classing I can now rework the tail end of the > gdbpy_print_insn function; instead of pulling the results out of the > DisassemblerResult object by calling back into Python, I now cast the > Python object back to its C++ type (disasm_result_object), and access > the fields directly from there. In later commits I will be reworking > the disasm_result_object type in order to hold information about the > styled disassembler output. > > The tests that dealt with sub-classing DisassemblerResult have been > removed, and a new test that confirms that DisassemblerResult can't be > sub-classed has been added. > --- > gdb/NEWS | 3 ++ > gdb/doc/python.texi | 2 + > gdb/python/py-disasm.c | 54 +++++++------------------- > gdb/testsuite/gdb.python/py-disasm.exp | 15 +++++-- > gdb/testsuite/gdb.python/py-disasm.py | 37 ------------------ > 5 files changed, 31 insertions(+), 80 deletions(-) OK for the documentation parts. Thanks. Reviewed-By: Eli Zaretskii