Peter Mackay
2015-May-08 06:29 UTC
[LLVMdev] Getting llc to emit debug info into a obj file from source .ll
Hello, I'm working on a binary translator project that emits an .ll file. I'm trying to debug it in Visual Studio and would like to be able to step through and see my generated .ll file in the debugger. Does LLVM support debug information corresponding to an input .ll file? My hunch is "no, as it expects debug info to come from Clang." I assemble it using: llc -filetype=obj -O0 -mtriple=x86_64-pc-windows-msvc -o=output.obj input.ll I've ran objdump on the file as follows: llvm-objdump -section-headers output.obj and see the following output: output.obj: file format COFF-x86-64 Sections: Idx Name Size Address Type 0 .text 00000012 0000000000000000 TEXT 1 .data 00000000 0000000000000000 DATA 2 .bss 00000000 0000000000000000 BSS 3 .drectve 00000018 0000000000000000 4 .xdata 00000008 0000000000000000 DATA 5 .pdata 0000000c 0000000000000000 DATA I don't think there's debugging information there, as the .text section is very small. Thanks, Peter
Robinson, Paul
2015-May-08 14:26 UTC
[LLVMdev] Getting llc to emit debug info into a obj file from source .ll
> -----Original Message----- > From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On > Behalf Of Peter Mackay > Sent: Thursday, May 07, 2015 11:29 PM > To: llvmdev at cs.uiuc.edu > Subject: [LLVMdev] Getting llc to emit debug info into a obj file from > source .ll > > Hello, > > I'm working on a binary translator project that emits an .ll file. I'm > trying to debug it in Visual Studio and would like to be able to step > through and see my generated .ll file in the debugger. > > Does LLVM support debug information corresponding to an input .ll > file? My hunch is "no, as it expects debug info to come from Clang."That's exactly right.> > I assemble it using: > > llc -filetype=obj -O0 -mtriple=x86_64-pc-windows-msvc -o=output.obj > input.ll > > I've ran objdump on the file as follows: > > llvm-objdump -section-headers output.obj > > and see the following output: > > output.obj: file format COFF-x86-64 > > Sections: > Idx Name Size Address Type > 0 .text 00000012 0000000000000000 TEXT > 1 .data 00000000 0000000000000000 DATA > 2 .bss 00000000 0000000000000000 BSS > 3 .drectve 00000018 0000000000000000 > 4 .xdata 00000008 0000000000000000 DATA > 5 .pdata 0000000c 0000000000000000 DATA > > I don't think there's debugging information there, as the .text > section is very small.DWARF info would be in sections whose names start with ".debug_" and not in the .text section. --paulr> > Thanks, > Peter > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
David Blaikie
2015-May-08 17:10 UTC
[LLVMdev] Getting llc to emit debug info into a obj file from source .ll
On Thu, May 7, 2015 at 11:29 PM, Peter Mackay <mackay.pete+llvm at gmail.com> wrote:> Hello, > > I'm working on a binary translator project that emits an .ll file. I'm > trying to debug it in Visual Studio and would like to be able to step > through and see my generated .ll file in the debugger. > > Does LLVM support debug information corresponding to an input .ll > file?For a brief time we had a "DebugIR" pass that would add debug info to unannotated IR so your debugger could step through at the IR level (rather than, say, the C++ level, etc). It bitrotted quickly & was removed due to lack of ownership/maintenance. - David> My hunch is "no, as it expects debug info to come from Clang." > > I assemble it using: > > llc -filetype=obj -O0 -mtriple=x86_64-pc-windows-msvc -o=output.obj > input.ll > > I've ran objdump on the file as follows: > > llvm-objdump -section-headers output.obj > > and see the following output: > > output.obj: file format COFF-x86-64 > > Sections: > Idx Name Size Address Type > 0 .text 00000012 0000000000000000 TEXT > 1 .data 00000000 0000000000000000 DATA > 2 .bss 00000000 0000000000000000 BSS > 3 .drectve 00000018 0000000000000000 > 4 .xdata 00000008 0000000000000000 DATA > 5 .pdata 0000000c 0000000000000000 DATA > > I don't think there's debugging information there, as the .text > section is very small. > > Thanks, > Peter > _______________________________________________ > 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/20150508/d01a9759/attachment.html>
Philip Reames
2015-May-08 20:10 UTC
[LLVMdev] Getting llc to emit debug info into a obj file from source .ll
On 05/08/2015 10:10 AM, David Blaikie wrote:> > > On Thu, May 7, 2015 at 11:29 PM, Peter Mackay > <mackay.pete+llvm at gmail.com <mailto:mackay.pete+llvm at gmail.com>> wrote: > > Hello, > > I'm working on a binary translator project that emits an .ll file. I'm > trying to debug it in Visual Studio and would like to be able to step > through and see my generated .ll file in the debugger. > > Does LLVM support debug information corresponding to an input .ll > file? > > > For a brief time we had a "DebugIR" pass that would add debug info to > unannotated IR so your debugger could step through at the IR level > (rather than, say, the C++ level, etc). It bitrotted quickly & was > removed due to lack of ownership/maintenance.Personally, I would love to see this restored since it's a very useful tool, but I don't have the expertise or time to assist with anything other than reviews.> > - David > > My hunch is "no, as it expects debug info to come from Clang." > > I assemble it using: > > llc -filetype=obj -O0 -mtriple=x86_64-pc-windows-msvc > -o=output.obj input.ll > > I've ran objdump on the file as follows: > > llvm-objdump -section-headers output.obj > > and see the following output: > > output.obj: file format COFF-x86-64 > > Sections: > Idx Name Size Address Type > 0 .text 00000012 0000000000000000 TEXT > 1 .data 00000000 0000000000000000 DATA > 2 .bss 00000000 0000000000000000 BSS > 3 .drectve 00000018 0000000000000000 > 4 .xdata 00000008 0000000000000000 DATA > 5 .pdata 0000000c 0000000000000000 DATA > > I don't think there's debugging information there, as the .text > section is very small. > > Thanks, > Peter > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> > http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > > _______________________________________________ > 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/20150508/697c9310/attachment.html>
Peter Mackay
2015-May-11 14:38 UTC
[LLVMdev] Getting llc to emit debug info into a obj file from source .ll
Thanks to all those who replied. Sorry for the delay in my getting back to the thread. I was able to somewhat work around the problem of having no debug info by first compiling the IR to an assembly file using the -S flag, and then assembling that to an object file using -c. Obviously the debug info corresponds to the assembly language file, but for my purposes this is actually OK. The IR file would be better, but there's not much difference in readability for my project as the labels and such are visible in the asm file. The debug info does indeed appear in sections named .debug_*. Currently the debug info only seems to work with Xcode, but it is there. I will investigate how to get the debug info into a format that MSVC understands. (CodeView?) Thanks again, Peter On 8 May 2015 at 15:26, Robinson, Paul <Paul_Robinson at playstation.sony.com> wrote:>> -----Original Message----- >> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On >> Behalf Of Peter Mackay >> Sent: Thursday, May 07, 2015 11:29 PM >> To: llvmdev at cs.uiuc.edu >> Subject: [LLVMdev] Getting llc to emit debug info into a obj file from >> source .ll >> >> Hello, >> >> I'm working on a binary translator project that emits an .ll file. I'm >> trying to debug it in Visual Studio and would like to be able to step >> through and see my generated .ll file in the debugger. >> >> Does LLVM support debug information corresponding to an input .ll >> file? My hunch is "no, as it expects debug info to come from Clang." > > That's exactly right. > >> >> I assemble it using: >> >> llc -filetype=obj -O0 -mtriple=x86_64-pc-windows-msvc -o=output.obj >> input.ll >> >> I've ran objdump on the file as follows: >> >> llvm-objdump -section-headers output.obj >> >> and see the following output: >> >> output.obj: file format COFF-x86-64 >> >> Sections: >> Idx Name Size Address Type >> 0 .text 00000012 0000000000000000 TEXT >> 1 .data 00000000 0000000000000000 DATA >> 2 .bss 00000000 0000000000000000 BSS >> 3 .drectve 00000018 0000000000000000 >> 4 .xdata 00000008 0000000000000000 DATA >> 5 .pdata 0000000c 0000000000000000 DATA >> >> I don't think there's debugging information there, as the .text >> section is very small. > > DWARF info would be in sections whose names start with ".debug_" > and not in the .text section. > --paulr > >> >> Thanks, >> Peter >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev