public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Phil Muldoon <pmuldoon@redhat.com>
To: Kevin Pouget <kevin.pouget@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: GDB Python API: stop/continue after breakpoint
Date: Fri, 11 Mar 2011 16:25:00 -0000	[thread overview]
Message-ID: <m3wrk58w0d.fsf@redhat.com> (raw)
In-Reply-To: <AANLkTim7t_4C8n=PJ8ZgCT=HsU7vdHMXyGWOe6QVCHfE@mail.gmail.com>	(Kevin Pouget's message of "Fri, 11 Mar 2011 17:08:57 +0100")

Kevin Pouget <kevin.pouget@gmail.com> writes:

> Hello,
>
> I've tried the GDB python interface today, which seems quite
> efficient, but there is one important thing I couldn't figure out by
> myself:
>
> how to restart GDB when a[n internal] breakpoint is hit ?
> from the testsuite I've got this code:


You almost can. One part is pending:

http://sourceware.org/ml/gdb-patches/2011-03/msg00656.html

The implementation of the "stop" API.  The idea behind this is that if a
breakpoint is hit, that is tracked from Python and has an implemented
stop method, that method would be called.  You can do what you like in
that method.  If you want the inferior process to continue, return True
otherwise return False (and print out/do whatever else you need to do in
Python).

Because internal breakpoints are not tracked by default in the Python
Breakpoint API, you would have to create your breakpoint by
instantiating a gdb.Breakpoint class, and pass the keyword
internal=True.

So, long story short soon.  OTOH I'm not sure if there is a unhacky way
of doing it now.  You could use a convenience function, but that patch
is replacing that hacky way.

Cheers

Phil
>
> def breakpoint_stop_handler (event):
>     if (isinstance (event, gdb.StopEvent)):
>         print "event type: stop"
>     if (isinstance (event, gdb.BreakpointEvent)):
>         print "stop reason: breakpoint"
>         print "breakpoint number: %s" % (event.breakpoint.number)
>         if ( event.inferior_thread is not None) :
>             print "thread num: %s" % (event.inferior_thread.num);
>         else:
>             print "all threads stopped"
>
> gdb.events.stop.connect (breakpoint_stop_handler)
>
>
> which where I get the notification of the stop, but I'd to be able to
> tell GDB something like
>
> enum bpstat_what_main_action {
>     /* Remove breakpoints, single step once, then put them back in and
>        go back to what we were doing.  It's possible that this should
>        be removed from the main_action and put into a separate field,
>        to more cleanly handle  BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE.  */
>     BPSTAT_WHAT_SINGLE,
>     /* Stop silently.  */
>     BPSTAT_WHAT_STOP_SILENT,
>
>     /* Stop and print.  */
>     BPSTAT_WHAT_STOP_NOISY,
> ...
> }
>
> to continue silently, stop silently or print the breakpoint hit.
>
> is it possible at this stage ?
>
> Thanks,
>
> Kevin

  reply	other threads:[~2011-03-11 16:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-11 16:09 Kevin Pouget
2011-03-11 16:25 ` Phil Muldoon [this message]
     [not found]   ` <AANLkTin_a87WgchmZnzi9_XX4DXh8q-r3P7EyyDAzTA4@mail.gmail.com>
2011-03-11 17:52     ` Kevin Pouget
2011-04-20 14:59       ` Kevin Pouget
2011-04-20 15:15         ` Phil Muldoon
2011-04-20 15:39         ` Tom Tromey
2011-04-21 13:01           ` Kevin Pouget
     [not found]             ` <BANLkTinwMfsxA24q-5ekbapVdM_OP6rOsQ@mail.gmail.com>
2011-04-21 14:32               ` Kevin Pouget
2011-04-20 15:20       ` Tom Tromey
2011-03-21 14:20   ` Kevin Pouget
2011-03-21 14:39     ` Phil Muldoon
2011-03-21 15:11       ` Kevin Pouget

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=m3wrk58w0d.fsf@redhat.com \
    --to=pmuldoon@redhat.com \
    --cc=gdb@sourceware.org \
    --cc=kevin.pouget@gmail.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).