473,509 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About extract call graph from C source code

Hi guiders,

sorry , since I don't know which group suit for this question,I just post this
question at these group.

As we know , we can get the run-time call graph by some proved tools .
now I have a problem about the extract call graph from statice C source code
, not from binary.

I have try to use cscope and write some perl script for it .
but final I find If there are have the function piont call or function
defined by macro , cscope have some problem to parse the source code .
At last I find I almost write a C language parser for it just like a compiler
Unfortuntaly I am not good at area .

Are there have another reliable ways or tools to extract call graph
from source code ?

Thanks

Xing
--
comp.lang.c.moderated - moderation address: cl**@plethora.net
Nov 14 '05 #1
6 16421
Xing Xu wrote:
I have try to use cscope and write some perl script for it .
but final I find If there are have the function piont call or function
defined by macro , cscope have some problem to parse the source code .


Try preprocessing the source first (cc -E on Unix) then give
the result to cscope.
--
comp.lang.c.moderated - moderation address: cl**@plethora.net
Nov 14 '05 #2
[Note: F'up2 reduced to one group --- should've been done by OP...]

In comp.lang.c.moderated Xing Xu <so****@163.com> wrote:
I have try to use cscope and write some perl script for it.
There's now a KDE GUI for cscope, called kscope, which has a calltree
extractor based on cscope ouput. You may want to use that, instead of
rolling your own. It's at http://kscope.sourceforge.net/
but final I find If there are have the function piont call or function
defined by macro, cscope have some problem to parse the source code.
Indeed, use of function pointers does throw cscope off track quite
reliably ;-(. The problem can be reduced considerably by always using
typedefs for function pointer types, to avoid extra parentheses inside
the parentheses of a function definition, i.e. you should have

typedef int (*t_fp)(char);
void somefunction(t_fp function_pointer_argument);

instead of

void somefunction (int (*function_pointer_argument)(char));

You'll still get an incomplete call graph, though, since use of
function pointers generally makes static analysis impossible. cscope
won't log passing of a function foo() as an argument to function bar()
as a call to foo().

I'm not sure I understand what you mean by "function defined by
macro". Cscope does not run its input through the C preprocessor, so
it can't expand macros. If your function definition is entirely
hidden inside a macro call like the "DEFUN" convention in Emacs source
code, that means cscope's parser won't catch it. You'ld have to
extend cscope's parser yourself to do that, and I'm not even sure it
can be done inside the given framework.
Are there have another reliable ways or tools to extract call graph
from source code ?


None that I know of, at least not if the source code is obfuscated by
heavy use of macros the tool doesn't know about. You could run the
tools on preprocessed sources, but that may well create as many new
problems as it solves given ones.

--
Hans-Bernhard Broeker (br*****@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
--
comp.lang.c.moderated - moderation address: cl**@plethora.net
Nov 14 '05 #3
In article <cl****************@plethora.net>, Xing Xu <so****@163.com> wrote:

Are there have another reliable ways or tools to extract call graph
from source code ?


Try cflow at ftp://ftp.tecgraf.puc-rio.br/pub/lhf/cflow.tar.gz .
--
comp.lang.c.moderated - moderation address: cl**@plethora.net
Nov 14 '05 #4
In comp.lang.c Xing Xu <so****@163.com> wrote:
sorry , since I don't know which group suit for this question,I just
post this question at these group. (linewrap adjusted) (snip cscope question>


In the likely case that you don't get all the information you need
from here, the following URL has suggestions for alternate groups to
post to:

http://www.msu.edu/~pfaffben/writing...off-topic.html

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
--
comp.lang.c.moderated - moderation address: cl**@plethora.net
Nov 14 '05 #5
>As we know , we can get the run-time call graph by some proved tools .
now I have a problem about the extract call graph from statice C source code
, not from binary. .....
Are there have another reliable ways or tools to extract call graph
from source code ?


Try doxygen www.doxygen.org

In the config you can tell it you're using C. I've not tried it with
'tricky' code (fn pointers and the like) so don't know how far you'll
get there but as far as static calls goes it's fine.

cheers,
--
John
--
comp.lang.c.moderated - moderation address: cl**@plethora.net
Nov 14 '05 #6
On Wed, 14 Jan 2004 01:39:21 +0000, Xing Xu wrote:
Are there have another reliable ways or tools to extract call graph from
source code ?


There are a few, smatch http://smatch.sourceforge.net/ is probably the
closest to a real compiler (unsurprisingly).

--
James Antill -- ja***@and.org
Need an efficient and powerful string library for C?
http://www.and.org/vstr/
--
comp.lang.c.moderated - moderation address: cl**@plethora.net
Nov 14 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3040
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
6
2887
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
10
1934
by: Steven T. Hatton | last post by:
# -- "If our hypothesis is about anything and not about some one or more particular things, then our deductions constitute mathematics. Thus mathematics may be defined as the subject in which we...
1
7760
by: Zlatko Matić | last post by:
Hello. I have a MS Access front end/PostgreSQL back-end combination. There is a report with nested graph (linked master/child fields). I used saved pass-through queries for both Record Source of...
20
3448
by: Sushil | last post by:
Hi gurus I was reading FAQ "alloca cannot be written portably, and is difficult to implement on machines without a conventional stack." I understand that the standard does not mandate...
8
2419
by: Jef Driesen | last post by:
I'm working on an image segmentation algorithm. An essential part of the algorithm is a graph to keep track of the connectivity between regions. At the moment I have a working implementation, but...
4
2885
by: Rose | last post by:
Hi, guys, Is there such a tool? I also hope it is free. Thanks! Rose
0
1515
by: Aamir Mahmood | last post by:
Hi guys, I need a tool that can create a method call graph from analysing my C# code or assembly. I actually want to list functions being called by each function recursively. And it should be...
2
1344
by: David F | last post by:
I a looking for a tool that creates a cross reference table for all global functions, and optionally class methods. That is, for each function, which function(s) does it call and what function(s) is...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7135
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.