summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_report.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-03-31 14:39:19 -0700
committerYabin Cui <yabinc@google.com>2016-04-01 10:54:47 -0700
commit4b6720d137c15b9485318255e89ffcd3c76ab579 (patch)
tree4c624d63da960690396c0c9e8d03d9fb84d96443 /simpleperf/cmd_report.cpp
parenteaa9c1dc0c2c7bd4570e0b7c605bac207e6ab3a3 (diff)
downloadextras-4b6720d137c15b9485318255e89ffcd3c76ab579.tar.gz
simpleperf: loosen unwinding arch check for system wide collection.
When doing system wide collection, it is possible that there are 32-bit compat processes running on 64-bit devices. It is not proper to abort in this situation. So loosen the check to allow it. Also add corresponding test. Bug: 27927427 Change-Id: I5c9253eb6e474497e4f37e234e0e523e141fab20
Diffstat (limited to 'simpleperf/cmd_report.cpp')
-rw-r--r--simpleperf/cmd_report.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/simpleperf/cmd_report.cpp b/simpleperf/cmd_report.cpp
index d42bf694..b9c3d6f7 100644
--- a/simpleperf/cmd_report.cpp
+++ b/simpleperf/cmd_report.cpp
@@ -272,6 +272,7 @@ class ReportCommand : public Command {
record_filename_("perf.data"),
record_file_arch_(GetBuildArch()),
use_branch_address_(false),
+ system_wide_collection_(false),
accumulate_callchain_(false),
print_callgraph_(false),
callgraph_show_callee_(true),
@@ -312,6 +313,7 @@ class ReportCommand : public Command {
std::unique_ptr<SampleTree> sample_tree_;
bool use_branch_address_;
std::string record_cmdline_;
+ bool system_wide_collection_;
bool accumulate_callchain_;
bool print_callgraph_;
bool callgraph_show_callee_;
@@ -569,8 +571,11 @@ void ReportCommand::ProcessSampleRecord(const SampleRecord& r) {
std::vector<char> stack(r.stack_user_data.data.begin(),
r.stack_user_data.data.begin() + r.stack_user_data.data.size());
ArchType arch = GetArchForAbi(ScopedCurrentArch::GetCurrentArch(), r.regs_user_data.abi);
+ // Normally do strict arch check when unwinding stack. But allow unwinding 32-bit processes
+ // on 64-bit devices for system wide profiling.
+ bool strict_arch_check = !system_wide_collection_;
std::vector<uint64_t> unwind_ips =
- UnwindCallChain(arch, *sample->thread, regs, stack);
+ UnwindCallChain(arch, *sample->thread, regs, stack, strict_arch_check);
if (!unwind_ips.empty()) {
ips.push_back(PERF_CONTEXT_USER);
ips.insert(ips.end(), unwind_ips.begin(), unwind_ips.end());
@@ -647,6 +652,20 @@ bool ReportCommand::ReadFeaturesFromRecordFile() {
std::vector<std::string> cmdline = record_file_reader_->ReadCmdlineFeature();
if (!cmdline.empty()) {
record_cmdline_ = android::base::Join(cmdline, ' ');
+ // TODO: the code to detect system wide collection option is fragile, remove it once we can
+ // do cross unwinding.
+ for (size_t i = 0; i < cmdline.size(); i++) {
+ std::string& s = cmdline[i];
+ if (s == "-a") {
+ system_wide_collection_ = true;
+ break;
+ } else if (s == "--call-graph" || s == "--cpu" || s == "-e" || s == "-f" || s == "-F" ||
+ s == "-j" || s == "-m" || s == "-o" || s == "-p" || s == "-t") {
+ i++;
+ } else if (!s.empty() && s[0] != '-') {
+ break;
+ }
+ }
}
return true;
}