waiting_for_stop_reply around remote_fileio_request

Message ID 861t8spl2o.fsf@gmail.com
State New, archived
Headers

Commit Message

Yao Qi Feb. 4, 2016, 3:11 p.m. UTC
  Pedro Alves <palves@redhat.com> writes:

> LGTM, with nits below.
>
>> diff --git a/gdb/remote.c b/gdb/remote.c
>> index d5701e3..f396a8f 100644
>> --- a/gdb/remote.c
>> +++ b/gdb/remote.c
>> @@ -6994,8 +6994,16 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
>>        status->value.sig = GDB_SIGNAL_0;
>>        break;
>>      case 'F':		/* File-I/O request.  */
>> +      /* GDB may access the inferior memory while handling the File-I/O
>> +	 request, but we don't want it GDB accessing memory while waiting
>
> Either "want it", or "want GDB", instead of  "want it GDB".
>
>
>>        remote_fileio_request (buf, rs->ctrlc_pending_p);
>>        rs->ctrlc_pending_p = 0;
>> +      /* GDB handled the File-I/O request, but the target is running
>> +	 again.  Keep waiting for events.  */
>
> s/but/and/.

Fixed.  Patch below is pushed in.
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 829a48c..a2b0d39 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@ 
+2016-02-04  Yao Qi  <yao.qi@linaro.org>
+
+	* remote.c (remote_wait_as): Set rs->waiting_for_stop_reply to
+	0 before handling 'F' and set it back afterwards.
+
 2016-02-02  Simon Marchi  <simon.marchi@ericsson.com>
 
 	* ui-out.c (MAX_UI_OUT_LEVELS): Remove.
diff --git a/gdb/remote.c b/gdb/remote.c
index 8831b50..b1af8aa 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6984,8 +6984,16 @@  remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
       status->value.sig = GDB_SIGNAL_0;
       break;
     case 'F':		/* File-I/O request.  */
+      /* GDB may access the inferior memory while handling the File-I/O
+	 request, but we don't want GDB accessing memory while waiting
+	 for a stop reply.  See the comments in putpkt_binary.  Set
+	 waiting_for_stop_reply to 0 temporarily.  */
+      rs->waiting_for_stop_reply = 0;
       remote_fileio_request (buf, rs->ctrlc_pending_p);
       rs->ctrlc_pending_p = 0;
+      /* GDB handled the File-I/O request, and the target is running
+	 again.  Keep waiting for events.  */
+      rs->waiting_for_stop_reply = 1;
       break;
     case 'N': case 'T': case 'S': case 'X': case 'W':
       {