473,424 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,424 software developers and data experts.

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 16401
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
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
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
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
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
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
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
by: Rose | last post by:
Hi, guys, Is there such a tool? I also hope it is free. Thanks! Rose
0
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
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.