Commit
20135676fc4c3912297c313b3e0d3cbd6cc402e3 ("PR24960, Memory leak
from disassembler") added "disassemble_free_target" to opcodes. This
is used to free target-specific data when finished with a
disassembler.
This patch changes gdb to call this function where needed.
gdb/ChangeLog
2020-01-19 Tom Tromey <tom@tromey.com>
* disasm.c (~gdb_disassembler): New destructor.
(gdb_buffered_insn_length): Call disassemble_free_target.
* disasm.h (class gdb_disassembler): Declare destructor. Use
DISABLE_COPY_AND_ASSIGN.
Change-Id: I245ba5b7dec5e5d9f29cd21832c6e2b4fecef047
+2020-01-19 Tom Tromey <tom@tromey.com>
+
+ * disasm.c (~gdb_disassembler): New destructor.
+ (gdb_buffered_insn_length): Call disassemble_free_target.
+ * disasm.h (class gdb_disassembler): Declare destructor. Use
+ DISABLE_COPY_AND_ASSIGN.
+
2020-01-19 Tom Tromey <tom@tromey.com>
* dwarf2read.c (abbrev_table_up): Move typedef earlier.
disassemble_init_for_target (&m_di);
}
+gdb_disassembler::~gdb_disassembler ()
+{
+ disassemble_free_target (&m_di);
+}
+
int
gdb_disassembler::print_insn (CORE_ADDR memaddr,
int *branch_delay_insns)
gdb_buffered_insn_length_init_dis (gdbarch, &di, insn, max_len, addr,
&disassembler_options_holder);
- return gdbarch_print_insn (gdbarch, addr, &di);
+ int result = gdbarch_print_insn (gdbarch, addr, &di);
+ disassemble_free_target (&di);
+ return result;
}
char *
: gdb_disassembler (gdbarch, file, dis_asm_read_memory)
{}
+ ~gdb_disassembler ();
+
+ DISABLE_COPY_AND_ASSIGN (gdb_disassembler);
+
int print_insn (CORE_ADDR memaddr, int *branch_delay_insns = NULL);
/* Return the gdbarch of gdb_disassembler. */