How to add a sentence to the enter entry and before return instruction of all the functions of my project . Thanks

StackOverflow https://stackoverflow.com/questions/23464403

  •  15-07-2023
  •  | 
  •  

Question

I want to print some useful message after entering or returning functions by adding the following sentence.

printf("enter %s\n", __FUNCTION__);

Add the following sentence before return instruction.

printf("exit %s\n", __FUNCTION__);

My OS is ubuntu. I think vim can do this work. Editing before return instruction is easy. However, to the first case, finding the first line of every function is not easy . Can gcc do this work during the precompiled period ? Can any one help me . Thanks very much.

Was it helpful?

Solution

You are considering an editor-based approach.

You could also consider a compiler based approach. You could extend GCC using your MELT extension which would add a pass. This pass would just have to add some extra Gimple into the GCC internal representations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top