Re: Can GDB support "temporal breakpoints"?
Pedro Alves <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <[email protected]> |
On 10/30/2014 12:18 PM, [email protected] wrote: >> I can also imagine a hack where you run a side program >> that sleeps for the specified period of time and it sends SIGUSR1 >> (or whatever) to the inferior, and then have gdb catch SIGUSR1, >> do whatever you want at that time, >> and then resume the inferior (discarding the signal). > > I'll investigate this solution, although I think I'll have the sma > intrusion problem (in the Linux kernel). Alternatively, write a little Python. You can subclass python's gdb.Breakpoint to create new breakpoint types, and implement the Breakpoint.stop method to adjust when the breakpoint causes a stop or not. See https://sourceware.org/gdb/onlinedocs/gdb/Breakpoints-In-Python.html In your case, you'd return false if the time hasn't passed yet. Something like: class bp_timer (gdb.Breakpoint): def stop (self): if timer has elapsed return True return False end (gdb) python bp = bp_timer("function_foo") Alternatively, write a convenience function in Python, that handles the "has time elapsed time" part. Then use that as breakpoint's condition predicate. Something along the lines of: (gdb) python mytimer = MyTimer(10) (gdb) break foo if $my_timer_elapsed_predicate(mytimer) https://sourceware.org/gdb/onlinedocs/gdb/Functions-In-Python.html Thanks, Pedro Alves