c++11 - Intercepting sleep calls in C++ -
is there way intercept calls sleep , sleep-like functions in c++? i'd love able replace implementation no-op or in alternative, multiply sleep time. imagine aid in determining correctness of concurrent programs identifying source of flakiness in tests.
i'm operating on gigantic codebase, using wrapper function less satisfactory. maybe there's way use ptrace or same techniques programs valgrind use intercept malloc?
for gcc users there simple way modify calls libraries , link against own functions without changing code itself.
if have snippet like:
... stuff ... anylibfunc(); ... stuff ... you can advice linker use wrapped method following line:
gcc program.c -wl,-wrap,anylibfunc -o program and have add implementation of wrapped func:
void __wrap_anylibfunc () { __real_anylibfunc( ); // call real function } in hope working on gcc environment!
Comments
Post a Comment