From: Kevin Pouget <kevin.pouget@gmail.com>
To: Khoo Yit Phang <khooyp@cs.umd.edu>
Cc: Tom Tromey <tromey@redhat.com>,
gdb-patches@sourceware.org, Doug Evans <dje@google.com>
Subject: Re: Handle SIGINT in Python
Date: Thu, 12 Jan 2012 15:52:00 -0000 [thread overview]
Message-ID: <CAPftXUJgSPMv7pDntMJh+5-2wR+N54UxG-mPR_csGvwL09DsOQ@mail.gmail.com> (raw)
In-Reply-To: <CADPb22QsbEyUN+U_5kEAO8-OFhkCzue_Vxqdmn6_eV0uNqRgHw@mail.gmail.com>
On Thu, Jan 12, 2012 at 1:17 AM, Doug Evans <dje@google.com> wrote:
>
> On Wed, Jan 11, 2012 at 12:55 PM, Tom Tromey <tromey@redhat.com> wrote:
> >>>>>> "Doug" == Doug Evans <dje@google.com> writes:
> >
> > Doug> There is value in having the SIGINT *only* affect the inferior.
> > Doug> It's up to the script to handle the various reasons why the inferior
> > Doug> may have stopped, and you don't (generally) want to interfere with
> > Doug> that (by interrupting the script too).
> >
> > I think Python code should have to request something like this
> > specially. The scripting case is less usual than the interactive
> > debugging (perhaps with some Python helper code) case. I think it would
> > be weird for the behavior the user sees, by default, to depend on
> > whether Python or GDB code was active at the moment of C-c.
>
> I'm not sure we're talking about the same thing.
> I wasn't suggesting the behaviour be different depending on whether
> GDB or Python was running.
> [For reference sake, to make sure we're on the same page, my comment
> is solely for the case where the inferior is launched by gdb, the
> inferior is running, has the terminal, and will get the SIGINT.]
>
> > That is, a C-c when processing a 'python' command in a breakpoint's
> > 'commands' list should have the same general effect as if we were
> > processing any other command.
>
> PTAL.
Hello,
just my 2 cents to the discussion.
[I'm not sure I could follow all the arguments, so my comments are
based on Khoo's patch]
+static void
+gdbpy_handle_sigint (int sig)
+{
+ PyErr_SetInterrupt ();
+}
I would be quite afraid if GDB could throw an
KeyboardInterruptException in any call to its API, there wouldn't be
any way to ensure internal consistency inside the script, except with
try_catch surrounding every GDB function call ...
In http://sourceware.org/bugzilla/show_bug.cgi?id=12615 I suggested
using something similar to what already exist in GDB:
> #define QUIT { \
> if (quit_flag) quit (); \
> if (deprecated_interactive_hook) deprecated_interactive_hook (); \
> }
and:
> /* Nonzero means a quit has been requested. */
> int quit_flag;
> int immediate_quit;
that is, setting a Python-reachable flag and let the script decides what to do.
`remote.c' mechanism
> /* Signal handler for SIGINT, while the target is executing. */
> static void
>
> handle_remote_sigint (int sig)
> {
> signal (sig, handle_remote_sigint_twice);
> ...
> /* Signal handler for SIGINT, installed after SIGINT has already been
> sent once. It will take effect the second time that the user sends
> a ^C. */
> static void
> handle_remote_sigint_twice (int sig)
could also be used to actually send the KeyboardInterruptException if
C^c is hit twice.
Kevin
next prev parent reply other threads:[~2012-01-12 15:25 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
2012-01-12 0:54 ` Doug Evans
2012-01-12 15:52 ` Kevin Pouget [this message]
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=CAPftXUJgSPMv7pDntMJh+5-2wR+N54UxG-mPR_csGvwL09DsOQ@mail.gmail.com \
--to=kevin.pouget@gmail.com \
--cc=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=khooyp@cs.umd.edu \
--cc=tromey@redhat.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