[1/2,GDBserver] Check input interrupt after reading in a packet
Commit Message
Pedro Alves <palves@redhat.com> writes:
> I think we should expand the explanation, like:
>
> /* The readchar above may have already read a '\003' out of the socket and
> moved it to the local buffer. For example, when GDB sends vCont;c immediately
> followed by interrupt (see gdb.base/interrupt-noterm.exp). As soon as we see
> the vCont;c, we'll resume the inferior and wait. Since we've already moved
> the '\003' to the local buffer, SIGIO won't help. In that case, if we don't
> check for interrupt after the vCont;c packet, the interrupt character would
> stay in the buffer unattended until after the next (unrelated) stop. */
>
Take it into the patch.
>> + if (readchar_bufcnt > 0 && *readchar_bufp == '\003')
>
> This should be a "while" instead of a single "if".
>
Fixed.
>> + {
>> + /* Consume the interrupt character in the buffer. */
>> + readchar ();
>> + (*the_target->request_interrupt) ();
>> + }
>> +
>> return bp - buf;
>> }
>
> Otherwise LGTM.
Patch below is pushed in.
@@ -1,3 +1,8 @@
+2016-01-26 Yao Qi <yao.qi@linaro.org>
+
+ * remote-utils.c (getpkt): If the buffer isn't empty, and the
+ first character is '\003', call *the_target->request_interrupt.
+
2016-01-25 Yao Qi <yao.qi@linaro.org>
* remote-utils.c (new_thread_notify): Remove.
@@ -1041,6 +1041,22 @@ getpkt (char *buf)
}
}
+ /* The readchar above may have already read a '\003' out of the socket
+ and moved it to the local buffer. For example, when GDB sends
+ vCont;c immediately followed by interrupt (see
+ gdb.base/interrupt-noterm.exp). As soon as we see the vCont;c, we'll
+ resume the inferior and wait. Since we've already moved the '\003'
+ to the local buffer, SIGIO won't help. In that case, if we don't
+ check for interrupt after the vCont;c packet, the interrupt character
+ would stay in the buffer unattended until after the next (unrelated)
+ stop. */
+ while (readchar_bufcnt > 0 && *readchar_bufp == '\003')
+ {
+ /* Consume the interrupt character in the buffer. */
+ readchar ();
+ (*the_target->request_interrupt) ();
+ }
+
return bp - buf;
}