[cfe-dev] How to check the flow of the clang compiler with an example

kalyan ponnala ponnala.kalyan at gmail.com
Thu Feb 25 07:50:49 PST 2010


Thanks charles, ted, and yun. It works. I can step through the clang parser
and lexer now.

I would like to know if we can add the -fms-extensions options to the
"clang-test" target. I could not build the regression tests until now. It
give me fatal errors saying " 'stdio.h' file not found.. 'stdlib.h' not
found etc."

Thanks.

On Wed, Feb 24, 2010 at 11:04 PM, Yun Chen <yun.go.chen at gmail.com> wrote:

> You open LLVM.sln. Set "clang" project as the "Start up" project.
>
> Then on project properties for "clang", under "Debugging" section, you
> set Command Arguments to something like this:
> -cc1 -fms-extensions -fsyntax-only G:\tmp\t.cpp
>
> Then you set a breakpoint in cc1_main, for example at "ExecuteAction".
> Step into it and it should not take long to see it in action.
>
>
> On Wed, Feb 24, 2010 at 8:46 PM, kalyan ponnala
> <ponnala.kalyan at gmail.com> wrote:
> >
> >
> > ---------- Forwarded message ----------
> > From: kalyan ponnala <ponnala.kalyan at gmail.com>
> > Date: Wed, Feb 24, 2010 at 8:42 PM
> > Subject: Re: [cfe-dev] How to check the flow of the clang compiler with
> an
> > example
> > To: Charles Davis <cdavis at mymail.mines.edu>
> >
> >
> > Thanks for the reply guys. I am able to run those commands correctly (I
> > guess) but i am not able to see whats going on inside the lexer and
> parser
> > as the debugger goes on with the helloworld.c program. I am not sure of
> what
> > is happening there as it does not show any output.
> > I tried these commands:
> > clang -cc1 -fms-extensions helloworld.c    -----it worked but no output
> > --nothing happened
> > clang -cc1 -fsyntax-only helloworld.c -fms-extensions -x c helloworld.c
> >
> > clang -fsyntax-only helloworld.c -###
> > etc etc...
> >
> > I set the breakpoints as you said charles. what more should I do? The .c
> > file is inside a visual studio project but I am accessing it through the
> > command line. Is it fine? Do I have to add some commands or paths to the
> > visual studio project file of helloworld.c ?
> >
> > Thanks.
> >
> > On Wed, Feb 24, 2010 at 8:00 PM, Charles Davis <cdavis at mymail.mines.edu>
> > wrote:
> >>
> >> kalyan ponnala wrote:
> >> >  Hi,
> >> > Thanks for the reply. I tried putting breakpoints at CIndex.cpp file
> in
> >> > CIndex target near
> >> >
> >> > Lexer Lex(SourceMgr.getLocForStartOfFile(BeginLocInfo.first),
> >> >
> >> >             CXXUnit->getASTContext().getLangOptions(),
> >> >
> >> >             Buffer.first, Buffer.first + BeginLocInfo.second,
> >> > Buffer.second);
> >> No, no, you want to put the breakpoint on Lexer::Lex(). It's in the
> >> clangLex target, in Lexer.h.
> >> >
> >> > and another breakpoint at Parser.cpp inside clangparser target.
> >> >
> >> > bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) {
> >> >
> >> >   Result = DeclGroupPtrTy();
> >> >
> >> >   if (Tok.is(tok::eof)) {
> >> >
> >> >     Actions.ActOnEndOfTranslationUnit();
> >> >
> >> >     return true;
> >> >
> >> >   }
> >> Good.
> >> >
> >> > When I tried to run the command clang -cc1 helloworld.c on the command
> >> > line , it generates 5 diagnostic messages saying error: unknown type
> >> > __int64 /*64-bit time value*/ and shows me different places inside
> >> > stdio.h and crtdefs.h.
> >> That is because you need to also pass -fms-extensions to use clang with
> >> MS headers.
> >>
> >> Chip
> >>
> >
> >
> >
> > --
> > Kalyan Ponnala
> > phone: 8163772059
> >
> >
> >
> > --
> > Kalyan Ponnala
> > phone: 8163772059
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> >
> >
>



-- 
Kalyan Ponnala
phone: 8163772059
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100225/82badd2f/attachment.html>


More information about the cfe-dev mailing list