This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Handle SIGINT in Python


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]