Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 175315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:40:37+00:00 2026-05-11T13:40:37+00:00

Can gcc spit out, given a C file, a list of the all function

  • 0

Can gcc spit out, given a C file, a list of the all function calls that occur, with filename and line number both for the call itself and for the function’s declaration?

I know gcc somehow retains this information with -g (debuggers rely on it) and that it can dump control flow graphs with -dr (but without filenames or line numbers); but is there a ready-to-use tool that takes gcc output and does what I want?

The reason I want such a tool to use gcc is that this will allow me to use it with the standard build system most gcc-based software comes with (e.g. ./configure && make) even in cases where tools that rely on their own preprocessor and/or parser are a major hassle to fit in. I’m already aware of several such tools, e.g. ctags. So this question is a followup to question 525899.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:40:38+00:00Added an answer on May 11, 2026 at 1:40 pm

    Try gcc option -fdump-tree-fixupcfg-lineno.

    It will ‘pretty print’ parsing AST (with line numbers) in a way that can easily be parsed using relatively simple lexer or any regex engine. Just find all non-keywords preceded by ‘=’ and followed by ‘(‘ – it will be function calls.

    All complex expressions will be split into several lines so no two function calls will appear on one line.

    Take simple program:

    #include <stdio.h> #include <stdlib.h> #include <math.h>  #define PI (3.1415926536)  int main(int argc, char *argv[]) {     double  angle = PI / 2.0;     printf('Sine = %lf, cosine = %lf\n', sin(angle), cos(angle));     return EXIT_SUCCESS; } 

    Compile it with -fdump-tree-fixupcfg-lineno and you get something like this:

    main (argc, argv) {   double angle;   int D.3381;   double D.3380;   double D.3379;    # BLOCK 2, starting at line 8   # PRED: ENTRY (fallthru)   [test.c : 8] angle = 1.57079632680000003119857865385711193084716796875e+0;   [test.c : 9] D.3379 = [test.c : 9] cos (angle);   [test.c : 9] D.3380 = [test.c : 9] sin (angle);   [test.c : 9] printf (&'Sine = %lf, cosine = %lf\n'[0], D.3380, D.3379);   [test.c : 10] D.3381 = 0;   return D.3381;   # SUCC: EXIT  } 

    You won’t get any complex expressions – just assignments and function call and no CPP macros, very easy to parse. Loops and conditionals don’t make it much more difficult.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Where can I find yylloc? I have included libfl.a (-lfl) in gcc command line,
Has anyone taken advantage of the automatic vectorization that gcc can do? In the
I am aware that on most GNU/Linux systems, GCC can be invoked by the
The v4 series of the gcc compiler can automatically vectorize loops using the SIMD
As far as I know, in gcc you can write something like: #define DBGPRINT(fmt...)
I know MSVC can do this via a pragma message -> http://support.microsoft.com/kb/155196 Does gcc
I'm trying to build python 2.5.2 on Solaris 8 using gcc 3.4.2. I can't
Can somebody point me to a resource that explains how to go about having
Can you cast a List<int> to List<string> somehow? I know I could loop through
Can a LINQ enabled app run on a machine that only has the .NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.