aboutsummaryrefslogtreecommitdiff
path: root/gdb/objfiles.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-03-02 12:29:48 -0700
committerTom Tromey <tom@tromey.com>2019-03-15 16:02:10 -0600
commit042d75e42c5572f333e0e06dabd3c5c4afab486c (patch)
tree32f8606eabd734669d29684d828893393fe29b51 /gdb/objfiles.h
parentdb92718b541158d4782dbc9f48401c20f2bbad6d (diff)
downloadgdb-042d75e42c5572f333e0e06dabd3c5c4afab486c.zip
gdb-042d75e42c5572f333e0e06dabd3c5c4afab486c.tar.gz
gdb-042d75e42c5572f333e0e06dabd3c5c4afab486c.tar.bz2
Allocate minimal symbols with malloc
Currently, minimal symbols are allocated on the per-BFD obstack. However, it is also possible for multiple symbol readers to create minimal symbols for a given objfile. In this case, the minimal symbols will be reallocated on the obstack, leading to some waste of storage. This is a memory leak, but I think it won't be caught by tools like valgrind, because valgrind doesn't know about obstacks. This patch fixes the problem by using malloc to allocate the storage for minimal symbols. gdb/ChangeLog 2019-03-15 Tom Tromey <tom@tromey.com> * objfiles.h (struct objfile_per_bfd_storage) <msymbols>: Now a unique_xmalloc_ptr. (objfile::msymbols_range::begin, objfile::msymbols_range::end): Update. * minsyms.c (lookup_minimal_symbol_by_pc_section) (build_minimal_symbol_hash_tables) (minimal_symbol_reader::install): Update.
Diffstat (limited to 'gdb/objfiles.h')
-rw-r--r--gdb/objfiles.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 1fa6f3c..b07ddfd 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -282,11 +282,9 @@ struct objfile_per_bfd_storage
name and a zero value for the address. This makes it easy to walk
through the array when passed a pointer to somewhere in the middle
of it. There is also a count of the number of symbols, which does
- not include the terminating null symbol. The array itself, as well
- as all the data that it points to, should be allocated on the
- objfile_obstack for this file. */
+ not include the terminating null symbol. */
- minimal_symbol *msymbols = NULL;
+ gdb::unique_xmalloc_ptr<minimal_symbol> msymbols;
int minimal_symbol_count = 0;
/* The number of minimal symbols read, before any minimal symbol
@@ -375,13 +373,13 @@ struct objfile
minimal_symbol_iterator begin () const
{
- return minimal_symbol_iterator (m_objfile->per_bfd->msymbols);
+ return minimal_symbol_iterator (m_objfile->per_bfd->msymbols.get ());
}
minimal_symbol_iterator end () const
{
return minimal_symbol_iterator
- (m_objfile->per_bfd->msymbols
+ (m_objfile->per_bfd->msymbols.get ()
+ m_objfile->per_bfd->minimal_symbol_count);
}