aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Metzger <markus.t.metzger@intel.com>2014-11-17 11:18:05 +0100
committerMarkus Metzger <markus.t.metzger@intel.com>2015-07-02 12:52:19 +0200
commit010a18a1b12ec6d5219b7e602aa6abe12344dd1a (patch)
treed9a6517e7f3e0b3e9a4cdc51fd6ed02b41ceba15
parentb20a652466ea6e62e7d056188b79a0677a29f46e (diff)
downloadgdb-010a18a1b12ec6d5219b7e602aa6abe12344dd1a.zip
gdb-010a18a1b12ec6d5219b7e602aa6abe12344dd1a.tar.gz
gdb-010a18a1b12ec6d5219b7e602aa6abe12344dd1a.tar.bz2
btrace, linux: use data_size and data_offset
In struct perf_event_mmap_page there are new fields data_size and data_offset that give the location of the perf_event data buffer relative to the mmap page. Use them if they are present. gdb/ * nat/linux-btrace.c (linux_enable_bts): Check for PERF_ATTR_SIZE_VER5. Check for data_offset and data_size fields. Use them.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/nat/linux-btrace.c21
2 files changed, 22 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4c96e8a..a4cce4d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2015-07-02 Markus Metzger <markus.t.metzger@intel.com>
+ * nat/linux-btrace.c (linux_enable_bts): Check for
+ PERF_ATTR_SIZE_VER5.
+ Check for data_offset and data_size fields. Use them.
+
+2015-07-02 Markus Metzger <markus.t.metzger@intel.com>
+
* NEWS: Announce new commands "record btrace pt" and "record pt".
Announce new options "set|show record btrace pt buffer-size".
* btrace.c: Include "rsp-low.h".
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index ddd79a3..3b630f5 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -642,7 +642,7 @@ linux_enable_bts (ptid_t ptid, const struct btrace_config_bts *conf)
struct perf_event_mmap_page *header;
struct btrace_target_info *tinfo;
struct btrace_tinfo_bts *bts;
- unsigned long long size, pages;
+ unsigned long long size, pages, data_offset, data_size;
int pid, pg;
tinfo = xzalloc (sizeof (*tinfo));
@@ -704,16 +704,27 @@ linux_enable_bts (ptid_t ptid, const struct btrace_config_bts *conf)
break;
}
- if (header == MAP_FAILED)
+ if (pages == 0)
goto err_file;
+ data_offset = PAGE_SIZE;
+ data_size = size;
+
+#if defined (PERF_ATTR_SIZE_VER5)
+ if (offsetof (struct perf_event_mmap_page, data_size) <= header->size)
+ {
+ data_offset = header->data_offset;
+ data_size = header->data_size;
+ }
+#endif /* defined (PERF_ATTR_SIZE_VER5) */
+
bts->header = header;
- bts->bts.mem = ((const uint8_t *) header) + PAGE_SIZE;
- bts->bts.size = size;
+ bts->bts.mem = ((const uint8_t *) header) + data_offset;
+ bts->bts.size = data_size;
bts->bts.data_head = &header->data_head;
bts->bts.last_head = 0;
- tinfo->conf.bts.size = size;
+ tinfo->conf.bts.size = data_size;
return tinfo;
err_file: