Is there a way to measure elapsed time running the program under gdb?

Look to this:

         

Assume that we are debugging a file and in some random place, we set a breakpoint. Now in gdb we perform something and then we let the program continue the execution by using the gdb command line (run).

My question is here. I want to measure the elapsed time from the bp (breakpoint) until the program either successfully ends or some error occurs.

My suggestion is to use .gdbinit file, and in that file we call some C function to start the timer after run command and at the end of the execution we also call a gettime() C fun.

So, my pseudo code is a bit like this (.gdbinit file):

break *0x8048452 (random place)

//start time

run

//get time

More Hussien Al-haj Ahmad's questions See All
Similar questions and discussions