From: Markus Metzger <markus.t.metzger@intel.com>
To: jan.kratochvil@redhat.com
Cc: gdb-patches@sourceware.org, markus.t.metzger@gmail.com,
Pedro Alves <palves@redhat.com>
Subject: [patch v9 10/23] remote, btrace: add branch tracing protocol to Qbtrace packet
Date: Mon, 04 Mar 2013 17:07:00 -0000 [thread overview]
Message-ID: <1362416770-19750-11-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1362416770-19750-1-git-send-email-markus.t.metzger@intel.com>
We might want to add support for LBR branch tracing in the future.
To prepare for this, I would specify the branch trace recording method
in the Qbtrace packet when requesting branch tracing.
Similar to qXfer, I am adding separate packets for each recording method plus
one packet to disable tracing. The currently supported packets are:
Qbtrace:off
Qbtrace:bts
CC: Pedro Alves <palves@redhat.com>
2013-03-04 Markus Metzger <markus.t.metzger@intel.com>
---
gdb/doc/gdb.texinfo | 18 +++++++++---
gdb/gdbserver/server.c | 7 +++--
gdb/remote.c | 69 +++++++++++++++++++++++++----------------------
3 files changed, 54 insertions(+), 40 deletions(-)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 5ac450c..337675c 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -37321,7 +37321,12 @@ These are the currently defined stub features and their properties:
@tab @samp{-}
@tab Yes
-@item @samp{Qbtrace}
+@item @samp{Qbtrace:off}
+@tab Yes
+@tab @samp{-}
+@tab Yes
+
+@item @samp{Qbtrace:bts}
@tab Yes
@tab @samp{-}
@tab Yes
@@ -37562,8 +37567,11 @@ rather than reporting the hit to @value{GDBN}.
@item qbtrace
The remote stub understands the @samp{qbtrace} packet.
-@item Qbtrace
-The remote stub understands the @samp{Qbtrace} packet.
+@item Qbtrace:off
+The remote stub understands the @samp{Qbtrace:off} packet.
+
+@item Qbtrace:bts
+The remote stub understands the @samp{Qbtrace:bts} packet.
@end table
@@ -37942,8 +37950,8 @@ No new branch trace data is available.
A badly formed request or an error was encountered.
@end table
-@item Qbtrace:on
-Enable branch tracing for the current thread.
+@item Qbtrace:bts
+Enable branch tracing for the current thread using bts tracing.
Reply:
@table @samp
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index e755ba0..00cac8e 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -463,12 +463,12 @@ handle_btrace_general_set (char *own_buf)
err = NULL;
- if (strcmp (op, "on") == 0)
+ if (strcmp (op, "bts") == 0)
err = handle_btrace_enable (thread);
else if (strcmp (op, "off") == 0)
err = handle_btrace_disable (thread);
else
- err = "E.Bad Qbtrace operation. Use on or off.";
+ err = "E.Bad Qbtrace operation. Use bts or off.";
if (err != 0)
strcpy (own_buf, err);
@@ -1828,7 +1828,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
if (target_supports_btrace ())
{
strcat (own_buf, ";qbtrace+");
- strcat (own_buf, ";Qbtrace+");
+ strcat (own_buf, ";Qbtrace:bts+");
+ strcat (own_buf, ";Qbtrace:off+");
strcat (own_buf, ";qXfer:btrace:read+");
}
diff --git a/gdb/remote.c b/gdb/remote.c
index 787c596..2365713 100755
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1286,7 +1286,8 @@ enum {
PACKET_QDisableRandomization,
PACKET_QAgent,
PACKET_qbtrace,
- PACKET_Qbtrace,
+ PACKET_Qbtrace_off,
+ PACKET_Qbtrace_bts,
PACKET_qXfer_btrace,
PACKET_MAX
};
@@ -4000,7 +4001,8 @@ static struct protocol_feature remote_protocol_features[] = {
{ "tracenz", PACKET_DISABLE,
remote_string_tracing_feature, -1 },
{ "qbtrace", PACKET_DISABLE, remote_supported_packet, PACKET_qbtrace },
- { "Qbtrace", PACKET_DISABLE, remote_supported_packet, PACKET_Qbtrace },
+ { "Qbtrace:off", PACKET_DISABLE, remote_supported_packet, PACKET_Qbtrace_off },
+ { "Qbtrace:bts", PACKET_DISABLE, remote_supported_packet, PACKET_Qbtrace_bts },
{ "qXfer:btrace:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_btrace }
};
@@ -11140,7 +11142,9 @@ remote_supports_btrace (void)
{
if (remote_protocol_packets[PACKET_qbtrace].support != PACKET_ENABLE)
return 0;
- if (remote_protocol_packets[PACKET_Qbtrace].support != PACKET_ENABLE)
+ if (remote_protocol_packets[PACKET_Qbtrace_off].support != PACKET_ENABLE)
+ return 0;
+ if (remote_protocol_packets[PACKET_Qbtrace_bts].support != PACKET_ENABLE)
return 0;
if (remote_protocol_packets[PACKET_qXfer_btrace].support != PACKET_ENABLE)
return 0;
@@ -11148,12 +11152,13 @@ remote_supports_btrace (void)
return 1;
}
-/* Send the Qbtrace packet and check the response. */
+/* Enable branch tracing. */
-static void
-send_Qbtrace (ptid_t ptid, int enable)
+static struct btrace_target_info *
+remote_enable_btrace (ptid_t ptid)
{
- struct packet_config *packet = &remote_protocol_packets[PACKET_Qbtrace];
+ struct btrace_target_info *tinfo = NULL;
+ struct packet_config *packet = &remote_protocol_packets[PACKET_Qbtrace_bts];
struct remote_state *rs = get_remote_state ();
char *buf = rs->buf;
char *endbuf = rs->buf + get_remote_packet_size ();
@@ -11163,31 +11168,13 @@ send_Qbtrace (ptid_t ptid, int enable)
set_general_thread (ptid);
- buf += xsnprintf (buf, endbuf - buf, "%s:", packet->name);
- buf += xsnprintf (buf, endbuf - buf, enable ? "on" : "off");
+ buf += xsnprintf (buf, endbuf - buf, "%s", packet->name);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
if (packet_ok (rs->buf, packet) == PACKET_ERROR)
- {
- if (enable != 0)
- error (_("Could not enable branch tracing for %s: %s"),
- target_pid_to_str (ptid), rs->buf);
- else
- error (_("Could not disable branch tracing for %s: %s"),
- target_pid_to_str (ptid), rs->buf);
- }
-}
-
-/* Enable branch tracing. */
-
-static struct btrace_target_info *
-remote_enable_btrace (ptid_t ptid)
-{
- struct btrace_target_info *tinfo = NULL;
-
- /* This will throw an error if enabling failed. */
- send_Qbtrace (ptid, 1);
+ error (_("Could not enable branch tracing for %s: %s"),
+ target_pid_to_str (ptid), rs->buf);
tinfo = xzalloc (sizeof (*tinfo));
tinfo->ptid = ptid;
@@ -11200,8 +11187,23 @@ remote_enable_btrace (ptid_t ptid)
static void
remote_disable_btrace (struct btrace_target_info *tinfo)
{
- /* This will throw an error if disabling failed. */
- send_Qbtrace (tinfo->ptid, 0);
+ struct packet_config *packet = &remote_protocol_packets[PACKET_Qbtrace_off];
+ struct remote_state *rs = get_remote_state ();
+ char *buf = rs->buf;
+ char *endbuf = rs->buf + get_remote_packet_size ();
+
+ if (packet->support != PACKET_ENABLE)
+ error (_("Target does not support branch tracing."));
+
+ set_general_thread (tinfo->ptid);
+
+ buf += xsnprintf (buf, endbuf - buf, "%s", packet->name);
+ putpkt (rs->buf);
+ getpkt (&rs->buf, &rs->buf_size, 0);
+
+ if (packet_ok (rs->buf, packet) == PACKET_ERROR)
+ error (_("Could not disable branch tracing for %s: %s"),
+ target_pid_to_str (tinfo->ptid), rs->buf);
xfree (tinfo);
}
@@ -11927,8 +11929,11 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
add_packet_config_cmd (&remote_protocol_packets[PACKET_qbtrace],
"qbtrace", "query-btrace", 0);
- add_packet_config_cmd (&remote_protocol_packets[PACKET_Qbtrace],
- "Qbtrace", "enable-btrace", 0);
+ add_packet_config_cmd (&remote_protocol_packets[PACKET_Qbtrace_off],
+ "Qbtrace:off", "disable-btrace", 0);
+
+ add_packet_config_cmd (&remote_protocol_packets[PACKET_Qbtrace_bts],
+ "Qbtrace:bts", "enable-btrace", 0);
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_btrace],
"qXfer:btrace", "read-btrace", 0);
--
1.7.1
next prev parent reply other threads:[~2013-03-04 17:07 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-04 17:07 [patch v9 00/23] branch tracing support for Atom Markus Metzger
2013-03-04 17:07 ` [patch v9 02/23] linux, btrace: perf_event based branch tracing Markus Metzger
2013-03-05 20:06 ` Jan Kratochvil
2013-03-06 10:11 ` Mark Kettenis
2013-03-06 10:29 ` Metzger, Markus T
2013-03-04 17:07 ` [patch v9 04/23] xml, btrace: define btrace xml document style Markus Metzger
2013-03-05 20:07 ` Jan Kratochvil
2013-03-04 17:07 ` [patch v9 07/23] gdbserver, btrace: add generic btrace support Markus Metzger
2013-03-05 20:08 ` Jan Kratochvil
2013-03-06 9:15 ` Metzger, Markus T
2013-03-06 13:22 ` Jan Kratochvil
2013-03-04 17:07 ` Markus Metzger [this message]
2013-03-05 20:09 ` [patch v9 10/23] remote, btrace: add branch tracing protocol to Qbtrace packet Jan Kratochvil
2013-03-06 9:19 ` Metzger, Markus T
2013-03-04 17:07 ` [patch v9 16/23] record: default target methods Markus Metzger
2013-03-05 20:10 ` Jan Kratochvil
2013-03-04 17:07 ` [patch v9 05/23] remote, btrace: add branch trace remote ops Markus Metzger
2013-03-05 20:07 ` Jan Kratochvil
2013-03-06 9:00 ` Metzger, Markus T
2013-03-04 17:07 ` [patch v9 01/23] thread, btrace: add generic branch trace support Markus Metzger
2013-03-05 20:06 ` Jan Kratochvil
2013-03-05 22:02 ` Tom Tromey
2013-03-06 21:11 ` Doug Evans
2013-03-07 7:50 ` Metzger, Markus T
2013-03-07 22:57 ` Doug Evans
2013-03-04 17:07 ` [patch v9 03/23] linux, i386, amd64: enable btrace for 32bit and 64bit linux native Markus Metzger
2013-03-05 20:06 ` Jan Kratochvil
2013-03-04 17:07 ` [patch v9 08/23] gdbserver, linux, btrace: add btrace support for linux-low Markus Metzger
2013-03-05 20:09 ` Jan Kratochvil
2013-03-06 9:17 ` Metzger, Markus T
2013-03-06 13:33 ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 11/23] target: add add_deprecated_target_alias Markus Metzger
2013-03-05 20:09 ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 06/23] btrace, doc: document remote serial protocol Markus Metzger
2013-03-04 18:08 ` Eli Zaretskii
2013-03-05 20:08 ` Jan Kratochvil
2013-03-06 9:06 ` Metzger, Markus T
2013-03-06 9:50 ` Jan Kratochvil
2013-03-06 10:01 ` Metzger, Markus T
2013-03-06 12:07 ` Jan Kratochvil
2013-03-06 12:13 ` Metzger, Markus T
2013-03-06 12:17 ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 22/23] testsuite, gdb.btrace: add btrace tests Markus Metzger
2013-03-04 19:47 ` Jan Kratochvil
2013-03-05 6:39 ` Metzger, Markus T
2013-03-05 20:14 ` Jan Kratochvil
2013-03-06 15:32 ` christian.himpel
2013-03-06 16:35 ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 09/23] btrace, x86: disable on some processors Markus Metzger
2013-03-05 20:09 ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 19/23] record, btrace: add record-btrace target Markus Metzger
2013-03-05 20:13 ` Jan Kratochvil
2013-03-06 9:57 ` Metzger, Markus T
2013-03-06 13:35 ` Jan Kratochvil
2013-03-06 14:01 ` Metzger, Markus T
2013-03-06 16:28 ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 20/23] record-btrace, disas: omit pc prefix Markus Metzger
2013-03-05 20:13 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 14/23] record-full.c: rename record_ in record_full_ Markus Metzger
2013-03-05 20:10 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 13/23] record: make it build again Markus Metzger
2013-03-05 20:10 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 15/23] record-full.h: rename record_ into record_full_ Markus Metzger
2013-03-05 20:10 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 17/23] record: add "record instruction-history" command Markus Metzger
2013-03-04 18:14 ` Eli Zaretskii
2013-03-05 20:11 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 23/23] btrace, remote: drop qbtrace packet Markus Metzger
2013-03-04 18:15 ` Eli Zaretskii
2013-03-05 20:15 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 21/23] doc, record: document record changes Markus Metzger
2013-03-04 18:13 ` Eli Zaretskii
2013-03-05 20:13 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 18/23] record: add "record function-call-history" command Markus Metzger
2013-03-04 18:07 ` Eli Zaretskii
2013-03-05 20:12 ` Jan Kratochvil
2013-03-04 17:10 ` [patch v9 12/23] record: split record Markus Metzger
2013-03-05 20:09 ` Jan Kratochvil
2013-03-06 12:43 ` Crash of GDB with gdbserver btrace enabled [Re: [patch v9 00/23] branch tracing support for Atom] Jan Kratochvil
2013-03-06 14:40 ` Metzger, Markus T
2013-03-06 15:31 ` Metzger, Markus T
2013-03-06 17:06 ` Jan Kratochvil
2013-03-06 18:08 ` Metzger, Markus T
2013-03-07 9:06 ` Jan Kratochvil
2013-03-07 9:41 ` Metzger, Markus T
2013-03-07 10:00 ` Metzger, Markus T
2013-03-07 10:14 ` Jan Kratochvil
2013-03-07 10:33 ` Metzger, Markus T
2013-03-07 12:07 ` Jan Kratochvil
2013-03-07 12:33 ` Metzger, Markus T
2013-03-07 14:45 ` Jan Kratochvil
2013-03-07 15:22 ` Metzger, Markus T
2013-03-07 15:46 ` Jan Kratochvil
2013-03-07 15:12 ` Pedro Alves
2013-03-07 15:33 ` Metzger, Markus T
2013-03-07 15:39 ` Jan Kratochvil
2013-03-07 15:41 ` Pedro Alves
[not found] ` <20130318170643.GA15625@host2.jankratochvil.net>
[not found] ` <514758DA.2060905@redhat.com>
2013-03-20 15:52 ` [commit] [patch] Code cleanup: Remove parameter quitting [Re: Crash of GDB with gdbserver btrace enabled] Jan Kratochvil
[not found] ` <20130318192604.GA2786@host2.jankratochvil.net>
[not found] ` <51477828.30000@redhat.com>
2013-03-26 0:15 ` Jan Kratochvil
2013-04-03 18:05 ` Pedro Alves
2013-03-07 10:08 ` Crash of GDB with gdbserver btrace enabled [Re: [patch v9 00/23] branch tracing support for Atom] Jan Kratochvil
2013-03-06 15:41 ` Jan Kratochvil
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=1362416770-19750-11-git-send-email-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=markus.t.metzger@gmail.com \
--cc=palves@redhat.com \
/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