How do I get the return value using __cyg_profile_func_exit?

By using the tool function flag in gcc, you can force code to execute functions before and after each function execution. These functions are __cyg_profile_func_enter and __cyg_profile_func_exit with two parameters, the address of the current function; the second parameter to enter is the address of the calling site and to exit from the address from which it is returned.

Is there a way to get the value that was actually returned by the instrumental function?

+2


source to share


1 answer


As far as I know (and in no way citing me on this), to get the return value using __cyg_profile_func_exit we need to set our optimization flag to -O0, iirc, it doesn't work with degrees of optimization above that due to -O0 stores the return value in ebx, and higher optimization flags store the return value in eax; after which eip is called. So, to avoid the ebx killed by the toolkit function, we save it when we introduce the function, and restore it when we part.



Hope this helps, good luck.

+1


source







All Articles