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 6945323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:25:17+00:00 2026-05-27T13:25:17+00:00

I have an almost identical question as How to add code at the entry

  • 0

I have an almost identical question as How to add code at the entry of every function? but for C:

As I’m maintaining someone else’s large undocumented project, I wish to have code similar to

static C0UNT_identifier_not_used_anywhere_else = 0;
printf("%s%s:%d#%d", __func__, strrchr(__FILE__,'/'), __LINE__, ++C0UNT_identifier_not_used_anywhere_else);

to run on entry of every function, so that I

  1. have a log of what calls what, and
  2. can tell, on which nth call to a function it breaks.

The existing code comprises hundreds of source files, so it is unfeasible to put a macro e.g.

#define ENTRY_CODE ...
...
int function() {
  ENTRY_CODE
  ...
}

in every function. I am also not using DevStudio, Visual Studio or other compiler providing __cyg_profile_func_enter or such extensions.

Optionally, I’d like to printf the return value of each function on exit in a similar style. Can I do that too?

  • 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. Editorial Team
    Editorial Team
    2026-05-27T13:25:18+00:00Added an answer on May 27, 2026 at 1:25 pm

    Since you have tagged with gcc it has the -finstrument-functions option:

    Generate instrumentation calls for entry and exit to functions. …

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

Sidebar

Related Questions

I have two almost identical classes, in fact every member function is identical, every
I have 2 skins, almost identical, but differ in 1 small way that can
ok, yesterday I posted almost identical question here , but I wasn't able to
Sorry - my question is almost identical to this one but since it didn't
My question is almost identical to this one , but the solution there hasn't
I have two almost identical Beans. Bean Item contains a unique identifier (primary key),
I have two websites that have an almost identical database schema. the only difference
I have the following test, with two almost identical blocks. Now i am looking
This is almost identical to this question asked by another user, and is the
I have two tables almost identical: employee employee_history The second table has two additional

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.