* Can GDB support "temporal breakpoints"? @ 2014-10-29 18:55 joaoandreferro 2014-10-29 23:11 ` Doug Evans 0 siblings, 1 reply; 4+ messages in thread From: joaoandreferro @ 2014-10-29 18:55 UTC (permalink / raw) To: gdb Hello everyone, again, From what I've learned after reading GDB's excellent documentation, I know I can set a memory trigger (i. e., a breakpoint that is set every time a certain memory address changes) by setting a watchpoint at the desired memory address (a practical example is available here: http://stackoverflow.com/questions/58851/can-i-set-a-breakpoint-on-memory-access-in-gdb). The question I have now is if I can set a temporal breakpoint (i. e., a breakpoint that is only triggered after a user-defined amount of time has passed), in few words a breakpoint that is only fired after some kind of timer has expired. I haven't found anything related to this on the GDB docs, so I guess it's not possible, but they are huge and maybe I've missed something, somewhere. If anyone can confirm or deny this deduction, it would be great, because this feature is crucial to my work. Thanks for reading and regards, João ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can GDB support "temporal breakpoints"? 2014-10-29 18:55 Can GDB support "temporal breakpoints"? joaoandreferro @ 2014-10-29 23:11 ` Doug Evans 2014-10-30 12:18 ` joaoandreferro 0 siblings, 1 reply; 4+ messages in thread From: Doug Evans @ 2014-10-29 23:11 UTC (permalink / raw) To: joaoandreferro; +Cc: gdb On Wed, Oct 29, 2014 at 11:55 AM, <joaoandreferro@sapo.pt> wrote: > Hello everyone, again, > > From what I've learned after reading GDB's excellent documentation, I know I > can set a memory trigger (i. e., a breakpoint that is set every time a > certain memory address changes) by setting a watchpoint at the desired > memory address (a practical example is available here: > http://stackoverflow.com/questions/58851/can-i-set-a-breakpoint-on-memory-access-in-gdb). > The question I have now is if I can set a temporal breakpoint (i. e., a > breakpoint that is only triggered after a user-defined amount of time has > passed), in few words a breakpoint that is only fired after some kind of > timer has expired. I haven't found anything related to this on the GDB docs, > so I guess it's not possible, but they are huge and maybe I've missed > something, somewhere. If anyone can confirm or deny this deduction, it would > be great, because this feature is crucial to my work. Hi. There is no such thing, per se, but you might be able to approximate it by a breakpoint on a line of code that only triggers when the time has passed, or after the breakpoint is hit a certain number of times. 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). ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can GDB support "temporal breakpoints"? 2014-10-29 23:11 ` Doug Evans @ 2014-10-30 12:18 ` joaoandreferro 2014-10-30 12:43 ` Pedro Alves 0 siblings, 1 reply; 4+ messages in thread From: joaoandreferro @ 2014-10-30 12:18 UTC (permalink / raw) To: Doug Evans; +Cc: gdb Citando Doug Evans <dje@google.com>: > On Wed, Oct 29, 2014 at 11:55 AM, <joaoandreferro@sapo.pt> wrote: >> Hello everyone, again, >> >> From what I've learned after reading GDB's excellent documentation, I know I >> can set a memory trigger (i. e., a breakpoint that is set every time a >> certain memory address changes) by setting a watchpoint at the desired >> memory address (a practical example is available here: >> http://stackoverflow.com/questions/58851/can-i-set-a-breakpoint-on-memory-access-in-gdb). >> The question I have now is if I can set a temporal breakpoint (i. e., a >> breakpoint that is only triggered after a user-defined amount of time has >> passed), in few words a breakpoint that is only fired after some kind of >> timer has expired. I haven't found anything related to this on the GDB docs, >> so I guess it's not possible, but they are huge and maybe I've missed >> something, somewhere. If anyone can confirm or deny this deduction, it would >> be great, because this feature is crucial to my work. > > Hi. > > There is no such thing, per se, but you might be able to approximate it > by a breakpoint on a line of code that only triggers when the time > has passed, > or after the breakpoint is hit a certain number of times. Hi Doug, thanks for your answer. I know how I can set a breakpoint that only triggers after being hit a certain number of times, but how I'd be able to set a breakpoint on a line of code that only triggers after a certain time has passed? E. g., are you referring about writng a little piece of code (in C, for instance) executing something only after a timer manually set by myself, in that same code? If that's it, in that case I don't know if it will be possible, because I'm also using KGDB, and so I want the lowest intrusion possible. > > 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). Thanks! ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can GDB support "temporal breakpoints"? 2014-10-30 12:18 ` joaoandreferro @ 2014-10-30 12:43 ` Pedro Alves 0 siblings, 0 replies; 4+ messages in thread From: Pedro Alves @ 2014-10-30 12:43 UTC (permalink / raw) To: joaoandreferro, Doug Evans; +Cc: gdb 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-10-30 12:43 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-10-29 18:55 Can GDB support "temporal breakpoints"? joaoandreferro 2014-10-29 23:11 ` Doug Evans 2014-10-30 12:18 ` joaoandreferro 2014-10-30 12:43 ` Pedro Alves
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).