const std::vector<std::string>& args) {
// Read data section of perf.data to collect hit file information.
thread_tree_.ClearThreadAndMap();
- Dso::ReadKernelSymbolsFromProc();
+ if (CheckKernelSymbolAddresses()) {
+ Dso::ReadKernelSymbolsFromProc();
+ }
auto callback = [&](const Record* r) {
thread_tree_.Update(*r);
if (r->type() == PERF_RECORD_SAMPLE) {
GTEST_LOG_(INFO) << "Test requires root privilege";
return;
}
- system("echo 0 >/proc/sys/kernel/kptr_restrict");
TemporaryFile tmpfile;
ASSERT_TRUE(RunRecordCmd({"-a", "-o", tmpfile.path, "sleep", "1"}));
std::unique_ptr<RecordFileReader> reader = RecordFileReader::CreateInstance(tmpfile.path);
LOG(ERROR) << "failed to parse " << kptr_restrict_file << ": " << s;
return false;
}
+ // Accessible to everyone?
if (value == 0) {
return true;
}
+ // Accessible to root?
if (value == 1 && IsRoot()) {
return true;
}
+ // Can we make it accessible to us?
+ if (IsRoot() && android::base::WriteStringToFile("1", kptr_restrict_file)) {
+ return true;
+ }
LOG(WARNING) << "Access to kernel symbol addresses is restricted. If "
<< "possible, please do `echo 0 >/proc/sys/kernel/kptr_restrict` "
<< "to fix this.";