summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_record.cpp
diff options
context:
space:
mode:
authorThiƩbaud Weksteen <tweek@google.com>2020-11-19 15:07:46 +0100
committerThiƩbaud Weksteen <tweek@google.com>2020-12-01 15:22:07 +0100
commite7e750e5060f69d7a9dcc71abefc5c6e9d999e89 (patch)
tree47f203a978e6d1d8c53b3f7fb15afcb34d7f7064 /simpleperf/cmd_record.cpp
parentcae896b243eeb852b57c778e95b7ef5fae65d403 (diff)
downloadextras-e7e750e5060f69d7a9dcc71abefc5c6e9d999e89.tar.gz
Refactor loading of /proc/kallsyms
Moves related functions to a new source file (kallsyms.cpp). Adds support for the security.lower_kptr_restrict system property. The implementation of ScopedKptrUnrestrict is based on Perfetto (see aosp/1454882). Test: lunch aosp_crosshatch-userdebug; atest CtsSimpleperfTestCases Change-Id: Ie6ba7aab93d68be915583ad4f8551c627b35f292
Diffstat (limited to 'simpleperf/cmd_record.cpp')
-rw-r--r--simpleperf/cmd_record.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/simpleperf/cmd_record.cpp b/simpleperf/cmd_record.cpp
index b9aa5ba1..b4d9328a 100644
--- a/simpleperf/cmd_record.cpp
+++ b/simpleperf/cmd_record.cpp
@@ -53,6 +53,7 @@
#include "environment.h"
#include "event_selection_set.h"
#include "event_type.h"
+#include "kallsyms.h"
#include "read_apk.h"
#include "read_elf.h"
#include "read_symbol_map.h"
@@ -1193,11 +1194,12 @@ std::unique_ptr<RecordFileWriter> RecordCommand::CreateRecordFile(const std::str
bool RecordCommand::DumpKernelSymbol() {
if (can_dump_kernel_symbols_) {
- std::string kallsyms;
- if (event_selection_set_.NeedKernelSymbol() && CheckKernelSymbolAddresses()) {
- if (!android::base::ReadFileToString("/proc/kallsyms", &kallsyms)) {
- PLOG(ERROR) << "failed to read /proc/kallsyms";
- return false;
+ if (event_selection_set_.NeedKernelSymbol()) {
+ std::string kallsyms;
+ if (!LoadKernelSymbols(&kallsyms)) {
+ // Symbol loading may have failed due to the lack of permissions. This
+ // is not fatal, the symbols will appear as "unknown".
+ return true;
}
KernelSymbolRecord r(kallsyms);
if (!ProcessRecord(&r)) {
@@ -1671,8 +1673,9 @@ bool RecordCommand::DumpAdditionalFeatures(const std::vector<std::string>& args)
// Read data section of perf.data to collect hit file information.
thread_tree_.ClearThreadAndMap();
bool kernel_symbols_available = false;
- if (CheckKernelSymbolAddresses()) {
- Dso::ReadKernelSymbolsFromProc();
+ std::string kallsyms;
+ if (LoadKernelSymbols(&kallsyms)) {
+ Dso::SetKallsyms(kallsyms);
kernel_symbols_available = true;
}
std::unordered_set<int> loaded_symbol_maps;