summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2017-08-08 23:30:21 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-08-08 23:30:21 +0000
commitd51b8490692c460f3ce21d0157389b2066c94e01 (patch)
tree78a824b48d892885f75de9cf1a081d897f9ed6ff
parentf9ed7b5507b4355021acc22adc14451e2e2d63ef (diff)
parent6d087d5dc5f301516f51f94832ba093ba2f01129 (diff)
downloadextras-d51b8490692c460f3ce21d0157389b2066c94e01.tar.gz
Merge "simpleperf: add --exit-with-parent option in record cmd."
-rw-r--r--simpleperf/cmd_record.cpp6
-rw-r--r--simpleperf/cmd_record_test.cpp4
2 files changed, 8 insertions, 2 deletions
diff --git a/simpleperf/cmd_record.cpp b/simpleperf/cmd_record.cpp
index 487e2199..6b2be764 100644
--- a/simpleperf/cmd_record.cpp
+++ b/simpleperf/cmd_record.cpp
@@ -155,6 +155,8 @@ class RecordCommand : public Command {
" will be unwound while recording by default. But it may lose\n"
" records as stacking unwinding can be time consuming. Use this\n"
" option to unwind the user's stack after recording.\n"
+"--exit-with-parent Stop recording when the process starting\n"
+" simpleperf dies.\n"
"--start_profiling_fd fd_no After starting profiling, write \"STARTED\" to\n"
" <fd_no>, then close <fd_no>.\n"
"--symfs <dir> Look for files with symbols relative to this directory.\n"
@@ -188,8 +190,6 @@ class RecordCommand : public Command {
in_app_context_(false),
trace_offcpu_(false),
exclude_kernel_callchain_(false) {
- // Stop profiling if parent exits.
- prctl(PR_SET_PDEATHSIG, SIGHUP, 0, 0, 0);
// If we run `adb shell simpleperf record xxx` and stop profiling by ctrl-c, adb closes
// sockets connecting simpleperf. After that, simpleperf will receive SIGPIPE when writing
// to stdout/stderr, which is a problem when we use '--app' option. So ignore SIGPIPE to
@@ -525,6 +525,8 @@ bool RecordCommand::ParseOptions(const std::vector<std::string>& args,
wait_setting_speed_event_groups_.push_back(group_id);
}
}
+ } else if (args[i] == "--exit-with-parent") {
+ prctl(PR_SET_PDEATHSIG, SIGHUP, 0, 0, 0);
} else if (args[i] == "-g") {
fp_callchain_sampling_ = false;
dwarf_callchain_sampling_ = true;
diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp
index 48732302..56e1b225 100644
--- a/simpleperf/cmd_record_test.cpp
+++ b/simpleperf/cmd_record_test.cpp
@@ -486,3 +486,7 @@ TEST(record_cmd, trace_offcpu_option) {
ASSERT_EQ(info_map["trace_offcpu"], "true");
CheckEventType(tmpfile.path, "sched:sched_switch", 1u, 0u);
}
+
+TEST(record_cmd, exit_with_parent_option) {
+ ASSERT_TRUE(RunRecordCmd({"--exit-with-parent"}));
+}