public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Andrew Burgess <aburgess@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 4/5] gdb/python: rework how the disassembler API reads the result object
Date: Tue, 04 Apr 2023 14:38:00 +0300	[thread overview]
Message-ID: <83wn2rubc7.fsf@gnu.org> (raw)
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)

> Cc: Andrew Burgess <aburgess@redhat.com>
> Date: Tue,  4 Apr 2023 09:21:06 +0100
> From: Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org>
> 
> 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 <eliz@gnu.org>

  reply	other threads:[~2023-04-04 11:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-04  8:21 [PATCH 0/5] Disassembler Styling And The Python API Andrew Burgess
2023-04-04  8:21 ` [PATCH 1/5] gdb/doc: improve Python Disassembler API documentation Andrew Burgess
2023-04-04 11:36   ` Eli Zaretskii
2023-04-28 22:49     ` Andrew Burgess
2023-05-12 17:42       ` Andrew Burgess
2023-04-04  8:21 ` [PATCH 2/5] gdb/python: implement __repr__ methods for py-disasm.c types Andrew Burgess
2023-05-12 17:43   ` Andrew Burgess
2023-04-04  8:21 ` [PATCH 3/5] gdb/python: implement DisassemblerResult.__str__ method Andrew Burgess
2023-05-12 17:43   ` Andrew Burgess
2023-04-04  8:21 ` [PATCH 4/5] gdb/python: rework how the disassembler API reads the result object Andrew Burgess
2023-04-04 11:38   ` Eli Zaretskii [this message]
2023-04-04  8:21 ` [PATCH 5/5] gdb/python: extend the Python Disassembler API to allow for styling Andrew Burgess
2023-04-04 12:01   ` Eli Zaretskii
2023-04-28 23:11     ` Andrew Burgess
2023-04-17 16:25   ` Tom Tromey
2023-04-28 23:09     ` [PATCHv2 " Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83wn2rubc7.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).