From: Daniel Jacobowitz <drow@mvista.com>
To: gdb-patches@sources.redhat.com
Subject: RFA: Fix a big memory leak reading minimal symbols
Date: Sun, 26 Jan 2003 19:13:00 -0000 [thread overview]
Message-ID: <20030126191411.GA1824@nevyn.them.org> (raw)
This patch is good for a whopping 13% (7MB) of memory usage when reading in
all of mozilla's minimal symbols (stabs). The control flow looks like this
right now:
- init_minimal_symbol_collection in elf_symfile_read
- install_minimal_symbols in elfstab_build_psymtabs. Presumably added so
that we don't lose the minimal symbols above.
- dbx_symfile_read contains a complete init_minimal_symbol_collection /
install_minimal_symbols pair, which generally finds no minimal symbols
in ELF.
- install_minimal_symbols and matching cleanup in elf_symfile_read.
Only problem is, that second init_minimal_symbol_collection call zeroed out
the bunch pointer. We've installed them but we never free them, so they
just sit around wasting memory.
This patch arranges for all calls to init_minimal_symbol_collection in ELF
targets to be paired with matching cleanups and install_minimal_symbols
calls. This means that elfmdebug_build_psymtabs gets its own pair instead
of relying on elf_symfile_read, and that elf_symfile_read installs its own
minimal symbols much earlier.
I'd like a symtab maintainer to look over this patch; the more eyes the
better. I'm probably also short some copyright dates; I'll get them when/if
I check it in.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2002-01-26 Daniel Jacobowitz <drow@mvista.com>
* dbxread.c (elfstab_build_psymtabs): Don't call
install_minimal_symbols.
* elfread.c (elf_symfile_read): Call install_minimal_symbols
earlier.
* mdebugread.c (elfmdebug_build_psymtabs): Call
install_minimal_symbols and make appropriate cleanups.
Index: dbxread.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/dbxread.c,v
retrieving revision 1.40
diff -u -p -r1.40 dbxread.c
--- dbxread.c 18 Jan 2003 15:55:51 -0000 1.40
+++ dbxread.c 22 Jan 2003 23:19:29 -0000
@@ -3511,13 +3511,16 @@ elfstab_build_psymtabs (struct objfile *
buildsym_new_init ();
free_header_files ();
init_header_files ();
- install_minimal_symbols (objfile);
processing_acc_compilation = 1;
/* In an elf file, we've already installed the minimal symbols that came
from the elf (non-stab) symbol table, so always act like an
- incremental load here. */
+ incremental load here. dbx_symfile_read should not generate any new
+ minimal symbols, since we will have already read the ELF dynamic symbol
+ table and normal symbol entries won't be in the ".stab" section; but in
+ case it does, it will install them itself. */
+
dbx_symfile_read (objfile, 0);
}
\f
Index: elfread.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/elfread.c,v
retrieving revision 1.29
diff -u -p -r1.29 elfread.c
--- elfread.c 14 Jan 2003 00:49:03 -0000 1.29
+++ elfread.c 22 Jan 2003 23:16:02 -0000
@@ -542,6 +542,15 @@ elf_symfile_read (struct objfile *objfil
elf_symtab_read (objfile, 1);
+ /* Install any minimal symbols that have been collected as the current
+ minimal symbols for this objfile. The debug readers below this point
+ should not generate new minimal symbols; if they do it's their
+ responsibility to install them. "mdebug" appears to be the only one
+ which will do this. */
+
+ install_minimal_symbols (objfile);
+ do_cleanups (back_to);
+
/* Now process debugging information, which is contained in
special ELF sections. */
@@ -612,13 +621,6 @@ elf_symfile_read (struct objfile *objfil
if (DWARF2_BUILD_FRAME_INFO_P ())
DWARF2_BUILD_FRAME_INFO(objfile);
-
- /* Install any minimal symbols that have been collected as the current
- minimal symbols for this objfile. */
-
- install_minimal_symbols (objfile);
-
- do_cleanups (back_to);
}
/* This cleans up the objfile's sym_stab_info pointer, and the chain of
Index: mdebugread.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/mdebugread.c,v
retrieving revision 1.39
diff -u -p -r1.39 mdebugread.c
--- mdebugread.c 18 Jan 2003 15:55:52 -0000 1.39
+++ mdebugread.c 26 Jan 2003 17:01:39 -0000
@@ -4810,6 +4810,14 @@ elfmdebug_build_psymtabs (struct objfile
{
bfd *abfd = objfile->obfd;
struct ecoff_debug_info *info;
+ struct cleanup *back_to;
+
+ /* FIXME: It's not clear whether we should be getting minimal symbol
+ information from .mdebug in an ELF file, or whether we will.
+ Re-initialize the minimal symbol reader in case we do. */
+
+ init_minimal_symbol_collection ();
+ back_to = make_cleanup_discard_minimal_symbols ();
info = ((struct ecoff_debug_info *)
obstack_alloc (&objfile->psymbol_obstack,
@@ -4820,6 +4826,9 @@ elfmdebug_build_psymtabs (struct objfile
bfd_errmsg (bfd_get_error ()));
mdebug_build_psymtabs (objfile, swap, info);
+
+ install_minimal_symbols (objfile);
+ do_cleanups (back_to);
}
\f
next reply other threads:[~2003-01-26 19:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-26 19:13 Daniel Jacobowitz [this message]
2003-02-05 19:31 ` Elena Zannoni
2003-02-05 22:26 ` Daniel Jacobowitz
2003-02-19 21:20 ` Elena Zannoni
2003-02-20 19:32 ` Daniel Jacobowitz
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=20030126191411.GA1824@nevyn.them.org \
--to=drow@mvista.com \
--cc=gdb-patches@sources.redhat.com \
/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