fix init_cutu_and_read_dies
authorTom Tromey <tromey@redhat.com>
Mon, 22 Jul 2013 17:58:51 +0000 (17:58 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 22 Jul 2013 17:58:51 +0000 (17:58 +0000)
init_cutu_and_read_dies creates an outer cleanup and uses its
immediately nested inner cleanup conditionally.  This seems overly
complicated to me; simpler is to just deal with the outer cleanup and
drop the inner one.  That is what this patch implements.

* dwarf2read.c (init_cutu_and_read_dies): Remove 'free_cu_cleanup'.
Simplify cleanup handling.

gdb/ChangeLog
gdb/dwarf2read.c

index d472569e3df9b4087548d9073100180c9f98adb4..66039099c620b4a0d79a6c7cca765d8e5dafd2ea 100644 (file)
@@ -1,3 +1,8 @@
+2013-07-22  Tom Tromey  <tromey@redhat.com>
+
+       * dwarf2read.c (init_cutu_and_read_dies): Remove 'free_cu_cleanup'.
+       Simplify cleanup handling.
+
 2013-07-22  Tom Tromey  <tromey@redhat.com>
 
        * dwarf2read.c (dwarf_decode_line_header): Call do_cleanups
index 70ab302fb312da0f337cc108fc75e0c5d6fbd4a6..05388166ce07f6d92417f7459d54120cb23a5b16 100644 (file)
@@ -5015,7 +5015,7 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
   struct die_info *comp_unit_die;
   int has_children;
   struct attribute *attr;
-  struct cleanup *cleanups, *free_cu_cleanup = NULL;
+  struct cleanup *cleanups;
   struct signatured_type *sig_type = NULL;
   struct dwarf2_section_info *abbrev_section;
   /* Non-zero if CU currently points to a DWO file and we need to
@@ -5074,7 +5074,7 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
       init_one_comp_unit (cu, this_cu);
 
       /* If an error occurs while loading, release our storage.  */
-      free_cu_cleanup = make_cleanup (free_heap_comp_unit, cu);
+      make_cleanup (free_heap_comp_unit, cu);
     }
 
   /* Get the header.  */
@@ -5203,27 +5203,22 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
   die_reader_func (&reader, info_ptr, comp_unit_die, has_children, data);
 
   /* Done, clean up.  */
-  if (free_cu_cleanup != NULL)
+  if (keep)
     {
-      if (keep)
-       {
-         /* We've successfully allocated this compilation unit.  Let our
-            caller clean it up when finished with it.  */
-         discard_cleanups (free_cu_cleanup);
+      /* We've successfully allocated this compilation unit.  Let our
+        caller clean it up when finished with it.  */
+      discard_cleanups (cleanups);
 
-         /* We can only discard free_cu_cleanup and all subsequent cleanups.
-            So we have to manually free the abbrev table.  */
-         dwarf2_free_abbrev_table (cu);
+      /* We can only discard free_cu_cleanup and all subsequent cleanups.
+        So we have to manually free the abbrev table.  */
+      dwarf2_free_abbrev_table (cu);
 
-         /* Link this CU into read_in_chain.  */
-         this_cu->cu->read_in_chain = dwarf2_per_objfile->read_in_chain;
-         dwarf2_per_objfile->read_in_chain = this_cu;
-       }
-      else
-       do_cleanups (free_cu_cleanup);
+      /* Link this CU into read_in_chain.  */
+      this_cu->cu->read_in_chain = dwarf2_per_objfile->read_in_chain;
+      dwarf2_per_objfile->read_in_chain = this_cu;
     }
-
-  do_cleanups (cleanups);
+  else
+    do_cleanups (cleanups);
 }
 
 /* Read CU/TU THIS_CU in section SECTION,