Make GDB wait for events after handling target File-I/O

Message ID 5624EE71.4070403@codesourcery.com
State New, archived
Headers

Commit Message

Luis Machado Oct. 19, 2015, 1:21 p.m. UTC
  On 10/19/2015 07:21 AM, Pedro Alves wrote:
> On 10/16/2015 08:30 PM, Luis Machado wrote:
>
>> How does the attached update look?
>
> Is there a reason to keep the "rs->waiting_for_stop_reply = 1;" lines?

No, that was a mistake since we inverted the logic. What about the 
following?

Now we'll only set rs->waiting_for_stop_reply to 1 when resuming in 
"all-stop" mode.
  

Comments

Pedro Alves Oct. 19, 2015, 1:24 p.m. UTC | #1
On 10/19/2015 02:21 PM, Luis Machado wrote:
> On 10/19/2015 07:21 AM, Pedro Alves wrote:
>> On 10/16/2015 08:30 PM, Luis Machado wrote:
>>
>>> How does the attached update look?
>>
>> Is there a reason to keep the "rs->waiting_for_stop_reply = 1;" lines?
> 
> No, that was a mistake since we inverted the logic. What about the 
> following?
> 
> Now we'll only set rs->waiting_for_stop_reply to 1 when resuming in 
> "all-stop" mode.
> 

Thanks.  This version LGTM.
  
Luis Machado Oct. 19, 2015, 1:37 p.m. UTC | #2
On 10/19/2015 11:24 AM, Pedro Alves wrote:
> On 10/19/2015 02:21 PM, Luis Machado wrote:
>> On 10/19/2015 07:21 AM, Pedro Alves wrote:
>>> On 10/16/2015 08:30 PM, Luis Machado wrote:
>>>
>>>> How does the attached update look?
>>>
>>> Is there a reason to keep the "rs->waiting_for_stop_reply = 1;" lines?
>>
>> No, that was a mistake since we inverted the logic. What about the
>> following?
>>
>> Now we'll only set rs->waiting_for_stop_reply to 1 when resuming in
>> "all-stop" mode.
>>
>
> Thanks.  This version LGTM.
>

Thanks. Pushed now as 29090fb629734b7980f058f4a7e24a0369e9bb49.
  

Patch

2015-10-19  Luis Machado  <lgustavo@codesourcery.com>

	* remote.c (remote_wait_as): Set rs->waiting_for_stop_reply to 0
	when handling 'E', 'T', 'S', 'X' and 'W' packets.
	Do not set rs->waiting_for_stop_reply back to 1.
---
 gdb/remote.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index f40f791..fed397a 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6635,9 +6635,6 @@  remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
 
   rs->stop_reason = TARGET_STOPPED_BY_NO_REASON;
 
-  /* We got something.  */
-  rs->waiting_for_stop_reply = 0;
-
   /* Assume that the target has acknowledged Ctrl-C unless we receive
      an 'F' or 'O' packet.  */
   if (buf[0] != 'F' && buf[0] != 'O')
@@ -6648,6 +6645,8 @@  remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
     case 'E':		/* Error of some sort.	*/
       /* We're out of sync with the target now.  Did it continue or
 	 not?  Not is more likely, so report a stop.  */
+      rs->waiting_for_stop_reply = 0;
+
       warning (_("Remote failure reply: %s"), buf);
       status->kind = TARGET_WAITKIND_STOPPED;
       status->value.sig = GDB_SIGNAL_0;
@@ -6658,7 +6657,12 @@  remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
       break;
     case 'T': case 'S': case 'X': case 'W':
       {
-	struct stop_reply *stop_reply
+	struct stop_reply *stop_reply;
+
+	/* There is a stop reply to handle.  */
+	rs->waiting_for_stop_reply = 0;
+
+	stop_reply
 	  = (struct stop_reply *) remote_notif_parse (&notif_client_stop,
 						      rs->buf);
 
@@ -6667,10 +6671,6 @@  remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
       }
     case 'O':		/* Console output.  */
       remote_console_output (buf + 1);
-
-      /* The target didn't really stop; keep waiting.  */
-      rs->waiting_for_stop_reply = 1;
-
       break;
     case '\0':
       if (rs->last_sent_signal != GDB_SIGNAL_0)
@@ -6686,17 +6686,11 @@  remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
 
 	  strcpy ((char *) buf, rs->last_sent_step ? "s" : "c");
 	  putpkt ((char *) buf);
-
-	  /* We just told the target to resume, so a stop reply is in
-	     order.  */
-	  rs->waiting_for_stop_reply = 1;
 	  break;
 	}
       /* else fallthrough */
     default:
       warning (_("Invalid remote reply: %s"), buf);
-      /* Keep waiting.  */
-      rs->waiting_for_stop_reply = 1;
       break;
     }
 
-- 
1.9.1