开发者

Using GDB in timer functions

开发者 https://www.devze.com 2023-02-21 18:55 出处:网络
I have a C program which uses a timer, when the timer expires the program does something (sets a flag).

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号