473,585 Members | 2,496 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.mod erated - moderation address: cl**@plethora.n et
Nov 14 '05 #1
6 16433
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.mod erated - moderation address: cl**@plethora.n et
Nov 14 '05 #2
[Note: F'up2 reduced to one group --- should've been done by OP...]

In comp.lang.c.mod erated 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_pointe r_argument);

instead of

void somefunction (int (*function_poin ter_argument)(c har));

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.mod erated - moderation address: cl**@plethora.n et
Nov 14 '05 #3
In article <cl************ ****@plethora.n et>, 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.mod erated - moderation address: cl**@plethora.n et
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)cybers pace.org | don't, I need to know. Flames welcome.
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
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.mod erated - moderation address: cl**@plethora.n et
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.mod erated - moderation address: cl**@plethora.n et
Nov 14 '05 #7

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

Similar topics

2
3042
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 to have an easier time understanding what I do. Therefore this weekend I'm going to spend 3 days just writing comments. Before I do it, I thought...
6
2902
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 this, and came across a problem that I haven't been able to solve elegantly. The problem is to find "linker" vertexes that a pair of verteces from...
10
1945
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 never know what we are talking about, nor whether what we are saying is true." - Bertrand Russell
1
7767
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 the report and Row Source of the nested graph. It works, but, when I have a lot of data, the report has several hundreds pages and opening of the...
20
3465
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 "heap" or "stack" I'm curious to know the implemenations which dont have stack or heap.
8
2433
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 it's not flexible enough anymore and I need something more advanced. I already have a data structure in mind, but I don't know how to implement that...
4
2894
by: Rose | last post by:
Hi, guys, Is there such a tool? I also hope it is free. Thanks! Rose
0
1522
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 done by looking at the project source code or assembly. Any suggestion will be appreciated.
2
1349
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 it called by. A visual directed graph is a 'nice to have' but a table, or even a sorted list will do. It would be nice if I can select the scope:...
0
7836
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8336
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8212
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6606
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2343
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1175
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.