diff options
author | Josh Gao <jmgao@google.com> | 2017-08-21 14:31:17 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2017-12-15 14:11:12 -0800 |
commit | 2b2ae0c88ef83c4c53297ff54fa601b18c014fa4 (patch) | |
tree | 832d3ab764da9a63d4e22001f18045fa13078dd5 /debuggerd/debuggerd_test.cpp | |
parent | 385ea22741ed5bad794fb6b1dff2b46481f241c4 (diff) |
crash_dump: fork a copy of the target's address space.
Reduce the amount of time that a process remains paused by pausing its
threads, fetching their registers, and then performing unwinding on a
copy of its address space. This also works around a kernel change
that's in 4.9 that prevents ptrace from reading memory of processes
that we don't have immediate permissions to ptrace (even if we
previously ptraced them).
Bug: http://b/62112103
Bug: http://b/63989615
Test: treehugger
Change-Id: I7b9cc5dd8f54a354bc61f1bda0d2b7a8a55733c4
Diffstat (limited to 'debuggerd/debuggerd_test.cpp')
-rw-r--r-- | debuggerd/debuggerd_test.cpp | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp index 8d0c98bb0..0d17a3b5c 100644 --- a/debuggerd/debuggerd_test.cpp +++ b/debuggerd/debuggerd_test.cpp @@ -245,6 +245,8 @@ void CrasherTest::AssertDeath(int signo) { int status; pid_t pid = TIMEOUT(5, waitpid(crasher_pid, &status, 0)); if (pid != crasher_pid) { + printf("failed to wait for crasher (pid %d)\n", crasher_pid); + sleep(100); FAIL() << "failed to wait for crasher: " << strerror(errno); } @@ -341,13 +343,12 @@ TEST_F(CrasherTest, signal) { int intercept_result; unique_fd output_fd; StartProcess([]() { - abort(); + while (true) { + sleep(1); + } }); StartIntercept(&output_fd); - - // Wait for a bit, or we might end up killing the process before the signal - // handler even gets a chance to be registered. - std::this_thread::sleep_for(100ms); + FinishCrasher(); ASSERT_EQ(0, kill(crasher_pid, SIGSEGV)); AssertDeath(SIGSEGV); @@ -439,19 +440,6 @@ TEST_F(CrasherTest, wait_for_gdb) { AssertDeath(SIGABRT); } -// wait_for_gdb shouldn't trigger on manually sent signals. -TEST_F(CrasherTest, wait_for_gdb_signal) { - if (!android::base::SetProperty(kWaitForGdbKey, "1")) { - FAIL() << "failed to enable wait_for_gdb"; - } - - StartProcess([]() { - abort(); - }); - ASSERT_EQ(0, kill(crasher_pid, SIGSEGV)) << strerror(errno); - AssertDeath(SIGSEGV); -} - TEST_F(CrasherTest, backtrace) { std::string result; int intercept_result; @@ -596,15 +584,13 @@ TEST_F(CrasherTest, competing_tracer) { int intercept_result; unique_fd output_fd; StartProcess([]() { - while (true) { - } + raise(SIGABRT); }); StartIntercept(&output_fd); - FinishCrasher(); ASSERT_EQ(0, ptrace(PTRACE_SEIZE, crasher_pid, 0, 0)); - ASSERT_EQ(0, kill(crasher_pid, SIGABRT)); + FinishCrasher(); int status; ASSERT_EQ(crasher_pid, waitpid(crasher_pid, &status, 0)); @@ -622,6 +608,10 @@ TEST_F(CrasherTest, competing_tracer) { regex += R"( \(.+debuggerd_test)"; ASSERT_MATCH(result, regex.c_str()); + ASSERT_EQ(crasher_pid, waitpid(crasher_pid, &status, 0)); + ASSERT_TRUE(WIFSTOPPED(status)); + ASSERT_EQ(SIGABRT, WSTOPSIG(status)); + ASSERT_EQ(0, ptrace(PTRACE_DETACH, crasher_pid, 0, SIGABRT)); AssertDeath(SIGABRT); } |