I am trying to intercept a function with Valgrind, according to their example .
I can intercept a global function when building with gcc, however, when I compile the same code with g ++, the interception does not work.
Is there anything special about compiler flags that I should specify?
Here is my sample application:
#include <stdio.h> #include "valgrind.h" __attribute__ ((noinline)) void foo() { printf("inside foo\n"); } void I_WRAP_SONAME_FNNAME_ZU(NONE,foo)() { OrigFn fn; VALGRIND_GET_ORIG_FN(fn); printf("*** Before foo()\n"); CALL_FN_v_v(fn); printf("*** After foo()\n"); } int main() { foo(); return 0; }
When compiling with GCC, the output is:
*** Before foo()
inside foo
*** After foo()
However, when compiling with g ++, the output is simply
inside foo
source share