Skip to content

Commit eac5440

Browse files
yabincGerrit Code Review
authored and
Gerrit Code Review
committed
Merge "Simpleperf: warn if it can't read kernel symbols addresses."
2 parents 482fe9e + 8a52e97 commit eac5440

File tree

6 files changed

+24
-13
lines changed

6 files changed

+24
-13
lines changed

simpleperf/cmd_help.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void HelpCommand::PrintShortHelp() {
6060
"common options:\n"
6161
" -h/--help Print this help information.\n"
6262
" --log <severity> Set the minimum severity of logging. Possible severities\n"
63-
" include debug, warning, error, fatal. Default is error.\n"
63+
" include debug, warning, error, fatal. Default is warning.\n"
6464
"subcommands:\n");
6565
for (auto& cmd_name : GetAllCommandNames()) {
6666
std::unique_ptr<Command> cmd = CreateCommandInstance(cmd_name);

simpleperf/darwin_support/darwin_support.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
#include "dwarf_unwind.h"
2121
#include "environment.h"
2222

23-
std::vector<uint64_t> UnwindCallChain(const ThreadEntry&, const RegSet&,
24-
const std::vector<char>&) {
23+
std::vector<uint64_t> UnwindCallChain(const ThreadEntry&, const RegSet&, const std::vector<char>&) {
2524
return std::vector<uint64_t>();
2625
}
2726

simpleperf/dso.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ struct SymbolComparator {
150150
}
151151
};
152152

153-
154153
std::string Dso::GetAccessiblePath() const {
155154
return symfs_dir_ + path_;
156155
}
@@ -228,8 +227,22 @@ bool Dso::LoadKernel() {
228227
return false;
229228
}
230229
}
230+
231231
ProcessKernelSymbols("/proc/kallsyms",
232232
std::bind(&KernelSymbolCallback, std::placeholders::_1, this));
233+
bool allZero = true;
234+
for (auto& symbol : symbols_) {
235+
if (symbol.addr != 0) {
236+
allZero = false;
237+
break;
238+
}
239+
}
240+
if (allZero) {
241+
LOG(WARNING) << "Symbol addresses in /proc/kallsyms are all zero. Check "
242+
"/proc/sys/kernel/kptr_restrict if possible.";
243+
symbols_.clear();
244+
return false;
245+
}
233246
}
234247
return true;
235248
}

simpleperf/dwarf_unwind.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323

2424
#include "thread_tree.h"
2525

26-
#define SetUContextReg(dst, perf_regno) \
27-
do { \
28-
uint64_t value; \
26+
#define SetUContextReg(dst, perf_regno) \
27+
do { \
28+
uint64_t value; \
2929
if (GetRegValue(regs, perf_regno, &value)) { \
30-
dst = value; \
31-
} \
30+
dst = value; \
31+
} \
3232
} while (0)
3333

3434
static ucontext_t BuildUContextFromRegs(const RegSet& regs __attribute__((unused))) {
@@ -94,8 +94,7 @@ static ucontext_t BuildUContextFromRegs(const RegSet& regs __attribute__((unused
9494
return ucontext;
9595
}
9696

97-
std::vector<uint64_t> UnwindCallChain(const ThreadEntry& thread,
98-
const RegSet& regs,
97+
std::vector<uint64_t> UnwindCallChain(const ThreadEntry& thread, const RegSet& regs,
9998
const std::vector<char>& stack) {
10099
std::vector<uint64_t> result;
101100
if (GetCurrentArch() != GetBuildArch()) {

simpleperf/dwarf_unwind.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
struct ThreadEntry;
2525

2626
std::vector<uint64_t> UnwindCallChain(const ThreadEntry& thread, const RegSet& regs,
27-
const std::vector<char>& stack);
27+
const std::vector<char>& stack);
2828

2929
#endif // SIMPLE_PERF_DWARF_UNWIND_H_

simpleperf/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static std::map<std::string, android::base::LogSeverity> log_severity_map = {
3333
int main(int argc, char** argv) {
3434
InitLogging(argv, android::base::StderrLogger);
3535
std::vector<std::string> args;
36-
android::base::LogSeverity log_severity = android::base::ERROR;
36+
android::base::LogSeverity log_severity = android::base::WARNING;
3737

3838
if (argc == 1) {
3939
args.push_back("help");

0 commit comments

Comments
 (0)