public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] Call disassemble_free_target in gdb
Date: Mon, 20 Jan 2020 04:56:00 -0000	[thread overview]
Message-ID: <4d89c1c79fa53ff2c4e9574148b59d83c21db6d2@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT 4d89c1c79fa53ff2c4e9574148b59d83c21db6d2 ***

commit 4d89c1c79fa53ff2c4e9574148b59d83c21db6d2
Author:     Tom Tromey <tom@tromey.com>
AuthorDate: Sat Jan 11 11:40:45 2020 -0700
Commit:     Tom Tromey <tom@tromey.com>
CommitDate: Sun Jan 19 13:24:32 2020 -0700

    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

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0fd5dffc82..93a125b3e7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+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.
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 7dfbd2fb47..e45c840068 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 0bda4df58c..b0f535eaa2 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.  */


             reply	other threads:[~2020-01-20  4:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-20  4:56 gdb-buildbot [this message]
2020-01-20  4:56 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, branch master gdb-buildbot
2020-01-21  8:38 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
2020-01-21  9:00 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2020-01-21  9:09 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2020-01-21  9:34 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2020-01-21  9:35 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2020-01-21  9:37 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot
2020-01-21  9:53 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4d89c1c79fa53ff2c4e9574148b59d83c21db6d2@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).