Need help for generating tag files for source code - Help

This is a discussion on Need help for generating tag files for source code - Help ; hi all, 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. ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Need help for generating tag files for source code

  1. Need help for generating tag files for source code

    hi all,
    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?

    thanks in advance
    Prasanna Bhat Mavinkuli

  2. Re: Need help for generating tag files for source code

    boss_bhat@yahoo.co.in (prasanna bhat mavinkuli) writes:

    > hi all,
    > 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?


    Check out cscope.

    --
    Måns Rullgård
    mru@inprovide.com

  3. Re: Need help for generating tag files for source code

    prasanna bhat mavinkuli 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

    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

    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.Toerring@physik.fu-berlin.de
    \__________________________ http://www.toerring.de

  4. Re: Need help for generating tag files for source code

    On 28 Mar 2005 02:34:13 -0800, boss_bhat@yahoo.co.in (prasanna bhat
    mavinkuli) wrote:

    >we can obtain list of all function definitions in C/c++
    >source files using ctags.


    ...."we" as in those of us taking this class that want you do do our
    homework for us?

    --
    Joe Zeff
    The Guy With the Sideburns
    "Always there are two, the BOFH and the PFY."
    http://www.lasfs.org http://home.earthlink.net/~sidebrnz

+ Reply to Thread