diff options
author | David Srbecky <dsrbecky@google.com> | 2018-02-23 18:06:13 +0000 |
---|---|---|
committer | David Srbecky <dsrbecky@google.com> | 2019-03-29 14:01:32 +0000 |
commit | 91dc724d5ba73d60cc0f7c2b01e559e899ff3a87 (patch) | |
tree | fac7af5e6c483517979497b2c3e17a58bc7df5c0 /libunwindstack/include/unwindstack/JitDebug.h | |
parent | d2a07ef525b8413f93c7e951ac3a2a78d09339ad (diff) | |
download | unwinding-91dc724d5ba73d60cc0f7c2b01e559e899ff3a87.tar.gz |
Check for data races when reading JIT/DEX entries.
Update the entries only when the list is modified by the runtime.
Check that the list wasn't concurrently modified when being read.
Bug: 124287208
Test: libunwindstack_test
Test: art/test.py -b --host -r -t 137-cfi
Change-Id: I87ba70322053a01b3d5be1fdf6310e1dc21bb084
Diffstat (limited to 'libunwindstack/include/unwindstack/JitDebug.h')
-rw-r--r-- | libunwindstack/include/unwindstack/JitDebug.h | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/libunwindstack/include/unwindstack/JitDebug.h b/libunwindstack/include/unwindstack/JitDebug.h index 8b7b4b5..0c3ded9 100644 --- a/libunwindstack/include/unwindstack/JitDebug.h +++ b/libunwindstack/include/unwindstack/JitDebug.h @@ -19,6 +19,7 @@ #include <stdint.h> +#include <map> #include <memory> #include <mutex> #include <string> @@ -30,40 +31,24 @@ namespace unwindstack { // Forward declarations. -class Elf; class Maps; enum ArchEnum : uint8_t; -class JitDebug : public Global { +template <typename Symfile> +class JitDebug { public: - explicit JitDebug(std::shared_ptr<Memory>& memory); - JitDebug(std::shared_ptr<Memory>& memory, std::vector<std::string>& search_libs); - virtual ~JitDebug(); - - Elf* GetElf(Maps* maps, uint64_t pc); - - private: - void Init(Maps* maps); - - uint64_t (JitDebug::*read_descriptor_func_)(uint64_t) = nullptr; - uint64_t (JitDebug::*read_entry_func_)(uint64_t*, uint64_t*) = nullptr; - - uint64_t ReadDescriptor32(uint64_t); - uint64_t ReadDescriptor64(uint64_t); - - 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; - - void ProcessArch() override; - - uint64_t entry_addr_ = 0; - bool initialized_ = false; - std::vector<Elf*> elf_list_; - - std::mutex lock_; + static std::unique_ptr<JitDebug> Create(ArchEnum arch, std::shared_ptr<Memory>& memory, + std::vector<std::string> search_libs = {}); + virtual ~JitDebug() {} + + // Find symbol file for given pc. + virtual Symfile* Get(Maps* maps, uint64_t pc) = 0; + + // Find symbol for given pc. + bool GetFunctionName(Maps* maps, uint64_t pc, std::string* name, uint64_t* offset) { + Symfile* file = Get(maps, pc); + return file != nullptr && file->GetFunctionName(pc, name, offset); + } }; } // namespace unwindstack |