Ryan Savitski | 703bcab | 2019-12-18 14:38:14 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 | #ifndef SRC_PROFILING_PERF_UNWIND_SUPPORT_H_ |
| 18 | #define SRC_PROFILING_PERF_UNWIND_SUPPORT_H_ |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <unwindstack/Regs.h> |
| 22 | |
| 23 | #include <memory> |
| 24 | |
| 25 | #include "perfetto/ext/base/scoped_file.h" |
| 26 | |
| 27 | namespace perfetto { |
| 28 | namespace profiling { |
| 29 | |
| 30 | // Returns a bitmask for sampling the userspace register set, used when |
| 31 | // configuring perf events. |
| 32 | uint64_t PerfUserRegsMaskForCurrentArch(); |
| 33 | |
| 34 | // Converts the raw sampled register bytes to libunwindstack's representation |
| 35 | // (correct arch-dependent subclass). Advances |data| pointer to past the |
| 36 | // register data. The unique_ptr can be empty, if there were no userspace |
| 37 | // registers to sample (i.e. we've sampled a kernel thread). |
| 38 | // TODO(rsavitski): come up with a better signature (also consider how much to |
| 39 | // isolate libunwindstack types). |
| 40 | std::unique_ptr<unwindstack::Regs> ReadPerfUserRegsData(const char** data); |
| 41 | |
| 42 | } // namespace profiling |
| 43 | } // namespace perfetto |
| 44 | |
| 45 | #endif // SRC_PROFILING_PERF_UNWIND_SUPPORT_H_ |