This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Can GDB support "temporal breakpoints"?
- From: Pedro Alves <palves at redhat dot com>
- To: joaoandreferro at sapo dot pt, Doug Evans <dje at google dot com>
- Cc: gdb <gdb at sourceware dot org>
- Date: Thu, 30 Oct 2014 12:43:00 +0000
- Subject: Re: Can GDB support "temporal breakpoints"?
- Authentication-results: sourceware.org; auth=none
- References: <20141029185541 dot Horde dot _3keczfPGLf4wL2j8_4tFw6 at mail dot sapo dot pt> <CADPb22QdQuCi6Ca3Y5EVYXdsdVmq_sKzE91AVkcpAHLO9f80DA at mail dot gmail dot com> <20141030121815 dot Horde dot 8vqm4_U-9cztH4TOoUFeYQ2 at mail dot sapo dot pt>
On 10/30/2014 12:18 PM, joaoandreferro@sapo.pt 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