Using GDB in timer functions
I have a C program which uses a timer, when the timer expires the program does something (sets a flag).
My question is: When i set the breakpoints and run the program 开发者_如何转开发using GDB, and use "step" to check line by line, does the timer keeps on ticking in the background? or does it halt till i press "s" again (the next step)?
Assuming you used CLOCK_REALTIME
, yes. The timer will keep ticking along and if you spend a bunch of time looking at a single instruction it will send its signal the next time something in your program is executed. You can use CLOCK_THREAD_CPUTIME_ID
or CLOCK_PROCESS_CPUTIME_ID
in Linux after 2.6.12, but those will probably not get you what you want, since they don't measure wall clock time.
精彩评论