I think you probably need to pass -O0 to llvm-ld. The link-time optimizations are probably killing your debug info. --Owen On May 5, 2008, at 8:21 PM, Mark Oskin wrote:> Hi everyone again, > > I did discover the following works (see below). However, does anyone > know of the "proper" way with LLVM? > > llvm-gcc -g -c -emit-llvm helloworld.c > opt -load=mypass.dylib -mypass < helloworld.o > helloworld-mypass.o > llc -fast -f -o helloworld.s helloworld-mypass.o > as -o helloworld-prime.o > gcc -o helloworld helloworld-prime.o > gdb helloworld > > On May 5, 2008, at 4:17 PM, Mark Oskin wrote: > >> Hi everyone, >> >> I have a question that seems simple, but has been confounding me for >> several hours. I'd like to debug a binary produced with LLVM. For >> the life of me, I can't get any symbols into gdb and llvm-db won't >> even start the program nor load any useful information about it. >> Here's my current strategy (which isn't working): >> >> llvm-gcc -g -O0 -c -emit-llvm helloworld.c >> opt -load=mypass.dylib -mypass < helloworld.o > helloworld-mypass.o >> llvm-ld -native -o helloworld helloworld-mypass.o >> gdb helloworld >> >> I've tried several variations on the above. >> >> Any suggestions? >> >> Note, what is critical about the whole thing is I must run "mypass" >> on >> the bytecode file. I'm hoping there's an easy fix, that will both >> allow me to run my arbitrary pass, and debug a program. >> >> thanks, >> >> -Mark >> _______________________________________________ >> LLVM Developers mailing list >> 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 -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4260 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080505/73986ba0/attachment.bin>
> I think you probably need to pass -O0 to llvm-ld. The link-time > optimizations are probably killing your debug info. >No dice. Doing it this way makes gdb spew out this: warning: Could not find object file "/var/folders/cQ/cQ+L3+RP2RWOpE +8ZNQdPU+++TI/-Tmp-//ccVljWhn.o" - no debug information available for "defs.h" And then no debug symbols are available. I also discovered a major down side to the "solution" I found last night. While the line number data does get successfully transfered into gdb, I cannot inspect any variables. Those appear to have been lost. Any other suggestions out there? thanks! -mark> --Owen > > On May 5, 2008, at 8:21 PM, Mark Oskin wrote: > >> Hi everyone again, >> >> I did discover the following works (see below). However, does anyone >> know of the "proper" way with LLVM? >> >> llvm-gcc -g -c -emit-llvm helloworld.c >> opt -load=mypass.dylib -mypass < helloworld.o > helloworld-mypass.o >> llc -fast -f -o helloworld.s helloworld-mypass.o >> as -o helloworld-prime.o >> gcc -o helloworld helloworld-prime.o >> gdb helloworld >> >> On May 5, 2008, at 4:17 PM, Mark Oskin wrote: >> >>> Hi everyone, >>> >>> I have a question that seems simple, but has been confounding me for >>> several hours. I'd like to debug a binary produced with LLVM. For >>> the life of me, I can't get any symbols into gdb and llvm-db won't >>> even start the program nor load any useful information about it. >>> Here's my current strategy (which isn't working): >>> >>> llvm-gcc -g -O0 -c -emit-llvm helloworld.c >>> opt -load=mypass.dylib -mypass < helloworld.o > helloworld-mypass.o >>> llvm-ld -native -o helloworld helloworld-mypass.o >>> gdb helloworld >>> >>> I've tried several variations on the above. >>> >>> Any suggestions? >>> >>> Note, what is critical about the whole thing is I must run >>> "mypass" on >>> the bytecode file. I'm hoping there's an easy fix, that will both >>> allow me to run my arbitrary pass, and debug a program. >>> >>> thanks, >>> >>> -Mark >>> _______________________________________________ >>> LLVM Developers mailing list >>> 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 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Just re-sending this. Anyone have any suggestions on how to proceed with debugging LLVM produced executables? The problem appears to be register-allocated variables. Global variables and syntax lines do get symbols using the llc / as method I described below. -Mark On May 6, 2008, at 7:36 AM, Mark Oskin wrote:> >> I think you probably need to pass -O0 to llvm-ld. The link-time >> optimizations are probably killing your debug info. >> > No dice. Doing it this way makes gdb spew out this: > > warning: Could not find object file "/var/folders/cQ/cQ+L3+RP2RWOpE > +8ZNQdPU+++TI/-Tmp-//ccVljWhn.o" - no debug information available for > "defs.h" > > And then no debug symbols are available. > > I also discovered a major down side to the "solution" I found last > night. While the line number data does get successfully transfered > into gdb, I cannot inspect any variables. Those appear to have been > lost. > > Any other suggestions out there? > > thanks! > > -mark > >> --Owen >> >> On May 5, 2008, at 8:21 PM, Mark Oskin wrote: >> >>> Hi everyone again, >>> >>> I did discover the following works (see below). However, does >>> anyone >>> know of the "proper" way with LLVM? >>> >>> llvm-gcc -g -c -emit-llvm helloworld.c >>> opt -load=mypass.dylib -mypass < helloworld.o > helloworld-mypass.o >>> llc -fast -f -o helloworld.s helloworld-mypass.o >>> as -o helloworld-prime.o >>> gcc -o helloworld helloworld-prime.o >>> gdb helloworld >>> >>> On May 5, 2008, at 4:17 PM, Mark Oskin wrote: >>> >>>> Hi everyone, >>>> >>>> I have a question that seems simple, but has been confounding me >>>> for >>>> several hours. I'd like to debug a binary produced with LLVM. For >>>> the life of me, I can't get any symbols into gdb and llvm-db won't >>>> even start the program nor load any useful information about it. >>>> Here's my current strategy (which isn't working): >>>> >>>> llvm-gcc -g -O0 -c -emit-llvm helloworld.c >>>> opt -load=mypass.dylib -mypass < helloworld.o > helloworld-mypass.o >>>> llvm-ld -native -o helloworld helloworld-mypass.o >>>> gdb helloworld >>>> >>>> I've tried several variations on the above. >>>> >>>> Any suggestions? >>>> >>>> Note, what is critical about the whole thing is I must run >>>> "mypass" on >>>> the bytecode file. I'm hoping there's an easy fix, that will both >>>> allow me to run my arbitrary pass, and debug a program. >>>> >>>> thanks, >>>> >>>> -Mark >>>> _______________________________________________ >>>> LLVM Developers mailing list >>>> 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 >> >> _______________________________________________ >> LLVM Developers mailing list >> 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