It is very easy to modify gprof to profile wall clocks. The only 8 characters to replace are:
ITIMER_PROF -> ITIMER_REAL SIGPROF -> SIGALRM
in the glibc/sysdeps/posix/profil.c , the __profil function, next to the setitimer and sigaction (more precise __Setitimer and __sigaction )
After the change, any program that uses SIGALRM will be interrupted, and any program that does not restart the syscall lock code may produce incorrect results.
In addition, you can directly modify int values ββin a glibc binary (please do not do this throughout the libc.so system, create a separate copy and pass it to the program with LD_LIBRARY_PATH)
For a binary patch, ITIMER_PROF is 2; ITIMER_REAL - 0; SIGPROF is 27 (0x1b); SIGALRM is 14 (0x0e). There are two places for each constant in the profil glibc function.
Another way is to write ptrace-debugger, which will change the arguments to the setitimer and sigaction functions at run time.
osgx
source share