Function Call Tree Command in UNIX.

V

Vinay

Hi Everybody

I have been looking out for a Function call tree command in Unix
environment.

Given a piece of source code(millions of lines), there is a function
F1() calling F2() calling F3().

The tools should analyse the C/C++ source code & provide a tree-like
structure denoting the sequence of calls made by a particular
function..

I know that VC++ IDE do provides this facilities, but not aware in the
case of UNIX.

Please let me know if any body has come across such a tool in UNIX
environment.

Thanks & Regards,
- Vinay
 
J

jacob navia

Vinay said:
Hi Everybody

I have been looking out for a Function call tree command in Unix
environment.

Given a piece of source code(millions of lines), there is a function
F1() calling F2() calling F3().

The tools should analyse the C/C++ source code & provide a tree-like
structure denoting the sequence of calls made by a particular
function..

I know that VC++ IDE do provides this facilities, but not aware in the
case of UNIX.

Please let me know if any body has come across such a tool in UNIX
environment.

Thanks & Regards,
- Vinay
The QIDE does that under linux. It is a port of the lcc-win32 IDE to Linux.

You can buy it at
http://www.q-software-solutions.com
 
B

Benjamin Ketcham

Vinay said:
Hi Everybody

I have been looking out for a Function call tree command in Unix
environment.

Given a piece of source code(millions of lines), there is a function
F1() calling F2() calling F3().

The tools should analyse the C/C++ source code & provide a tree-like
structure denoting the sequence of calls made by a particular
function..

I know that VC++ IDE do provides this facilities, but not aware in the
case of UNIX.

Please let me know if any body has come across such a tool in UNIX
environment.

Thanks & Regards,
- Vinay

Take a look at "gprof".
 
G

G. S. Hayes

Hi Everybody

I have been looking out for a Function call tree command in Unix
environment.

Given a piece of source code(millions of lines), there is a function
F1() calling F2() calling F3().

The tools should analyse the C/C++ source code & provide a tree-like
structure denoting the sequence of calls made by a particular
function..

cscope (http://cscope.sourceforge.net) is probably what you want.

Personally I find ctags + vim's tags support to be a godsend; this
combination allows you to drill down through the call stack--you can
put your cursor on a call to func1() and hit C-] and you jump to the
definition of func1; then when func1 calls func2(), hit C-] again and
you jump to the definition of func2. Once you've seen what func2
does, hit C-t to pop back up to func1 and then hit C-t again to pop
back to the original call to func1. It's a very useful tool for
navigating through source code (off-topic: ctags supports other
languages as well, including Java, C++, Python, Perl, Visual Basic,
C#, HTML, JavaScript, Lisp, SQL, PHP, etc).
 
V

Vinay

Hi Everybody

I have been looking out for a Function call tree command in Unix
environment.

Given a piece of source code(millions of lines), there is a function
F1() calling F2() calling F3().

The tools should analyse the C/C++ source code & provide a tree-like
structure denoting the sequence of calls made by a particular
function..

cscope (http://cscope.sourceforge.net) is probably what you want.

Personally I find ctags + vim's tags support to be a godsend; this
combination allows you to drill down through the call stack--you can
put your cursor on a call to func1() and hit C-] and you jump to the
definition of func1; then when func1 calls func2(), hit C-] again and
you jump to the definition of func2. Once you've seen what func2
does, hit C-t to pop back up to func1 and then hit C-t again to pop
back to the original call to func1. It's a very useful tool for
navigating through source code (off-topic: ctags supports other
languages as well, including Java, C++, Python, Perl, Visual Basic,
C#, HTML, JavaScript, Lisp, SQL, PHP, etc).


Yes I do know about ctags. But ctags don't work if the function has
same name. I have been working on 2-3 demoans which either use some
shared code or implement the same function in their code & avoid the
shared code. if i use ctags on the shared code then ctags+vi won't
show me about multiple declarion of the same function & will direct me
to some other path.
 
G

G. S. Hayes

Yes I do know about ctags. But ctags don't work if the function has
same name.

This is getting way off-topic. Sadly google groups won't let me set
followups.

With vim+exuberant ctags you can differentiate same-named functions a
couple of ways. First, if a function is statically scoped it'll only
jump there from the same file or if there are no other matches. It'll
prefer externs in the current file over externs in other files, and
it'll prefer statics in the current file over externs in general.

Second, after you hit C-] you can use :tn to get the next matching
tag. So if a.c and b.c both have a frob() function and C-] takes you
to a.c's frob(), you can use :tn to get to b.c's frob() (use :tp to
get the previous tag; this mechanism will go to statically scoped
functions in other files after it runs out of alternatives).

Third, if you have a top-level dir with:
main.c
daemon1/wobble.c
daemon2/wobble.c

make sure you use per-directory tags files (so that you have tags,
daemon1/tags, and daemon2/tags) and set tags appropriately so it
searches the current directory first; that way you'll automatically go
to the tag in the current directory first (but can still use :tnext
and :tprev to see the other matches if you want).
 
V

Vinay

Yes I do know about ctags. But ctags don't work if the function has
same name.

This is getting way off-topic. Sadly google groups won't let me set
followups.

With vim+exuberant ctags you can differentiate same-named functions a
couple of ways. First, if a function is statically scoped it'll only
jump there from the same file or if there are no other matches. It'll
prefer externs in the current file over externs in other files, and
it'll prefer statics in the current file over externs in general.

Second, after you hit C-] you can use :tn to get the next matching
tag. So if a.c and b.c both have a frob() function and C-] takes you
to a.c's frob(), you can use :tn to get to b.c's frob() (use :tp to
get the previous tag; this mechanism will go to statically scoped
functions in other files after it runs out of alternatives).

Third, if you have a top-level dir with:
main.c
daemon1/wobble.c
daemon2/wobble.c

make sure you use per-directory tags files (so that you have tags,
daemon1/tags, and daemon2/tags) and set tags appropriately so it
searches the current directory first; that way you'll automatically go
to the tag in the current directory first (but can still use :tnext
and :tprev to see the other matches if you want).

Thanks a lot!!!
- Vinay.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top