Christopher Ferris | e7ba4cc | 2017-04-04 14:06:58 -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_SYMBOLS_H |
| 18 | #define _LIBUNWINDSTACK_SYMBOLS_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | |
| 22 | #include <string> |
| 23 | #include <vector> |
| 24 | |
Christopher Ferris | d226a51 | 2017-07-14 10:37:19 -0700 | [diff] [blame] | 25 | namespace unwindstack { |
| 26 | |
Christopher Ferris | e7ba4cc | 2017-04-04 14:06:58 -0700 | [diff] [blame] | 27 | // Forward declaration. |
| 28 | class Memory; |
| 29 | |
| 30 | class Symbols { |
| 31 | struct Info { |
| 32 | Info(uint64_t start_offset, uint64_t end_offset, uint64_t str_offset) |
| 33 | : start_offset(start_offset), end_offset(end_offset), str_offset(str_offset) {} |
| 34 | uint64_t start_offset; |
| 35 | uint64_t end_offset; |
| 36 | uint64_t str_offset; |
| 37 | }; |
| 38 | |
| 39 | public: |
| 40 | Symbols(uint64_t offset, uint64_t size, uint64_t entry_size, uint64_t str_offset, |
| 41 | uint64_t str_size); |
| 42 | virtual ~Symbols() = default; |
| 43 | |
| 44 | const Info* GetInfoFromCache(uint64_t addr); |
| 45 | |
| 46 | template <typename SymType> |
| 47 | bool GetName(uint64_t addr, uint64_t load_bias, Memory* elf_memory, std::string* name, |
| 48 | uint64_t* func_offset); |
| 49 | |
Christopher Ferris | 150db12 | 2017-12-20 18:49:01 -0800 | [diff] [blame] | 50 | template <typename SymType> |
| 51 | bool GetGlobal(Memory* elf_memory, const std::string& name, uint64_t* memory_address); |
| 52 | |
Christopher Ferris | e7ba4cc | 2017-04-04 14:06:58 -0700 | [diff] [blame] | 53 | void ClearCache() { |
| 54 | symbols_.clear(); |
| 55 | cur_offset_ = offset_; |
| 56 | } |
| 57 | |
| 58 | private: |
| 59 | uint64_t cur_offset_; |
| 60 | uint64_t offset_; |
| 61 | uint64_t end_; |
| 62 | uint64_t entry_size_; |
| 63 | uint64_t str_offset_; |
| 64 | uint64_t str_end_; |
| 65 | |
| 66 | std::vector<Info> symbols_; |
| 67 | }; |
| 68 | |
Christopher Ferris | d226a51 | 2017-07-14 10:37:19 -0700 | [diff] [blame] | 69 | } // namespace unwindstack |
| 70 | |
Christopher Ferris | e7ba4cc | 2017-04-04 14:06:58 -0700 | [diff] [blame] | 71 | #endif // _LIBUNWINDSTACK_SYMBOLS_H |