blob: a815aae7138aec7464e4214bedd860ec257bc959 [file] [log] [blame]
Christopher Ferris6f3981c2017-07-27 09:29:18 -07001/*
2 * Copyright (C) 2017 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 _LIBBACKTRACE_UNWINDSTACK_MAP_H
18#define _LIBBACKTRACE_UNWINDSTACK_MAP_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
Christopher Ferris5f118512017-09-01 11:17:16 -070023#include <memory>
Christopher Ferris0b06a592018-01-19 10:26:36 -080024#include <mutex>
25#include <unordered_map>
Christopher Ferris5f118512017-09-01 11:17:16 -070026
Christopher Ferris6f3981c2017-07-27 09:29:18 -070027#include <backtrace/BacktraceMap.h>
Christopher Ferris150db122017-12-20 18:49:01 -080028#include <unwindstack/JitDebug.h>
Christopher Ferris6f3981c2017-07-27 09:29:18 -070029#include <unwindstack/Maps.h>
30
Christopher Ferris0b06a592018-01-19 10:26:36 -080031// Forward declarations.
32class UnwindDexFile;
33
Christopher Ferris6f3981c2017-07-27 09:29:18 -070034class UnwindStackMap : public BacktraceMap {
35 public:
36 explicit UnwindStackMap(pid_t pid);
Christopher Ferris0b06a592018-01-19 10:26:36 -080037 ~UnwindStackMap();
Christopher Ferris6f3981c2017-07-27 09:29:18 -070038
39 bool Build() override;
40
Christopher Ferris7937a362018-01-18 11:15:49 -080041 void FillIn(uint64_t addr, backtrace_map_t* map) override;
Christopher Ferris6f3981c2017-07-27 09:29:18 -070042
Christopher Ferris7937a362018-01-18 11:15:49 -080043 virtual std::string GetFunctionName(uint64_t pc, uint64_t* offset) override;
Josh Gaoebea0ef2017-09-06 15:39:14 -070044 virtual std::shared_ptr<unwindstack::Memory> GetProcessMemory() override final;
Josh Gao358de182017-09-06 22:16:09 -070045
Christopher Ferris6f3981c2017-07-27 09:29:18 -070046 unwindstack::Maps* stack_maps() { return stack_maps_.get(); }
47
Christopher Ferris5f118512017-09-01 11:17:16 -070048 const std::shared_ptr<unwindstack::Memory>& process_memory() { return process_memory_; }
49
Christopher Ferris150db122017-12-20 18:49:01 -080050 unwindstack::JitDebug* GetJitDebug() { return jit_debug_.get(); }
51
Christopher Ferris0b06a592018-01-19 10:26:36 -080052 UnwindDexFile* GetDexFile(uint64_t dex_file_offset, unwindstack::MapInfo* info);
53
Christopher Ferris6f3981c2017-07-27 09:29:18 -070054 protected:
Christopher Ferrisb7de5f52017-12-01 21:37:37 -080055 uint64_t GetLoadBias(size_t index) override;
56
Christopher Ferris6f3981c2017-07-27 09:29:18 -070057 std::unique_ptr<unwindstack::Maps> stack_maps_;
Christopher Ferris5f118512017-09-01 11:17:16 -070058 std::shared_ptr<unwindstack::Memory> process_memory_;
Christopher Ferris150db122017-12-20 18:49:01 -080059 std::unique_ptr<unwindstack::JitDebug> jit_debug_;
Christopher Ferris0b06a592018-01-19 10:26:36 -080060#ifndef NO_LIBDEXFILE
61 std::mutex dex_lock_;
62 std::unordered_map<uint64_t, UnwindDexFile*> dex_files_;
63#endif
Christopher Ferris6f3981c2017-07-27 09:29:18 -070064};
65
66#endif // _LIBBACKTRACE_UNWINDSTACK_MAP_H