From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org 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 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=R9+MfnD8xVLuirLVZu2FQiVGos5TSrEqx7TG157pd4U=; b=nwi8o14jMBwW U9lzo7Xbyx9dSAshlConGVKp0UdnZSpMI3jh/6eFdi0l1sHIIKweU/XdQkRmGrXiTqOtkhK8GaMEk InChkZLGZD9KBF5PyVm8RSnoZMKkHFz9XfIr4ZSYSR/xRJCAgTxcztKzG1FVUJ2AqNuAD8YQoqfOe tEh3gQ/X+9OqXQ8hVAT37wS/f8EiiUFG5murOhORQobYc0qBamkX+2W5cPeYc0CYuUnzIlqvM8ebi zl8lLP7tYC26+XVyau85OIQd+8bHndyTpx9zL2vH8ZHq5mKJwI80parIQgErOFWi0eMTaTHuQHKZg QvyzZDJwAvfp23jARKW0Eg==; 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> From: Eli Zaretskii 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-Spam-Status: No, score=1.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > 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