Matt Pharr
2011-Apr-30 00:49 UTC
[LLVMdev] DWARF not being generated for local variable, though MD looks right(?)
I'm running into a problem with generating debugging information that I'm not sure how to debug; I'd be happy to have some suggestions about where to start digging in. In short, I believe that I'm correctly generating debug info (with DIBuilder, which has so far been quite nice!), and a scan of the meta-data in the IR looks generally right. However, if I run dwarfdump on my object file, I'm not seeing any DIE information for the local variables. I'm wondering what might be going wrong along the way. More specifically, given a program that is equivalent to the following in C: float foo() { float y = 1234; return y; } My compiler generates the following IR (pay no attention to the ___ at the end of "foo"..): define i32 @foo___(<4 x i32>) nounwind readnone alwaysinline { entry: tail call void @llvm.dbg.value(metadata !6, i64 0, metadata !4), !dbg !7 ret i32 1234 } declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone !llvm.dbg.sp = !{!0} !llvm.dbg.lv.foo___ = !{!4} !0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"foo", metadata !"foo", metadata !"foo___", metadata !1, i32 4, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 0, i1 true, i32 (<4 x i32>)* @foo___, null, null} ; [ DW_TAG_subprogram ] !1 = metadata !{i32 589865, metadata !"a.c", metadata !"/Users/mmp/foo/", metadata !2} ; [ DW_TAG_file_type ] !2 = metadata !{i32 589841, i32 0, i32 12, metadata !"a.c", metadata !"/Users/mmp/foo", metadata !"foo", i1 true, i1 true, metadata !"-g", i32 0} ; [ DW_TAG_compile_unit ] !3 = metadata !{i32 589860, metadata !2, metadata !"int32", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] !4 = metadata !{i32 590080, metadata !5, metadata !"y", metadata !1, i32 5, metadata !3, i32 0} ; [ DW_TAG_auto_variable ] !5 = metadata !{i32 589835, metadata !0, i32 4, i32 0, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] !6 = metadata !{i32 1234} !7 = metadata !{i32 5, i32 0, metadata !5, null} However, if I run dwarfdump on the object file, there's nothing there for the variable 'y' (see below). Note that I am able to get correct DWARF output for global variables, so presumably the rest of my infrastructure isn't totally broken. Any guidance about how best to proceed would be greatly appreciated! Thanks, -matt ---------------------------------------------------------------------- File: a.o (x86_64) ---------------------------------------------------------------------- .debug_info contents: 0x00000000: Compile Unit: length = 0x00000043 version = 0x0002 abbr_offset = 0x00000000 addr_size = 0x08 (next CU at 0x00000047) 0x0000000b: TAG_compile_unit [1] * AT_producer( "volta" ) AT_language( DW_LANG_C99 ) AT_name( "a.c" ) AT_entry_pc( 0x0000000000000000 ) AT_stmt_list( 0x00000000 ) AT_comp_dir( "/Users/mmp/foo" ) AT_APPLE_optimized( 0x01 ) AT_APPLE_flags( "-g" ) 0x00000039: TAG_subprogram [2] AT_name( "foo" ) AT_MIPS_linkage_name( "foo___" ) AT_external( 0x01 ) 0x00000046: NULL
Devang Patel
2011-May-02 16:36 UTC
[LLVMdev] DWARF not being generated for local variable, though MD looks right(?)
On Apr 29, 2011, at 5:49 PM, Matt Pharr wrote:> I'm running into a problem with generating debugging information that I'm not sure how to debug; I'd be happy to have some suggestions about where to start digging in. > > In short, I believe that I'm correctly generating debug info (with DIBuilder, which has so far been quite nice!), and a scan of the meta-data in the IR looks generally right. However, if I run dwarfdump on my object file, I'm not seeing any DIE information for the local variables. I'm wondering what might be going wrong along the way. > > More specifically, given a program that is equivalent to the following in C: > > float foo() { > float y = 1234; > return y; > } > > My compiler generates the following IR (pay no attention to the ___ at the end of "foo"..): > > define i32 @foo___(<4 x i32>) nounwind readnone alwaysinline { > entry: > tail call void @llvm.dbg.value(metadata !6, i64 0, metadata !4), !dbg !7 > ret i32 1234 > } >Here there is not any instruction (ignoring dbg intrinsics) with line number information. If you add !dbg !7 at the end of 'ret' then it'll work. - Devang> declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone > > !llvm.dbg.sp = !{!0} > !llvm.dbg.lv.foo___ = !{!4} > > !0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"foo", metadata !"foo", metadata !"foo___", metadata !1, i32 4, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 0, i1 true, i32 (<4 x i32>)* @foo___, null, null} ; [ DW_TAG_subprogram ] > !1 = metadata !{i32 589865, metadata !"a.c", metadata !"/Users/mmp/foo/", metadata !2} ; [ DW_TAG_file_type ] > !2 = metadata !{i32 589841, i32 0, i32 12, metadata !"a.c", metadata !"/Users/mmp/foo", metadata !"foo", i1 true, i1 true, metadata !"-g", i32 0} ; [ DW_TAG_compile_unit ] > !3 = metadata !{i32 589860, metadata !2, metadata !"int32", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] > !4 = metadata !{i32 590080, metadata !5, metadata !"y", metadata !1, i32 5, metadata !3, i32 0} ; [ DW_TAG_auto_variable ] > !5 = metadata !{i32 589835, metadata !0, i32 4, i32 0, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] > !6 = metadata !{i32 1234} > !7 = metadata !{i32 5, i32 0, metadata !5, null} > > However, if I run dwarfdump on the object file, there's nothing there for the variable 'y' (see below). Note that I am able to get correct DWARF output for global variables, so presumably the rest of my infrastructure isn't totally broken. > > Any guidance about how best to proceed would be greatly appreciated! > > Thanks, > -matt > > > ---------------------------------------------------------------------- > File: a.o (x86_64) > ---------------------------------------------------------------------- > .debug_info contents: > > 0x00000000: Compile Unit: length = 0x00000043 version = 0x0002 abbr_offset = 0x00000000 addr_size = 0x08 (next CU at 0x00000047) > > 0x0000000b: TAG_compile_unit [1] * > AT_producer( "volta" ) > AT_language( DW_LANG_C99 ) > AT_name( "a.c" ) > AT_entry_pc( 0x0000000000000000 ) > AT_stmt_list( 0x00000000 ) > AT_comp_dir( "/Users/mmp/foo" ) > AT_APPLE_optimized( 0x01 ) > AT_APPLE_flags( "-g" ) > > 0x00000039: TAG_subprogram [2] > AT_name( "foo" ) > AT_MIPS_linkage_name( "foo___" ) > AT_external( 0x01 ) > > 0x00000046: NULL > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110502/f6157c66/attachment.html>
Renato Golin
2011-May-02 20:39 UTC
[LLVMdev] DWARF not being generated for local variable, though MD looks right(?)
On 2 May 2011 17:36, Devang Patel <dpatel at apple.com> wrote:> Here there is not any instruction (ignoring dbg intrinsics) with line number > information. If you add !dbg !7 at the end of 'ret' then it'll work.Hi Devang, Why does type/variable information depend on line information? cheers, --renato
Seemingly Similar Threads
- [LLVMdev] DWARF not being generated for local variable, though MD looks right(?)
- [LLVMdev] DWARF not being generated for local variable, though MD looks right(?)
- [LLVMdev] DWARF not being generated for local variable, though MD looks right(?)
- [LLVMdev] Writing unit tests for DWARF?
- [LLVMdev] dwarf directory table and file table