[PATCHv2 0/3] Add Python API for the disassembler

Andrew Burgess aburgess@redhat.com
Wed Mar 23 22:41:38 GMT 2022


Finally gotten back to this work!

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.

All feedback welcome,

Thanks,
Andrew

---

Andrew Burgess (3):
  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/Makefile.in                        |   1 +
 gdb/NEWS                               |  34 +
 gdb/arm-tdep.c                         |   4 +-
 gdb/data-directory/Makefile.in         |   1 +
 gdb/disasm.c                           |  64 +-
 gdb/disasm.h                           |  89 ++-
 gdb/doc/python.texi                    | 239 ++++++
 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/testsuite/gdb.python/py-disasm.c   |  25 +
 gdb/testsuite/gdb.python/py-disasm.exp | 150 ++++
 gdb/testsuite/gdb.python/py-disasm.py  | 456 ++++++++++++
 19 files changed, 2176 insertions(+), 47 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