Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Need help for generating tag files for source code
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
jens.toerr...@physik.fu-berlin.de  
View profile  
 More options Mar 28 2005, 2:59 pm
Newsgroups: comp.os.linux.development.apps, comp.os.linux.help
From: Jens.Toerr...@physik.fu-berlin.de
Date: 28 Mar 2005 19:59:06 GMT
Local: Mon, Mar 28 2005 2:59 pm
Subject: Re: Need help for generating tag files for source code
prasanna bhat mavinkuli <boss_b...@yahoo.co.in> wrote:

> I am a fresher to Linux. Actually I want to get a list
> of all the function calls made in C, C++ source files.
> we can obtain list of all function definitions in C/c++
> source files using ctags. Any other utility available
> on linux that can give the list of all function calls
> invoked in source files?

Do you mean all functions that are referenced in the C code
or do you mean all functions that in a run of the program
are called? The latter is a question that can't be answered
generally, since what functions get invoked can depend on
how the program gets started or on external input it receives.
With something as simple as

#include <stdio.h>

void func_a( void ) {
    printf( "Program was called with no arguments\n" );

}

void func_b( void ) {
    printf( "Program was called with at least one argument\n" );

}

int main( int argc, char *argv[ ] ) {
    if ( argc <= 1 )
        func_a( );
    else
        func_b( );
    return 0;

}

you already can't tell. But even the first question can be hard
to answer when function pointers are used. E.g.

#include <stdio.h>

void func_a( void ) {
    printf( "Program was called with no arguments\n" );

}

void func_b( void ) {
    printf( "Program was called with at least one argument\n" );

}

int main( int argc, char *argv[ ] ) {
     void ( *f )( void );
     f = argc <= 1 ? func_a : func_b;
     f( );
         return 0;

}

makes it hard to automatically detect if func_a() or func_b() are
actually used at all (here it's still rather obvious, but things
can get a lot more complicated). Moreover, a function can be defined
in one source file but only used from a different one. Even the
compiler can't find out then - gcc has the '-funused-function' option
to warn you about function that are declared as static but aren't used,
but that's as far as you can get with a compiler (since it always only
sees a single souce file). If e.g. a functions address is assigned to
a function pointer and this one is passed to a function in a different
C source file it's impossible to say what function is going to be in-
voked by just looking at source file where the function pointer is used
to call the function. Only the linker would be able to tell which of
the symbols it found in the object files are never used. So writing
such a tool would definitely not be simple and would need to know all
about the commands used to create the final executable. Your best
chance is probably using a profiler that creates a list of which func-
tion where called how often (and how much time was spent in the
functions). But, of course, if the flow of control in the program
depends on external input the list might differ from invocation to
invocation.
                                   Regards, Jens
--
  \   Jens Thoms Toerring  ___  Jens.Toerr...@physik.fu-berlin.de
   \__________________________  http://www.toerring.de

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.