aboutsummaryrefslogtreecommitdiff
path: root/gdb/extension-priv.h
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2021-09-17 18:11:40 +0100
committerAndrew Burgess <aburgess@redhat.com>2022-06-15 09:44:54 +0100
commite4ae302562aba1bd166919d76341fb631e2d470a (patch)
tree9336fab35e71571a0fdd7e1ebf1a6ee58b56af9a /gdb/extension-priv.h
parentf0c2e3e020d350b410e1bbe4ed636f2ea228d555 (diff)
downloadgdb-e4ae302562aba1bd166919d76341fb631e2d470a.zip
gdb-e4ae302562aba1bd166919d76341fb631e2d470a.tar.gz
gdb-e4ae302562aba1bd166919d76341fb631e2d470a.tar.bz2
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.
Diffstat (limited to 'gdb/extension-priv.h')
-rw-r--r--gdb/extension-priv.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h
index d9450b5..7c74e72 100644
--- a/gdb/extension-priv.h
+++ b/gdb/extension-priv.h
@@ -263,6 +263,21 @@ struct extension_language_ops
contents, or an empty optional. */
gdb::optional<std::string> (*colorize_disasm) (const std::string &content,
gdbarch *gdbarch);
+
+ /* Print a single instruction from ADDRESS in architecture GDBARCH. INFO
+ is the standard libopcodes disassembler_info structure. Bytes for the
+ instruction being printed should be read using INFO->read_memory_func
+ as the actual instruction bytes might be in a buffer.
+
+ Use INFO->fprintf_func to print the results of the disassembly, and
+ return the length of the instruction.
+
+ If no instruction can be disassembled then return an empty value and
+ other extension languages will get a chance to perform the
+ disassembly. */
+ gdb::optional<int> (*print_insn) (struct gdbarch *gdbarch,
+ CORE_ADDR address,
+ struct disassemble_info *info);
};
/* State necessary to restore a signal handler to its previous value. */