From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>
Subject: [PATCH 2/3] fix init_cutu_and_read_dies
Date: Tue, 18 Jun 2013 19:51:00 -0000 [thread overview]
Message-ID: <1371584669-1687-3-git-send-email-tromey@redhat.com> (raw)
In-Reply-To: <1371584669-1687-1-git-send-email-tromey@redhat.com>
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/dwarf2read.c | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index bbb8584..484a307 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4988,7 +4988,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
@@ -5047,7 +5047,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. */
@@ -5176,27 +5176,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,
--
1.8.1.4
next prev parent reply other threads:[~2013-06-18 19:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 19:44 [PATCH 0/3] a few more fixes from the cleanup checker Tom Tromey
2013-06-18 19:44 ` [PATCH 3/3] fix solib-som.c Tom Tromey
2013-06-18 19:44 ` [PATCH 1/3] fix dwarf_decode_line_header Tom Tromey
2013-06-18 19:51 ` Tom Tromey [this message]
2013-07-22 20:25 ` Regression for fission-reread.exp and pr13961.exp [Re: [PATCH 2/3] fix init_cutu_and_read_dies] Jan Kratochvil
2013-07-22 20:49 ` Tom Tromey
2013-07-23 6:50 ` Tom Tromey
2013-07-24 8:02 ` Jan Kratochvil
2013-07-22 17:50 ` [PATCH 0/3] a few more fixes from the cleanup checker Tom Tromey
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=1371584669-1687-3-git-send-email-tromey@redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
/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