public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/115272] [debug] complex type is hard to related back to base type
Date: Wed, 29 May 2024 12:08:36 +0000	[thread overview]
Message-ID: <bug-115272-4-ynNw70V3YI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-115272-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115272

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
With this patch:
...
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 8ec3856873e..ea3318396e0 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -13247,6 +13247,7 @@ base_type_die (tree type, bool reverse)
   bool fpt_used = false;
   struct fixed_point_type_info fpt_info;
   tree type_bias = NULL_TREE;
+  tree type_attr = NULL_TREE;

   /* If this is a subtype that should not be emitted as a subrange type,
      use the base type.  See subrange_type_for_debug_p.  */
@@ -13342,6 +13343,8 @@ base_type_die (tree type, bool reverse)
        }
       else
        encoding = DW_ATE_lo_user;
+      if (!dwarf_strict)
+       type_attr = TREE_TYPE (type);
       break;

     case BOOLEAN_TYPE:
@@ -13421,6 +13424,13 @@ base_type_die (tree type, bool reverse)
                     | dw_scalar_form_reference,
                     NULL);

+  if (type_attr != NULL_TREE)
+    {
+      dw_die_ref type_attr_die
+       = modified_type_die (type_attr, 0, reverse, comp_unit_die ());
+      add_AT_die_ref (base_type_result, DW_AT_type, type_attr_die);
+    }
+
   return base_type_result;
 }

...
on x86_64 we get:
...
 <1><32>: Abbrev Number: 2 (DW_TAG_base_type)
    <33>   DW_AT_byte_size   : 4
    <34>   DW_AT_encoding    : 4        (float)
    <34>   DW_AT_name        : float
 <1><38>: Abbrev Number: 3 (DW_TAG_base_type)
    <39>   DW_AT_byte_size   : 8
    <3a>   DW_AT_encoding    : 3        (complex float)
    <3a>   DW_AT_type        : <0x32>
    <3e>   DW_AT_name        : complex float
 <1><56>: Abbrev Number: 2 (DW_TAG_base_type)
    <57>   DW_AT_byte_size   : 8
    <58>   DW_AT_encoding    : 4        (float)
    <58>   DW_AT_name        : double
 <1><5c>: Abbrev Number: 3 (DW_TAG_base_type)
    <5d>   DW_AT_byte_size   : 16
    <5e>   DW_AT_encoding    : 3        (complex float)
    <5e>   DW_AT_type        : <0x56>
    <62>   DW_AT_name        : complex double
 <1><7b>: Abbrev Number: 2 (DW_TAG_base_type)
    <7c>   DW_AT_byte_size   : 16
    <7d>   DW_AT_encoding    : 4        (float)
    <7d>   DW_AT_name        : long double
 <1><81>: Abbrev Number: 3 (DW_TAG_base_type)
    <82>   DW_AT_byte_size   : 32
    <83>   DW_AT_encoding    : 3        (complex float)
    <83>   DW_AT_type        : <0x7b>
    <87>   DW_AT_name        : complex long double
...

  parent reply	other threads:[~2024-05-29 12:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-29  9:49 [Bug debug/115272] New: " vries at gcc dot gnu.org
2024-05-29 11:18 ` [Bug debug/115272] " rguenth at gcc dot gnu.org
2024-05-29 11:19 ` rguenth at gcc dot gnu.org
2024-05-29 12:03 ` vries at gcc dot gnu.org
2024-05-29 12:08 ` vries at gcc dot gnu.org [this message]
2024-06-19 15:38 ` 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-115272-4-ynNw70V3YI@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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).