aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-01-11 11:40:45 -0700
committerTom Tromey <tom@tromey.com>2020-01-19 13:24:32 -0700
commit4d89c1c79fa53ff2c4e9574148b59d83c21db6d2 (patch)
tree94022b7b116870b53b48e77ad9ab82d0e49cbd2d
parentc0ab21c22bb28a2e1a42195d3fe9b9de9e7fd66b (diff)
downloadgdb-4d89c1c79fa53ff2c4e9574148b59d83c21db6d2.zip
gdb-4d89c1c79fa53ff2c4e9574148b59d83c21db6d2.tar.gz
gdb-4d89c1c79fa53ff2c4e9574148b59d83c21db6d2.tar.bz2
Call disassemble_free_target in gdb
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
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/disasm.c9
-rw-r--r--gdb/disasm.h4
3 files changed, 19 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0fd5dff..93a125b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
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.
(die_reader_func_ftype): Remove.
(cutu_reader): New class.
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 7dfbd2f..e45c840 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -781,6 +781,11 @@ gdb_disassembler::gdb_disassembler (struct gdbarch *gdbarch,
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)
@@ -908,7 +913,9 @@ gdb_buffered_insn_length (struct gdbarch *gdbarch,
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 *
diff --git a/gdb/disasm.h b/gdb/disasm.h
index 0bda4df..b0f535e 100644
--- a/gdb/disasm.h
+++ b/gdb/disasm.h
@@ -47,6 +47,10 @@ public:
: 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. */