aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/read.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-09-29 18:49:08 -0600
committerTom Tromey <tom@tromey.com>2020-09-29 20:29:06 -0600
commitfe56917a86c37fbf4399583f4fa041227594d187 (patch)
tree2e9e30bfc67b8b861c3ce510fddfb8a8eb7859ed /gdb/dwarf2/read.c
parent414ad644a86fab3e5c22f622c5f586ce7a8bcf03 (diff)
downloadbinutils-fe56917a86c37fbf4399583f4fa041227594d187.zip
binutils-fe56917a86c37fbf4399583f4fa041227594d187.tar.gz
binutils-fe56917a86c37fbf4399583f4fa041227594d187.tar.bz2
Add reprocessing flag to struct attribute
Some forms require "reprocessing" -- a second pass to update their value appropriately. In this case, we'll set the unsigned value on the attribute, and then later set it to the correct value. To handle this, we introduce a reprocessing flag to attribute. Then, we manage this flag to ensure that setting and unsetting is done properly. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_cutu_die_from_dwo): Use OBSTACK_ZALLOC. (read_attribute_reprocess, read_attribute_value): Update. (read_attribute): Clear requires_reprocessing. * dwarf2/attribute.h (struct attribute) <as_unsigned_reprocess, form_requires_reprocessing>: New methods. <string_init>: Clear requires_reprocessing. <set_unsigned_reprocess>: New method. <name>: Shrink by one bit. <requires_reprocessing>: New member. * dwarf2/attribute.c (attribute::form_requires_reprocessing): New method.
Diffstat (limited to 'gdb/dwarf2/read.c')
-rw-r--r--gdb/dwarf2/read.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index c572ed4..57b667e 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -6869,7 +6869,7 @@ read_cutu_die_from_dwo (dwarf2_cu *cu,
else if (stub_comp_dir != NULL)
{
/* Reconstruct the comp_dir attribute to simplify the code below. */
- comp_dir = XOBNEW (&cu->comp_unit_obstack, struct attribute);
+ comp_dir = OBSTACK_ZALLOC (&cu->comp_unit_obstack, struct attribute);
comp_dir->name = DW_AT_comp_dir;
comp_dir->form = DW_FORM_string;
comp_dir->set_string_noncanonical (stub_comp_dir);
@@ -19640,7 +19640,7 @@ read_attribute_reprocess (const struct die_reader_specs *reader,
{
case DW_FORM_addrx:
case DW_FORM_GNU_addr_index:
- DW_ADDR (attr) = read_addr_index (cu, DW_UNSND (attr));
+ DW_ADDR (attr) = read_addr_index (cu, attr->as_unsigned_reprocess ());
break;
case DW_FORM_loclistx:
DW_UNSND (attr) = read_loclist_index (cu, DW_UNSND (attr));
@@ -19655,7 +19655,7 @@ read_attribute_reprocess (const struct die_reader_specs *reader,
case DW_FORM_strx4:
case DW_FORM_GNU_str_index:
{
- unsigned int str_index = DW_UNSND (attr);
+ unsigned int str_index = attr->as_unsigned_reprocess ();
gdb_assert (!attr->canonical_string_p ());
if (reader->dwo_file != NULL)
attr->set_string_noncanonical (read_dwo_str_index (reader,
@@ -19879,7 +19879,8 @@ read_attribute_value (const struct die_reader_specs *reader,
case DW_FORM_addrx:
case DW_FORM_GNU_addr_index:
*need_reprocess = true;
- DW_UNSND (attr) = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+ attr->set_unsigned_reprocess (read_unsigned_leb128 (abfd, info_ptr,
+ &bytes_read));
info_ptr += bytes_read;
break;
case DW_FORM_strx:
@@ -19916,7 +19917,7 @@ read_attribute_value (const struct die_reader_specs *reader,
info_ptr += bytes_read;
}
*need_reprocess = true;
- DW_UNSND (attr) = str_index;
+ attr->set_unsigned_reprocess (str_index);
}
break;
default:
@@ -19957,6 +19958,7 @@ read_attribute (const struct die_reader_specs *reader,
{
attr->name = abbrev->name;
attr->string_is_canonical = 0;
+ attr->requires_reprocessing = 0;
return read_attribute_value (reader, attr, abbrev->form,
abbrev->implicit_const, info_ptr,
need_reprocess);