Devang Patel
2011-Feb-24 19:52 UTC
[LLVMdev] [patch] Dwarf Debug info support for COFF object files
On Feb 24, 2011, at 11:36 AM, Devang Patel wrote:> > On Feb 12, 2011, at 2:07 AM, Nathan Jeffords wrote: > >> Hello All, >> >> I have created a set of patches that get dwarf debugging support working for the COFF object file. I also believe I have fixed what appears to be a bug in how line info sections are referred to from the DW_TAG_compile_unit DIE. I have run some basic tests, analyzed dumps of both the objects files and the final executables, and run a test program against mingw-gdb and everything looks to be in order. >> >> Here is a short description of what the patches accomplish >> >> die.patch: >> adds a new DIEValue type to represent a section relative label. (their was already a type id specified so I provided a class modeled after DIELabel) >> >> secrel-fixup.patch: >> creats a new target specific fixup type (reloc_coff_secrel32) to represent COFF Section Relative relocations and updats the COFF object writer to write it as COFF_IMAGE_REL_AMD64_SREL32 >> >> secrel-streamer.patch >> adds a new directive in the MCStreamer interface to allow the AsmPrinter to emit a section relative label and provides implementations for all existings Streamer (all but WinCOFF either forward or error on it) >> >> secrel-dwarf.patch >> updates dwarf printing code to make use of the new directive & DIE value where appropriate (this is where the bug fix is) >> >> coff-debug.patch >> turns the dwarf output on in the X86/COFF AsmInfo classes > > This patches look fine. I am curious, how are you testing debug info support for COFF ?Well, this patch fails following FE tests on darwin. LLVM :: FrontendC++/2006-11-06-StackTrace.cpp LLVM :: FrontendC++/2006-11-30-Pubnames.cpp LLVM :: FrontendC++/2010-08-31-ByValArg.cpp LLVM :: FrontendC/2009-02-17-BitField-dbg.c LLVM :: FrontendC/2010-01-14-StaticVariable.c LLVM :: FrontendC/2010-02-16-DbgVarScope.c LLVM :: FrontendObjC/2009-08-17-DebugInfo.m - Devang
Devang Patel
2011-Feb-24 21:08 UTC
[LLVMdev] [patch] Dwarf Debug info support for COFF object files
On Feb 24, 2011, at 11:52 AM, Devang Patel wrote:> > On Feb 24, 2011, at 11:36 AM, Devang Patel wrote: > >> >> On Feb 12, 2011, at 2:07 AM, Nathan Jeffords wrote: >> >>> Hello All, >>> >>> I have created a set of patches that get dwarf debugging support working for the COFF object file. I also believe I have fixed what appears to be a bug in how line info sections are referred to from the DW_TAG_compile_unit DIE. I have run some basic tests, analyzed dumps of both the objects files and the final executables, and run a test program against mingw-gdb and everything looks to be in order. >>> >>> Here is a short description of what the patches accomplish >>> >>> die.patch: >>> adds a new DIEValue type to represent a section relative label. (their was already a type id specified so I provided a class modeled after DIELabel) >>> >>> secrel-fixup.patch: >>> creats a new target specific fixup type (reloc_coff_secrel32) to represent COFF Section Relative relocations and updats the COFF object writer to write it as COFF_IMAGE_REL_AMD64_SREL32 >>> >>> secrel-streamer.patch >>> adds a new directive in the MCStreamer interface to allow the AsmPrinter to emit a section relative label and provides implementations for all existings Streamer (all but WinCOFF either forward or error on it) >>> >>> secrel-dwarf.patch >>> updates dwarf printing code to make use of the new directive & DIE value where appropriate (this is where the bug fix is) >>> >>> coff-debug.patch >>> turns the dwarf output on in the X86/COFF AsmInfo classes >> >> This patches look fine. I am curious, how are you testing debug info support for COFF ? > > Well, this patch fails following FE tests on darwin. > LLVM :: FrontendC++/2006-11-06-StackTrace.cpp > LLVM :: FrontendC++/2006-11-30-Pubnames.cpp > LLVM :: FrontendC++/2010-08-31-ByValArg.cpp > LLVM :: FrontendC/2009-02-17-BitField-dbg.c > LLVM :: FrontendC/2010-01-14-StaticVariable.c > LLVM :: FrontendC/2010-02-16-DbgVarScope.c > LLVM :: FrontendObjC/2009-08-17-DebugInfo.mThis is because of @@ -1903,7 +1912,8 @@ addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_addr, Asm->GetTempSymbol("section_line")); else - addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0); + addSectionOffset(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_addr, + Asm->GetTempSymbol("section_line")); if (!Dir.empty()) addString(Die, dwarf::DW_AT_comp_dir, dwarf::DW_FORM_string, Dir); You probably wanted to do... @@ -1904,8 +1913,8 @@ // DW_AT_stmt_list is a offset of line number information for this // compile unit in debug_line section. if (Asm->MAI->doesDwarfUsesAbsoluteLabelForStmtList()) - addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_addr, - Asm->GetTempSymbol("section_line")); + addSectionOffset(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_addr, + Asm->GetTempSymbol("section_line")); else addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0); I updated this part and applied your patch. r126425 Thanks for the contribution! - Devang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110224/f64e8829/attachment.html>
Nathan Jeffords
2011-Feb-25 03:45 UTC
[LLVMdev] [patch] Dwarf Debug info support for COFF object files
Thanks for taking the time to review this and get it into the mainline. [snip] This is because of> > @@ -1903,7 +1912,8 @@ > addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_addr, > Asm->GetTempSymbol("section_line")); > else > - addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0); > + addSectionOffset(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_addr, > + Asm->GetTempSymbol("section_line")); > > if (!Dir.empty()) > addString(Die, dwarf::DW_AT_comp_dir, dwarf::DW_FORM_string, Dir); > > > You probably wanted to do... > > @@ -1904,8 +1913,8 @@ > // DW_AT_stmt_list is a offset of line number information for this > // compile unit in debug_line section. > if (Asm->MAI->doesDwarfUsesAbsoluteLabelForStmtList()) > - addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_addr, > - Asm->GetTempSymbol("section_line")); > + addSectionOffset(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_addr, > + Asm->GetTempSymbol("section_line")); > else > addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0); > >I am not sure about this, Looking at it now I don't understand what the return value of doesDwarfUsesAbsoluteLabelForStmtList is supposed to mean. I know that when I allowed the COFF's MCAsmInfo to use this line: addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0); I got a relocation that caused an absolute pointer to the debug_line section instead of the offset from the beginning of the section. This looked like a bug too me. To me it doesn't matter: I can change DwarfUsesAbsoluteLabelForStmtList to true for MCAsmInfoCOFF and get the correct behavior for COFF output. [snip] -Nathan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110224/1b91218c/attachment.html>
Seemingly Similar Threads
- [LLVMdev] [patch] Dwarf Debug info support for COFF object files
- [LLVMdev] Debug information under windows
- [LLVMdev] Debug information under windows
- [LLVMdev] [patch] DwarfDebug problem with line section
- [LLVMdev] [patch] DwarfDebug problem with line section