[LLVMbugs] [Bug 7595] New: DWARF debug info does not handle forward declarations properly
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Jul 8 08:36:26 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=7595
Summary: DWARF debug info does not handle forward declarations
properly
Product: clang
Version: trunk
Platform: Other
OS/Version: FreeBSD
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: kan at freebsd.org
CC: llvmbugs at cs.uiuc.edu
Created an attachment (id=5190)
--> (http://llvm.org/bugs/attachment.cgi?id=5190)
Create DICompositeType node with FlagFwdDecl for forward declatations of
scructs and unions
Given the following trivial example:
struct a;
union b;
void foo(struct a *ptr_a, union b *ptr_b)
{
}
clang 2.7 and trunk both end up generating the following DWARF info fragment do
describe pointers to struct a and union b:
<1>< 229> DW_TAG_structure_type
DW_AT_name fwd.type.0
DW_AT_byte_size 0
DW_AT_decl_file 2 /home/kan/test/ctf/test.c
DW_AT_decl_line 1
<1>< 244> DW_TAG_pointer_type
DW_AT_type <229>
DW_AT_byte_size 8
DW_AT_decl_file 2 /home/kan/test/ctf/test.c
DW_AT_decl_line 0
<1>< 252> DW_TAG_union_type
DW_AT_name fwd.type.1
DW_AT_byte_size 0
DW_AT_decl_file 2 /home/kan/test/ctf/test.c
DW_AT_decl_line 2
<1>< 267> DW_TAG_pointer_type
DW_AT_type <252>
DW_AT_byte_size 8
DW_AT_decl_file 2 /home/kan/test/ctf/test.c
DW_AT_decl_line 0
Note the use of fictitious zero-sized structures fwd.type.[12].
Attached patch attempts to fix this, by emitting proper struct and enum
definitions with DW_AT_declaration=1 for forward declarations. This results in
the following (correct) DWARF fragment:
<1>< 229> DW_TAG_structure_type
DW_AT_name a
DW_AT_declaration yes(1)
<1>< 233> DW_TAG_pointer_type
DW_AT_type <229>
DW_AT_byte_size 8
DW_AT_decl_file 2 /home/kan/test/ctf/test.c
DW_AT_decl_line 0
<1>< 241> DW_TAG_union_type
DW_AT_name b
DW_AT_declaration yes(1)
<1>< 245> DW_TAG_pointer_type
DW_AT_type <241>
DW_AT_byte_size 8
DW_AT_decl_file 2 /home/kan/test/ctf/test.c
DW_AT_decl_line 0
Note proper names and DW_TAG_declaration use and notice that respective
pointers now actually make sense.
As a side effect, this makes OpenSolaris' ctftools work properly on FreeBSD
kernel compiled with clang, instead of taking ages to compile, mostly sifting
though tons of fwd.type.<num> fictitious types.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list