gdb: add extension language print_insn hook

This commit is setup for the next commit.

In the next commit I will add a Python API to intercept the print_insn
calls within GDB, each print_insn call is responsible for
disassembling, and printing one instruction.  After the next commit it
will be possible for a user to write Python code that either wraps
around the existing disassembler, or even, in extreme situations,
entirely replaces the existing disassembler.

This commit does not add any new Python API.

What this commit does is put the extension language framework in place
for a print_insn hook.  There's a new callback added to 'struct
extension_language_ops', which is then filled in with nullptr for Python
and Guile.

Finally, in the disassembler, the code is restructured so that the new
extension language function ext_lang_print_insn is called before we
delegate to gdbarch_print_insn.

After this, the next commit can focus entirely on providing a Python
implementation of the new print_insn callback.

There should be no user visible change after this commit.
This commit is contained in:
Andrew Burgess
2021-09-17 18:11:40 +01:00
committed by Andrew Burgess
parent f0c2e3e020
commit e4ae302562
6 changed files with 78 additions and 4 deletions

View File

@@ -327,6 +327,16 @@ extern gdb::optional<std::string> ext_lang_colorize
extern gdb::optional<std::string> ext_lang_colorize_disasm
(const std::string &content, gdbarch *gdbarch);
/* Calls extension_language_ops::print_insn for each extension language,
returning the result from the first extension language that returns a
non-empty result (any further extension languages are not then called).
All arguments are forwarded to extension_language_ops::print_insn, see
that function for a full description. */
extern gdb::optional<int> ext_lang_print_insn
(struct gdbarch *gdbarch, CORE_ADDR address, struct disassemble_info *info);
#if GDB_SELF_TEST
namespace selftests {
extern void (*hook_set_active_ext_lang) ();