Simpleperf: warn if it can't read kernel symbols addresses.
And a little format adjustment.
Bug: 24404256
Change-Id: Ie8dcd37138a693df18101d415e6e3243f4963582
diff --git a/simpleperf/dso.cpp b/simpleperf/dso.cpp
index 69cbcc3..13f2bfe 100644
--- a/simpleperf/dso.cpp
+++ b/simpleperf/dso.cpp
@@ -150,7 +150,6 @@
}
};
-
std::string Dso::GetAccessiblePath() const {
return symfs_dir_ + path_;
}
@@ -228,8 +227,22 @@
return false;
}
}
+
ProcessKernelSymbols("/proc/kallsyms",
std::bind(&KernelSymbolCallback, std::placeholders::_1, this));
+ bool allZero = true;
+ for (auto& symbol : symbols_) {
+ if (symbol.addr != 0) {
+ allZero = false;
+ break;
+ }
+ }
+ if (allZero) {
+ LOG(WARNING) << "Symbol addresses in /proc/kallsyms are all zero. Check "
+ "/proc/sys/kernel/kptr_restrict if possible.";
+ symbols_.clear();
+ return false;
+ }
}
return true;
}