public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/27336] [dwarf-5] abort on info addr in gdb.cp/temargs.exp
Date: Wed, 03 Feb 2021 18:18:12 +0000	[thread overview]
Message-ID: <bug-27336-4717-0kMQ9ettBe@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-27336-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=27336

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
Tentative fix:
...
diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h
index aded129764a..baf93903d19 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 () >= (LONGEST)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 bcac94ed36a..35e6ba0044a 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -21427,10 +21427,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)
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2021-02-03 18:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-03 14:17 [Bug symtab/27336] New: " vries at gcc dot gnu.org
2021-02-03 15:28 ` [Bug symtab/27336] " vries at gcc dot gnu.org
2021-02-03 16:51 ` vries at gcc dot gnu.org
2021-02-03 18:18 ` vries at gcc dot gnu.org [this message]
2021-02-04 10:08 ` vries at gcc dot gnu.org
2021-02-05 12:32 ` vries at gcc dot gnu.org
2021-02-22  2:37 ` tromey at sourceware dot org
2021-02-24 22:58 ` cvs-commit at gcc dot gnu.org
2021-02-24 22:59 ` vries at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-27336-4717-0kMQ9ettBe@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).