| Christopher Ferris | c9dee84 | 2017-11-03 14:50:27 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2016 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_DWARF_EH_FRAME_WITH_HDR_H | 
|  | 18 | #define _LIBUNWINDSTACK_DWARF_EH_FRAME_WITH_HDR_H | 
|  | 19 |  | 
|  | 20 | #include <stdint.h> | 
|  | 21 |  | 
|  | 22 | #include <unordered_map> | 
|  | 23 |  | 
|  | 24 | #include "DwarfEhFrame.h" | 
|  | 25 |  | 
|  | 26 | namespace unwindstack { | 
|  | 27 |  | 
|  | 28 | // Forward declarations. | 
|  | 29 | class Memory; | 
|  | 30 |  | 
|  | 31 | template <typename AddressType> | 
|  | 32 | class DwarfEhFrameWithHdr : public DwarfEhFrame<AddressType> { | 
|  | 33 | public: | 
|  | 34 | // Add these so that the protected members of DwarfSectionImpl | 
|  | 35 | // can be accessed without needing a this->. | 
|  | 36 | using DwarfSectionImpl<AddressType>::memory_; | 
|  | 37 | using DwarfSectionImpl<AddressType>::fde_count_; | 
|  | 38 | using DwarfSectionImpl<AddressType>::entries_offset_; | 
|  | 39 | using DwarfSectionImpl<AddressType>::entries_end_; | 
|  | 40 | using DwarfSectionImpl<AddressType>::last_error_; | 
|  | 41 |  | 
|  | 42 | struct FdeInfo { | 
|  | 43 | AddressType pc; | 
|  | 44 | uint64_t offset; | 
|  | 45 | }; | 
|  | 46 |  | 
|  | 47 | DwarfEhFrameWithHdr(Memory* memory) : DwarfEhFrame<AddressType>(memory) {} | 
|  | 48 | virtual ~DwarfEhFrameWithHdr() = default; | 
|  | 49 |  | 
|  | 50 | bool Init(uint64_t offset, uint64_t size) override; | 
|  | 51 |  | 
|  | 52 | bool GetFdeOffsetFromPc(uint64_t pc, uint64_t* fde_offset) override; | 
|  | 53 |  | 
|  | 54 | const DwarfFde* GetFdeFromIndex(size_t index) override; | 
|  | 55 |  | 
|  | 56 | const FdeInfo* GetFdeInfoFromIndex(size_t index); | 
|  | 57 |  | 
|  | 58 | bool GetFdeOffsetSequential(uint64_t pc, uint64_t* fde_offset); | 
|  | 59 |  | 
|  | 60 | bool GetFdeOffsetBinary(uint64_t pc, uint64_t* fde_offset, uint64_t total_entries); | 
|  | 61 |  | 
|  | 62 | protected: | 
|  | 63 | uint8_t version_; | 
|  | 64 | uint8_t ptr_encoding_; | 
|  | 65 | uint8_t table_encoding_; | 
|  | 66 | size_t table_entry_size_; | 
|  | 67 |  | 
|  | 68 | uint64_t ptr_offset_; | 
|  | 69 |  | 
|  | 70 | uint64_t entries_data_offset_; | 
|  | 71 | uint64_t cur_entries_offset_ = 0; | 
|  | 72 |  | 
|  | 73 | std::unordered_map<uint64_t, FdeInfo> fde_info_; | 
|  | 74 | }; | 
|  | 75 |  | 
|  | 76 | }  // namespace unwindstack | 
|  | 77 |  | 
|  | 78 | #endif  // _LIBUNWINDSTACK_DWARF_EH_FRAME_WITH_HDR_H |