From 75033d08412577fb8ffcf76971e8d0393d14a8aa Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Mon, 4 Apr 2022 22:52:58 +0100 Subject: gdb: unify two dis_asm_read_memory functions in disasm.c After the recent restructuring of the disassembler code, GDB has ended up with two identical class static functions, both called dis_asm_read_memory, with identical implementations. My first thought was to move these out of their respective classes, and just make them global functions, then I'd only need a single copy. And maybe that's the right way to go. But I disliked that by doing that I loose the encapsulation of the method with the corresponding disassembler class. So, instead, I placed the static method into its own class, and had both the gdb_non_printing_memory_disassembler and gdb_disassembler classes inherit from this new class as an additional base-class. In terms of code generated, I don't think there's any significant difference with this approach, but I think this better reflects how the function is closely tied to the disassembler. There should be no user visible changes after this commit. --- gdb/disasm.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'gdb/disasm.c') diff --git a/gdb/disasm.c b/gdb/disasm.c index 53cd6f5..c6edc92 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -132,9 +132,9 @@ line_has_code_p (htab_t table, struct symtab *symtab, int line) /* Wrapper of target_read_code. */ int -gdb_disassembler::dis_asm_read_memory (bfd_vma memaddr, gdb_byte *myaddr, - unsigned int len, - struct disassemble_info *info) +gdb_disassembler_memory_reader::dis_asm_read_memory + (bfd_vma memaddr, gdb_byte *myaddr, unsigned int len, + struct disassemble_info *info) { return target_read_code (memaddr, myaddr, len); } @@ -1021,16 +1021,6 @@ gdb_non_printing_disassembler::null_fprintf_styled_func return 0; } -/* See disasm.h. */ - -int -gdb_non_printing_memory_disassembler::dis_asm_read_memory - (bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, - struct disassemble_info *dinfo) -{ - return target_read_code (memaddr, myaddr, length); -} - /* A non-printing disassemble_info management class. The disassemble_info setup by this class will not print anything to the output stream (there is no output stream), and the instruction to be disassembled will be -- cgit v1.1