1 /* 2 * Copyright (C) 2018 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_GLOBAL_H 18 #define _LIBUNWINDSTACK_GLOBAL_H 19 20 #include <stdint.h> 21 22 #include <memory> 23 #include <mutex> 24 #include <string> 25 #include <unordered_map> 26 #include <vector> 27 28 #include <unwindstack/Elf.h> 29 #include <unwindstack/Memory.h> 30 31 namespace unwindstack { 32 33 // Forward declarations. 34 class Maps; 35 struct MapInfo; 36 37 class Global { 38 public: 39 explicit Global(std::shared_ptr<Memory>& memory); 40 Global(std::shared_ptr<Memory>& memory, std::vector<std::string>& search_libs); 41 virtual ~Global() = default; 42 43 void SetArch(ArchEnum arch); 44 arch()45 ArchEnum arch() { return arch_; } 46 47 protected: 48 uint64_t GetVariableOffset(MapInfo* info, const std::string& variable); 49 void FindAndReadVariable(Maps* maps, const char* variable); 50 51 virtual bool ReadVariableData(uint64_t offset) = 0; 52 53 virtual void ProcessArch() = 0; 54 55 ArchEnum arch_ = ARCH_UNKNOWN; 56 57 std::shared_ptr<Memory> memory_; 58 std::vector<std::string> search_libs_; 59 }; 60 61 } // namespace unwindstack 62 63 #endif // _LIBUNWINDSTACK_GLOBAL_H 64