Commit | Line | Data |
---|---|---|
7c97f91e MM |
1 | /* Linux-dependent part of branch trace support for GDB, and GDBserver. |
2 | ||
b811d2c2 | 3 | Copyright (C) 2013-2020 Free Software Foundation, Inc. |
7c97f91e MM |
4 | |
5 | Contributed by Intel Corp. <markus.t.metzger@intel.com> | |
6 | ||
7 | This file is part of GDB. | |
8 | ||
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. | |
13 | ||
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. | |
18 | ||
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/>. */ | |
21 | ||
1a5c2598 TT |
22 | #ifndef NAT_LINUX_BTRACE_H |
23 | #define NAT_LINUX_BTRACE_H | |
7c97f91e | 24 | |
268a13a5 | 25 | #include "gdbsupport/btrace-common.h" |
7c97f91e MM |
26 | #if HAVE_LINUX_PERF_EVENT_H |
27 | # include <linux/perf_event.h> | |
28 | #endif | |
29 | ||
53f81362 GB |
30 | struct target_ops; |
31 | ||
aadf7753 MM |
32 | #if HAVE_LINUX_PERF_EVENT_H |
33 | /* A Linux perf event buffer. */ | |
34 | struct perf_event_buffer | |
35 | { | |
36 | /* The mapped memory. */ | |
37 | const uint8_t *mem; | |
38 | ||
39 | /* The size of the mapped memory in bytes. */ | |
e7b01ce0 | 40 | size_t size; |
aadf7753 MM |
41 | |
42 | /* A pointer to the data_head field for this buffer. */ | |
e7b01ce0 | 43 | volatile __u64 *data_head; |
aadf7753 MM |
44 | |
45 | /* The data_head value from the last read. */ | |
e7b01ce0 | 46 | __u64 last_head; |
aadf7753 | 47 | }; |
aadf7753 | 48 | |
f4abbc16 MM |
49 | /* Branch trace target information for BTS tracing. */ |
50 | struct btrace_tinfo_bts | |
7c97f91e | 51 | { |
7c97f91e MM |
52 | /* The Linux perf_event configuration for collecting the branch trace. */ |
53 | struct perf_event_attr attr; | |
54 | ||
aadf7753 | 55 | /* The perf event file. */ |
7c97f91e | 56 | int file; |
aadf7753 MM |
57 | |
58 | /* The perf event configuration page. */ | |
59 | volatile struct perf_event_mmap_page *header; | |
60 | ||
61 | /* The BTS perf event buffer. */ | |
62 | struct perf_event_buffer bts; | |
f4abbc16 | 63 | }; |
b20a6524 | 64 | |
bc504a31 PA |
65 | /* Branch trace target information for Intel Processor Trace |
66 | tracing. */ | |
b20a6524 MM |
67 | struct btrace_tinfo_pt |
68 | { | |
69 | /* The Linux perf_event configuration for collecting the branch trace. */ | |
70 | struct perf_event_attr attr; | |
71 | ||
72 | /* The perf event file. */ | |
73 | int file; | |
74 | ||
75 | /* The perf event configuration page. */ | |
76 | volatile struct perf_event_mmap_page *header; | |
77 | ||
78 | /* The trace perf event buffer. */ | |
79 | struct perf_event_buffer pt; | |
80 | }; | |
f4abbc16 MM |
81 | #endif /* HAVE_LINUX_PERF_EVENT_H */ |
82 | ||
83 | /* Branch trace target information per thread. */ | |
84 | struct btrace_target_info | |
85 | { | |
86 | /* The ptid of this thread. */ | |
87 | ptid_t ptid; | |
88 | ||
89 | /* The obtained branch trace configuration. */ | |
90 | struct btrace_config conf; | |
91 | ||
92 | #if HAVE_LINUX_PERF_EVENT_H | |
93 | /* The branch tracing format specific information. */ | |
94 | union | |
95 | { | |
96 | /* CONF.FORMAT == BTRACE_FORMAT_BTS. */ | |
97 | struct btrace_tinfo_bts bts; | |
b20a6524 MM |
98 | |
99 | /* CONF.FORMAT == BTRACE_FORMAT_PT. */ | |
100 | struct btrace_tinfo_pt pt; | |
f4abbc16 | 101 | } variant; |
7c97f91e | 102 | #endif /* HAVE_LINUX_PERF_EVENT_H */ |
7c97f91e MM |
103 | }; |
104 | ||
969c39fb | 105 | /* See to_enable_btrace in target.h. */ |
f4abbc16 MM |
106 | extern struct btrace_target_info * |
107 | linux_enable_btrace (ptid_t ptid, const struct btrace_config *conf); | |
7c97f91e | 108 | |
969c39fb MM |
109 | /* See to_disable_btrace in target.h. */ |
110 | extern enum btrace_error linux_disable_btrace (struct btrace_target_info *ti); | |
7c97f91e | 111 | |
969c39fb | 112 | /* See to_read_btrace in target.h. */ |
734b0e4b | 113 | extern enum btrace_error linux_read_btrace (struct btrace_data *btrace, |
969c39fb MM |
114 | struct btrace_target_info *btinfo, |
115 | enum btrace_read_type type); | |
7c97f91e | 116 | |
f4abbc16 MM |
117 | /* See to_btrace_conf in target.h. */ |
118 | extern const struct btrace_config * | |
119 | linux_btrace_conf (const struct btrace_target_info *); | |
120 | ||
1a5c2598 | 121 | #endif /* NAT_LINUX_BTRACE_H */ |