aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-06-05 09:38:53 -0600
committerTom Tromey <tromey@adacore.com>2024-06-24 09:11:30 -0600
commit4122e647d571b35b4aba73ec481bc2d72d193e54 (patch)
tree7b374b0fc15acefc01f99a3fd754fa1feaf72174 /gdb/dwarf2
parentf59be2ed3946b69a969c65dd7093b4e865bba003 (diff)
downloadbinutils-4122e647d571b35b4aba73ec481bc2d72d193e54.zip
binutils-4122e647d571b35b4aba73ec481bc2d72d193e54.tar.gz
binutils-4122e647d571b35b4aba73ec481bc2d72d193e54.tar.bz2
Don't obstack-allocate the call site hash table
The call site hash table is the last hash table using obstack allocation. In one large (non-public) test case, these hash tables take a substiantial amount of memory. Some of this memory is wasted -- whenever the hash table is resized, the old table is not freed. This patch fixes the problem by changing this hash table to be heap-allocated. This means that resizing will no longer "leak" memory.
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/cu.h2
-rw-r--r--gdb/dwarf2/read.c13
2 files changed, 7 insertions, 8 deletions
diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h
index d23cc9b..b0ec2d6 100644
--- a/gdb/dwarf2/cu.h
+++ b/gdb/dwarf2/cu.h
@@ -170,7 +170,7 @@ public:
std::vector<delayed_method_info> method_list;
/* To be copied to symtab->call_site_htab. */
- htab_t call_site_htab = nullptr;
+ htab_up call_site_htab;
/* Non-NULL if this CU came from a DWO file.
There is an invariant here that is important to remember:
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index eee8b45..01d1a6b 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -6233,7 +6233,7 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language)
else
cust->set_epilogue_unwind_valid (true);
- cust->set_call_site_htab (cu->call_site_htab);
+ cust->set_call_site_htab (std::move (cu->call_site_htab));
}
per_objfile->set_symtab (cu->per_cu, cust);
@@ -10208,13 +10208,12 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
}
unrelocated_addr pc = attr->as_address ();
- if (cu->call_site_htab == NULL)
- cu->call_site_htab = htab_create_alloc_ex (16, call_site::hash,
- call_site::eq, NULL,
- &objfile->objfile_obstack,
- hashtab_obstack_allocate, NULL);
+ if (cu->call_site_htab == nullptr)
+ cu->call_site_htab.reset (htab_create_alloc (16, call_site::hash,
+ call_site::eq, nullptr,
+ xcalloc, xfree));
struct call_site call_site_local (pc, nullptr, nullptr);
- slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT);
+ slot = htab_find_slot (cu->call_site_htab.get (), &call_site_local, INSERT);
if (*slot != NULL)
{
complaint (_("Duplicate PC %s for DW_TAG_call_site "