1 /* Linux-dependent part of branch trace support for GDB, and GDBserver.
3 Copyright (C) 2013-2018 Free Software Foundation, Inc.
5 Contributed by Intel Corp. <markus.t.metzger@intel.com>
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #ifndef LINUX_BTRACE_H
23 #define LINUX_BTRACE_H
25 #include "btrace-common.h"
27 #if HAVE_LINUX_PERF_EVENT_H
28 # include <linux/perf_event.h>
33 #if HAVE_LINUX_PERF_EVENT_H
34 /* A Linux perf event buffer. */
35 struct perf_event_buffer
37 /* The mapped memory. */
40 /* The size of the mapped memory in bytes. */
43 /* A pointer to the data_head field for this buffer. */
44 volatile __u64
*data_head
;
46 /* The data_head value from the last read. */
50 /* Branch trace target information for BTS tracing. */
51 struct btrace_tinfo_bts
53 /* The Linux perf_event configuration for collecting the branch trace. */
54 struct perf_event_attr attr
;
56 /* The perf event file. */
59 /* The perf event configuration page. */
60 volatile struct perf_event_mmap_page
*header
;
62 /* The BTS perf event buffer. */
63 struct perf_event_buffer bts
;
66 /* Branch trace target information for Intel Processor Trace
68 struct btrace_tinfo_pt
70 /* The Linux perf_event configuration for collecting the branch trace. */
71 struct perf_event_attr attr
;
73 /* The perf event file. */
76 /* The perf event configuration page. */
77 volatile struct perf_event_mmap_page
*header
;
79 /* The trace perf event buffer. */
80 struct perf_event_buffer pt
;
82 #endif /* HAVE_LINUX_PERF_EVENT_H */
84 /* Branch trace target information per thread. */
85 struct btrace_target_info
87 /* The ptid of this thread. */
90 /* The obtained branch trace configuration. */
91 struct btrace_config conf
;
93 #if HAVE_LINUX_PERF_EVENT_H
94 /* The branch tracing format specific information. */
97 /* CONF.FORMAT == BTRACE_FORMAT_BTS. */
98 struct btrace_tinfo_bts bts
;
100 /* CONF.FORMAT == BTRACE_FORMAT_PT. */
101 struct btrace_tinfo_pt pt
;
103 #endif /* HAVE_LINUX_PERF_EVENT_H */
106 /* See to_supports_btrace in target.h. */
107 extern int linux_supports_btrace (struct target_ops
*, enum btrace_format
);
109 /* See to_enable_btrace in target.h. */
110 extern struct btrace_target_info
*
111 linux_enable_btrace (ptid_t ptid
, const struct btrace_config
*conf
);
113 /* See to_disable_btrace in target.h. */
114 extern enum btrace_error
linux_disable_btrace (struct btrace_target_info
*ti
);
116 /* See to_read_btrace in target.h. */
117 extern enum btrace_error
linux_read_btrace (struct btrace_data
*btrace
,
118 struct btrace_target_info
*btinfo
,
119 enum btrace_read_type type
);
121 /* See to_btrace_conf in target.h. */
122 extern const struct btrace_config
*
123 linux_btrace_conf (const struct btrace_target_info
*);
125 #endif /* LINUX_BTRACE_H */