Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: joaoandreferro@sapo.pt, Doug Evans <dje@google.com>
Cc: gdb <gdb@sourceware.org>
Subject: Re: Can GDB support "temporal breakpoints"?
Date: Thu, 30 Oct 2014 12:43:00 -0000	[thread overview]
Message-ID: <54523254.8070706@redhat.com> (raw)
In-Reply-To: <20141030121815.Horde.8vqm4_U-9cztH4TOoUFeYQ2@mail.sapo.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


      reply	other threads:[~2014-10-30 12:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-29 18:55 joaoandreferro
2014-10-29 23:11 ` Doug Evans
2014-10-30 12:18   ` joaoandreferro
2014-10-30 12:43     ` Pedro Alves [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54523254.8070706@redhat.com \
    --to=palves@redhat.com \
    --cc=dje@google.com \
    --cc=gdb@sourceware.org \
    --cc=joaoandreferro@sapo.pt \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox