Christopher Ferris | 150db12 | 2017-12-20 18:49:01 -0800 | [diff] [blame] | 1 | /* |
| 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 _LIBUNWINDSTACK_JIT_DEBUG_H |
| 18 | #define _LIBUNWINDSTACK_JIT_DEBUG_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | |
| 22 | #include <memory> |
| 23 | #include <mutex> |
| 24 | #include <string> |
| 25 | #include <vector> |
| 26 | |
| 27 | namespace unwindstack { |
| 28 | |
| 29 | // Forward declarations. |
| 30 | class Elf; |
| 31 | class Maps; |
| 32 | class Memory; |
| 33 | enum ArchEnum : uint8_t; |
| 34 | |
| 35 | class JitDebug { |
| 36 | public: |
| 37 | explicit JitDebug(std::shared_ptr<Memory>& memory); |
| 38 | JitDebug(std::shared_ptr<Memory>& memory, std::vector<std::string>& search_libs); |
| 39 | ~JitDebug(); |
| 40 | |
| 41 | Elf* GetElf(Maps* maps, uint64_t pc); |
| 42 | |
| 43 | void SetArch(ArchEnum arch); |
| 44 | |
| 45 | private: |
| 46 | void Init(Maps* maps); |
| 47 | |
| 48 | std::shared_ptr<Memory> memory_; |
| 49 | uint64_t entry_addr_ = 0; |
| 50 | bool initialized_ = false; |
| 51 | std::vector<Elf*> elf_list_; |
| 52 | std::vector<std::string> search_libs_; |
| 53 | |
| 54 | std::mutex lock_; |
| 55 | |
| 56 | uint64_t (JitDebug::*read_descriptor_func_)(uint64_t) = nullptr; |
| 57 | uint64_t (JitDebug::*read_entry_func_)(uint64_t*, uint64_t*) = nullptr; |
| 58 | |
| 59 | uint64_t ReadDescriptor32(uint64_t); |
| 60 | uint64_t ReadDescriptor64(uint64_t); |
| 61 | |
| 62 | uint64_t ReadEntry32Pack(uint64_t* start, uint64_t* size); |
| 63 | uint64_t ReadEntry32Pad(uint64_t* start, uint64_t* size); |
| 64 | uint64_t ReadEntry64(uint64_t* start, uint64_t* size); |
| 65 | }; |
| 66 | |
| 67 | } // namespace unwindstack |
| 68 | |
| 69 | #endif // _LIBUNWINDSTACK_JIT_DEBUG_H |