Fix a memory leak and remove an unused member
authorTom Tromey <tom@tromey.com>
Mon, 24 Feb 2020 22:50:57 +0000 (15:50 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 24 Feb 2020 22:50:58 +0000 (15:50 -0700)
I noticed that setup_type_unit_groups leaks the symtab vector -- it
allocates this with XNEWVEC, but from what I can tell, nothing frees
it.  This patch changes it to use XOBNEWVEC.

Also, the type_unit_unshareable::num_symtabs member is assigned but
never read.  So, this removes it.

gdb/ChangeLog
2020-02-24  Tom Tromey  <tom@tromey.com>

* dwarf2/read.h (struct type_unit_unshareable) <num_symtabs>:
Remove.
* dwarf2/read.c (dwarf2_cu::setup_type_unit_groups): Use
XOBNEWVEC.

gdb/ChangeLog
gdb/dwarf2/read.c

index 2507b9c7dd025601b02420a866ae7362d6488212..1a159470e66796ef8e2f319b6378e2416d21eff6 100644 (file)
@@ -1,3 +1,10 @@
+2020-02-24  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2/read.h (struct type_unit_unshareable) <num_symtabs>:
+       Remove.
+       * dwarf2/read.c (dwarf2_cu::setup_type_unit_groups): Use
+       XOBNEWVEC.
+
 2020-02-24  Tom Tromey  <tom@tromey.com>
 
        * dwarf2/read.h (struct dwarf2_per_cu_data) <type_unit_group_p>:
index 0f514eafe880b4a4efd6d2a7eacf7e0247e431de..d97956ecb6ace0dcda4c111ae25e077f835f5654 100644 (file)
@@ -589,10 +589,6 @@ struct type_unit_group
   /* The data used to construct the hash key.  */
   struct stmt_list_hash hash;
 
-  /* The number of symtabs from the line header.
-     The value here must match line_header.num_file_names.  */
-  unsigned int num_symtabs;
-
   /* The symbol tables for this TU (obtained from the files listed in
      DW_AT_stmt_list).
      WARNING: The order of entries here must match the order of entries
@@ -10854,9 +10850,9 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
         process_full_type_unit still needs to know if this is the first
         time.  */
 
-      tu_group->num_symtabs = line_header->file_names_size ();
-      tu_group->symtabs = XNEWVEC (struct symtab *,
-                                  line_header->file_names_size ());
+      tu_group->symtabs
+       = XOBNEWVEC (&COMPUNIT_OBJFILE (cust)->objfile_obstack,
+                    struct symtab *, line_header->file_names_size ());
 
       auto &file_names = line_header->file_names ();
       for (i = 0; i < file_names.size (); ++i)
This page took 0.036541 seconds and 4 git commands to generate.