From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15867 invoked by alias); 11 Dec 2012 06:41:05 -0000 Received: (qmail 15755 invoked by uid 22791); 11 Dec 2012 06:41:02 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Dec 2012 06:40:54 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1TiJWP-0002Dz-IO from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Mon, 10 Dec 2012 22:40:53 -0800 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 10 Dec 2012 22:40:53 -0800 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.1.289.1; Mon, 10 Dec 2012 22:40:50 -0800 From: Yao Qi To: Subject: [PATCH 5/8] Different notification from packets. Date: Tue, 11 Dec 2012 06:41:00 -0000 Message-ID: <1355208017-9204-6-git-send-email-yao@codesourcery.com> In-Reply-To: <1355208017-9204-1-git-send-email-yao@codesourcery.com> References: <1355208017-9204-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-12/txt/msg00302.txt.bz2 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 * 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); } -- 1.7.7.6