diff options
Diffstat (limited to 'simpleperf/OfflineUnwinder.h')
-rw-r--r-- | simpleperf/OfflineUnwinder.h | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/simpleperf/OfflineUnwinder.h b/simpleperf/OfflineUnwinder.h index b0ff7ac5..e5091167 100644 --- a/simpleperf/OfflineUnwinder.h +++ b/simpleperf/OfflineUnwinder.h @@ -19,10 +19,15 @@ #include <memory> #include <vector> +#include <unordered_map> #include "perf_regs.h" #include "thread_tree.h" +#if defined(__linux__) +#include <unwindstack/Maps.h> +#endif + namespace simpleperf { struct ThreadEntry; @@ -50,14 +55,26 @@ struct UnwindingResult { uint64_t stack_end; }; +#if defined(__linux__) +class UnwindMaps : public unwindstack::Maps { + public: + void UpdateMaps(const MapSet& map_set); + + private: + uint64_t version_ = 0u; + std::vector<const MapEntry*> entries_; +}; + class OfflineUnwinder { public: - static std::unique_ptr<OfflineUnwinder> Create(bool collect_stat); - virtual ~OfflineUnwinder() {} + OfflineUnwinder(bool collect_stat); + + bool UnwindCallChain(const ThreadEntry& thread, const RegSet& regs, const char* stack, + size_t stack_size, std::vector<uint64_t>* ips, std::vector<uint64_t>* sps); - virtual bool UnwindCallChain(const ThreadEntry& thread, const RegSet& regs, const char* stack, - size_t stack_size, std::vector<uint64_t>* ips, - std::vector<uint64_t>* sps) = 0; + bool HasStat() const { + return collect_stat_; + } const UnwindingResult& GetUnwindingResult() const { return unwinding_result_; @@ -67,13 +84,27 @@ class OfflineUnwinder { return is_callchain_broken_for_incomplete_jit_debug_info_; } - protected: - OfflineUnwinder() {} - + private: + bool collect_stat_; UnwindingResult unwinding_result_; - bool is_callchain_broken_for_incomplete_jit_debug_info_ = false; + bool is_callchain_broken_for_incomplete_jit_debug_info_; + + std::unordered_map<pid_t, UnwindMaps> cached_maps_; +}; + +#else // defined(__linux__) + +class OfflineUnwinder { + public: + OfflineUnwinder(bool) {} + bool UnwindCallChain(const ThreadEntry&, const RegSet&, const char*, size_t, + std::vector<uint64_t>*, std::vector<uint64_t>*) { + return false; + } }; +#endif // !defined(__linux__) + } // namespace simpleperf #endif // SIMPLE_PERF_OFFLINE_UNWINDER_H_ |