This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v2 3/8] Code cleanup: Refactor abbrev_table_read_table cycle
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Victor Leschuk <vleschuk at accesssoftek dot com>
- Date: Sun, 19 Feb 2017 22:28:18 +0100
- Subject: [PATCH v2 3/8] Code cleanup: Refactor abbrev_table_read_table cycle
- Authentication-results: sourceware.org; auth=none
- References: <148753968011.4016.6818202131640662529.stgit@host1.jankratochvil.net>
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 <jan.kratochvil@redhat.com>
* 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 =