Discussion:
Call graph emacs tool
(too old to reply)
George Kadianakis
2010-08-20 16:15:43 UTC
Permalink
Greetings,

I think I'm loosing faith in Emacs. It's the first time I'm looking
for a tool and I don't get countless .el scripts with a trivial Google
search.

I'm looking for a tool (preferably an Emacs tool, but _seriously_
anything will do) that will give me all possible code paths to a given
function of a C project.

For example:
Input: (magic-script function)
Output: 1) main() [main.c] -> function_1() [main.c] -> function_2() [oh.c] -> function_3() [oh.c] -> function_4() [ohlol.c] -> function() [yay.c]
2) main() [main.c] -> function_5() [yay.c] -> function_3() [oh.c] -> function_2() [oh.c] -> function() [yay.c]
3) etcetera

GNU cflow is actually doing that _but_ it doesn't support multiple
source files and it's not Emacs integrable.

Do you people know of any such tools?

Thank you :)
Suvayu Ali
2010-08-21 01:38:23 UTC
Permalink
I'm looking for a tool (preferably an Emacs tool, but_seriously_
anything will do) that will give me all possible code paths to a given
function of a C project.
Input: (magic-script function)
Output: 1) main() [main.c] -> function_1() [main.c] -> function_2() [oh.c] -> function_3() [oh.c] -> function_4() [ohlol.c] -> function() [yay.c]
2) main() [main.c] -> function_5() [yay.c] -> function_3() [oh.c] -> function_2() [oh.c] -> function() [yay.c]
3) etcetera
GNU cflow is actually doing that_but_ it doesn't support multiple
source files and it's not Emacs integrable.
Do you people know of any such tools?
I am not sure what you mean by all possible code paths to a function,
but if you mean something like this,
<Loading Image...>

Then you can take a look at Semantic and the CEDET project[1].

[1]http://cedet.sourceforge.net/
--
Suvayu

Open source is the future. It sets us free.
Richard Riley
2010-08-21 01:50:07 UTC
Permalink
Post by Suvayu Ali
I'm looking for a tool (preferably an Emacs tool, but_seriously_
anything will do) that will give me all possible code paths to a given
function of a C project.
Input: (magic-script function)
Output: 1) main() [main.c] -> function_1() [main.c] -> function_2() [oh.c] -> function_3() [oh.c] -> function_4() [ohlol.c] -> function() [yay.c]
2) main() [main.c] -> function_5() [yay.c] -> function_3() [oh.c] -> function_2() [oh.c] -> function() [yay.c]
3) etcetera
GNU cflow is actually doing that_but_ it doesn't support multiple
source files and it's not Emacs integrable.
Do you people know of any such tools?
I am not sure what you mean by all possible code paths to a function,
but if you mean something like this,
<http://i288.photobucket.com/albums/ll164/jalladandtux/screenies/emacs-symbol-reference-w-cedet.png>
What is that supposed to be? Is that a call stack?
Suvayu Ali
2010-08-21 03:04:56 UTC
Permalink
Post by Richard Riley
Post by Suvayu Ali
I'm looking for a tool (preferably an Emacs tool, but_seriously_
anything will do) that will give me all possible code paths to a given
function of a C project.
Input: (magic-script function)
Output: 1) main() [main.c] -> function_1() [main.c] -> function_2() [oh.c] -> function_3() [oh.c] -> function_4() [ohlol.c] -> function() [yay.c]
2) main() [main.c] -> function_5() [yay.c] -> function_3() [oh.c] -> function_2() [oh.c] -> function() [yay.c]
3) etcetera
GNU cflow is actually doing that_but_ it doesn't support multiple
source files and it's not Emacs integrable.
Do you people know of any such tools?
I am not sure what you mean by all possible code paths to a function,
but if you mean something like this,
<http://i288.photobucket.com/albums/ll164/jalladandtux/screenies/emacs-symbol-reference-w-cedet.png>
What is that supposed to be? Is that a call stack?
Maybe I have misunderstood the OP's question.

