Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 5/8] Different notification from packets.
Date: Tue, 11 Dec 2012 06:41:00 -0000	[thread overview]
Message-ID: <1355208017-9204-6-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1355208017-9204-1-git-send-email-yao@codesourcery.com>

The next patch needs to know whether we get a normal packet or
notification from getpkt_or_notif_sane.  This patch adds a boolean
pointer in argument to indicate which is got on return.

gdb:

2012-12-11  Yao Qi  <yao@codesourcery.com>

	* remote.c (getpkt_or_notif_sane): Add one more argument in
	its declaration.
	(getpkt_or_notif_sane_1): Add one more argument.
	(getpkt_sane): Update caller.
	(getpkt_or_notif_sane): Likewise.  Update call
	togetpkt_or_notif_sane_1.
	(remote_wait_ns): Update caller.
---
 gdb/remote.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index 05b5b1f..f3ab5ce 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -90,7 +90,7 @@ static void cleanup_sigint_signal_handler (void *dummy);
 static void initialize_sigint_signal_handler (void);
 static int getpkt_sane (char **buf, long *sizeof_buf, int forever);
 static int getpkt_or_notif_sane (char **buf, long *sizeof_buf,
-				 int forever);
+				 int forever, int *is_notif);
 
 static void handle_remote_sigint (int);
 static void handle_remote_sigint_twice (int);
@@ -5692,15 +5692,16 @@ remote_wait_ns (ptid_t ptid, struct target_waitstatus *status, int options)
   struct remote_state *rs = get_remote_state ();
   struct stop_reply *stop_reply;
   int ret;
+  int is_notif = 0;
 
   /* If in non-stop mode, get out of getpkt even if a
      notification is received.	*/
 
   ret = getpkt_or_notif_sane (&rs->buf, &rs->buf_size,
-			      0 /* forever */);
+			      0 /* forever */, &is_notif);
   while (1)
     {
-      if (ret != -1)
+      if (ret != -1 && !is_notif)
 	switch (rs->buf[0])
 	  {
 	  case 'E':		/* Error of some sort.	*/
@@ -5737,7 +5738,7 @@ remote_wait_ns (ptid_t ptid, struct target_waitstatus *status, int options)
 
       /* Otherwise do a blocking wait.  */
       ret = getpkt_or_notif_sane (&rs->buf, &rs->buf_size,
-				  1 /* forever */);
+				  1 /* forever */, &is_notif);
     }
 }
 
@@ -7419,11 +7420,13 @@ getpkt (char **buf,
    0, this function is allowed to time out gracefully and return an
    indication of this to the caller.  Otherwise return the number of
    bytes read.  If EXPECTING_NOTIF, consider receiving a notification
-   enough reason to return to the caller.  */
+   enough reason to return to the caller.  On return, *IS_NOTIF stores
+   a boolean whether GDB reads a notification  or not from remote.
+   IS_NOTIF can be NULL.  */
 
 static int
 getpkt_or_notif_sane_1 (char **buf, long *sizeof_buf, int forever,
-			int expecting_notif)
+			int expecting_notif, int *is_notif)
 {
   struct remote_state *rs = get_remote_state ();
   int c;
@@ -7524,6 +7527,8 @@ getpkt_or_notif_sane_1 (char **buf, long *sizeof_buf, int forever,
 	  /* Skip the ack char if we're in no-ack mode.  */
 	  if (!rs->noack_mode)
 	    serial_write (remote_desc, "+", 1);
+	  if (is_notif != NULL)
+	    *is_notif = 0;
 	  return val;
 	}
 
@@ -7545,13 +7550,15 @@ getpkt_or_notif_sane_1 (char **buf, long *sizeof_buf, int forever,
 				  str);
 	      do_cleanups (old_chain);
 	    }
+	  if (is_notif != NULL)
+	    *is_notif = 1;
 
 	  handle_notification (*buf);
 
 	  /* Notifications require no acknowledgement.  */
 
 	  if (expecting_notif)
-	    return -1;
+	    return val;
 	}
     }
 }
@@ -7559,13 +7566,15 @@ getpkt_or_notif_sane_1 (char **buf, long *sizeof_buf, int forever,
 static int
 getpkt_sane (char **buf, long *sizeof_buf, int forever)
 {
-  return getpkt_or_notif_sane_1 (buf, sizeof_buf, forever, 0);
+  return getpkt_or_notif_sane_1 (buf, sizeof_buf, forever, 0, NULL);
 }
 
 static int
-getpkt_or_notif_sane (char **buf, long *sizeof_buf, int forever)
+getpkt_or_notif_sane (char **buf, long *sizeof_buf, int forever,
+		      int *is_notif)
 {
-  return getpkt_or_notif_sane_1 (buf, sizeof_buf, forever, 1);
+  return getpkt_or_notif_sane_1 (buf, sizeof_buf, forever, 1,
+				 is_notif);
 }
 
 \f
-- 
1.7.7.6


  parent reply	other threads:[~2012-12-11  6:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-11  6:40 [PATCH 0/8, V4] A general notification in GDB RSP Yao Qi
2012-12-11  6:40 ` [PATCH 2/8] de-couple %Stop from notification: gdbserver Yao Qi
2012-12-12 17:06   ` Pedro Alves
2012-12-11  6:41 ` [PATCH 3/8] de-couple %Stop from notification: gdb Yao Qi
2012-12-12 17:32   ` Pedro Alves
2012-12-11  6:41 ` [PATCH 6/8] Handle notification for all-stop Yao Qi
2012-12-12 18:28   ` Pedro Alves
2012-12-11  6:41 ` [PATCH 4/8] command 'set debug notification' Yao Qi
2012-12-11  7:06   ` Eli Zaretskii
2012-12-12 17:57     ` Pedro Alves
2012-12-12 18:59       ` Eli Zaretskii
2012-12-12 19:17         ` Pedro Alves
2012-12-11  6:41 ` Yao Qi [this message]
2012-12-12 18:14   ` [PATCH 5/8] Different notification from packets Pedro Alves
2012-12-11  6:41 ` [PATCH 1/8] new queue.h in common/ Yao Qi
2012-12-12 17:05   ` Pedro Alves
2012-12-11  6:41 ` [PATCH 7/8] Cleanup pending queues before resume in all-stop Yao Qi
2012-12-12 18:22   ` Pedro Alves
2012-12-11  6:41 ` [PATCH 8/8] RSP notification 'Test' Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355208017-9204-6-git-send-email-yao@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox