Re: [Ctool-users] retrieving the name of the current function from a Statement
Brought to you by:
flisakow
From: <cto...@kh...> - 2006-06-19 15:55:27
|
On Sun, 18 Jun 2006, Shaun Flisakowski wrote: Thanks Shawn, > > If you're calling a callback for each function, you can set the name > inside it (to a global), then you'll have it for each statement you > do from within it. > > Take a look at the atFuncDef() method in the call-graph example: > exampes/cgraph/cgraph.cpp That's what I'd been doing for findFunctionDef() findExpr(). My problem was, if calling findStemnt() from main without calling either of the other 2 callbacks, I couldn't figure out how to tell which function the statement was part of (that's where I thought the info would be somewhere in the symbol table of the statement. is it there? this is not an essential question, since i've solved my problem for now, just curiosity as i didn't find it easily). Now that i'm getting my head around c++ and oo I've realised I can use findFunctionDef() and cast its FunctionDef parameter to a Block which then gives me access to the findStemnt() callback. so sorry, it was a case of still figuring out how it all holds together.. thanks for the quick answer! nessim > > Shawn > > On Jun 18, 2006, at 6:13 AM, cto...@kh... wrote: > > > Dear all, > > > > First, thanks for all the good work on ctool, i'm hoping to start > > building some useful > > tools around it.. > > > > I'm currently working on a simple control-flow aware function call > > graph. > > I can easily get a list of all control flow statements by calling > > findStemnt() with a callback. > > > > In the callback, I'd like to know what function the statement is > > part of. > > Unfortunately I haven't been able to find that.. > > > > Although I can find the name of the executing function in the > > TransUnit's syms SymTbl I don't see how to differentiate it from > > any of the other > > functions visible at the same level in the table. > > > > in the first level of the SymTbl i do see the __FUNCTION__ and > > __PRETTY_FUNCTION__ > > symbols which seem like good candidates but neither is defined. > > > > Any help is appreciated! > > > > thanks, > > nessim > > ps. i'm using cpp-3.3.5 and cpp-4.0 > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > The Borg assimilated my cat...He doesn't act any differently. > > unknown > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > > > _______________________________________________ > > Ctool-users mailing list > > Cto...@li... > > https://lists.sourceforge.net/lists/listinfo/ctool-users > > > |