[cfe-dev] main functions of clang

James Molloy james.molloy at arm.com
Mon Dec 12 07:00:48 PST 2011


Just type "gdb -args" before your command line.

 

You'll need to unwrap the driver invocation from the actual  cc1 invocation
by giving the -### argument to clang. This will cause it to print out its
cc1 command line:

 

./bin/clang -ast-print -S test.c -o - -###

 

Then take that and run it under gdb:

 

Gdb -args "./bin/clang" "-cc1" ...

 

And set a breakpoint where you care:

 

(gdb) b StmtPrinter.cpp:49

(gdb) r

 

Breakpoint 1, (anonymous namespace)::StmtPrinter::PrintStmt
(this=0xffffabd0, S=0xad9a438, SubIndent=2)

 

Done.

 

Cheers,

 

James

 

From: eyasu getahun [mailto:eya.get at gmail.com] 
Sent: 12 December 2011 14:37
To: Hans Wennborg
Cc: James Molloy; cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] main functions of clang

 


Hi Hans,

I can't use debugger. Because am using Linux  command line to run clang.
There is no debugging option at Linux. Thanks for the idea.

On Mon, Dec 12, 2011 at 10:23 PM, Hans Wennborg <hans at chromium.org> wrote:

On Mon, Dec 12, 2011 at 2:03 PM, eyasu getahun <eya.get at gmail.com> wrote:
>
> Hey James,
>
> Thanks for the command line option. But where is the function called? I
mean
> in which main method of clang it is called? We know that every function
must
> be called at least at one main method/function to be executed. Let me make
> it clear like this way:
>
> int main ()//main method
> {
> S->Printpretty(context);
> }
>
> So, which main method is calling our printpretty() function? Hope now its
> clear for you.

Hi Eyasu,

The best way to find out where a function is called from is to run
Clang in a debugger, set a breakpoint in the function you are asking
about (StmtPrinter::PrintStmt), and look at the stack trace.

 - Hans




-- 
With Best Regards,

===========================================
Eyasu Getahun

1 Fusionopolis way, #08-10 Connexis North Tower
Singapore 138632, Singapore
Mobile: +393279239907
===========================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111212/de67dd8d/attachment.html>


More information about the cfe-dev mailing list