Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "event_attr.h" |
| 18 | |
| 19 | #include <inttypes.h> |
| 20 | #include <stdio.h> |
| 21 | #include <string> |
| 22 | #include <unordered_map> |
| 23 | |
Elliott Hughes | 66dd09e | 2015-12-04 14:00:57 -0800 | [diff] [blame] | 24 | #include <android-base/logging.h> |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 25 | |
Yabin Cui | f897452 | 2017-07-17 14:36:37 -0700 | [diff] [blame] | 26 | #include "environment.h" |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 27 | #include "event_type.h" |
| 28 | #include "utils.h" |
| 29 | |
Yabin Cui | a22f3b9 | 2020-09-01 10:52:28 -0700 | [diff] [blame] | 30 | namespace simpleperf { |
| 31 | |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 32 | static std::string BitsToString(const std::string& name, uint64_t bits, |
| 33 | const std::vector<std::pair<int, std::string>>& bit_names) { |
| 34 | std::string result; |
| 35 | for (auto& p : bit_names) { |
| 36 | if (bits & p.first) { |
| 37 | bits &= ~p.first; |
| 38 | if (!result.empty()) { |
| 39 | result += ", "; |
| 40 | } |
| 41 | result += p.second; |
| 42 | } |
| 43 | } |
| 44 | if (bits != 0) { |
| 45 | LOG(DEBUG) << "unknown " << name << " bits: " << std::hex << bits; |
| 46 | } |
| 47 | return result; |
| 48 | } |
| 49 | |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 50 | static std::string SampleTypeToString(uint64_t sample_type) { |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 51 | static std::vector<std::pair<int, std::string>> sample_type_names = { |
Yabin Cui | f569b47 | 2015-04-30 09:43:26 -0700 | [diff] [blame] | 52 | {PERF_SAMPLE_ADDR, "addr"}, |
Yabin Cui | 76769e5 | 2015-07-13 12:23:54 -0700 | [diff] [blame] | 53 | {PERF_SAMPLE_BRANCH_STACK, "branch_stack"}, |
Yabin Cui | f569b47 | 2015-04-30 09:43:26 -0700 | [diff] [blame] | 54 | {PERF_SAMPLE_CALLCHAIN, "callchain"}, |
| 55 | {PERF_SAMPLE_CPU, "cpu"}, |
| 56 | {PERF_SAMPLE_ID, "id"}, |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 57 | {PERF_SAMPLE_IP, "ip"}, |
Yabin Cui | f569b47 | 2015-04-30 09:43:26 -0700 | [diff] [blame] | 58 | {PERF_SAMPLE_PERIOD, "period"}, |
| 59 | {PERF_SAMPLE_RAW, "raw"}, |
| 60 | {PERF_SAMPLE_READ, "read"}, |
Yabin Cui | 76769e5 | 2015-07-13 12:23:54 -0700 | [diff] [blame] | 61 | {PERF_SAMPLE_REGS_USER, "regs_user"}, |
| 62 | {PERF_SAMPLE_STACK_USER, "stack_user"}, |
Yabin Cui | f569b47 | 2015-04-30 09:43:26 -0700 | [diff] [blame] | 63 | {PERF_SAMPLE_STREAM_ID, "stream_id"}, |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 64 | {PERF_SAMPLE_TID, "tid"}, |
| 65 | {PERF_SAMPLE_TIME, "time"}, |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 66 | }; |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 67 | return BitsToString("sample_type", sample_type, sample_type_names); |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 70 | static std::string ReadFormatToString(uint64_t read_format) { |
| 71 | static std::vector<std::pair<int, std::string>> read_format_names = { |
| 72 | {PERF_FORMAT_TOTAL_TIME_ENABLED, "total_time_enabled"}, |
| 73 | {PERF_FORMAT_TOTAL_TIME_RUNNING, "total_time_running"}, |
| 74 | {PERF_FORMAT_ID, "id"}, |
| 75 | {PERF_FORMAT_GROUP, "group"}, |
| 76 | }; |
| 77 | return BitsToString("read_format", read_format, read_format_names); |
| 78 | } |
| 79 | |
| 80 | perf_event_attr CreateDefaultPerfEventAttr(const EventType& event_type) { |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 81 | perf_event_attr attr; |
| 82 | memset(&attr, 0, sizeof(attr)); |
| 83 | attr.size = sizeof(perf_event_attr); |
| 84 | attr.type = event_type.type; |
| 85 | attr.config = event_type.config; |
Yabin Cui | a46794f | 2015-12-03 10:31:37 -0800 | [diff] [blame] | 86 | attr.disabled = 0; |
Yabin Cui | 323e945 | 2015-04-20 18:07:17 -0700 | [diff] [blame] | 87 | // Changing read_format affects the layout of the data read from perf_event_file, namely |
| 88 | // PerfCounter in event_fd.h. |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 89 | attr.read_format = |
| 90 | PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_TOTAL_TIME_RUNNING | PERF_FORMAT_ID; |
Yabin Cui | 2d6efe4 | 2016-04-01 20:22:35 -0700 | [diff] [blame] | 91 | attr.sample_type |= PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_TIME | PERF_SAMPLE_PERIOD | |
Thiébaud Weksteen | 4848ee0 | 2020-10-23 16:06:59 +0200 | [diff] [blame] | 92 | PERF_SAMPLE_CPU | PERF_SAMPLE_ID; |
Yabin Cui | f569b47 | 2015-04-30 09:43:26 -0700 | [diff] [blame] | 93 | |
| 94 | if (attr.type == PERF_TYPE_TRACEPOINT) { |
Yabin Cui | bfc11b6 | 2015-08-19 10:12:51 -0700 | [diff] [blame] | 95 | // Tracepoint information are stored in raw data in sample records. |
Yabin Cui | f897452 | 2017-07-17 14:36:37 -0700 | [diff] [blame] | 96 | if (CanRecordRawData()) { |
| 97 | attr.sample_type |= PERF_SAMPLE_RAW; |
| 98 | } |
Yabin Cui | f569b47 | 2015-04-30 09:43:26 -0700 | [diff] [blame] | 99 | } |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 100 | return attr; |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 103 | void DumpPerfEventAttr(const perf_event_attr& attr, size_t indent) { |
Yabin Cui | c10a9dc | 2016-06-15 12:10:33 -0700 | [diff] [blame] | 104 | std::string event_name = GetEventNameByAttr(attr); |
Yabin Cui | 2672dea | 2015-05-21 12:17:23 -0700 | [diff] [blame] | 105 | PrintIndented(indent, "event_attr: for event type %s\n", event_name.c_str()); |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 106 | |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 107 | PrintIndented(indent + 1, "type %u, size %u, config %llu\n", attr.type, attr.size, attr.config); |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 108 | |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 109 | if (attr.freq != 0) { |
| 110 | PrintIndented(indent + 1, "sample_freq %llu\n", attr.sample_freq); |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 111 | } else { |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 112 | PrintIndented(indent + 1, "sample_period %llu\n", attr.sample_period); |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 115 | PrintIndented(indent + 1, "sample_type (0x%llx) %s\n", attr.sample_type, |
| 116 | SampleTypeToString(attr.sample_type).c_str()); |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 117 | |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 118 | PrintIndented(indent + 1, "read_format (0x%llx) %s\n", attr.read_format, |
| 119 | ReadFormatToString(attr.read_format).c_str()); |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 120 | |
Yabin Cui | 41d4ba9 | 2015-06-22 12:27:58 -0700 | [diff] [blame] | 121 | PrintIndented(indent + 1, "disabled %u, inherit %u, pinned %u, exclusive %u\n", attr.disabled, |
| 122 | attr.inherit, attr.pinned, attr.exclusive); |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 123 | |
Yabin Cui | d115b2f | 2015-06-15 13:57:23 -0700 | [diff] [blame] | 124 | PrintIndented(indent + 1, "exclude_user %u, exclude_kernel %u, exclude_hv %u\n", |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 125 | attr.exclude_user, attr.exclude_kernel, attr.exclude_hv); |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 126 | |
Yabin Cui | 2db05b4 | 2018-07-16 14:04:49 -0700 | [diff] [blame] | 127 | PrintIndented(indent + 1, "exclude_idle %u, mmap %u, mmap2 %u, comm %u, freq %u\n", |
| 128 | attr.exclude_idle, attr.mmap, attr.mmap2, attr.comm, attr.freq); |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 129 | |
Yabin Cui | 41d4ba9 | 2015-06-22 12:27:58 -0700 | [diff] [blame] | 130 | PrintIndented(indent + 1, "inherit_stat %u, enable_on_exec %u, task %u\n", attr.inherit_stat, |
| 131 | attr.enable_on_exec, attr.task); |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 132 | |
Yabin Cui | d115b2f | 2015-06-15 13:57:23 -0700 | [diff] [blame] | 133 | PrintIndented(indent + 1, "watermark %u, precise_ip %u, mmap_data %u\n", attr.watermark, |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 134 | attr.precise_ip, attr.mmap_data); |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 135 | |
Yabin Cui | d115b2f | 2015-06-15 13:57:23 -0700 | [diff] [blame] | 136 | PrintIndented(indent + 1, "sample_id_all %u, exclude_host %u, exclude_guest %u\n", |
Yabin Cui | 9759e1b | 2015-04-28 15:54:13 -0700 | [diff] [blame] | 137 | attr.sample_id_all, attr.exclude_host, attr.exclude_guest); |
Yabin Cui | d5bccd1 | 2019-07-12 13:09:15 -0700 | [diff] [blame] | 138 | PrintIndented(indent + 1, "config2 0x%llx\n", attr.config2); |
Yabin Cui | 76769e5 | 2015-07-13 12:23:54 -0700 | [diff] [blame] | 139 | PrintIndented(indent + 1, "branch_sample_type 0x%" PRIx64 "\n", attr.branch_sample_type); |
Yabin Cui | 3c8c213 | 2015-08-13 20:30:20 -0700 | [diff] [blame] | 140 | PrintIndented(indent + 1, "exclude_callchain_kernel %u, exclude_callchain_user %u\n", |
| 141 | attr.exclude_callchain_kernel, attr.exclude_callchain_user); |
Yabin Cui | 5dfca1b | 2021-11-10 15:57:29 -0800 | [diff] [blame] | 142 | PrintIndented(indent + 1, "comm_exec %u, use_clockid %u, context_switch %u\n", attr.comm_exec, |
| 143 | attr.use_clockid, attr.context_switch); |
Yabin Cui | 76769e5 | 2015-07-13 12:23:54 -0700 | [diff] [blame] | 144 | PrintIndented(indent + 1, "sample_regs_user 0x%" PRIx64 "\n", attr.sample_regs_user); |
| 145 | PrintIndented(indent + 1, "sample_stack_user 0x%" PRIx64 "\n", attr.sample_stack_user); |
Yabin Cui | e3fc447 | 2024-08-29 15:47:50 -0700 | [diff] [blame] | 146 | PrintIndented(indent + 1, "clockid %d\n", attr.clockid); |
| 147 | PrintIndented(indent + 1, "sample_regs_intr %" PRIu64 "\n", attr.sample_regs_intr); |
| 148 | PrintIndented(indent + 1, "aux_watermark %u\n", attr.aux_watermark); |
| 149 | PrintIndented(indent + 1, "sample_max_stack %u\n", attr.sample_max_stack); |
| 150 | PrintIndented(indent + 1, "aux_sample_size %u\n", attr.aux_sample_size); |
| 151 | PrintIndented(indent + 1, "sig_data 0x%" PRIx64 "\n", attr.sig_data); |
| 152 | PrintIndented(indent + 1, "config3 0x%" PRIx64 "\n", attr.config3); |
Yabin Cui | 67d3abd | 2015-04-16 15:26:31 -0700 | [diff] [blame] | 153 | } |
Yabin Cui | 2d6efe4 | 2016-04-01 20:22:35 -0700 | [diff] [blame] | 154 | |
Yabin Cui | 06ed3ef | 2023-04-07 13:19:00 -0700 | [diff] [blame] | 155 | bool GetCommonEventIdPositionsForAttrs(const EventAttrIds& attrs, |
Thiébaud Weksteen | 4848ee0 | 2020-10-23 16:06:59 +0200 | [diff] [blame] | 156 | size_t* event_id_pos_in_sample_records, |
| 157 | size_t* event_id_reverse_pos_in_non_sample_records) { |
Yabin Cui | 2d6efe4 | 2016-04-01 20:22:35 -0700 | [diff] [blame] | 158 | // When there are more than one perf_event_attrs, we need to read event id |
| 159 | // in each record to decide current record should use which attr. So |
| 160 | // we need to determine the event id position in a record here. |
| 161 | std::vector<uint64_t> sample_types; |
| 162 | for (const auto& attr : attrs) { |
Yabin Cui | 06ed3ef | 2023-04-07 13:19:00 -0700 | [diff] [blame] | 163 | sample_types.push_back(attr.attr.sample_type); |
Yabin Cui | 2d6efe4 | 2016-04-01 20:22:35 -0700 | [diff] [blame] | 164 | } |
| 165 | // First determine event_id_pos_in_sample_records. |
| 166 | // If PERF_SAMPLE_IDENTIFIER is enabled, it is just after perf_event_header. |
| 167 | // If PERF_SAMPLE_ID is enabled, then PERF_SAMPLE_IDENTIFIER | IP | TID | TIME | ADDR |
| 168 | // should also be the same. |
| 169 | bool identifier_enabled = true; |
| 170 | bool id_enabled = true; |
| 171 | uint64_t flags_before_id_mask = PERF_SAMPLE_IDENTIFIER | PERF_SAMPLE_IP | PERF_SAMPLE_TID | |
Thiébaud Weksteen | 4848ee0 | 2020-10-23 16:06:59 +0200 | [diff] [blame] | 172 | PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR; |
Yabin Cui | 2d6efe4 | 2016-04-01 20:22:35 -0700 | [diff] [blame] | 173 | uint64_t flags_before_id = sample_types[0] & flags_before_id_mask; |
| 174 | bool flags_before_id_are_the_same = true; |
| 175 | for (auto type : sample_types) { |
| 176 | identifier_enabled &= (type & PERF_SAMPLE_IDENTIFIER) != 0; |
| 177 | id_enabled &= (type & PERF_SAMPLE_ID) != 0; |
| 178 | flags_before_id_are_the_same &= (type & flags_before_id_mask) == flags_before_id; |
| 179 | } |
| 180 | if (identifier_enabled) { |
| 181 | *event_id_pos_in_sample_records = sizeof(perf_event_header); |
| 182 | } else if (id_enabled && flags_before_id_are_the_same) { |
| 183 | uint64_t pos = sizeof(perf_event_header); |
| 184 | while (flags_before_id != 0) { |
| 185 | // Each flags takes 8 bytes in sample records. |
| 186 | flags_before_id &= flags_before_id - 1; |
| 187 | pos += 8; |
| 188 | } |
| 189 | *event_id_pos_in_sample_records = pos; |
| 190 | } else { |
| 191 | LOG(ERROR) << "perf_event_attrs don't have a common event id position in sample records"; |
| 192 | return false; |
| 193 | } |
| 194 | |
| 195 | // Secondly determine event_id_reverse_pos_in_non_sample_record. |
| 196 | // If sample_id_all is not enabled, there is no event id in non sample records. |
| 197 | // If PERF_SAMPLE_IDENTIFIER is enabled, it is at the last 8 bytes of the record. |
| 198 | // If PERF_SAMPLE_ID is enabled, then PERF_SAMPLE_IDENTIFIER | CPU | STREAM_ID should |
| 199 | // also be the same. |
| 200 | bool sample_id_all_enabled = true; |
| 201 | for (const auto& attr : attrs) { |
Yabin Cui | 06ed3ef | 2023-04-07 13:19:00 -0700 | [diff] [blame] | 202 | if (attr.attr.sample_id_all == 0) { |
Yabin Cui | 2d6efe4 | 2016-04-01 20:22:35 -0700 | [diff] [blame] | 203 | sample_id_all_enabled = false; |
| 204 | } |
| 205 | } |
| 206 | if (!sample_id_all_enabled) { |
| 207 | LOG(ERROR) << "there are perf_event_attrs not enabling sample_id_all, so can't determine " |
| 208 | << "perf_event_attr for non sample records"; |
| 209 | return false; |
| 210 | } |
| 211 | uint64_t flags_after_id_mask = PERF_SAMPLE_IDENTIFIER | PERF_SAMPLE_CPU | PERF_SAMPLE_STREAM_ID; |
| 212 | uint64_t flags_after_id = sample_types[0] & flags_after_id_mask; |
| 213 | bool flags_after_id_are_the_same = true; |
| 214 | for (auto type : sample_types) { |
| 215 | flags_after_id_are_the_same &= (type & flags_after_id_mask) == flags_after_id; |
| 216 | } |
| 217 | if (identifier_enabled) { |
| 218 | *event_id_reverse_pos_in_non_sample_records = 8; |
| 219 | } else if (id_enabled && flags_after_id_are_the_same) { |
| 220 | uint64_t pos = 8; |
| 221 | while (flags_after_id != 0) { |
| 222 | // Each flag takes 8 bytes in sample_id of non sample records. |
| 223 | flags_after_id &= flags_after_id - 1; |
| 224 | pos += 8; |
| 225 | } |
| 226 | *event_id_reverse_pos_in_non_sample_records = pos; |
| 227 | } else { |
Thiébaud Weksteen | 4848ee0 | 2020-10-23 16:06:59 +0200 | [diff] [blame] | 228 | LOG(ERROR) |
| 229 | << "perf_event_attrs don't have a common event id reverse position in non sample records"; |
Yabin Cui | 2d6efe4 | 2016-04-01 20:22:35 -0700 | [diff] [blame] | 230 | return false; |
| 231 | } |
| 232 | return true; |
| 233 | } |
| 234 | |
| 235 | bool IsTimestampSupported(const perf_event_attr& attr) { |
| 236 | return attr.sample_id_all && (attr.sample_type & PERF_SAMPLE_TIME); |
| 237 | } |
Yabin Cui | c10a9dc | 2016-06-15 12:10:33 -0700 | [diff] [blame] | 238 | |
Yabin Cui | fc22b8f | 2016-08-04 14:47:50 -0700 | [diff] [blame] | 239 | bool IsCpuSupported(const perf_event_attr& attr) { |
| 240 | return attr.sample_id_all && (attr.sample_type & PERF_SAMPLE_CPU); |
| 241 | } |
| 242 | |
Yabin Cui | c10a9dc | 2016-06-15 12:10:33 -0700 | [diff] [blame] | 243 | std::string GetEventNameByAttr(const perf_event_attr& attr) { |
Yabin Cui | 16a6ace | 2020-10-01 14:56:32 -0700 | [diff] [blame] | 244 | std::string name = "unknown"; |
| 245 | auto callback = [&](const EventType& event_type) { |
Yabin Cui | d5bccd1 | 2019-07-12 13:09:15 -0700 | [diff] [blame] | 246 | // An event type uses both type and config value to define itself. But etm event type |
| 247 | // only uses type value (whose config value is used to set etm options). |
| 248 | if (event_type.type == attr.type && |
Yabin Cui | 16a6ace | 2020-10-01 14:56:32 -0700 | [diff] [blame] | 249 | (event_type.config == attr.config || event_type.IsEtmEvent())) { |
| 250 | name = event_type.name; |
Yabin Cui | c10a9dc | 2016-06-15 12:10:33 -0700 | [diff] [blame] | 251 | if (attr.exclude_user && !attr.exclude_kernel) { |
| 252 | name += ":k"; |
| 253 | } else if (attr.exclude_kernel && !attr.exclude_user) { |
| 254 | name += ":u"; |
| 255 | } |
Yabin Cui | 16a6ace | 2020-10-01 14:56:32 -0700 | [diff] [blame] | 256 | return false; |
Yabin Cui | c10a9dc | 2016-06-15 12:10:33 -0700 | [diff] [blame] | 257 | } |
Yabin Cui | 16a6ace | 2020-10-01 14:56:32 -0700 | [diff] [blame] | 258 | return true; |
| 259 | }; |
| 260 | EventTypeManager::Instance().ForEachType(callback); |
| 261 | return name; |
Yabin Cui | c10a9dc | 2016-06-15 12:10:33 -0700 | [diff] [blame] | 262 | } |
Yabin Cui | a22f3b9 | 2020-09-01 10:52:28 -0700 | [diff] [blame] | 263 | |
Yabin Cui | fcca320 | 2023-04-07 14:01:09 -0700 | [diff] [blame] | 264 | void ReplaceRegAndStackWithCallChain(perf_event_attr& attr) { |
| 265 | attr.sample_type &= ~(PERF_SAMPLE_REGS_USER | PERF_SAMPLE_STACK_USER); |
| 266 | attr.exclude_callchain_user = 0; |
| 267 | attr.sample_regs_user = 0; |
| 268 | attr.sample_stack_user = 0; |
| 269 | } |
| 270 | |
Yabin Cui | a22f3b9 | 2020-09-01 10:52:28 -0700 | [diff] [blame] | 271 | } // namespace simpleperf |