summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_record.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2018-04-24 14:44:48 -0700
committerYabin Cui <yabinc@google.com>2018-04-24 14:53:30 -0700
commitc160f2cf9b620b57ec3d1f2b8710e0feb8fbd81c (patch)
tree9e39aee550ecc65460d061c603a9e02335e0b46b /simpleperf/cmd_record.cpp
parent7aed4125be59e756f980bc4ba90350e32088770a (diff)
downloadextras-c160f2cf9b620b57ec3d1f2b8710e0feb8fbd81c.tar.gz
simpleperf: fix recording Java code with -p option.
When recording with both --app and -p option, simpleperf doesn't start JITDebugReader, thus can't profile JITed and interpreted Java code. This patch fixes it. Also change test.py to test it. Bug: none Test: run simpleperf_unit_test. Test: run test.py. Change-Id: Ib03fe689ad7c4ebbd69fd3c66a21f496dfdcf97f
Diffstat (limited to 'simpleperf/cmd_record.cpp')
-rw-r--r--simpleperf/cmd_record.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/simpleperf/cmd_record.cpp b/simpleperf/cmd_record.cpp
index 9e86965c..345cfd30 100644
--- a/simpleperf/cmd_record.cpp
+++ b/simpleperf/cmd_record.cpp
@@ -386,7 +386,6 @@ bool RecordCommand::PrepareRecording(Workload* workload) {
// 4. Add monitored targets.
bool need_to_check_targets = false;
- pid_t app_pid = 0;
if (system_wide_collection_) {
event_selection_set_.AddMonitoredThreads({-1});
} else if (!event_selection_set_.HasMonitoredTarget()) {
@@ -406,10 +405,6 @@ bool RecordCommand::PrepareRecording(Workload* workload) {
std::set<pid_t> pids = WaitForAppProcesses(app_package_name_);
event_selection_set_.AddMonitoredProcesses(pids);
need_to_check_targets = true;
- if (!pids.empty()) {
- // TODO: support a JITDebugReader for each app process?
- app_pid = *pids.begin();
- }
} else {
LOG(ERROR)
<< "No threads to monitor. Try `simpleperf help record` for help";
@@ -419,7 +414,16 @@ bool RecordCommand::PrepareRecording(Workload* workload) {
need_to_check_targets = true;
}
// Profiling JITed/interpreted Java code is supported starting from Android P.
- if (app_pid != 0 && GetAndroidVersion() >= kAndroidVersionP) {
+ if (!system_wide_collection_ && !app_package_name_.empty() &&
+ GetAndroidVersion() >= kAndroidVersionP) {
+ pid_t app_pid = 0;
+ // TODO: support a JITDebugReader for each app process?
+ if (!event_selection_set_.GetMonitoredProcesses().empty()) {
+ app_pid = *event_selection_set_.GetMonitoredProcesses().begin();
+ } else if (!event_selection_set_.GetMonitoredThreads().empty()) {
+ app_pid = *event_selection_set_.GetMonitoredThreads().begin();
+ }
+ CHECK_NE(app_pid, 0);
// JIT symfiles are stored in temporary files, and are deleted after recording. But if
// `-g --no-unwind` option is used, we want to keep symfiles to support unwinding in
// the debug-unwind cmd.