From 31f21a282356c1a5aca5109abe3db1d68f5c880d Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Wed, 7 Mar 2018 15:55:48 -0800 Subject: simpleperf: Fix cached map in OfflineUnwinder. In system wide profiling, sometimes a sample record goes before all mmap records of a process. Then thread.maps->version = 0 and cached_map.map isn't created. This is caught by simpleperf_unit_test. Bug: none Test: run simpleperf_unit_test. Change-Id: I99254396d0fb22531f735ff3193b8d3b1f9641dd --- simpleperf/OfflineUnwinder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'simpleperf') diff --git a/simpleperf/OfflineUnwinder.cpp b/simpleperf/OfflineUnwinder.cpp index ae33cafd..9d561447 100644 --- a/simpleperf/OfflineUnwinder.cpp +++ b/simpleperf/OfflineUnwinder.cpp @@ -131,7 +131,7 @@ bool OfflineUnwinder::UnwindCallChain(const ThreadEntry& thread, const RegSet& r auto map_it = cached_maps_.find(thread.pid); CachedMap& cached_map = (map_it == cached_maps_.end() ? cached_maps_[thread.pid] : map_it->second); - if (cached_map.version < thread.maps->version) { + if (!cached_map.map || cached_map.version < thread.maps->version) { std::vector bt_maps(thread.maps->maps.size()); size_t map_index = 0; for (auto& map : thread.maps->maps) { -- cgit v1.2.3