-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDexFile.h
69 lines (53 loc) · 2.12 KB
/
DexFile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBUNWINDSTACK_DEX_FILE_H
#define _LIBUNWINDSTACK_DEX_FILE_H
#include <stdint.h>
#include <map>
#include <memory>
#include <utility>
#include <unwindstack/SharedString.h>
#include <art_api/dex_file_support.h>
namespace unwindstack {
struct MapInfo;
class Memory;
class DexFile {
struct Info {
uint32_t offset; // Symbol start offset (relative to start of dex file).
SharedString name;
};
public:
bool IsValidPc(uint64_t dex_pc) {
return base_addr_ <= dex_pc && (dex_pc - base_addr_) < file_size_;
}
bool GetFunctionName(uint64_t dex_pc, SharedString* method_name, uint64_t* method_offset);
static std::unique_ptr<DexFile> Create(uint64_t base_addr, uint64_t file_size, Memory* memory,
MapInfo* info);
private:
DexFile(std::unique_ptr<Memory>&& memory, uint64_t base_addr, uint64_t file_size,
std::unique_ptr<art_api::dex::DexFile>&& dex)
: memory_(std::move(memory)),
base_addr_(base_addr),
file_size_(file_size),
dex_(std::move(dex)) {}
std::unique_ptr<Memory> memory_; // Memory range containing the dex file.
uint64_t base_addr_ = 0; // Absolute address where this DEX file is in memory.
uint64_t file_size_ = 0; // Total number of bytes in the dex file.
std::unique_ptr<art_api::dex::DexFile> dex_; // Loaded underling dex object.
std::map<uint32_t, Info> symbols_; // Cache of read symbols (keyed by *end* offset).
};
} // namespace unwindstack
#endif // _LIBUNWINDSTACK_DEX_FILE_H