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

Yao Qi yao@codesourcery.com
Thu Nov 8 08:39:00 GMT 2012


As a result of previous patch, GDB has NTrace 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:

	* tracepoint.c (remote_notif_parse_trace): Assert that trace is
	not running and call 'observer_notify_trace_stopped'.

gdb/testsuite:

	* gdb.trace/mi-trace-changed.exp (test_trace_buffer_full): New.
---
 gdb/testsuite/gdb.trace/mi-trace-changed.exp |   83 ++++++++++++++++++++++++++
 gdb/tracepoint.c                             |    6 ++-
 2 files changed, 88 insertions(+), 1 deletions(-)

diff --git a/gdb/testsuite/gdb.trace/mi-trace-changed.exp b/gdb/testsuite/gdb.trace/mi-trace-changed.exp
index 0b27eb9..d50cf8e 100644
--- a/gdb/testsuite/gdb.trace/mi-trace-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-trace-changed.exp
@@ -81,4 +81,87 @@ 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)"
+	    }
+	}
+
+	mi_gdb_test "-trace-start" "-trace-start\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"
+	set see_trace_stopped_notification 0
+	gdb_expect {
+	    # We don't set stop-notes.
+	    -re ".*=trace-stopped,note" {
+		fail "$test:stop notes"
+	    }
+	    -re ".*=trace-stopped" {
+		set see_trace_stopped_notification 1
+	    }
+	    timeout {
+		fail "$test (timeout)"
+	    }
+	}
+
+	if { $see_trace_stopped_notification } {
+	    pass $test
+	} else {
+	    fail $test
+	}
+
+	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.c b/gdb/tracepoint.c
index 6a4ba78..44a05b6 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -1711,7 +1711,11 @@ process_tracepoint_on_disconnect (void)
 static void
 remote_notif_parse_trace (struct notif *self, char *buf, void *data)
 {
-  parse_trace_status (buf + 1, current_trace_status ());
+  struct trace_status *ts = current_trace_status ();
+
+  parse_trace_status (buf + 1, ts);
+  gdb_assert (!ts->running);
+  observer_notify_trace_stopped (trace_stop_notes);
 }
 
 static void
-- 
1.7.7.6



More information about the Gdb-patches mailing list