From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10573 invoked by alias); 18 Jun 2013 19:44:36 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 10442 invoked by uid 89); 18 Jun 2013 19:44:36 -0000 X-Spam-SWARE-Status: No, score=-7.5 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 18 Jun 2013 19:44:35 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5IJiYNX017503 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Jun 2013 15:44:34 -0400 Received: from barimba.redhat.com (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5IJiWll021231; Tue, 18 Jun 2013 15:44:33 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/3] fix init_cutu_and_read_dies Date: Tue, 18 Jun 2013 19:51:00 -0000 Message-Id: <1371584669-1687-3-git-send-email-tromey@redhat.com> In-Reply-To: <1371584669-1687-1-git-send-email-tromey@redhat.com> References: <1371584669-1687-1-git-send-email-tromey@redhat.com> X-SW-Source: 2013-06/txt/msg00461.txt.bz2 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