[Bug debug/34037] New: [4.1/4.2/4.3 Regression] Bounds for VLAs not emitted into debuginfo
jakub at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Thu Nov 8 22:49:00 GMT 2007
With -g -O0 -dA
void bar (char *, char *, char *, int size);
void foo (int size)
{
char temp[size];
char temp3[48];
temp[size-1] = '\0';
{
char temp2[size];
bar (temp, temp2, temp3, size);
}
};
in 3.4.x we got:
...
.uleb128 0x4 # (DIE (0x74) DW_TAG_variable)
.byte 0x1 # DW_AT_artificial
.long 0x104 # DW_AT_type
.byte 0x6 # DW_AT_location
.byte 0x91 # DW_OP_fbreg
.sleb128 -20
.byte 0x94 # DW_OP_deref_size
.byte 0x4
.byte 0x31 # DW_OP_lit1
.byte 0x1c # DW_OP_minus
...
.uleb128 0x8 # (DIE (0xdc) DW_TAG_array_type)
.long 0xef # DW_AT_sibling
.long 0x115 # DW_AT_type
.uleb128 0x9 # (DIE (0xe5) DW_TAG_subrange_type)
.long 0xef # DW_AT_type
.long 0x74 # DW_AT_upper_bound
.byte 0x0 # end of children of DIE 0xdc
but 4.1/4.2/4.3 only have DW_AT_upper_bound for temp3 array where it is
constant.
There seem to be 2 problems. When gimplifying, the vars are gimplified into
temp vars in gimplify_type_sizes and as those vars are DECL_ARTIFICIAL and
DECL_IGNORED_P, they are usually even at -O0 just deleted as trivially dead
e.g. by CSE. This part could be fixed say by:
--- gcc/gimplify.c.jj 2007-10-30 11:46:29.000000000 +0100
+++ gcc/gimplify.c 2007-11-08 22:50:35.000000000 +0100
@@ -6171,6 +6171,18 @@ gimplify_type_sizes (tree type, tree *li
/* These types may not have declarations, so handle them here. */
gimplify_type_sizes (TREE_TYPE (type), list_p);
gimplify_type_sizes (TYPE_DOMAIN (type), list_p);
+ /* When not optimizing, ensure VLA bounds aren't removed. */
+ if (!optimize
+ && TYPE_DOMAIN (type)
+ && INTEGRAL_TYPE_P (TYPE_DOMAIN (type)))
+ {
+ t = TYPE_MIN_VALUE (TYPE_DOMAIN (type));
+ if (t && TREE_CODE (t) == VAR_DECL && DECL_ARTIFICIAL (t))
+ DECL_IGNORED_P (t) = 0;
+ t = TYPE_MAX_VALUE (TYPE_DOMAIN (type));
+ if (t && TREE_CODE (t) == VAR_DECL && DECL_ARTIFICIAL (t))
+ DECL_IGNORED_P (t) = 0;
+ }
break;
case RECORD_TYPE:
The next problem is on the dwarf2out.c side, in add_bound_info we have:
dw_die_ref decl_die = lookup_decl_die (bound);
/* ??? Can this happen, or should the variable have been bound
first? Probably it can, since I imagine that we try to create
the types of parameters in the order in which they exist in
the list, and won't have created a forward reference to a
later parameter. */
if (decl_die != NULL)
add_AT_die_ref (subrange_die, bound_attr, decl_die);
It seems most even non-artificial VAR_DECLs aren't even
equate_decl_number_to_die'ed, so lookup_decl_die won't find them anyway.
Ideas? For -O1 and above, I guess we need to wait for Alex or some alternate
representation which would allow us to see how can they be computed even if
they were optimized out.
--
Summary: [4.1/4.2/4.3 Regression] Bounds for VLAs not emitted
into debuginfo
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jakub at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34037
More information about the Gcc-bugs
mailing list