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 v3 09/16] linux, i386, amd64: enable btrace for 32bit and 64bit linux native
Date: Tue, 14 Aug 2012 13:01:00 -0000	[thread overview]
Message-ID: <1344949171-9545-10-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1344949171-9545-1-git-send-email-markus.t.metzger@intel.com>

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

Install the btrace target ops for i386-linux-nat and amd64-linux-nat.

2012-08-14 Markus Metzger <markus.t.metzger@intel.com>

	* amd64-linux-nat.c: Include btrace.h and linux-btrace.h.
	(_initialize_amd64_linux_nat): Initialize btrace ops.
	* i386-linux.nat.c: Include btrace.h and linux-btrace.h.
	(_initialize_i386_linux_nat): Initialize btrace ops.
	* config/i386/linux.mh: Add linux-btrace.o.
	* config/i386/linux64.mh: Add linux-btrace.o.


---
 gdb/amd64-linux-nat.c      |   51 ++++++++++++++++++++++++++++++++++++++++++++
 gdb/config/i386/linux.mh   |    3 +-
 gdb/config/i386/linux64.mh |    2 +-
 gdb/i386-linux-nat.c       |   51 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 105 insertions(+), 2 deletions(-)

diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 01982ac..3cfa45c 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -25,6 +25,8 @@
 #include "regset.h"
 #include "linux-nat.h"
 #include "amd64-linux-tdep.h"
+#include "linux-btrace.h"
+#include "btrace.h"
 
 #include "gdb_assert.h"
 #include "gdb_string.h"
@@ -1079,6 +1081,48 @@ amd64_linux_read_description (struct target_ops *ops)
     }
 }
 
+/* Enable branch tracing for @ptid.  */
+static struct btrace_target_info *
+amd64_linux_enable_btrace (ptid_t ptid)
+{
+  struct btrace_target_info *tinfo;
+
+  errno = 0;
+  tinfo = linux_enable_btrace (ptid);
+
+  if (!tinfo)
+    error (_("Could not enable branch tracing for %s: %s."),
+	   target_pid_to_str (ptid), safe_strerror (errno));
+
+  return tinfo;
+}
+
+/* Disable branch tracing for @ptid.  */
+static void
+amd64_linux_disable_btrace (struct btrace_target_info *tinfo)
+{
+  int errcode = linux_disable_btrace (tinfo);
+
+  if (errcode)
+    error (_("Could not disable branch tracing: %s."), safe_strerror (errcode));
+}
+
+/* Read branch trace data for @tinfo.  */
+static VEC (btrace_block_s) *
+amd64_linux_read_btrace (struct btrace_target_info *tinfo)
+{
+  /* Fill in the number of bits in a pointer for this architecture.  */
+  if (!tinfo->ptr_bits)
+    {
+      struct gdbarch *gdbarch = target_gdbarch;
+
+      if (gdbarch)
+	tinfo->ptr_bits = gdbarch_ptr_bit (gdbarch);
+    }
+
+  return linux_read_btrace (tinfo);
+}
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 void _initialize_amd64_linux_nat (void);
 
@@ -1117,6 +1161,13 @@ _initialize_amd64_linux_nat (void)
 
   t->to_read_description = amd64_linux_read_description;
 
+  /* Add btrace methods.  */
+  t->to_supports_btrace = linux_supports_btrace;
+  t->to_enable_btrace = amd64_linux_enable_btrace;
+  t->to_disable_btrace = amd64_linux_disable_btrace;
+  t->to_btrace_has_changed = linux_btrace_has_changed;
+  t->to_read_btrace = amd64_linux_read_btrace;
+
   /* Register the target.  */
   linux_nat_add_target (t);
   linux_nat_set_new_thread (t, amd64_linux_new_thread);
diff --git a/gdb/config/i386/linux.mh b/gdb/config/i386/linux.mh
index 8316d87..7c64e83 100644
--- a/gdb/config/i386/linux.mh
+++ b/gdb/config/i386/linux.mh
@@ -4,7 +4,8 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o \
 	i386-nat.o i386-linux-nat.o \
 	proc-service.o linux-thread-db.o \
-	linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
+	linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
+	linux-btrace.o
 NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The dynamically loaded libthread_db needs access to symbols in the
diff --git a/gdb/config/i386/linux64.mh b/gdb/config/i386/linux64.mh
index d2b95fd..8d782c1 100644
--- a/gdb/config/i386/linux64.mh
+++ b/gdb/config/i386/linux64.mh
@@ -3,7 +3,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
 	i386-nat.o amd64-nat.o amd64-linux-nat.o \
 	linux-nat.o linux-osdata.o \
 	proc-service.o linux-thread-db.o linux-fork.o \
-	linux-procfs.o linux-ptrace.o
+	linux-procfs.o linux-ptrace.o linux-btrace.o
 NAT_FILE= config/nm-linux.h
 NAT_CDEPS = $(srcdir)/proc-service.list
 
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index 5a65ef6..0248fd7 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -25,6 +25,8 @@
 #include "regset.h"
 #include "target.h"
 #include "linux-nat.h"
+#include "linux-btrace.h"
+#include "btrace.h"
 
 #include "gdb_assert.h"
 #include "gdb_string.h"
