This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/24570] New: unit-at-a-time: debug info not emitted for unused global variables
- From: "tomas dot vanek at fbl dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Oct 2005 16:47:55 -0000
- Subject: [Bug c/24570] New: unit-at-a-time: debug info not emitted for unused global variables
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Both
Target: i686-pc-linux-gnu
Configured with: ../configure --disable-nls --with-dwarf2
Thread model: posix
gcc version 4.0.2
and
Target: avr
Configured with: ../configure --prefix=/usr/local/avr --target=avr
--disable-nls --with-dwarf2 --enable-languages=c
Thread model: single
gcc version 4.0.2
do not emit stabs or emit incomplete dwarf debug info for an unused global
variable when compiled unit-at-a-time (-O2 or -Os).
var.c:
int used_variable;
int unused_variable __attribute__((unused));
int use_one(void)
{
return used_variable;
}
gcc -S var.c -gstabs
and avr-gcc -S -mmcu=atmega8 var.c -gstabs
works good and generates stabs for both variables
.Lscope0:
.comm used_variable,4,4
.comm unused_variable,4,4
.stabs "used_variable:G(0,1)",32,0,0,0
.stabs "unused_variable:G(0,1)",32,0,0,0
.stabs "",100,0,0,.Letext0
.Letext0:
gcc -S var.c -gstabs -funit-at-a-time
or avr-gcc -S -mmcu=atmega8 var.c -gstabs -funit-at-a-time
As soon as unit-at-a-time is active, stabs for unused var is gone
.Lscope0:
.stabs "used_variable:G(0,1)",32,0,0,0
.comm unused_variable,4,4
.comm used_variable,4,4
.stabs "",100,0,0,.Letext0
.Letext0:
gcc -S var.c -gdwarf-2 -dA -funit-at-a-time
or avr-gcc -S -mmcu=atmega8 var.c -gdwarf-2 -dA -funit-at-a-time
With dwarf, the unused variable is emited without location as if it was
external.
.uleb128 0x4 # (DIE (0x63) DW_TAG_variable)
.ascii "used_variable\0" # DW_AT_name
.byte 0x1 # DW_AT_decl_file
.byte 0x1 # DW_AT_decl_line
.long 0x5c # DW_AT_type
.byte 0x1 # DW_AT_external
.byte 0x5 # DW_AT_location
.byte 0x3 # DW_OP_addr
.long used_variable
.uleb128 0x5 # (DIE (0x7f) DW_TAG_variable)
.ascii "unused_variable\0" # DW_AT_name
.byte 0x1 # DW_AT_decl_file
.byte 0x2 # DW_AT_decl_line
.long 0x5c # DW_AT_type
.byte 0x1 # DW_AT_external
.byte 0x0 # end of children of DIE 0xb
.section .debug_abbrev
The problem is caused by calling c_write_global_declarations_2 () before
cgraph_varpool_assemble_pending_decls (), which generates rtx for unused
variables.
I tried a dirty hack: insert an extra call of
cgraph_varpool_assemble_pending_decls () into
procedure c_write_global_declarations() in c-decl.c just before the last block
if - for - c_write_global_declarations_2
and it solved the problem. Of course I don't know what it breaks...
--
Summary: unit-at-a-time: debug info not emitted for unused global
variables
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tomas dot vanek at fbl dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24570