[LLVMdev] Dwarf debug info misses while clang codegen
Kevin
keigi1203 at gmail.com
Tue Aug 21 02:16:08 PDT 2012
I'm trying to write a llvm pass to add debug info into a non-debug-info bitcode
file. I have been read http://llvm.org/docs/SourceLevelDebugging.html. And I use
DIBuilder to produce the debug metadata. I know I can't get all information form
ir code . So I add some manual info as test data. After executing my pass, I can
find debug info metadata in my generated bitcode. Those metadata include
"DICompileUnit" , "DIFile", "DIVariable" ,"DISubprogram", "DILexicalBlock".
Just like
------------------------------------------------------------------------------
84 !0 = metadata !{i32 786449, i32 0, i32 4, metadata !"hello.cpp", metadata
!"/proj/mtk04456", metadata !"clang version", i1 true, i1 true, metadata
!"flag", i32 0, metadata !1, metadata !1, metadata !1, metadata !1} ; [
DW_TAG_compile_unit ] [/p roj/mtk04456/hello.cpp] [DW_LANG_C_plus_plus]
------------------------------------------------------------------------------
First problem happen : DICompileUnit doesn't find the last four metadata (i.e.
enums types, retained types, subprograms, global variables). But
DIBuilder::CreateCompileUnit(...) doesn't need any MDNode* arg. It will find
those four metadata in the function. I don't know why it can't point to right
reference. So I use MDNode::getOperand(..)->replaceAllUseWith(...) to replace
those four metadata with right MDNode.
But when I compile my new bitcode to elf file. ( clang++ -g hello.bc -o exec)
I can't find my debug info when I use readelf. ( readelf -w exec > log )
There just have one TAG .
Number TAG
1 DW_TAG_compile_unit [no children]
DW_AT_producer DW_FORM_strp
DW_AT_language DW_FORM_data2
DW_AT_name DW_FORM_strp
DW_AT_low_pc DW_FORM_addr
DW_AT_stmt_list DW_FORM_data4
DW_AT_comp_dir DW_FORM_strp
Unknown AT value: 3fe1 DW_FORM_flag
Unknown AT value: 3fe2 DW_FORM_strp
I can't find other dwarf TAG in my object file.
Is the metadata wrong? Or I loss some step when I generate metadata?
If you need my pass's source. Please give me your mail. I will mail it for you.
Thanks!!
More information about the llvm-dev
mailing list