mirror of
https://gitee.com/openharmony/developtools_hiperf
synced 2024-11-27 01:30:28 +00:00
!217 hiperf支持user模式非root模式->不支持-a参数和采集调用栈不包含kernel符号
Merge pull request !217 from 孙帅元/master
This commit is contained in:
commit
e0f2ac90fa
@ -146,6 +146,11 @@ bool SubCommandRecord::GetOptions(std::vector<std::string> &args)
|
||||
if (!Option::GetOptionValue(args, "-a", targetSystemWide_)) {
|
||||
return false;
|
||||
}
|
||||
if (targetSystemWide_ && !IsRoot()) {
|
||||
HLOGD("-a option needs root privilege for system wide profiling.");
|
||||
printf("-a option needs root privilege for system wide profiling.\n");
|
||||
return false;
|
||||
}
|
||||
if (!Option::GetOptionValue(args, "--exclude-hiperf", excludeHiperf_)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -58,6 +58,11 @@ bool SubCommandStat::ParseOption(std::vector<std::string> &args)
|
||||
HLOGD("get option -a failed");
|
||||
return false;
|
||||
}
|
||||
if (targetSystemWide_ && !IsRoot()) {
|
||||
HLOGD("-a option needs root privilege for system wide profiling.");
|
||||
printf("-a option needs root privilege for system wide profiling.\n");
|
||||
return false;
|
||||
}
|
||||
if (!Option::GetOptionValue(args, "-c", selectCpus_)) {
|
||||
HLOGD("get option -c failed");
|
||||
return false;
|
||||
|
@ -952,6 +952,11 @@ public:
|
||||
bool hasChangeKptr = false;
|
||||
std::string oldKptrRestrict = ReadFileToString(KPTR_RESTRICT);
|
||||
if (oldKptrRestrict.front() != '0') {
|
||||
if (!IsRoot()) {
|
||||
HLOGD("user mode do not load kernel syms");
|
||||
printf("Hiperf is not running as root mode. Do not need load kernel syms\n");
|
||||
return false;
|
||||
}
|
||||
printf("/proc/sys/kernel/kptr_restrict is NOT 0, will try set it to 0.\n");
|
||||
hasChangeKptr = WriteStringToFile(KPTR_RESTRICT, "0");
|
||||
if (!hasChangeKptr) {
|
||||
@ -999,7 +1004,9 @@ public:
|
||||
if (onRecording_) {
|
||||
const auto startTime = std::chrono::steady_clock::now();
|
||||
if (!LoadKernelSyms()) {
|
||||
printf("parse kalsyms failed.\n");
|
||||
if (IsRoot()) {
|
||||
printf("parse kalsyms failed.\n");
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
const auto thisTime = std::chrono::steady_clock::now();
|
||||
|
Loading…
Reference in New Issue
Block a user