@@ -1008,6 +1010,48 @@ i386_linux_read_description (struct target_ops *ops)
     return tdesc_i386_linux;
 }
 
+/* Enable branch tracing for @ptid.  */
+static struct btrace_target_info *
+i386_linux_enable_btrace (ptid_t ptid)
+{
+  struct btrace_target_info *tinfo;
+
+  errno = 0;
+  tinfo = linux_enable_btrace (ptid);
+
+  if (!tinfo)
+    error (_("Could not enable branch tracing for %s: %s."),
+	   target_pid_to_str (ptid), safe_strerror (errno));
+
+  return tinfo;
+}
+
+/* Disable branch tracing for @ptid.  */
+static void
+i386_linux_disable_btrace (struct btrace_target_info *tinfo)
+{
+  int errcode = linux_disable_btrace (tinfo);
+
+  if (errcode)
+    error (_("Could not disable branch tracing: %s."), safe_strerror (errcode));
+}
+
+/* Read branch trace data for @tinfo.  */
+static VEC (btrace_block_s) *
+i386_linux_read_btrace (struct btrace_target_info *tinfo)
+{
+  /* Fill in the number of bits in a pointer for this architecture.  */
+  if (!tinfo->ptr_bits)
+    {
+      struct gdbarch *gdbarch = target_gdbarch;
+
+      if (gdbarch)
+	tinfo->ptr_bits = gdbarch_ptr_bit (gdbarch);
+    }
+
+  return linux_read_btrace (tinfo);
+}
+
 /* -Wmissing-prototypes */
 extern initialize_file_ftype _initialize_i386_linux_nat;
 
@@ -1041,6 +1085,13 @@ _initialize_i386_linux_nat (void)
 
   t->to_read_description = i386_linux_read_description;
 
+  /* Add btrace methods.  */
+  t->to_supports_btrace = linux_supports_btrace;
+  t->to_enable_btrace = i386_linux_enable_btrace;
+  t->to_disable_btrace = i386_linux_disable_btrace;
+  t->to_btrace_has_changed = linux_btrace_has_changed;
+  t->to_read_btrace = i386_linux_read_btrace;
+
   /* Register the target.  */
   linux_nat_add_target (t);
   linux_nat_set_new_thread (t, i386_linux_new_thread);
-- 
1.7.1


  parent reply	other threads:[~2012-08-14 13:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-14 13:01 [patch v3 00/16] branch tracing support for Atom markus.t.metzger
2012-08-14 13:00 ` [patch v3 02/16] disas: add precise instructions flag markus.t.metzger
2012-08-14 13:00 ` [patch v3 10/16] xml, btrace: define btrace xml document style markus.t.metzger
2012-08-14 13:00 ` [patch v3 01/16] gdbserver, build: add -DGDBSERVER markus.t.metzger
2012-08-15  0:41   ` Doug Evans
2012-08-15  7:59     ` Metzger, Markus T
2012-08-14 13:01 ` [patch v3 12/16] gdbserver, btrace: add generic btrace support markus.t.metzger
2012-08-14 13:01 ` [patch v3 05/16] thread, btrace: add generic branch trace support markus.t.metzger
2012-08-14 13:01 ` [patch v3 07/16] configure: add check for perf_event header markus.t.metzger
2012-08-14 13:01 ` [patch v3 03/16] source: add flags to print_source_lines () markus.t.metzger
2012-09-11 20:14   ` Tom Tromey
2012-09-12  8:34     ` Metzger, Markus T
2012-08-14 13:01 ` [patch v3 04/16] source, disasm: optionally prefix source lines with filename markus.t.metzger
2012-09-11 20:21   ` Tom Tromey
2012-08-14 13:01 ` markus.t.metzger [this message]
2012-08-14 13:01 ` [patch v3 16/16] btrace, x86: restrict to Atom markus.t.metzger
2012-08-14 13:27   ` Mark Kettenis
     [not found]     ` <A78C989F6D9628469189715575E55B2307ACF558@IRSMSX102.ger.corp.intel.com>
2012-08-14 15:57       ` FW: " Metzger, Markus T
2012-09-24 12:23       ` Metzger, Markus T
2012-09-27  7:08         ` Joel Brobecker
2012-09-28  2:40         ` Mark Kettenis
2012-09-28  6:51           ` Metzger, Markus T
2012-10-01 19:24             ` Mark Kettenis
2012-10-04  7:51               ` Metzger, Markus T
2012-08-14 13:01 ` [patch v3 08/16] linux, btrace: perf_event based branch tracing markus.t.metzger
2012-08-14 13:01 ` [patch v3 11/16] remote, btrace: add branch trace remote ops markus.t.metzger
2012-08-14 13:01 ` [patch v3 13/16] gdbserver, linux, btrace: add btrace support for linux-low markus.t.metzger
2012-08-14 13:03 ` [patch v3 15/16] test, btrace: more branch tracing tests markus.t.metzger
2012-08-14 13:03 ` [patch v3 14/16] test, btrace: add " markus.t.metzger
2012-08-14 13:03 ` [patch v3 06/16] cli, btrace: add btrace cli 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=1344949171-9545-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