This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/3] MI notification on trace stop: triggered by remote


As a result of previous patch, GDB has a Trace rsp notification.
In this patch, GDB starts to use NTrace 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:

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

	* remote-notif-trace.c: Include "observer.h".
	 (remote_notif_parse_trace): Assert that trace is
	 not running and call 'observer_notify_trace_stopped'.
	* tracepoint.h (trace_stop_notes): Declare.

gdb/testsuite:

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

	* gdb.trace/mi-trace-changed.exp (test_trace_buffer_full): New.
---
 gdb/remote-notif-trace.c                     |    9 +++-
 gdb/testsuite/gdb.trace/mi-trace-changed.exp |   74 ++++++++++++++++++++++++++
 gdb/tracepoint.h                             |    1 +
 3 files changed, 83 insertions(+), 1 deletions(-)

diff --git a/gdb/remote-notif-trace.c b/gdb/remote-notif-trace.c
index 9f74580..eeba41b 100644
--- a/gdb/remote-notif-trace.c
+++ b/gdb/remote-notif-trace.c
@@ -22,13 +22,20 @@
 #include "remote.h"
 #include "tracepoint.h"
 #include "remote-notif.h"
+#include "observer.h"
 
 static void
 remote_notif_trace_parse (struct notif_client *self, char *buf,
 			  struct notif_event *event)
 {
   if (strncmp (buf, "stop:", 5) == 0)
-    parse_trace_status (buf + 5 + 1, current_trace_status ());
+    {
+      struct trace_status *ts = current_trace_status ();
+
+      parse_trace_status (buf + 5 + 1, ts);
+      gdb_assert (!ts->running);
+      observer_notify_trace_stopped (trace_stop_notes);
+    }
   else
     error (_("Unknown trace notification."));
 }
diff --git a/gdb/testsuite/gdb.trace/mi-trace-changed.exp b/gdb/testsuite/gdb.trace/mi-trace-changed.exp
index 7654638..9b22b96 100644
--- a/gdb/testsuite/gdb.trace/mi-trace-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-trace-changed.exp
@@ -82,4 +82,78 @@ 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
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
index ced29fa..831f54d 100644
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -142,6 +142,7 @@ struct trace_status *current_trace_status (void);
 
 extern char *default_collect;
 
+extern char *trace_stop_notes;
 /* Struct to collect random info about tracepoints on the target.  */
 
 struct uploaded_tp
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]