This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[PATCH] Improve debug info for packed arrays with constant bounds (PR fortran/22244)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Cc: Alexandre Oliva <aoliva at redhat dot com>, Jan Kratochvil <jkratoch at redhat dot com>, Daniel Jacobowitz <drow at false dot org>
- Date: Tue, 14 Aug 2007 08:02:36 -0400
- Subject: [PATCH] Improve debug info for packed arrays with constant bounds (PR fortran/22244)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The following patch certainly doesn't address all problems with debug info
for arrays, but at least handles the most common easy case.
In gimple the arrays are still represented as flat arrays with zero lower
bound, but for debuginfo they are represented as multi-dimensional if rank >
1 and with correct bounds, provided all bounds are constant and the array
is packed.
Tested on x86_64, both with normal make check and make check with
RUNTESTFLAGS=--target_board=unix/-g
and also with gdb on:
integer a(0:5,7:15)
double precision b(3)
real c(-3:12,1:3,0:6)
a(:,:) = 1
a(0,7) = 5
a(5,15) = 6
b(:) = 3
b(1) = 2.5
b(2) = 6
c(:,:,:) = 0.5
c(-3,1,0) = 1
c(12,3,6) = 2
c(0,1,0) = 0.5
end
compiled with -g.
Ok for 4.3/4.2/4.1?
2007-08-14 Jakub Jelinek <jakub@redhat.com>
PR fortran/22244
* Make-lang.in (fortran/trans-types.o): Depend on $(FLAGS_H).
* trans-types.c: Include flags.h.
(gfc_get_nodesc_array_type): Add TYPE_DECL TYPE_NAME with
correct bounds and dimensions for packed arrays.
--- gcc/fortran/Make-lang.in (revision 127395)
+++ gcc/fortran/Make-lang.in (working copy)
@@ -310,7 +310,7 @@ fortran/trans-decl.o: $(GFORTRAN_TRANS_D
$(CGRAPH_H) $(TARGET_H) $(FUNCTION_H) $(FLAGS_H) $(RTL_H) $(TREE_GIMPLE_H) \
$(TREE_DUMP_H)
fortran/trans-types.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-types.h \
- $(REAL_H) toplev.h $(TARGET_H)
+ $(REAL_H) toplev.h $(TARGET_H) $(FLAGS_H)
fortran/trans-const.o: $(GFORTRAN_TRANS_DEPS)
fortran/trans-expr.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h
fortran/trans-stmt.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h
--- gcc/fortran/trans-types.c (revision 127395)
+++ gcc/fortran/trans-types.c (working copy)
@@ -36,6 +36,7 @@ along with GCC; see the file COPYING3.
#include "trans-types.h"
#include "trans-const.h"
#include "real.h"
+#include "flags.h"
#if (GFC_MAX_DIMENSIONS < 10)
@@ -1232,7 +1233,7 @@ gfc_get_nodesc_array_type (tree etype, g
{
/* Fill in the stride and bound components of the type. */
if (known_stride)
- tmp = gfc_conv_mpz_to_tree (stride, gfc_index_integer_kind);
+ tmp = gfc_conv_mpz_to_tree (stride, gfc_index_integer_kind);
else
tmp = NULL_TREE;
GFC_TYPE_ARRAY_STRIDE (type, n) = tmp;
@@ -1330,6 +1331,24 @@ gfc_get_nodesc_array_type (tree etype, g
mpz_clear (stride);
mpz_clear (delta);
+ /* In debug info represent packed arrays as multi-dimensional
+ if they have rank > 1 and with proper bounds, instead of flat
+ arrays. */
+ if (known_stride && write_symbols != NO_DEBUG)
+ {
+ tree gtype = etype, rtype, type_decl;
+
+ for (n = as->rank - 1; n >= 0; n--)
+ {
+ rtype = build_range_type (gfc_array_index_type,
+ GFC_TYPE_ARRAY_LBOUND (type, n),
+ GFC_TYPE_ARRAY_UBOUND (type, n));
+ gtype = build_array_type (gtype, rtype);
+ }
+ TYPE_NAME (type) = type_decl = build_decl (TYPE_DECL, NULL, gtype);
+ DECL_ORIGINAL_TYPE (type_decl) = gtype;
+ }
+
if (packed != PACKED_STATIC || !known_stride)
{
/* For dummy arrays and automatic (heap allocated) arrays we
Jakub