Its the result of the command `semantic-symref-symbol'. It looks up your
symbol in all your project include paths and presents all references to
the symbol as links. You can jump to it with `RET' or you can view with
`<space>'. In this case the symbol was a handy method I had written.

There is a similar function for tags with a small difference, instead of
presenting it in a buffer, it cycles through all the matches in a
"completion like" buffer. All of this is of course with the CVS version
of CEDET.

Is that what the OP was looking for?
--
Suvayu

Open source is the future. It sets us free.
Pranav Peshwe
2010-08-21 03:13:11 UTC
Permalink
If I've understood you correctly, any tool that can build a (static) call
graph should suffice. Just that, you'll have to manually reverse trace paths
starting from function().

Do CMIIW...
Post by George Kadianakis
Greetings,
I think I'm loosing faith in Emacs. It's the first time I'm looking
for a tool and I don't get countless .el scripts with a trivial Google
search.
I'm looking for a tool (preferably an Emacs tool, but _seriously_
anything will do) that will give me all possible code paths to a given
function of a C project.
Input: (magic-script function)
Output: 1) main() [main.c] -> function_1() [main.c] -> function_2() [oh.c]
-> function_3() [oh.c] -> function_4() [ohlol.c] -> function() [yay.c]
2) main() [main.c] -> function_5() [yay.c] -> function_3() [oh.c] ->
function_2() [oh.c] -> function() [yay.c]
3) etcetera
GNU cflow is actually doing that _but_ it doesn't support multiple
source files and it's not Emacs integrable.
Do you people know of any such tools?
Thank you :)
George Kadianakis
2010-08-21 12:36:26 UTC
Permalink
Post by Pranav Peshwe
If I've understood you correctly, any tool that can build a (static) call
graph should suffice. Just that, you'll have to manually reverse trace paths
starting from function().
Do CMIIW...
Practically, yes. But the process of manually reversing the trace path
is not easy because of the multiple code paths that may lead to a
function call.

What I'm looking for, is basically what GNU cflow calls a reverse
graph [1] but I'd like it to be able to give me code paths that span
multiple files (cflow can only process a single source file).
Post by Pranav Peshwe
I am not sure what you mean by all possible code paths to a function,
but if you mean something like this,
<http://i288.photobucket.com/albums/ll164/jalladandtux/screenies/emacs-symbol-reference-w-cedet.png>
Then you can take a look at Semantic and the CEDET project[1].
[1]http://cedet.sourceforge.net/
Unfortunately, Semantic or etags don't have the functionality I look
for.

[1]: http://www.gnu.org/software/cflow/manual/cflow.html#Direct-and-Reverse
rustom
2010-08-21 15:35:48 UTC
Permalink
Post by George Kadianakis
Post by Pranav Peshwe
If I've understood you correctly, any tool that can build a (static) call
graph should suffice. Just that, you'll have to manually reverse trace paths
starting from function().
Do CMIIW...
Practically, yes. But the process of manually reversing the trace path
is not easy because of the multiple code paths that may lead to a
function call.
What I'm looking for, is basically what GNU cflow calls a reverse
graph [1] but I'd like it to be able to give me code paths that span
multiple files (cflow can only process a single source file).
It seems to be taking multiple files for me

And thats what the man page says http://linux.die.net/man/1/cflow
Gary
2010-08-21 16:18:44 UTC
Permalink
This post might be inappropriate. Click to display it.
Suvayu Ali
2010-08-21 18:07:36 UTC
Permalink
Post by George Kadianakis
Unfortunately, Semantic or etags don't have the functionality I look
for.
[1]:http://www.gnu.org/software/cflow/manual/cflow.html#Direct-and-Reverse
Okay thanks, sorry couldn't be of much help and sorry for the noise.
--
Suvayu

Open source is the future. It sets us free.
rustom
2010-08-24 15:52:52 UTC
Permalink
Post by Suvayu Ali
Post by George Kadianakis
Unfortunately, Semantic or etags don't have the functionality I look
for.
[1]:http://www.gnu.org/software/cflow/manual/cflow.html#Direct-and-Reverse
Okay thanks, sorry couldn't be of much help and sorry for the noise.
--
Suvayu
Open source is the future. It sets us free.
Take a look at this
http://www.spinellis.gr/cscout/
George Kadianakis
2010-08-25 17:02:02 UTC
Permalink
Post by Gary
Post by George Kadianakis
I'd like it to be able to give me code paths that span
multiple files (cflow can only process a single source file).
http://www.gnu.org/software/cflow/manual/cflow.html#Direct-and-Reverse
Are you sure? "GNU cflow analyzes a *collection of* C source files and
prints a graph, charting control flow within the program." (my
emphasis).
Hey,

yeah I noticed the emphasized part in cflow's DESCRIPTION as well, but
by doing some brief checks and studying the online manual [1], I see
no sign of cflow being able to understand source file relationships.

I'm intrigued on writing this myself (most probably on top of cflow),
but I'm trying to avoid finding out in a week that this has already
been done.

Anyone else that is aware of such a tool is most welcome to post :)

PS: Sorry for fubaring the mail threading, but I'm not subscribed to
the list and I forgot to request CC:ing :)

[1]: http://www.gnu.org/software/cflow/manual/cflow.html

Loading...