Hi David, thanks for replying.<br><br>Yes I did narrow down the problem to a more specific line, if I run this code which was provided at [2] and I adapted a small piece of [1]:<br><br>-----<br>import sys<br>import clang.cindex<br>

<br>def callexpr_visitor(node, parent, userdata):<br>    if node.kind == clang.cindex.CursorKind.CALL_EXPR:<br>        print 'Found %s [line=%s, col=%s]' % (<br>                clang.cindex.Cursor_displayname(node), node.location.line, node.location.column)<br>

    return 2 # means continue visiting recursively<br><br>index = clang.cindex.Index.create()<br>tu = index.parse(sys.argv[1])<br>#clang.cindex.Cursor_visit(<br>#        tu.cursor,<br>#        clang.cindex.Cursor_visit_callback(callexpr_visitor),<br>

#        None)<br>print 'Translation unit:', tu.spelling<br><b><span style="color:rgb(255,0,0)">f = tu.get_includes()<br>    print 'test'</span></b><br>------------------<br>Adding the method in red makes it crash, That is, the tu.get_includes crashes. I look at the <b>cindex.py</b> but I cant figured what is wrong it seemed to me like a normal use of the method. <br>

<br>The reasons I stayed on C was because I saw few comments that python was still catching up on making available the methods provided by libclang, and given that libclang itself is not expected to provide all the features from clang itself, I saw myself going more far away from the functionalities going that way (I dont know C++ which is what kept me away from Clang AST usage). But the strongest reason was the problem itself that happened (otherwise I would have just used that code for my purposes). <br>

<br>Thanks,<br><br clear="all">Carlos Andrade<br><div><a href="http://carlosandrade.co" target="_blank">http://carlosandrade.co</a></div><br>
<br><br><div class="gmail_quote">2012/6/17 David Röthlisberger <span dir="ltr"><<a href="mailto:david@rothlis.net" target="_blank">david@rothlis.net</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">On 17 Jun 2012, at 08:24, Carlos Andrade wrote:<br>
><br>
> I managed to create a transversal using libclang on C, map it to code and get its types but now I am stuck trying to output it like a tree like it is done at [1]. For some unknown reason [1] crashes here with the warning "Python quit unexpectedly while using libclang.dylib plug-in. (Running on an OS Lion).<br>


><br>
</div>> [1] <a href="https://gist.github.com/2503232" target="_blank">https://gist.github.com/2503232</a><br>
<br>
Can you narrow down the failure to a specific line of python + line of<br>
the input translation unit? I suspect it might be something to do with<br>
accessing a property of an invalid type.<br>
<div class="im"><br>
> On my C version I can get each node being printed, but what I wanted is what [1] does: Print the structure of the tree (who is child of who) and I was trying to do so by tying to verify if the child is NULL but I cant find any method available to do so. [2] Seems to suggest this doesnt even exist on libclang C.<br>


><br>
</div>> [2] <a href="http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang/" target="_blank">http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang/</a><br>
<br>
Have you considered writing your program in python? I found that using<br>
the ipython shell (with its tab-completion) was really helpful for<br>
exploring the libclang API.<br>
<br>
(I apologise for not actually answering your question, but I don't know<br>
enough about the libclang C interface.)<br>
<br>
Cheers<br>
Dave.<br>
<br>
</blockquote></div><br>