tags:

views:

181

answers:

2

I have some very large C files, having lots of functions. I need to trace the execution path at run time. There is no way I can trace it through debugging as its a hypervisor code currently running over qemu and doing a lot of binary translations.

Can anyone point me to some script in Perl or Python which can add a printf at the starting of all functions and the text could be something like "I am in < function name >"?

+20  A: 

Just pass -finstrument-functions to gcc when compiling. See the gcc(1) man page for details.

Ignacio Vazquez-Abrams
Perfect answer to the spirit of the question.
Noufal Ibrahim
@Ignacio +1. Just to add, then entry code might look like:printf("Function details: %s\n", ____PRETTY_FUNCTION____); ____PRETTY_FUNCTION____ is predefined macro that provides a string containing function name + signature.
Fanatic23
+2  A: 

Here is a nice example of what you want.

Yousf