]>
Commit | Line | Data |
---|---|---|
7c97f91e MM |
1 | /* Linux-dependent part of branch trace support for GDB, and GDBserver. |
2 | ||
1d506c26 | 3 | Copyright (C) 2013-2024 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" |
cdda72c2 | 26 | #include "gdbsupport/gdb-checked-static-cast.h" |
7c97f91e MM |
27 | #if HAVE_LINUX_PERF_EVENT_H |
28 | # include <linux/perf_event.h> | |
29 | #endif | |
30 | ||
53f81362 GB |
31 | struct target_ops; |
32 | ||
aadf7753 MM |
33 | #if HAVE_LINUX_PERF_EVENT_H |
34 | /* A Linux perf event buffer. */ | |
35 | struct perf_event_buffer | |
36 | { | |
37 | /* The mapped memory. */ | |
38 | const uint8_t *mem; | |
39 | ||
40 | /* The size of the mapped memory in bytes. */ | |
e7b01ce0 | 41 | size_t size; |
aadf7753 MM |
42 | |
43 | /* A pointer to the data_head field for this buffer. */ | |
e7b01ce0 | 44 | volatile __u64 *data_head; |
aadf7753 MM |
45 | |
46 | /* The data_head value from the last read. */ | |
e7b01ce0 | 47 | __u64 last_head; |
aadf7753 | 48 | }; |
cdda72c2 | 49 | #endif /* HAVE_LINUX_PERF_EVENT_H */ |
aadf7753 | 50 | |
cdda72c2 MM |
51 | /* Branch trace target information per thread. */ |
52 | struct linux_btrace_target_info final : public btrace_target_info | |
7c97f91e | 53 | { |
cdda72c2 MM |
54 | linux_btrace_target_info (ptid_t ptid) |
55 | : btrace_target_info (ptid) | |
56 | {} | |
aadf7753 | 57 | |
cdda72c2 | 58 | #if HAVE_LINUX_PERF_EVENT_H |
b20a6524 | 59 | /* The Linux perf_event configuration for collecting the branch trace. */ |
cdda72c2 | 60 | struct perf_event_attr attr {}; |
b20a6524 MM |
61 | |
62 | /* The perf event file. */ | |
cdda72c2 | 63 | int file = -1; |
b20a6524 | 64 | |
cdda72c2 MM |
65 | /* The perf event configuration page. */ |
66 | volatile struct perf_event_mmap_page *header = nullptr; | |
b20a6524 | 67 | |
cdda72c2 MM |
68 | /* The perf event buffer containing the trace data. */ |
69 | struct perf_event_buffer pev {}; | |
7c97f91e | 70 | #endif /* HAVE_LINUX_PERF_EVENT_H */ |
7c97f91e MM |
71 | }; |
72 | ||
969c39fb | 73 | /* See to_enable_btrace in target.h. */ |
f4abbc16 MM |
74 | extern struct btrace_target_info * |
75 | linux_enable_btrace (ptid_t ptid, const struct btrace_config *conf); | |
7c97f91e | 76 | |
969c39fb MM |
77 | /* See to_disable_btrace in target.h. */ |
78 | extern enum btrace_error linux_disable_btrace (struct btrace_target_info *ti); | |
7c97f91e | 79 | |
969c39fb | 80 | /* See to_read_btrace in target.h. */ |
734b0e4b | 81 | extern enum btrace_error linux_read_btrace (struct btrace_data *btrace, |
969c39fb MM |
82 | struct btrace_target_info *btinfo, |
83 | enum btrace_read_type type); | |
7c97f91e | 84 | |
f4abbc16 MM |
85 | /* See to_btrace_conf in target.h. */ |
86 | extern const struct btrace_config * | |
87 | linux_btrace_conf (const struct btrace_target_info *); | |
88 | ||
1a5c2598 | 89 | #endif /* NAT_LINUX_BTRACE_H */ |