[LLVMdev] clang with -emit-llvm

Dmitry Mikushin dmitry at kernelgen.org
Tue Jan 1 12:19:33 PST 2013


Somenath,

Are you attaching debugger to clang? In this case - clang is just a driver,
that invokes other executables for each individual step of compilation.
Most likely you should debug clang's cc1:

marcusmae at M17xR4:~/rpmbuild/BUILD/llvm/build$ gdb clang
(gdb) b llvm::BasicBlock::Create
Breakpoint 1 at 0x9f0965: file
/home/marcusmae/rpmbuild/BUILD/llvm/build/include/llvm/BasicBlock.h, line
104.
(gdb) r *-cc1* -S test.c -emit-llvm -o -
Starting program: /home/marcusmae/rpmbuild/CHROOT/opt/kernelgen/bin/clang
-cc1 -S test.c -emit-llvm -o -
[Thread debugging using libthread_db enabled]
Using host libthread_db library
"/home/marcusmae/rpmbuild/CHROOT/opt/kernelgen/lib/libthread_db.so.1".

Breakpoint 1, llvm::BasicBlock::Create (Context=..., Name=...,
Parent=0x22df6f0, InsertBefore=0x0)
    at
/home/marcusmae/rpmbuild/BUILD/llvm/build/include/llvm/BasicBlock.h:104
104        return new BasicBlock(Context, Name, Parent, InsertBefore);
(gdb)

- D.

2013/1/1 Somenath Chakraborty <some.chak at gmail.com>

> Hello,
>
> I have just started using llvm. I was trying to debug how *clang*generates IR for very simple C testcases (few assignments
> and if-condsitions).
> To get a hold on the basic functions, I put some break points on following
> functions but debugger *didn't stop*:
>
> llvm::BasicBlock::Create
> llvm::BinaryOperator::CreateAdd (design has binary op)
> llvm::Value::Value
> llvm::BranchInst::Create (design has if/else)
> ...
> and quite a few
>
> The command line I used :
>
> *clang -S test.c -emit-llvm -o - *
>
> Here I could see the entire LLVM code generated and shown in stdout. I am
> almost sure that I have missed something very basic. Can anyone please help
> me in setting *proper breakpoints* so that I can debug through the entire
> IR generation phase.
>
> Sorry for asking this basic question.
>
> Thanks.
>
> _______________________________________________
> 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/20130101/5e4b0dec/attachment.html>


More information about the llvm-dev mailing list