Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: markus.t.metzger@intel.com
To: gdb-patches@sourceware.org
Cc: markus.t.metzger@gmail.com, jan.kratochvil@redhat.com,
	palves@redhat.com,        tromey@redhat.com, kettenis@gnu.org,
	       Markus Metzger <markus.t.metzger@intel.com>
Subject: [patch v5 09/12] gdbserver, linux, btrace: add btrace support for linux-low
Date: Fri, 07 Dec 2012 10:37:00 -0000	[thread overview]
Message-ID: <1354876644-25749-10-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1354876644-25749-1-git-send-email-markus.t.metzger@intel.com>

From: Markus Metzger <markus.t.metzger@intel.com>

Implement btrace target ops in target linux-low using the common linux-btrace
functions.

2012-12-07 Markus Metzger <markus.t.metzger@intel.com>

gdbserver/
	* linux-low: Include linux-btrace.h.
	(linux_low_enable_btrace): New function.
	(linux_low_read_btrace): New function.
	(linux_target_ops): Add btrace ops.
	* configure.srv (i[34567]86-*-linux*): Add linux-btrace.o.
	Add srv_linux_btrace=yes.
	(x86_64-*-linux*): Add linux-btrace.o.
	Add srv_linux_btrace=yes.
	* configure.ac: Define HAVE_LINUX_BTRACE.
	* config.in: Regenerated.
	* configure: Regenerated.


---
 gdb/gdbserver/config.in     |    3 ++
 gdb/gdbserver/configure     |    6 ++++
 gdb/gdbserver/configure.ac  |    5 ++++
 gdb/gdbserver/configure.srv |    6 +++-
 gdb/gdbserver/linux-low.c   |   57 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index b791b89..76fa209 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -73,6 +73,9 @@
 /* Define to 1 if you have the `dl' library (-ldl). */
 #undef HAVE_LIBDL
 
+/* Define if the target supports branch tracing. */
+#undef HAVE_LINUX_BTRACE
+
 /* Define to 1 if you have the <linux/elf.h> header file. */
 #undef HAVE_LINUX_ELF_H
 
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index ab22b5e..b5e23b4 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -4981,6 +4981,12 @@ $as_echo "#define HAVE_PTRACE_GETFPXREGS 1" >>confdefs.h
   fi
 fi
 
+if test "${srv_linux_btrace}" = "yes"; then
+
+$as_echo "#define HAVE_LINUX_BTRACE 1" >>confdefs.h
+
+fi
+
 if test "$ac_cv_header_sys_procfs_h" = yes; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lwpid_t in sys/procfs.h" >&5
 $as_echo_n "checking for lwpid_t in sys/procfs.h... " >&6; }
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 35da28b..1865074 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -279,6 +279,11 @@ if test "${srv_linux_regsets}" = "yes"; then
   fi
 fi
 
+if test "${srv_linux_btrace}" = "yes"; then
+  AC_DEFINE(HAVE_LINUX_BTRACE, 1,
+	    [Define if the target supports branch tracing.])
+fi
+
 if test "$ac_cv_header_sys_procfs_h" = yes; then
   BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
   BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index d1e04a9..3492c16 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -97,10 +97,11 @@ case "${target}" in
 			    srv_xmlfiles="${srv_xmlfiles} $srv_amd64_linux_xmlfiles"
 			fi
 			srv_tgtobj="linux-low.o linux-osdata.o linux-x86-low.o i386-low.o i387-fp.o linux-procfs.o"
-			srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
+			srv_tgtobj="${srv_tgtobj} linux-ptrace.o linux-btrace.o"
 			srv_linux_usrregs=yes
 			srv_linux_regsets=yes
 			srv_linux_thread_db=yes
+			srv_linux_btrace=yes
 			ipa_obj="${ipa_i386_linux_regobj} linux-i386-ipa.o"
 			;;
   i[34567]86-*-lynxos*)	srv_regobj="i386.o"
@@ -293,11 +294,12 @@ case "${target}" in
 			;;
   x86_64-*-linux*)	srv_regobj="$srv_amd64_linux_regobj $srv_i386_linux_regobj"
 			srv_tgtobj="linux-low.o linux-osdata.o linux-x86-low.o i386-low.o i387-fp.o linux-procfs.o"
-			srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
+			srv_tgtobj="${srv_tgtobj} linux-ptrace.o linux-btrace.o"
 			srv_xmlfiles="$srv_i386_linux_xmlfiles $srv_amd64_linux_xmlfiles"
 			srv_linux_usrregs=yes # This is for i386 progs.
 			srv_linux_regsets=yes
 			srv_linux_thread_db=yes
