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 #include <unwindstack/Global.h> 28 #include <unwindstack/Memory.h> 29 30 namespace unwindstack { 31 32 // Forward declarations. 33 class Elf; 34 class Maps; 35 enum ArchEnum : uint8_t; 36 37 class JitDebug : public Global { 38 public: 39 explicit JitDebug(std::shared_ptr<Memory>& memory); 40 JitDebug(std::shared_ptr<Memory>& memory, std::vector<std::string>& search_libs); 41 virtual ~JitDebug(); 42 43 Elf* GetElf(Maps* maps, uint64_t pc); 44 45 private: 46 void Init(Maps* maps); 47 48 uint64_t (JitDebug::*read_descriptor_func_)(uint64_t) = nullptr; 49 uint64_t (JitDebug::*read_entry_func_)(uint64_t*, uint64_t*) = nullptr; 50 51 uint64_t ReadDescriptor32(uint64_t); 52 uint64_t ReadDescriptor64(uint64_t); 53 54 uint64_t ReadEntry32Pack(uint64_t* start, uint64_t* size); 55 uint64_t ReadEntry32Pad(uint64_t* start, uint64_t* size); 56 uint64_t ReadEntry64(uint64_t* start, uint64_t* size); 57 58 bool ReadVariableData(uint64_t ptr_offset) override; 59 60 void ProcessArch() override; 61 62 uint64_t entry_addr_ = 0; 63 bool initialized_ = false; 64 std::vector<Elf*> elf_list_; 65 66 std::mutex lock_; 67 }; 68 69 } // namespace unwindstack 70 71 #endif // _LIBUNWINDSTACK_JIT_DEBUG_H 72