aboutsummaryrefslogtreecommitdiff
path: root/gdb/disasm.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-02-04 16:51:45 +0000
committerAndrew Burgess <aburgess@redhat.com>2022-02-07 09:59:16 +0000
commit59091b1280b4ba301a2f147fbe51ea4816246ba2 (patch)
tree81fedf649c177123e8efcd6d14b380765928845b /gdb/disasm.c
parent61fb73769a0168afa466bb2245a1a233942203bb (diff)
downloadbinutils-59091b1280b4ba301a2f147fbe51ea4816246ba2.zip
binutils-59091b1280b4ba301a2f147fbe51ea4816246ba2.tar.gz
binutils-59091b1280b4ba301a2f147fbe51ea4816246ba2.tar.bz2
gdb/disasm: combine the no printing disassembler setup code
We have three places in gdb where we initialise a disassembler that will not print anything (used for figuring out the length of instructions, or collecting other information from the disassembler). Each of these places has its own stub function to act as a print like callback, the stub function is identical in each case, and just does nothing. In this commit I create a new function to initialise a disassembler that doesn't print anything, and have all three locations use this new function. There's now only one non-printing stub function. There should be no user visible changes after this commit.
Diffstat (limited to 'gdb/disasm.c')
-rw-r--r--gdb/disasm.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/gdb/disasm.c b/gdb/disasm.c
index bfccbfc..44c702a 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -891,16 +891,23 @@ gdb_insn_length (struct gdbarch *gdbarch, CORE_ADDR addr)
return gdb_print_insn (gdbarch, addr, &null_stream, NULL);
}
-/* fprintf-function for gdb_buffered_insn_length. This function is a
- nop, we don't want to print anything, we just want to compute the
- length of the insn. */
+/* An fprintf-function for use by the disassembler when we know we don't
+ want to print anything. Always returns success. */
static int ATTRIBUTE_PRINTF (2, 3)
-gdb_buffered_insn_length_fprintf (void *stream, const char *format, ...)
+gdb_disasm_null_printf (void *stream, const char *format, ...)
{
return 0;
}
+/* See disasm.h. */
+
+void
+init_disassemble_info_for_no_printing (struct disassemble_info *dinfo)
+{
+ init_disassemble_info (dinfo, nullptr, gdb_disasm_null_printf);
+}
+
/* Initialize a struct disassemble_info for gdb_buffered_insn_length.
Upon return, *DISASSEMBLER_OPTIONS_HOLDER owns the string pointed
to by DI.DISASSEMBLER_OPTIONS. */
@@ -912,7 +919,7 @@ gdb_buffered_insn_length_init_dis (struct gdbarch *gdbarch,
CORE_ADDR addr,
std::string *disassembler_options_holder)
{
- init_disassemble_info (di, NULL, gdb_buffered_insn_length_fprintf);
+ init_disassemble_info_for_no_printing (di);
/* init_disassemble_info installs buffer_read_memory, etc.
so we don't need to do that here.