[PATCHv4 0/5] Add Python API for the disassembler

Andrew Burgess aburgess@redhat.com
Tue May 3 10:12:23 GMT 2022


Ping!

I'd like to see if I can get this work moved forward.

I'd probably just push this work on the grounds we could back it out if
anyone complains after the fact ... except for patch #3, which extends
the Python API, and I'd prefer at least a little review before I merge
this, even if it was just reading the documentation to check the new API
makes sense.

All thoughts welcome,

Thanks,
Andrew



Andrew Burgess <aburgess@redhat.com> writes:

> Changes in v4:
>
>   - Patch #1 from v3 series has been merged,
>
>   - Addressed Eli's feedback on previous series,
>
>   - Rebased onto current upstream/master.
>
> Changes in v3:
>
>   - Rebased to current master, and retested,
>
>   - Patch #1 is new in this series,
>
>   - Patch #2 is changed slightly from v2, I've reworked the
>     disassembler classes in a slightly different way now, in order to
>     prepare for patches #5 and #6.
>
>   - Patch #3 is unchanged from v2,
>
>   - Patch #4 is unchanged from v2,
>
>   - Patch #5 is new in v3.  I've included it here as the changes in #2
>     only make sense knowing that patch #5 is coming,
>
>   - Patch #6 is a small cleanup only possible after #2 and #5 have landed.
>
> Changes in v2:
>
>   - The first 3 patches from the v1 series were merged a while back,
>     these were all refactoring, or auxiliary features,
>
>   - There's a new #1 patch in the v2 series that does some new
>     refactoring of GDB's disassembler classes, this was required in
>     order to simplify the #3 patch,
>
>   - Patch #2 in the v2 series is largely unchanged from patch #4 in
>     the v1 series,
>
>   - The syntax highlighting work that was in the v1 series was spun
>     out into its own patch, and has been merged separately,
>
>   - The format_address helper function that appeared in the v1 series,
>     and that Simon suggested I make more general, was spun out into
>     its own patch, and merged separately,
>
>   - Finally, patch #3 in the v2 series is pretty much a complete
>     rewrite from the v1 series in order to follow the approach
>     suggested by Simon.  Results are now returned directly, either via
>     'return' or by raising an exception, in contrast to the original
>     approach which involved "setting" the result into an existing
>     state object.
>
> ---
>
> Andrew Burgess (5):
>   gdb: add new base class to gdb_disassembler
>   gdb: add extension language print_insn hook
>   gdb/python: implement the print_insn extension language hook
>   gdb: refactor the non-printing disassemblers
>   gdb: unify two dis_asm_read_memory functions in disasm.c
>
>  gdb/Makefile.in                        |   1 +
>  gdb/NEWS                               |  34 +
>  gdb/arc-linux-tdep.c                   |  15 +-
>  gdb/arc-tdep.c                         |  29 +-
>  gdb/arc-tdep.h                         |   5 -
>  gdb/arm-tdep.c                         |   4 +-
>  gdb/data-directory/Makefile.in         |   1 +
>  gdb/disasm-selftests.c                 |  70 +-
>  gdb/disasm.c                           | 172 ++---
>  gdb/disasm.h                           | 207 +++++-
>  gdb/doc/python.texi                    | 247 +++++++
>  gdb/extension-priv.h                   |  15 +
>  gdb/extension.c                        |  20 +
>  gdb/extension.h                        |  17 +
>  gdb/guile/guile.c                      |   6 +-
>  gdb/mips-tdep.c                        |   4 +-
>  gdb/python/lib/gdb/disassembler.py     | 109 +++
>  gdb/python/py-disasm.c                 | 970 +++++++++++++++++++++++++
>  gdb/python/python-internal.h           |  16 +
>  gdb/python/python.c                    |   3 +
>  gdb/s12z-tdep.c                        |  26 +-
>  gdb/testsuite/gdb.python/py-disasm.c   |  25 +
>  gdb/testsuite/gdb.python/py-disasm.exp | 150 ++++
>  gdb/testsuite/gdb.python/py-disasm.py  | 456 ++++++++++++
>  24 files changed, 2405 insertions(+), 197 deletions(-)
>  create mode 100644 gdb/python/lib/gdb/disassembler.py
>  create mode 100644 gdb/python/py-disasm.c
>  create mode 100644 gdb/testsuite/gdb.python/py-disasm.c
>  create mode 100644 gdb/testsuite/gdb.python/py-disasm.exp
>  create mode 100644 gdb/testsuite/gdb.python/py-disasm.py
>
> -- 
> 2.25.4



More information about the Gdb-patches mailing list