From patchwork Sun Feb 19 21:28:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 19301 Received: (qmail 115194 invoked by alias); 19 Feb 2017 21:28:23 -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 115116 invoked by uid 89); 19 Feb 2017 21:28:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=sk:read_un 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, 19 Feb 2017 21:28:20 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 15A6E8553D; Sun, 19 Feb 2017 21:28:21 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-221.ams2.redhat.com [10.36.116.221]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1JLSJlV020770; Sun, 19 Feb 2017 16:28:20 -0500 Subject: [PATCH v2 3/8] Code cleanup: Refactor abbrev_table_read_table cycle From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Victor Leschuk Date: Sun, 19 Feb 2017 22:28:18 +0100 Message-ID: <148753969859.4016.11708558461065078561.stgit@host1.jankratochvil.net> In-Reply-To: <148753968011.4016.6818202131640662529.stgit@host1.jankratochvil.net> References: <148753968011.4016.6818202131640662529.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 e0ede18..a987e0e 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -15339,12 +15339,16 @@ abbrev_table_read_table (struct dwarf2_section_info *section, abbrev_ptr += 1; /* now read in declarations */ - abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); - abbrev_ptr += bytes_read; - abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); - abbrev_ptr += bytes_read; - while (abbrev_name) + for (;;) { + abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); + abbrev_ptr += bytes_read; + abbrev_form = 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; @@ -15354,12 +15358,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 = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); - abbrev_ptr += bytes_read; - abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); - abbrev_ptr += bytes_read; + ++cur_abbrev->num_attrs; } cur_abbrev->attrs =