[PATCH 1/2] NTrace rsp notification.
Yao Qi
yao@codesourcery.com
Thu Nov 8 08:39:00 GMT 2012
This patch adds a new RSP notification %NTrace, which notifies GDB
when the trace is stopped in remote side.
gdb/gdbserver:
* notif.c (notif_packets): Add 'notif_trace'.
(notif_process): Handle NOTIF_TRRACE.
* notif.h (enum notif_type): New NOTIF_TRACE.
Declare variable 'notif_trace'.
* tracepoint.c: Include "notif.h".
(notif_reply_trace): New.
(notif_trace): New variable.
(stop_tracing) [!IN_PROCESS_AGENT]: Call notif_process.
gdb:
* remote-notif.c (notifs): Add 'notif_packet_trace'.
* remote-notif.h: Declare notif_packet_trace.
* tracepoint.c: INclude "remote-notif.h".
(remote_notif_parse_trace): New.
(remote_notif_ack_trace): New.
(remote_notif_alloc_reply_trace): New.
(notif_packet_trace): New variable.
---
gdb/gdbserver/notif.c | 4 ++++
gdb/gdbserver/notif.h | 3 ++-
gdb/gdbserver/tracepoint.c | 23 +++++++++++++++++++++++
gdb/remote-notif.c | 1 +
gdb/remote-notif.h | 1 +
gdb/tracepoint.c | 36 ++++++++++++++++++++++++++++++++++++
6 files changed, 67 insertions(+), 1 deletions(-)
diff --git a/gdb/gdbserver/notif.c b/gdb/gdbserver/notif.c
index bd2d01d..0e321c5 100644
--- a/gdb/gdbserver/notif.c
+++ b/gdb/gdbserver/notif.c
@@ -70,6 +70,7 @@ static struct notif *notif_packets[] =
{
¬if_stop,
¬if_test,
+ ¬if_trace,
NULL,
};
@@ -160,6 +161,9 @@ notif_process (struct notif *np, ptid_t ptid, void *data)
case NOTIF_TEST:
new_notif = xmalloc (sizeof (struct notif_reply));
break;
+ case NOTIF_TRACE:
+ new_notif = xmalloc (sizeof (struct notif_reply));
+ break;
default:
error ("Unknown notification type");
}
diff --git a/gdb/gdbserver/notif.h b/gdb/gdbserver/notif.h
index f53255e..2431afd 100644
--- a/gdb/gdbserver/notif.h
+++ b/gdb/gdbserver/notif.h
@@ -41,7 +41,7 @@ struct vstop_notif
struct target_waitstatus status;
};
-enum notif_type { NOTIF_STOP, NOTIF_TEST };
+enum notif_type { NOTIF_STOP, NOTIF_TEST, NOTIF_TRACE, };
/* A type notification to GDB. An object of 'struct notif' represents
a type of notification. */
@@ -67,6 +67,7 @@ typedef struct notif
} *notif_p;
extern struct notif notif_stop;
+extern struct notif notif_trace;
int handle_notif_ack (char *own_buf);
void notif_send_reply (struct notif *notif, char *own_buf);
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 1526838..4ef954d 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -3372,6 +3372,24 @@ cmd_qtstart (char *packet)
write_ok (packet);
}
+#ifndef IN_PROCESS_AGENT
+#include "notif.h"
+
+static void cmd_qtstatus (char *packet);
+
+static void
+notif_reply_trace (struct notif_reply *reply, char *own_buf)
+{
+ cmd_qtstatus (own_buf);
+}
+
+struct notif notif_trace =
+{
+ "vTraced", "NTrace", NOTIF_TRACE, NULL, notif_reply_trace
+};
+
+#endif
+
/* End a tracing run, filling in a stop reason to report back to GDB,
and removing the tracepoints from the code. */
@@ -3472,6 +3490,11 @@ stop_tracing (void)
}
unpause_all (1);
+
+#ifndef IN_PROCESS_AGENT
+ if (current_inferior != NULL)
+ notif_process (¬if_trace, current_ptid, NULL);
+#endif
}
static int
diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index 154cffc..d7ac7f7 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -89,6 +89,7 @@ static struct notif *notifs[] =
{
(struct notif *) ¬if_packet_stop,
¬if_packet_test,
+ ¬if_packet_trace,
};
static void do_notif_reply_xfree (void *arg);
diff --git a/gdb/remote-notif.h b/gdb/remote-notif.h
index ac291e6..318c17a 100644
--- a/gdb/remote-notif.h
+++ b/gdb/remote-notif.h
@@ -90,6 +90,7 @@ void remote_notif_discard_replies (int pid);
void remote_notif_process (struct notif *except);
extern struct notif_stop notif_packet_stop;
+extern struct notif notif_packet_trace;
extern unsigned int notif_debug;
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index d6b94e4..6a4ba78 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -1705,6 +1705,42 @@ process_tracepoint_on_disconnect (void)
" GDB is disconnected\n"));
}
+/* Notification on tracing is stopped. */
+#include "remote-notif.h"
+
+static void
+remote_notif_parse_trace (struct notif *self, char *buf, void *data)
+{
+ parse_trace_status (buf + 1, current_trace_status ());
+}
+
+static void
+remote_notif_ack_trace (struct notif *self, char *buf, void *data)
+{
+ struct notif_reply *reply = (struct notif_reply *) data;
+
+ /* acknowledge */
+ putpkt ((char *) self->ack_command);
+}
+
+static struct notif_reply *
+remote_notif_alloc_reply_trace (void)
+{
+ struct notif_reply *reply = xmalloc (sizeof (struct notif_reply));
+
+ reply->dtr = NULL;
+
+ return reply;
+}
+
+struct notif notif_packet_trace =
+{
+ "NTrace", "vTraced",
+ remote_notif_parse_trace,
+ remote_notif_ack_trace,
+ remote_notif_alloc_reply_trace,
+ NULL, NULL,
+};
void
start_tracing (char *notes)
--
1.7.7.6
More information about the Gdb-patches
mailing list