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 6/6] MI notification on trace stop: triggered by remote
Date: Mon, 19 Aug 2013 01:56:00 -0000	[thread overview]
Message-ID: <1376877311-4135-7-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1376877311-4135-1-git-send-email-yao@codesourcery.com>

As a result of previous patch, GDB has a Trace remote notification.
In this patch, GDB starts to use Trace notification, and emits MI
notification '=trace-stopped' to front-end.  A test case is
added to see if MI trace-stopped notification is emitted when trace
buffer is full.

gdb:

	* remote-notif-trace.c: Include "observer.h".
	(remote_notif_trace_status_parse): Call
	observer_notify_trace_changed.

gdb/testsuite:

	* gdb.trace/mi-trace-changed.exp (test_trace_buffer_full): New.
---
 gdb/remote-notif-trace.c                     |   11 ++++
 gdb/testsuite/gdb.trace/mi-trace-changed.exp |   75 ++++++++++++++++++++++++++
 2 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/gdb/remote-notif-trace.c b/gdb/remote-notif-trace.c
index d9ff1c1..65c1748 100644
--- a/gdb/remote-notif-trace.c
+++ b/gdb/remote-notif-trace.c
@@ -22,6 +22,7 @@
 #include "remote.h"
 #include "tracepoint.h"
 #include "remote-notif.h"
+#include "observer.h"
 
 static void
 remote_notif_trace_status_parse (struct notif_client *self, char *buf,
@@ -31,6 +32,16 @@ remote_notif_trace_status_parse (struct notif_client *self, char *buf,
 
   gdb_assert (buf[0] == 'T');
   parse_trace_status (buf + 1, ts);
+
+  /* When the tracing is stopped, there is no changes anymore in
+     the trace, so the remote stub can't send another notification.
+     We don't have to worry about notifying 'trace_changed' observer
+     with argument 1 twice.
+     The remote stub can't request tracing start and the remote stub
+     may send multiple trace notifications on various status changes,
+     we don't notify 'trace_changed' observer with argument 0.  */
+  if (!ts->running)
+    observer_notify_trace_changed (0);
 }
 
 static void
diff --git a/gdb/testsuite/gdb.trace/mi-trace-changed.exp b/gdb/testsuite/gdb.trace/mi-trace-changed.exp
index fbd6fe7..9d6cfff 100644
--- a/gdb/testsuite/gdb.trace/mi-trace-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-trace-changed.exp
@@ -71,4 +71,79 @@ proc test_normal_tstart_stop { } {
 
 test_normal_tstart_stop
 
+# Verify that MI notification '=trace-stopped' is emitted when trace
+# buffer is full.
+
+proc test_trace_buffer_full { } {
+    with_test_prefix "tracebuffer full" {
+	global mi_gdb_prompt
+
+	if [mi_gdb_start] {
+	    return
+	}
+	mi_run_to_main
+
+	mi_gdb_test "-break-insert -a func2" {.*\^done,bkpt=.*} \
+	    "insert tracepoint on func2"
+
+	send_gdb "actions\n"
+	gdb_expect {
+	    -re "End with" {
+	    }
+	}
+
+	send_gdb "collect buf\nend\n"
+	set test "define actions"
+	gdb_expect {
+	    -re ".*${mi_gdb_prompt}$" {
+		pass $test
+	    }
+	    timeout {
+		fail "$test (timeout)"
+	    }
+	}
+
+	# No =trace-started notification.
+	mi_gdb_test "-trace-start" "-trace-start\r\n=breakpoint-modified\[^\n\]+\r\n\\^done" \
+	    "start trace without notification"
+	mi_gdb_test "-break-insert end" {.*\^done,bkpt=.*} \
+	    "insert breakpoint on end"
+
+	mi_send_resuming_command "exec-continue" \
+	    "continuing execution to end"
+
+	set test "trace-stopped triggered by bufferfull"
+	gdb_expect {
+	    # We don't set stop-notes.
+	    -re "=trace-stopped\\\\n" {
+		pass "$test"
+	    }
+	    timeout {
+		fail "$test (timeout)"
+	    }
+	}
+
+	global async
+	# In sync mode, eat all the output.  Don't have to do so in
+	# async mode.
+	if {!$async} {
+	    gdb_expect {
+		-re ".*${mi_gdb_prompt}$" {
+		}
+	    }
+	}
+	# GDB has got the rsp notifcation from remote stub that trace
+	# is stopped.
+	mi_gdb_test "tstop" ".*Trace is not running.*" \
+	    "tstop on stopped"
+
+	mi_gdb_test "-trace-status" ".*\\^done.*stop-reason=\"overflow\".*" \
+	    "trace-status"
+
+	mi_gdb_exit
+    }
+}
+
+test_trace_buffer_full
+
 return 0
-- 
1.7.7.6


  parent reply	other threads:[~2013-08-19  1:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-19  1:56 [PATCH 0/6 V5] MI notification on trace started/stopped Yao Qi
2013-08-19  1:56 ` [PATCH 1/6] Move notif_queue to remote_state Yao Qi
2013-09-25 16:12   ` Pedro Alves
2013-09-30  7:34     ` Yao Qi
2013-09-30  7:58       ` Move pending_event to remote_notif_state ([PATCH 1/6] Move notif_queue to remote_state) Yao Qi
2013-09-30 19:34         ` Pedro Alves
2013-10-04  7:42           ` Yao Qi
2013-09-30 17:08       ` [PATCH 1/6] Move notif_queue to remote_state Pedro Alves
2013-10-01 14:08         ` Yao Qi
2013-10-02  1:54         ` Yao Qi
2013-10-02 10:48           ` Pedro Alves
2013-10-04  7:36             ` Yao Qi
2013-08-19  1:56 ` [PATCH 4/6] async remote notification 'Trace' Yao Qi
2013-08-19  1:56 ` Yao Qi [this message]
2013-08-19  1:56 ` [PATCH 3/6] Query supported notifications by qSupported Yao Qi
2013-08-19  1:56 ` [PATCH 5/6] MI notification on trace started/stopped:basic Yao Qi
2013-08-19  1:56 ` [PATCH 2/6] Add annex in an async remote notification Yao Qi
2013-09-26 18:43   ` Pedro Alves
2013-09-27  1:44     ` Yao Qi
2013-10-18  1:05       ` Yao Qi
2013-09-02  0:14 ` [PATCH 0/6 V5] MI notification on trace started/stopped Yao Qi
2013-09-18 13:24 ` [ping 2]: " Yao Qi
2013-09-18 13:25   ` Pedro Alves

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=1376877311-4135-7-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