This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: exceptions.KeyboardInterrupt is thrown in gdb.base/random-signal.exp
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 03 Dec 2015 17:19:19 +0000
- Subject: Re: exceptions.KeyboardInterrupt is thrown in gdb.base/random-signal.exp
- Authentication-results: sourceware.org; auth=none
- References: <86ziy2xdt7 dot fsf at gmail dot com> <5655E141 dot 7030503 at redhat dot com> <86zixut7ju dot fsf at gmail dot com> <566039BF dot 5000207 at redhat dot com> <86oae7sbl8 dot fsf at gmail dot com>
On 12/03/2015 05:09 PM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
>
>> IMO, if the inferior is running and target_terminal_inferior is not in
>> effect (*) then the ctrl-c should _not_ trigger a Python
>> KeyboardInterrupt, but instead
>> be sent to the target -- if the target is running and we're running some
>> not-supposed-to-be-interactive Python unwinder code while processing
>> some internal stop
>> event, we know that the Python code will finish quickly and the target
>> should stop
>> for the SIGINT very soon. IOW, we treat the ctrl-c at exactly the
>> wrong time as if
>> it had been pressed a little sooner or later, outside Python.
>>
>> (*) - and it shouldn't, while an internal event is being processed.
>
> If I understand you correctly, ctrl-c shouldn't trigger a Python
> KeyboardInterrupt, and we should fix it somewhere in GDB.
Yes.
>
>>
>> To handle the case of something going wrong and gdb getting stuck in a loop too
>> long that the target's SIGINT takes forever to be processed, we could make gdb
>> react to a _second_ (impatient) ctrl-c as "okay, I'm sick of waiting,
>> please stop
>> whatever you're doing". This is like how remote.c handles ctrl-c at exactly the
>> wrong moment (while an internal event is processed) nowadays:
>>
>> https://sourceware.org/ml/gdb-patches/2015-08/msg00574.html
>
> I don't know how is this problem related to the second ctrl-c. It is
> expected that single ctrl-c should interrupt the target, why do we need
> the second ctrl-c in this case?
>
Say the Python code has a bug and ends up stuck in a loop and
doesn't finish quickly what it's supposed to do (the target is never
re-resumed and the SIGINT stop never processed). The user types
ctrl-c, and, nothing happens. After a while, the user gets sick of waiting,
and presses ctrl-c again. At this point, we could ask the user what
do to, raise KeyboardInterrupt, Quit, etc.
Thanks,
Pedro Alves