From patchwork Sun Feb 12 20:23:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 19232 Received: (qmail 40888 invoked by alias); 12 Feb 2017 20:23:19 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 40816 invoked by uid 89); 12 Feb 2017 20:23:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1769 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 12 Feb 2017 20:23:17 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 849AA3B74F; Sun, 12 Feb 2017 20:23:17 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-221.ams2.redhat.com [10.36.116.221]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1CKNGma024099; Sun, 12 Feb 2017 15:23:16 -0500 Subject: [PATCH 4/8] Code cleanup: Refactor abbrev_table_read_table cycle From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Victor Leschuk Date: Sun, 12 Feb 2017 21:23:15 +0100 Message-ID: <148693099506.9024.3530322781952121865.stgit@host1.jankratochvil.net> In-Reply-To: <148693097396.9024.2288256732840761882.stgit@host1.jankratochvil.net> References: <148693097396.9024.2288256732840761882.stgit@host1.jankratochvil.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-IsSubscribed: yes Hi, I find it as an improvement on its own, it prevents more code duplication in a future patch. Jan gdb/ChangeLog 2017-02-11 Jan Kratochvil * dwarf2read.c (abbrev_table_read_table): Read the data only once. --- gdb/dwarf2read.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 1137541..e9c1b6a 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -15341,12 +15341,16 @@ abbrev_table_read_table (struct dwarf2_section_info *section, abbrev_ptr += 1; /* now read in declarations */ - abbrev_name = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); - abbrev_ptr += bytes_read; - abbrev_form = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); - abbrev_ptr += bytes_read; - while (abbrev_name) + for (;;) { + abbrev_name = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); + abbrev_ptr += bytes_read; + abbrev_form = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); + abbrev_ptr += bytes_read; + + if (abbrev_name == 0) + break; + if (cur_abbrev->num_attrs == allocated_attrs) { allocated_attrs += ATTR_ALLOC_CHUNK; @@ -15356,12 +15360,9 @@ abbrev_table_read_table (struct dwarf2_section_info *section, cur_attrs[cur_abbrev->num_attrs].name = (enum dwarf_attribute) abbrev_name; - cur_attrs[cur_abbrev->num_attrs++].form + cur_attrs[cur_abbrev->num_attrs].form = (enum dwarf_form) abbrev_form; - abbrev_name = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); - abbrev_ptr += bytes_read; - abbrev_form = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); - abbrev_ptr += bytes_read; + ++cur_abbrev->num_attrs; } cur_abbrev->attrs =