Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: <Paul_Koning@Dell.com>
Cc: <dje@google.com>, <khooyp@cs.umd.edu>, <gdb-patches@sourceware.org>
Subject: Re: Handle SIGINT in Python
Date: Wed, 11 Jan 2012 21:23:00 -0000	[thread overview]
Message-ID: <m3zkdu3prv.fsf@fleche.redhat.com> (raw)
In-Reply-To: <09787EF419216C41A903FD14EE5506DD030F1EAD9E@AUSX7MCPC103.AMER.DELL.COM>	(Paul Koning's message of "Wed, 11 Jan 2012 15:03:08 -0600")

>>>>> "Paul" ==   <Paul_Koning@Dell.com> writes:

Paul> To get what you're asking (C-c work like in non-Python settings in
Paul> GDB) all that would be needed is for the interpreter top level to
Paul> check for specifically the KeyboardInterrupt exception and give that
Paul> to the GDB C-c handler, rather than printing the default exception
Paul> traceback.  It would still do that for other (non-interrupt)
Paul> exceptions.

I think there are basically 2 cases to consider: does the SIGINT arrive
in Python code, or in GDB code?

In GDB code, the SIGINT handler should be handle_sigint.  (AFAIK --
there may be other situations, and I'm not familiar with all of them).
This sets quit_flag.  Then, appropriate spots in GDB invoke QUIT, which
checks this flag and calls 'fatal' if it is set.  fatal just throws a
RETURN_QUIT exception.

In Python code, <mumble> is the SIGINT handler.  I believe it calls
PyErr_SetInterrupt.  Then Python does something similar: it checks this
flag periodically and turns it into a KeyboardInterrupt exception.


We are already pretty good at converting GDB exceptions to Python
exceptions.  gdbpy_convert_exception handles the RETURN_QUIT ->
KeyboardInterrupt case already.

We are pretty bad at converting Python exceptions to GDB exceptions.
See:
http://sourceware.org/bugzilla/show_bug.cgi?id=12174
This is the problem where we lose information in exception round-trips.

So, one idea would be to make this better: fix the round-trip problem,
and convert KeyboardInterrupt to RETURN_QUIT, then find all the
Python->GDB boundaries and make them deal with this as appropriate.

Perhaps we could also just have a single SIGINT handler that can handle
all cases.  I am not sure.

Tom


  reply	other threads:[~2012-01-11 21:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-10 21:31 Khoo Yit Phang
2012-01-10 21:47 ` Doug Evans
2012-01-10 22:09   ` Khoo Yit Phang
2012-01-11 20:59   ` Tom Tromey
2012-01-11 21:06     ` Paul_Koning
2012-01-11 21:23       ` Tom Tromey [this message]
2012-01-12  0:54     ` Doug Evans
2012-01-12 15:52       ` Kevin Pouget
2012-01-12 16:48         ` Paul_Koning
2012-01-13 10:55           ` Kevin Pouget
2012-01-13 12:11             ` Paul_Koning
2012-01-10 21:49 ` Tom Tromey
2012-01-11 21:15 ` Tom Tromey
2012-01-11 21:49   ` Khoo Yit Phang
2012-01-11 22:46     ` Khoo Yit Phang
2012-01-20 21:40     ` Tom Tromey
2012-01-22 16:36       ` Khoo Yit Phang
2012-01-22 20:54         ` Khoo Yit Phang

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=m3zkdu3prv.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=Paul_Koning@Dell.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=khooyp@cs.umd.edu \
    /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