From: Khoo Yit Phang <khooyp@cs.umd.edu>
To: Tom Tromey <tromey@redhat.com>
Cc: Khoo Yit Phang <khooyp@cs.umd.edu>, gdb-patches@sourceware.org
Subject: Re: Handle SIGINT in Python
Date: Wed, 11 Jan 2012 21:49:00 -0000 [thread overview]
Message-ID: <1FE2845A-162C-48D7-A3D0-C0F2D6DFA09B@cs.umd.edu> (raw)
In-Reply-To: <m34nw254qr.fsf@fleche.redhat.com>
Hi,
On Jan 11, 2012, at 4:06 PM, Tom Tromey wrote:
>>>>>> "Yit" == Khoo Yit Phang <khooyp@cs.umd.edu> writes:
>
> Yit> I've written a patch to GDB's Python support to allow SIGINT to
> Yit> interrupt a running script to address the bug
> Yit> http://sourceware.org/bugzilla/show_bug.cgi?id=13265 (I've attached my
> Yit> patch to that page).
>
> See my other note about how to send the patch; and my other other note
> about copyright assignments.
I'll attach a patch in a moment.
> I don't understand why this code doesn't just pass the old signal
> handler as an argument to the cleanup function. I think that would be
> more readable.
> What happens when the Python code calls back into gdb?
> We do this in many places in gdb/python/*.c.
> It seems to me that you'd have to temporarily push gdb's SIGINT handler
> again.
It is not the old signal handler that's being restored. My implementation handles the following sequence of events:
... SIGINT is handle_sigint_orig ...
(gdb) python
... SIGINT is python_handle_sigint
>>> gdb.execute("something that changes the SIGINT handler to handle_sigint_new")
... python_handle_sigint is suspended and SIGINT is restored to handle_sigint_orig
... gdb.execute runs and changes SIGINT is updated to handle_sigint_new
... python_handle_sigint is resumed, but python_saved_sigint_handler is now handle_sigint_new
>>> ^D
... SIGINT is handle_sigint_new, *not* handle_sigint_orig
(gdb)
> Could we possibly solve this problem without constantly resetting the
> SIGINT handler? Maybe via a combination of a global flag plus a call
> into Python from handle_sigint?
It is possible, I just need a way to call PySet_Interrupt. But it seems to be that it would require adding hooks to events-top.c and, which seems like a separate project.
> Our python->gdb exception story is not super. And, we lose information
> in the round trip. This might (or might not...) be a prerequisite to
> solving this problem.
I don't think it's a problem, unless for nested calls to python like "py gdb.execute('py ...')".
Yit
January 11, 2012
next prev parent reply other threads:[~2012-01-11 21:46 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
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 [this message]
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=1FE2845A-162C-48D7-A3D0-C0F2D6DFA09B@cs.umd.edu \
--to=khooyp@cs.umd.edu \
--cc=gdb-patches@sourceware.org \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).