This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 2/4]: Handle SIGINT under Python by raising KeyboardInterrupt
- From: Tom Tromey <tromey at redhat dot com>
- To: Khoo Yit Phang <khooyp at cs dot umd dot edu>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 25 Jul 2012 11:28:14 -0600
- Subject: Re: [PATCH 2/4]: Handle SIGINT under Python by raising KeyboardInterrupt
- References: <E7EE97CE-30A6-4C4A-8606-CB86F204207D@cs.umd.edu>
>>>>> "Yit" == Khoo Yit Phang <khooyp@cs.umd.edu> writes:
Yit> diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
Yit> --- a/gdb/python/python-internal.h
Yit> +++ b/gdb/python/python-internal.h
Yit> @@ -102,8 +102,11 @@
Yit> #include "command.h"
Yit> #include "breakpoint.h"
Yit> +#include "defs.h"
I think this should not be needed. It ought to be in each individual .c
file.
Yit> +static sig_t gdbpy_saved_sigint_handler;
Rather than use a global, it seems a bit better to me to store the old
signal handler in the python_env, and then restore it from there.
Yit> +static void
Yit> +gdbpy_handle_sigint (int sig)
All new functions need an introductory comment.
In cases like these the comment can be reasonably short.
Yit> +{
Yit> + PyErr_SetInterrupt ();
The gdb style seems to be to reinstall the signal handler here:
signal (sig, gdbpy_handle_sigint);
PyErr_SetInterrupt ();
I guess this is for safety on SysV-like systems.
I have no idea whether this is still relevant, but it seems harmless.
Yit> + gdbpy_suspend_sigint_handler ();
This addition handles one instance of the python->gdb transition, but
there are many more to fix.
Tom