+			srv_linux_btrace=yes
 			ipa_obj="${ipa_amd64_linux_regobj} linux-amd64-ipa.o"
 			;;
   x86_64-*-mingw*)	srv_regobj="$srv_amd64_regobj"
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index c697f6b..5f5a5a3 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -84,6 +84,10 @@
 #endif
 #endif
 
+#ifdef HAVE_LINUX_BTRACE
+#include "linux-btrace.h"
+#endif
+
 #ifndef HAVE_ELF32_AUXV_T
 /* Copied from glibc's elf.h.  */
 typedef struct
@@ -5794,6 +5798,46 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf,
   return len;
 }
 
+#ifdef HAVE_LINUX_BTRACE
+
+/* Enable branch tracing.  */
+
+static struct btrace_target_info *
+linux_low_enable_btrace (ptid_t ptid)
+{
+  struct btrace_target_info *tinfo;
+
+  tinfo = linux_enable_btrace (ptid);
+  if (tinfo)
+	tinfo->ptr_bits = register_size (0) * 8;
+
+  return tinfo;
+}
+
+/* Read branch trace data as btrace xml document.  */
+
+static void
+linux_low_read_btrace (struct btrace_target_info *tinfo, struct buffer *buffer)
+{
+  VEC (btrace_block_s) *btrace;
+  struct btrace_block *block;
+  int i;
+
+  btrace = linux_read_btrace (tinfo);
+
+  buffer_grow_str (buffer, "<!DOCTYPE btrace SYSTEM \"btrace.dtd\">\n");
+  buffer_grow_str (buffer, "<btrace version=\"1.0\">\n");
+
+  for (i = 0; VEC_iterate (btrace_block_s, btrace, i, block); i++)
+    buffer_xml_printf (buffer, "<block begin=\"0x%s\" end=\"0x%s\"/>\n",
+		       paddress (block->begin), paddress (block->end));
+
+  buffer_grow_str (buffer, "</btrace>\n");
+
+  VEC_free (btrace_block_s, btrace);
+}
+#endif /* HAVE_LINUX_BTRACE */
+
 static struct target_ops linux_target_ops = {
   linux_create_inferior,
   linux_attach,
@@ -5858,6 +5902,19 @@ static struct target_ops linux_target_ops = {
   linux_get_min_fast_tracepoint_insn_len,
   linux_qxfer_libraries_svr4,
   linux_supports_agent,
+#ifdef HAVE_LINUX_BTRACE
+  linux_supports_btrace,
+  linux_low_enable_btrace,
+  linux_disable_btrace,
+  linux_btrace_has_changed,
+  linux_low_read_btrace,
+#else
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+#endif
 };
 
 static void
-- 
1.7.1


  parent reply	other threads:[~2012-12-07 10:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07 10:37 [patch v5 00/12] branch tracing support for Atom markus.t.metzger
2012-12-07 10:37 ` [patch v5 06/12] remote, btrace: add branch trace remote ops markus.t.metzger
2012-12-07 10:37 ` markus.t.metzger [this message]
2012-12-07 10:38 ` [patch v5 05/12] xml, btrace: define btrace xml document style markus.t.metzger
2012-12-07 10:38 ` [patch v5 07/12] btrace, doc: document remote serial protocol markus.t.metzger
2012-12-07 15:09   ` Eli Zaretskii
2012-12-13  8:43     ` Metzger, Markus T
2012-12-13 17:02       ` Eli Zaretskii
2012-12-13 17:09       ` Pedro Alves
2012-12-14  7:53         ` Metzger, Markus T
2012-12-07 10:38 ` [patch v5 04/12] linux, i386, amd64: enable btrace for 32bit and 64bit linux native markus.t.metzger
2012-12-07 10:38 ` [patch v5 12/12] btrace, x86: disable on some processors markus.t.metzger
2012-12-07 10:38 ` [patch v5 10/12] test, btrace: add branch tracing tests markus.t.metzger
2012-12-07 10:38 ` [patch v5 08/12] gdbserver, btrace: add generic btrace support markus.t.metzger
2012-12-07 10:38 ` [patch v5 01/12] thread, btrace: add generic branch trace support markus.t.metzger
2012-12-07 10:38 ` [patch v5 02/12] cli, btrace: add btrace cli markus.t.metzger
2012-12-07 15:16   ` Eli Zaretskii
2012-12-13  9:14     ` Metzger, Markus T
2012-12-07 10:38 ` [patch v5 03/12] linux, btrace: perf_event based branch tracing markus.t.metzger
2012-12-07 10:39 ` [patch v5 11/12] test, btrace: more branch tracing tests markus.t.metzger

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=1354876644-25749-10-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=kettenis@gnu.org \
    --cc=markus.t.metzger@gmail.com \
    --cc=palves@redhat.com \
    --cc=tromey@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