public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Fix debug info for packed array types in Ada
@ 2021-09-03  8:54 Eric Botcazou
  2021-09-06  7:04 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Botcazou @ 2021-09-03  8:54 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 664 bytes --]

Hi,

packed array types are sometimes represented with integer types under the hood
in Ada, but we nevertheless need to emit them as array types in the debug info
so we have the types.get_array_descr_info langhook for this purpose; but it is
not invoked from modified_type_die, which is responsible for:

FAIL: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all
FAIL: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all(3)

in the GDB testsuite.

Tested on x86-64/Linux, both GCC and GDB, OK for the mainline?


2021-09-03  Eric Botcazou  <ebotcazou@adacore.com>

	* dwarf2out.c (modified_type_die): Deal with all array types earlier.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1686 bytes --]

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 07a479f6382..85fc24cc2b6 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -13542,6 +13542,7 @@ modified_type_die (tree type, int cv_quals, bool reverse,
   tree qualified_type;
   tree name, low, high;
   dw_die_ref mod_scope;
+  struct array_descr_info info;
   /* Only these cv-qualifiers are currently handled.  */
   const int cv_qual_mask = (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE
 			    | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC | 
@@ -13786,6 +13787,13 @@ modified_type_die (tree type, int cv_quals, bool reverse,
 	    }
 	}
     }
+  else if (TREE_CODE (type) == ARRAY_TYPE
+	   || (lang_hooks.types.get_array_descr_info
+	       && lang_hooks.types.get_array_descr_info (type, &info)))
+    {
+      gen_type_die (type, context_die);
+      return lookup_type_die (type);
+    }
   else if (code == INTEGER_TYPE
 	   && TREE_TYPE (type) != NULL_TREE
 	   && subrange_type_for_debug_p (type, &low, &high))
@@ -13836,13 +13844,12 @@ modified_type_die (tree type, int cv_quals, bool reverse,
 	      return lookup_type_die (t);
 	  return lookup_type_die (type);
 	}
-      else if (TREE_CODE (type) != VECTOR_TYPE
-	       && TREE_CODE (type) != ARRAY_TYPE)
-	return lookup_type_die (type_main_variant (type));
-      else
-	/* Vectors have the debugging information in the type,
-	   not the main variant.  */
+      /* Vectors have the debugging information in the type,
+	 not the main variant.  */
+      else if (TREE_CODE (type) == VECTOR_TYPE)
 	return lookup_type_die (type);
+      else
+	return lookup_type_die (type_main_variant (type));
     }
 
   /* Builtin types don't have a DECL_ORIGINAL_TYPE.  For those,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] Fix debug info for packed array types in Ada
  2021-09-03  8:54 [patch] Fix debug info for packed array types in Ada Eric Botcazou
@ 2021-09-06  7:04 ` Richard Biener
  2021-09-06  9:02   ` Eric Botcazou
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2021-09-06  7:04 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: GCC Patches

On Fri, Sep 3, 2021 at 10:55 AM Eric Botcazou <botcazou@adacore.com> wrote:
>
> Hi,
>
> packed array types are sometimes represented with integer types under the hood
> in Ada, but we nevertheless need to emit them as array types in the debug info
> so we have the types.get_array_descr_info langhook for this purpose; but it is
> not invoked from modified_type_die, which is responsible for:
>
> FAIL: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all
> FAIL: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all(3)
>
> in the GDB testsuite.
>
> Tested on x86-64/Linux, both GCC and GDB, OK for the mainline?

OK, I suppose this should also help some Fortran array descriptor cases?

Richard.

>
> 2021-09-03  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * dwarf2out.c (modified_type_die): Deal with all array types earlier.
>
> --
> Eric Botcazou

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] Fix debug info for packed array types in Ada
  2021-09-06  7:04 ` Richard Biener
@ 2021-09-06  9:02   ` Eric Botcazou
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Botcazou @ 2021-09-06  9:02 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

> OK, I suppose this should also help some Fortran array descriptor cases?

Thanks.  This changes something only if array types in the source code are not 
always represented by ARRAY_TYPEs in the IR.

-- 
Eric Botcazou



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-06  9:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03  8:54 [patch] Fix debug info for packed array types in Ada Eric Botcazou
2021-09-06  7:04 ` Richard Biener
2021-09-06  9:02   ` Eric Botcazou

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).