aboutsummaryrefslogtreecommitdiff
path: root/gdb
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:07 -0600
commitd4df075e8b946da354dc11690a793cf5c17394aa (patch)
tree4c83c093d28cdb13a977411cd2b0d7a753023439 /gdb
parentbf23a26804608145c316c7516b1aceecc055a888 (diff)
downloadgdb-d4df075e8b946da354dc11690a793cf5c17394aa.zip
gdb-d4df075e8b946da354dc11690a793cf5c17394aa.tar.gz
gdb-d4df075e8b946da354dc11690a793cf5c17394aa.tar.bz2
Add attribute::as_unsigned method
This introduces a new attribute::as_unsigned method and changes a few spots to use it. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dw2_get_file_names_reader) (dwarf2_build_include_psymtabs, handle_DW_AT_stmt_list) (dwarf2_cu::setup_type_unit_groups, fill_in_loclist_baton) (dwarf2_symbol_mark_computed): Use as_unsigned. * dwarf2/attribute.h (struct attribute) <as_unsigned>: New method. <form_is_section_offset>: Update comment.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/dwarf2/attribute.h11
-rw-r--r--gdb/dwarf2/read.c22
3 files changed, 31 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6fa5fff..9c161e4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,15 @@
2020-09-29 Tom Tromey <tom@tromey.com>
+ * dwarf2/read.c (dw2_get_file_names_reader)
+ (dwarf2_build_include_psymtabs, handle_DW_AT_stmt_list)
+ (dwarf2_cu::setup_type_unit_groups, fill_in_loclist_baton)
+ (dwarf2_symbol_mark_computed): Use as_unsigned.
+ * dwarf2/attribute.h (struct attribute) <as_unsigned>: New
+ method.
+ <form_is_section_offset>: Update comment.
+
+2020-09-29 Tom Tromey <tom@tromey.com>
+
* dwarf2/read.c (dwarf2_access_attribute): Rename from
dwarf2_default_access_attribute. Look up attribute.
(dwarf2_add_field, dwarf2_add_type_defn, dwarf2_add_member_fn):
diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h
index cb25208..c2e14ef 100644
--- a/gdb/dwarf2/attribute.h
+++ b/gdb/dwarf2/attribute.h
@@ -82,9 +82,18 @@ struct attribute
return u.unsnd;
}
+ /* Return the unsigned value. Requires that the form be an unsigned
+ form, and that reprocessing not be needed. */
+ ULONGEST as_unsigned () const
+ {
+ gdb_assert (form_is_unsigned ());
+ gdb_assert (!requires_reprocessing);
+ return u.unsnd;
+ }
+
/* Return non-zero if ATTR's value is a section offset --- classes
lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise.
- You may use DW_UNSND (attr) to retrieve such offsets.
+ You may use the as_unsigned method to retrieve such offsets.
Section 7.5.4, "Attribute Encodings", explains that no attribute
may have a value that belongs to more than one of these classes; it
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index fe9522c..43c9adb 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -3210,11 +3210,11 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader,
sect_offset line_offset {};
attr = dwarf2_attr (comp_unit_die, DW_AT_stmt_list, cu);
- if (attr != nullptr)
+ if (attr != nullptr && attr->form_is_unsigned ())
{
struct quick_file_names find_entry;
- line_offset = (sect_offset) DW_UNSND (attr);
+ line_offset = (sect_offset) attr->as_unsigned ();
/* We may have already read in this line header (TU line header sharing).
If we have we're done. */
@@ -6297,8 +6297,8 @@ dwarf2_build_include_psymtabs (struct dwarf2_cu *cu,
struct attribute *attr;
attr = dwarf2_attr (die, DW_AT_stmt_list, cu);
- if (attr != nullptr)
- lh = dwarf_decode_line_header ((sect_offset) DW_UNSND (attr), cu);
+ if (attr != nullptr && attr->form_is_unsigned ())
+ lh = dwarf_decode_line_header ((sect_offset) attr->as_unsigned (), cu);
if (lh == NULL)
return; /* No linetable, so no includes. */
@@ -11004,10 +11004,10 @@ handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu,
gdb_assert (! cu->per_cu->is_debug_types);
attr = dwarf2_attr (die, DW_AT_stmt_list, cu);
- if (attr == NULL)
+ if (attr == NULL || !attr->form_is_unsigned ())
return;
- sect_offset line_offset = (sect_offset) DW_UNSND (attr);
+ sect_offset line_offset = (sect_offset) attr->as_unsigned ();
/* The line header hash table is only created if needed (it exists to
prevent redundant reading of the line table for partial_units).
@@ -11197,9 +11197,9 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
/* We have to handle the case of both a missing DW_AT_stmt_list or bad
debug info. */
line_header_up lh;
- if (attr != NULL)
+ if (attr != NULL && attr->form_is_unsigned ())
{
- sect_offset line_offset = (sect_offset) DW_UNSND (attr);
+ sect_offset line_offset = (sect_offset) attr->as_unsigned ();
lh = dwarf_decode_line_header (line_offset, this);
}
if (lh == NULL)
@@ -23983,8 +23983,8 @@ fill_in_loclist_baton (struct dwarf2_cu *cu,
gdb_assert (baton->per_cu);
/* We don't know how long the location list is, but make sure we
don't run off the edge of the section. */
- baton->size = section->size - DW_UNSND (attr);
- baton->data = section->buffer + DW_UNSND (attr);
+ baton->size = section->size - attr->as_unsigned ();
+ baton->data = section->buffer + attr->as_unsigned ();
if (cu->base_address.has_value ())
baton->base_address = *cu->base_address;
else
@@ -24004,7 +24004,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
/* .debug_loc{,.dwo} may not exist at all, or the offset may be outside
the section. If so, fall through to the complaint in the
other branch. */
- && DW_UNSND (attr) < section->get_size (objfile))
+ && attr->as_unsigned () < section->get_size (objfile))
{
struct dwarf2_loclist_baton *baton;