|
|
689258 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
689258 |
From: Fedora GDB patches <invalid@email.com>
|
|
|
689258 |
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
|
|
689258 |
Subject: gdb-linux_perf-bundle.patch
|
|
|
689258 |
|
|
|
689258 |
;; [dts+el7] [x86*] Bundle linux_perf.h for libipt (RH BZ 1256513).
|
|
|
689258 |
;;=fedora
|
|
|
689258 |
|
|
|
689258 |
diff --git a/gdb/configure b/gdb/configure
|
|
|
689258 |
--- a/gdb/configure
|
|
|
689258 |
+++ b/gdb/configure
|
|
|
689258 |
@@ -12059,7 +12059,7 @@ else
|
|
|
689258 |
|
|
|
689258 |
#include <linux/perf_event.h>
|
|
|
689258 |
#ifndef PERF_ATTR_SIZE_VER5
|
|
|
689258 |
-# error
|
|
|
689258 |
+// error // PERF_ATTR_SIZE_VER5_BUNDLE is not available here - Fedora+RHEL
|
|
|
689258 |
#endif
|
|
|
689258 |
|
|
|
689258 |
_ACEOF
|
|
|
689258 |
diff --git a/gdb/configure.ac b/gdb/configure.ac
|
|
|
689258 |
--- a/gdb/configure.ac
|
|
|
689258 |
+++ b/gdb/configure.ac
|
|
|
689258 |
@@ -1477,7 +1477,7 @@ else
|
|
|
689258 |
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
|
|
|
689258 |
#include <linux/perf_event.h>
|
|
|
689258 |
#ifndef PERF_ATTR_SIZE_VER5
|
|
|
689258 |
-# error
|
|
|
689258 |
+// error // PERF_ATTR_SIZE_VER5_BUNDLE is not available here - Fedora+RHEL
|
|
|
689258 |
#endif
|
|
|
689258 |
]])], [perf_event=yes], [perf_event=no])
|
|
|
689258 |
if test "$perf_event" != yes; then
|
|
|
689258 |
diff --git a/gdb/gdb.c b/gdb/gdb.c
|
|
|
689258 |
--- a/gdb/gdb.c
|
|
|
689258 |
+++ b/gdb/gdb.c
|
|
|
689258 |
@@ -20,11 +20,19 @@
|
|
|
689258 |
#include "main.h"
|
|
|
689258 |
#include "interps.h"
|
|
|
689258 |
|
|
|
689258 |
+#ifdef PERF_ATTR_SIZE_VER5_BUNDLE
|
|
|
689258 |
+extern "C" void __libipt_init(void);
|
|
|
689258 |
+#endif
|
|
|
689258 |
+
|
|
|
689258 |
int
|
|
|
689258 |
main (int argc, char **argv)
|
|
|
689258 |
{
|
|
|
689258 |
struct captured_main_args args;
|
|
|
689258 |
|
|
|
689258 |
+#ifdef PERF_ATTR_SIZE_VER5_BUNDLE
|
|
|
689258 |
+ __libipt_init();
|
|
|
689258 |
+#endif
|
|
|
689258 |
+
|
|
|
689258 |
memset (&args, 0, sizeof args);
|
|
|
689258 |
args.argc = argc;
|
|
|
689258 |
args.argv = argv;
|
|
|
689258 |
diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h
|
|
|
689258 |
--- a/gdb/nat/linux-btrace.h
|
|
|
689258 |
+++ b/gdb/nat/linux-btrace.h
|
|
|
689258 |
@@ -28,6 +28,177 @@
|
|
|
689258 |
# include <linux/perf_event.h>
|
|
|
689258 |
#endif
|
|
|
689258 |
|
|
|
689258 |
+#ifdef PERF_ATTR_SIZE_VER5_BUNDLE
|
|
|
689258 |
+#ifndef HAVE_LINUX_PERF_EVENT_H
|
|
|
689258 |
+# error "PERF_ATTR_SIZE_VER5_BUNDLE && !HAVE_LINUX_PERF_EVENT_H"
|
|
|
689258 |
+#endif
|
|
|
689258 |
+#ifndef PERF_ATTR_SIZE_VER5
|
|
|
689258 |
+#define PERF_ATTR_SIZE_VER5
|
|
|
689258 |
+#define perf_event_mmap_page perf_event_mmap_page_bundle
|
|
|
689258 |
+// kernel-headers-3.10.0-493.el7.x86_64/usr/include/linux/perf_event.h
|
|
|
689258 |
+/*
|
|
|
689258 |
+ * Structure of the page that can be mapped via mmap
|
|
|
689258 |
+ */
|
|
|
689258 |
+struct perf_event_mmap_page {
|
|
|
689258 |
+ __u32 version; /* version number of this structure */
|
|
|
689258 |
+ __u32 compat_version; /* lowest version this is compat with */
|
|
|
689258 |
+
|
|
|
689258 |
+ /*
|
|
|
689258 |
+ * Bits needed to read the hw events in user-space.
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * u32 seq, time_mult, time_shift, index, width;
|
|
|
689258 |
+ * u64 count, enabled, running;
|
|
|
689258 |
+ * u64 cyc, time_offset;
|
|
|
689258 |
+ * s64 pmc = 0;
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * do {
|
|
|
689258 |
+ * seq = pc->lock;
|
|
|
689258 |
+ * barrier()
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * enabled = pc->time_enabled;
|
|
|
689258 |
+ * running = pc->time_running;
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * if (pc->cap_usr_time && enabled != running) {
|
|
|
689258 |
+ * cyc = rdtsc();
|
|
|
689258 |
+ * time_offset = pc->time_offset;
|
|
|
689258 |
+ * time_mult = pc->time_mult;
|
|
|
689258 |
+ * time_shift = pc->time_shift;
|
|
|
689258 |
+ * }
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * index = pc->index;
|
|
|
689258 |
+ * count = pc->offset;
|
|
|
689258 |
+ * if (pc->cap_user_rdpmc && index) {
|
|
|
689258 |
+ * width = pc->pmc_width;
|
|
|
689258 |
+ * pmc = rdpmc(index - 1);
|
|
|
689258 |
+ * }
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * barrier();
|
|
|
689258 |
+ * } while (pc->lock != seq);
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * NOTE: for obvious reason this only works on self-monitoring
|
|
|
689258 |
+ * processes.
|
|
|
689258 |
+ */
|
|
|
689258 |
+ __u32 lock; /* seqlock for synchronization */
|
|
|
689258 |
+ __u32 index; /* hardware event identifier */
|
|
|
689258 |
+ __s64 offset; /* add to hardware event value */
|
|
|
689258 |
+ __u64 time_enabled; /* time event active */
|
|
|
689258 |
+ __u64 time_running; /* time event on cpu */
|
|
|
689258 |
+ union {
|
|
|
689258 |
+ __u64 capabilities;
|
|
|
689258 |
+ struct {
|
|
|
689258 |
+ __u64 cap_bit0 : 1, /* Always 0, deprecated, see commit 860f085b74e9 */
|
|
|
689258 |
+ cap_bit0_is_deprecated : 1, /* Always 1, signals that bit 0 is zero */
|
|
|
689258 |
+
|
|
|
689258 |
+ cap_user_rdpmc : 1, /* The RDPMC instruction can be used to read counts */
|
|
|
689258 |
+ cap_user_time : 1, /* The time_* fields are used */
|
|
|
689258 |
+ cap_user_time_zero : 1, /* The time_zero field is used */
|
|
|
689258 |
+ cap_____res : 59;
|
|
|
689258 |
+ };
|
|
|
689258 |
+ };
|
|
|
689258 |
+
|
|
|
689258 |
+ /*
|
|
|
689258 |
+ * If cap_user_rdpmc this field provides the bit-width of the value
|
|
|
689258 |
+ * read using the rdpmc() or equivalent instruction. This can be used
|
|
|
689258 |
+ * to sign extend the result like:
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * pmc <<= 64 - width;
|
|
|
689258 |
+ * pmc >>= 64 - width; // signed shift right
|
|
|
689258 |
+ * count += pmc;
|
|
|
689258 |
+ */
|
|
|
689258 |
+ __u16 pmc_width;
|
|
|
689258 |
+
|
|
|
689258 |
+ /*
|
|
|
689258 |
+ * If cap_usr_time the below fields can be used to compute the time
|
|
|
689258 |
+ * delta since time_enabled (in ns) using rdtsc or similar.
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * u64 quot, rem;
|
|
|
689258 |
+ * u64 delta;
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * quot = (cyc >> time_shift);
|
|
|
689258 |
+ * rem = cyc & (((u64)1 << time_shift) - 1);
|
|
|
689258 |
+ * delta = time_offset + quot * time_mult +
|
|
|
689258 |
+ * ((rem * time_mult) >> time_shift);
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * Where time_offset,time_mult,time_shift and cyc are read in the
|
|
|
689258 |
+ * seqcount loop described above. This delta can then be added to
|
|
|
689258 |
+ * enabled and possible running (if index), improving the scaling:
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * enabled += delta;
|
|
|
689258 |
+ * if (index)
|
|
|
689258 |
+ * running += delta;
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * quot = count / running;
|
|
|
689258 |
+ * rem = count % running;
|
|
|
689258 |
+ * count = quot * enabled + (rem * enabled) / running;
|
|
|
689258 |
+ */
|
|
|
689258 |
+ __u16 time_shift;
|
|
|
689258 |
+ __u32 time_mult;
|
|
|
689258 |
+ __u64 time_offset;
|
|
|
689258 |
+ /*
|
|
|
689258 |
+ * If cap_usr_time_zero, the hardware clock (e.g. TSC) can be calculated
|
|
|
689258 |
+ * from sample timestamps.
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * time = timestamp - time_zero;
|
|
|
689258 |
+ * quot = time / time_mult;
|
|
|
689258 |
+ * rem = time % time_mult;
|
|
|
689258 |
+ * cyc = (quot << time_shift) + (rem << time_shift) / time_mult;
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * And vice versa:
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * quot = cyc >> time_shift;
|
|
|
689258 |
+ * rem = cyc & (((u64)1 << time_shift) - 1);
|
|
|
689258 |
+ * timestamp = time_zero + quot * time_mult +
|
|
|
689258 |
+ * ((rem * time_mult) >> time_shift);
|
|
|
689258 |
+ */
|
|
|
689258 |
+ __u64 time_zero;
|
|
|
689258 |
+ __u32 size; /* Header size up to __reserved[] fields. */
|
|
|
689258 |
+
|
|
|
689258 |
+ /*
|
|
|
689258 |
+ * Hole for extension of the self monitor capabilities
|
|
|
689258 |
+ */
|
|
|
689258 |
+
|
|
|
689258 |
+ __u8 __reserved[118*8+4]; /* align to 1k. */
|
|
|
689258 |
+
|
|
|
689258 |
+ /*
|
|
|
689258 |
+ * Control data for the mmap() data buffer.
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * User-space reading the @data_head value should issue an smp_rmb(),
|
|
|
689258 |
+ * after reading this value.
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * When the mapping is PROT_WRITE the @data_tail value should be
|
|
|
689258 |
+ * written by userspace to reflect the last read data, after issueing
|
|
|
689258 |
+ * an smp_mb() to separate the data read from the ->data_tail store.
|
|
|
689258 |
+ * In this case the kernel will not over-write unread data.
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * See perf_output_put_handle() for the data ordering.
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * data_{offset,size} indicate the location and size of the perf record
|
|
|
689258 |
+ * buffer within the mmapped area.
|
|
|
689258 |
+ */
|
|
|
689258 |
+ __u64 data_head; /* head in the data section */
|
|
|
689258 |
+ __u64 data_tail; /* user-space written tail */
|
|
|
689258 |
+ __u64 data_offset; /* where the buffer starts */
|
|
|
689258 |
+ __u64 data_size; /* data buffer size */
|
|
|
689258 |
+
|
|
|
689258 |
+ /*
|
|
|
689258 |
+ * AUX area is defined by aux_{offset,size} fields that should be set
|
|
|
689258 |
+ * by the userspace, so that
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * aux_offset >= data_offset + data_size
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * prior to mmap()ing it. Size of the mmap()ed area should be aux_size.
|
|
|
689258 |
+ *
|
|
|
689258 |
+ * Ring buffer pointers aux_{head,tail} have the same semantics as
|
|
|
689258 |
+ * data_{head,tail} and same ordering rules apply.
|
|
|
689258 |
+ */
|
|
|
689258 |
+ __u64 aux_head;
|
|
|
689258 |
+ __u64 aux_tail;
|
|
|
689258 |
+ __u64 aux_offset;
|
|
|
689258 |
+ __u64 aux_size;
|
|
|
689258 |
+};
|
|
|
689258 |
+#endif // PERF_ATTR_SIZE_VER5
|
|
|
689258 |
+#endif // PERF_ATTR_SIZE_VER5_BUNDLE
|
|
|
689258 |
+
|
|
|
689258 |
struct target_ops;
|
|
|
689258 |
|
|
|
689258 |
#if HAVE_LINUX_PERF_EVENT_H
|