[CastXML] using castxml to generate control flow graph

Michka Popoff michkapopoff at gmail.com
Sun Oct 2 16:28:08 EDT 2016


Right, I did not realise you wanted information about variables defined inside the function’s body.

I think this can not be done with CastXML (GCCXML didn’t allow this too).
CastXML and GCCXML were written to generate XML files containing enough
information to generate bindings to other languages; the content of functions
is not of interest for that goal.

Of course if you want to do c++ analysis on these variables, castxml could
probably be extended to output that information. Not sure how much
work that would be though

Michka


> On 2 Oct 2016, at 19:51, Ranadeep Biswas <ranadeep at cmi.ac.in> wrote:
> 
> Hi Michka,
> 
> Thanks for the documentations. But I am still stuck.
> Can you tell me how to extract information for variables inside of a function? Consider this simple c++ code.
> 
> int f(){
>   int a = 3;
>   return a;
> }
> 
> how to extract information about variable a?
> 
> Thanks,
> Ranadeep
> 
> On Sat, Oct 1, 2016 at 9:39 PM, Michka Popoff <michkapopoff at gmail.com <mailto:michkapopoff at gmail.com>> wrote:
> Hi
> 
> There are a bunch of pygccxml examples here:
> http://pygccxml.readthedocs.io/en/develop/examples.html <http://pygccxml.readthedocs.io/en/develop/examples.html>
> 
> A simple example that almost looks like yours would be this one:
> http://pygccxml.readthedocs.io/en/develop/examples/variables/example.html <http://pygccxml.readthedocs.io/en/develop/examples/variables/example.html>
> 
> Hope this helps you getting started.
> 
> Michka
> 
>> On 1 Oct 2016, at 18:05, Ranadeep Biswas <ranadeep at cmi.ac.in <mailto:ranadeep at cmi.ac.in>> wrote:
>> 
>> Hi Matt,
>> 
>> Yes, I have tried Pygccxml. But I would prefer not to use Python.
>> But since that you mentioned pygccxml, can you give me an pygccxml example to parse x and y from that previous c++ code?
>> And if possible an example of castxml also to parse x and y. If trimming is not possible I am okay with that.
>> 
>> Thanks,
>> Ranadeep
>> 
>> On Sat, Oct 1, 2016 at 8:46 PM, Matt <mattator at gmail.com <mailto:mattator at gmail.com>> wrote:
>> Hi,
>> 
>> You can filter the results with pygccxml.
>> 
>> 2016-10-01 13:50 GMT+02:00 Ranadeep Biswas <ranadeep at cmi.ac.in <mailto:ranadeep at cmi.ac.in>>:
>> > Hello all,
>> >
>> > I am doing this project that needs to parse a c/c++ program and generate its
>> > control flow graph so that I can do some analysis on it. Can this be done
>> > using castxml?
>> >
>> > I tried to use castxml to generate xml output to build the CFG, but I can
>> > not generate the output as per my need. I could not find any good
>> > documentations. May be I am missing something.
>> >
>> > Consider this very simple c++ program.
>> >
>> > // foo.cpp
>> > int main(){
>> >   int x, y;
>> >   x = 0;
>> >   y = x + 3;
>> >   return 0;
>> > }
>> >
>> > now I run `castxml --castxml-cc-gnu g++ --castxml-gccxml foo.cpp`. It
>> > generates `foo.xml` file, but xml file contains a lot of other tags. But I
>> > don't find tags for variable x and y. Also is it possible to trim the
>> > output, so that I can get tags for only main, x, y and relevant types?
>> >
>> > Thanks,
>> >
>> > Ranadeep
>> > MSc CS 2nd year
>> > Chennai Mathematical Institute
>> >
>> >
>> > _______________________________________________
>> > CastXML mailing list
>> > CastXML at public.kitware.com <mailto:CastXML at public.kitware.com>
>> > http://public.kitware.com/mailman/listinfo/castxml <http://public.kitware.com/mailman/listinfo/castxml>
>> >
>> 
>> _______________________________________________
>> CastXML mailing list
>> CastXML at public.kitware.com <mailto:CastXML at public.kitware.com>
>> http://public.kitware.com/mailman/listinfo/castxml <http://public.kitware.com/mailman/listinfo/castxml>
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/castxml/attachments/20161002/9e34bc77/attachment.html>


More information about the CastXML mailing list