blob: dd70abafd202a624ae9f6eb88a7b178182b76041 [file] [log] [blame]
Christopher Ferris0b06a592018-01-19 10:26:36 -08001/*
2 * Copyright (C) 2018 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_UNWIND_DEX_FILE_H
18#define _LIBBACKTRACE_UNWIND_DEX_FILE_H
19
20#include <stdint.h>
21
22#include <memory>
23#include <string>
24#include <vector>
25
26#include <dex/dex_file-inl.h>
27
28namespace unwindstack {
29class Memory;
30struct MapInfo;
31} // namespace unwindstack
32
33class UnwindDexFile {
34 public:
35 UnwindDexFile() = default;
36 virtual ~UnwindDexFile() = default;
37
38 void GetMethodInformation(uint64_t dex_offset, std::string* method_name, uint64_t* method_offset);
39
40 static UnwindDexFile* Create(uint64_t dex_file_offset_in_memory, unwindstack::Memory* memory,
41 unwindstack::MapInfo* info);
42
43 protected:
44 std::unique_ptr<const art::DexFile> dex_file_;
45};
46
47class UnwindDexFileFromFile : public UnwindDexFile {
48 public:
49 UnwindDexFileFromFile() = default;
50 virtual ~UnwindDexFileFromFile();
51
52 bool Open(uint64_t dex_file_offset_in_file, const std::string& name);
53
54 private:
55 void* mapped_memory_ = nullptr;
56 size_t size_ = 0;
57};
58
59class UnwindDexFileFromMemory : public UnwindDexFile {
60 public:
61 UnwindDexFileFromMemory() = default;
62 virtual ~UnwindDexFileFromMemory() = default;
63
64 bool Open(uint64_t dex_file_offset_in_memory, unwindstack::Memory* memory);
65
66 private:
67 std::vector<uint8_t> memory_;
68};
69
70#endif // _LIBBACKTRACE_UNWIND_DEX_FILE_H