aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/dwarf2/attribute.c8
-rw-r--r--gdb/dwarf2/attribute.h27
-rw-r--r--gdb/dwarf2/read.c4
4 files changed, 47 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2305512..2ca7d3c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+2021-02-24 Tom de Vries <tdevries@suse.de>
+
+ PR symtab/27336
+ * dwarf2/attribute.c (attribute::form_is_signed): New function
+ factored out of ...
+ * dwarf2/attribute.h (attribute::as_signed): ... here.
+ (attribute::is_nonnegative, attribute::as_nonnegative): New function.
+ (attribute::form_is_signed): Declare.
+ * dwarf2/read.c (new_symbol): Use is_nonnegative and as_nonnegative
+ for DW_AT_decl_file.
+
2021-02-24 Kevin Buettner <kevinb@redhat.com>
* nat/aarch64-linux-hw-point.c: Add comment regarding include
diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c
index 3205b0f..6b8d541 100644
--- a/gdb/dwarf2/attribute.c
+++ b/gdb/dwarf2/attribute.c
@@ -190,6 +190,14 @@ attribute::form_is_unsigned () const
/* See attribute.h. */
bool
+attribute::form_is_signed () const
+{
+ return form == DW_FORM_sdata || form == DW_FORM_implicit_const;
+}
+
+/* See attribute.h. */
+
+bool
attribute::form_requires_reprocessing () const
{
return (form == DW_FORM_strx
diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h
index 56776d6..0af7470 100644
--- a/gdb/dwarf2/attribute.h
+++ b/gdb/dwarf2/attribute.h
@@ -70,7 +70,7 @@ struct attribute
form. */
LONGEST as_signed () const
{
- gdb_assert (form == DW_FORM_sdata || form == DW_FORM_implicit_const);
+ gdb_assert (form_is_signed ());
return u.snd;
}
@@ -92,6 +92,28 @@ struct attribute
return u.unsnd;
}
+ /* Return true if the value is nonnegative. Requires that that
+ reprocessing not be needed. */
+ bool is_nonnegative () const
+ {
+ if (form_is_unsigned ())
+ return true;
+ if (form_is_signed ())
+ return as_signed () >= 0;
+ return false;
+ }
+
+ /* Return the nonnegative value. Requires that that reprocessing not be
+ needed. */
+ ULONGEST as_nonnegative () const
+ {
+ if (form_is_unsigned ())
+ return as_unsigned ();
+ if (form_is_signed ())
+ return (ULONGEST)as_signed ();
+ gdb_assert (false);
+ }
+
/* Return non-zero if ATTR's value is a section offset --- classes
lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise.
You may use the as_unsigned method to retrieve such offsets.
@@ -147,6 +169,9 @@ struct attribute
/* Check if the attribute's form is an unsigned integer form. */
bool form_is_unsigned () const;
+ /* Check if the attribute's form is a signed integer form. */
+ bool form_is_signed () const;
+
/* Check if the attribute's form is a form that requires
"reprocessing". */
bool form_requires_reprocessing () const;
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 0fccce8..df7dd16 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -22225,10 +22225,10 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
attr = dwarf2_attr (die,
inlined_func ? DW_AT_call_file : DW_AT_decl_file,
cu);
- if (attr != nullptr && attr->form_is_unsigned ())
+ if (attr != nullptr && attr->is_nonnegative ())
{
file_name_index file_index
- = (file_name_index) attr->as_unsigned ();
+ = (file_name_index) attr->as_nonnegative ();
struct file_entry *fe;
if (cu->line_header != NULL)