aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2017-02-20 20:53:20 +0100
committerJan Kratochvil <jan.kratochvil@redhat.com>2017-02-20 20:59:40 +0100
commit22d2f3ab926890490deed2888f6f013031fa6a6e (patch)
tree457b64fe2b3f73c109e926f9c3e6aff90cc931b9
parent5f46c5a54825aabb3f30095c84ac30aff7400ac5 (diff)
downloadgdb-22d2f3ab926890490deed2888f6f013031fa6a6e.zip
gdb-22d2f3ab926890490deed2888f6f013031fa6a6e.tar.gz
gdb-22d2f3ab926890490deed2888f6f013031fa6a6e.tar.bz2
Code cleanup: Refactor abbrev_table_read_table cycle
I find it as an improvement on its own, it prevents more code duplication in a future patch. gdb/ChangeLog 2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf2read.c (abbrev_table_read_table): Read the data only once.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/dwarf2read.c21
2 files changed, 15 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 99fcca0..75f1b02 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com>
+ * dwarf2read.c (abbrev_table_read_table): Read the data only once.
+
+2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com>
+
* dwarf2read.c (dwarf2_ranges_process): New function from
dwarf2_ranges_read.
(dwarf2_ranges_read, dwarf2_record_block_ranges): Use
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 =