blob: 1a52354745d850c1a6d7bd102310101036e90b4b [file] [log] [blame]
Yabin Cui39e59792020-01-23 12:32:26 -08001/*
2 * Copyright (C) 2020 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#pragma once
18
19#include <unwindstack/Maps.h>
Yabin Cui91784fd2020-01-29 17:08:49 -080020#include <unwindstack/Regs.h>
Yabin Cui39e59792020-01-23 12:32:26 -080021
22#include "thread_tree.h"
23
24namespace simpleperf {
25
26class UnwindMaps : public unwindstack::Maps {
27 public:
28 void UpdateMaps(const MapSet& map_set);
29
30 private:
31 uint64_t version_ = 0u;
32 std::vector<const MapEntry*> entries_;
33};
34
Yabin Cui91784fd2020-01-29 17:08:49 -080035class OfflineUnwinderImpl : public OfflineUnwinder {
36 public:
37 OfflineUnwinderImpl(bool collect_stat) : collect_stat_(collect_stat) {
38 unwindstack::Elf::SetCachingEnabled(true);
39 }
40
41 bool UnwindCallChain(const ThreadEntry& thread, const RegSet& regs, const char* stack,
42 size_t stack_size, std::vector<uint64_t>* ips,
43 std::vector<uint64_t>* sps) override;
44
45 void LoadMetaInfo(const std::unordered_map<std::string, std::string>& info_map) override;
46 unwindstack::Regs* GetBacktraceRegs(const RegSet& regs);
47
48 private:
49 bool collect_stat_;
50 std::unordered_map<pid_t, UnwindMaps> cached_maps_;
51 uint64_t arm64_pac_mask_ = 0;
52};
53
Yabin Cui39e59792020-01-23 12:32:26 -080054} // namespace simpleperf