[0/5] Add Python API for the disassembler

Message ID cover.1634162144.git.andrew.burgess@embecosm.com
Headers show
Series
  • Add Python API for the disassembler
Related show

Message

Andrew Burgess Oct. 13, 2021, 9:59 p.m.
I had need for a mechanism to augment the output of the disassembler,
and I thought it would be neat if I could do this as a Python
extension, which lead to this patch series.

The first four patches are some prep-work, and light refactoring,
before patch five which adds all the new functionality.

There's an overview of the new Pyton API in patch #5.

All feedback welcome,

Thanks,
Andrew

---

Andrew Burgess (5):
  gdb: make disassembler fprintf callback a static member function
  gdb/python: new gdb.architecture_names function
  gdb/python: move gdb.Membuf support into a new file
  gdb: add extension language print_insn hook
  gdb/python: implement the print_insn extension language hook

 gdb/Makefile.in                        |   2 +
 gdb/NEWS                               |  46 ++
 gdb/data-directory/Makefile.in         |   1 +
 gdb/disasm.c                           |  63 +-
 gdb/disasm.h                           |  16 +-
 gdb/doc/gdb.texinfo                    |  14 +
 gdb/doc/python.texi                    | 261 +++++++
 gdb/extension-priv.h                   |  15 +
 gdb/extension.c                        |  20 +
 gdb/extension.h                        |  17 +
 gdb/guile/guile.c                      |   6 +-
 gdb/python/lib/gdb/disassembler.py     | 194 ++++++
 gdb/python/py-arch.c                   |  32 +
 gdb/python/py-disasm.c                 | 905 +++++++++++++++++++++++++
 gdb/python/py-inferior.c               | 182 +----
 gdb/python/py-membuf.c                 | 226 ++++++
 gdb/python/python-internal.h           |  27 +
 gdb/python/python.c                    |  16 +
 gdb/testsuite/gdb.base/style.exp       |  45 +-
 gdb/testsuite/gdb.python/py-arch.exp   |  51 ++
 gdb/testsuite/gdb.python/py-disasm.c   |  25 +
 gdb/testsuite/gdb.python/py-disasm.exp | 201 ++++++
 gdb/testsuite/gdb.python/py-disasm.py  | 538 +++++++++++++++
 23 files changed, 2696 insertions(+), 207 deletions(-)
 create mode 100644 gdb/python/lib/gdb/disassembler.py
 create mode 100644 gdb/python/py-disasm.c
 create mode 100644 gdb/python/py-membuf.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