diff options
Diffstat (limited to 'libunwindstack/include')
-rw-r--r-- | libunwindstack/include/unwindstack/DexFiles.h | 9 | ||||
-rw-r--r-- | libunwindstack/include/unwindstack/Global.h | 54 | ||||
-rw-r--r-- | libunwindstack/include/unwindstack/JitDebug.h | 10 |
3 files changed, 65 insertions, 8 deletions
diff --git a/libunwindstack/include/unwindstack/DexFiles.h b/libunwindstack/include/unwindstack/DexFiles.h index 26f5d35..c2fde74 100644 --- a/libunwindstack/include/unwindstack/DexFiles.h +++ b/libunwindstack/include/unwindstack/DexFiles.h @@ -25,16 +25,18 @@ #include <unordered_map> #include <vector> +#include <unwindstack/Global.h> +#include <unwindstack/Memory.h> + namespace unwindstack { // Forward declarations. class DexFile; class Maps; struct MapInfo; -class Memory; enum ArchEnum : uint8_t; -class DexFiles { +class DexFiles : public Global { public: explicit DexFiles(std::shared_ptr<Memory>& memory); DexFiles(std::shared_ptr<Memory>& memory, std::vector<std::string>& search_libs); @@ -60,8 +62,7 @@ class DexFiles { bool ReadEntry64(); - std::shared_ptr<Memory> memory_; - std::vector<std::string> search_libs_; + bool ReadVariableData(uint64_t ptr_offset) override; std::mutex lock_; bool initialized_ = false; diff --git a/libunwindstack/include/unwindstack/Global.h b/libunwindstack/include/unwindstack/Global.h new file mode 100644 index 0000000..70e3ddd --- /dev/null +++ b/libunwindstack/include/unwindstack/Global.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _LIBUNWINDSTACK_GLOBAL_H +#define _LIBUNWINDSTACK_GLOBAL_H + +#include <stdint.h> + +#include <memory> +#include <mutex> +#include <string> +#include <unordered_map> +#include <vector> + +#include <unwindstack/Memory.h> + +namespace unwindstack { + +// Forward declarations. +class Maps; +struct MapInfo; + +class Global { + public: + explicit Global(std::shared_ptr<Memory>& memory); + Global(std::shared_ptr<Memory>& memory, std::vector<std::string>& search_libs); + virtual ~Global() = default; + + protected: + uint64_t GetVariableOffset(MapInfo* info, const std::string& variable); + void FindAndReadVariable(Maps* maps, const char* variable); + + virtual bool ReadVariableData(uint64_t offset) = 0; + + std::shared_ptr<Memory> memory_; + std::vector<std::string> search_libs_; +}; + +} // namespace unwindstack + +#endif // _LIBUNWINDSTACK_GLOBAL_H diff --git a/libunwindstack/include/unwindstack/JitDebug.h b/libunwindstack/include/unwindstack/JitDebug.h index 0bcd0b0..ccb473f 100644 --- a/libunwindstack/include/unwindstack/JitDebug.h +++ b/libunwindstack/include/unwindstack/JitDebug.h @@ -24,15 +24,17 @@ #include <string> #include <vector> +#include <unwindstack/Global.h> +#include <unwindstack/Memory.h> + namespace unwindstack { // Forward declarations. class Elf; class Maps; -class Memory; enum ArchEnum : uint8_t; -class JitDebug { +class JitDebug : public Global { public: explicit JitDebug(std::shared_ptr<Memory>& memory); JitDebug(std::shared_ptr<Memory>& memory, std::vector<std::string>& search_libs); @@ -45,11 +47,9 @@ class JitDebug { private: void Init(Maps* maps); - std::shared_ptr<Memory> memory_; uint64_t entry_addr_ = 0; bool initialized_ = false; std::vector<Elf*> elf_list_; - std::vector<std::string> search_libs_; std::mutex lock_; @@ -62,6 +62,8 @@ class JitDebug { uint64_t ReadEntry32Pack(uint64_t* start, uint64_t* size); uint64_t ReadEntry32Pad(uint64_t* start, uint64_t* size); uint64_t ReadEntry64(uint64_t* start, uint64_t* size); + + bool ReadVariableData(uint64_t ptr_offset) override; }; } // namespace unwindstack |