diff options
author | Narayan Kamath <narayan@google.com> | 2017-05-24 15:07:25 +0100 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2017-05-31 10:35:32 +0100 |
commit | a73df601b7fe192001f4b9b5ddeb17b8efe3981b (patch) | |
tree | 268e9df211bc6e81391f8e121e9ccde25c70b26c /debuggerd/debuggerd_test.cpp | |
parent | 844940d751be6cf6078c9e816fc09356034c1b26 (diff) |
tombstoned: allow intercepts for java traces.
All intercept requests and crash dump requests must now specify a
dump_type, which can be one of kDebuggerdNativeBacktrace,
kDebuggerdTombstone or kDebuggerdJavaBacktrace. Each process can have
only one outstanding intercept registered at a time.
There's only one non-trivial change in this changeset; and that is
to crash_dump. We now pass the type of dump via a command line
argument instead of inferring it from the (resent) signal, this allows
us to connect to tombstoned before we wait for the signal as the
protocol requires.
Test: debuggerd_test
Change-Id: I189b215acfecd08ac52ab29117e3465da00e3a37
Diffstat (limited to 'debuggerd/debuggerd_test.cpp')
-rw-r--r-- | debuggerd/debuggerd_test.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp index f17724a40..8c00b76a0 100644 --- a/debuggerd/debuggerd_test.cpp +++ b/debuggerd/debuggerd_test.cpp @@ -88,14 +88,15 @@ constexpr char kWaitForGdbKey[] = "debug.debuggerd.wait_for_gdb"; } \ } while (0) -static void tombstoned_intercept(pid_t target_pid, unique_fd* intercept_fd, unique_fd* output_fd) { +static void tombstoned_intercept(pid_t target_pid, unique_fd* intercept_fd, unique_fd* output_fd, + DebuggerdDumpType intercept_type) { intercept_fd->reset(socket_local_client(kTombstonedInterceptSocketName, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_SEQPACKET)); if (intercept_fd->get() == -1) { FAIL() << "failed to contact tombstoned: " << strerror(errno); } - InterceptRequest req = {.pid = target_pid}; + InterceptRequest req = {.pid = target_pid, .dump_type = intercept_type}; unique_fd output_pipe_write; if (!Pipe(output_fd, &output_pipe_write)) { @@ -146,7 +147,7 @@ class CrasherTest : public ::testing::Test { CrasherTest(); ~CrasherTest(); - void StartIntercept(unique_fd* output_fd); + void StartIntercept(unique_fd* output_fd, DebuggerdDumpType intercept_type = kDebuggerdTombstone); // Returns -1 if we fail to read a response from tombstoned, otherwise the received return code. void FinishIntercept(int* result); @@ -172,12 +173,12 @@ CrasherTest::~CrasherTest() { android::base::SetProperty(kWaitForGdbKey, previous_wait_for_gdb ? "1" : "0"); } -void CrasherTest::StartIntercept(unique_fd* output_fd) { +void CrasherTest::StartIntercept(unique_fd* output_fd, DebuggerdDumpType intercept_type) { if (crasher_pid == -1) { FAIL() << "crasher hasn't been started"; } - tombstoned_intercept(crasher_pid, &this->intercept_fd, output_fd); + tombstoned_intercept(crasher_pid, &this->intercept_fd, output_fd, intercept_type); } void CrasherTest::FinishIntercept(int* result) { @@ -428,7 +429,7 @@ TEST_F(CrasherTest, backtrace) { StartProcess([]() { abort(); }); - StartIntercept(&output_fd); + StartIntercept(&output_fd, kDebuggerdNativeBacktrace); std::this_thread::sleep_for(500ms); @@ -595,11 +596,11 @@ TEST(tombstoned, no_notify) { pid_t pid = 123'456'789 + i; unique_fd intercept_fd, output_fd; - tombstoned_intercept(pid, &intercept_fd, &output_fd); + tombstoned_intercept(pid, &intercept_fd, &output_fd, kDebuggerdTombstone); { unique_fd tombstoned_socket, input_fd; - ASSERT_TRUE(tombstoned_connect(pid, &tombstoned_socket, &input_fd)); + ASSERT_TRUE(tombstoned_connect(pid, &tombstoned_socket, &input_fd, kDebuggerdTombstone)); ASSERT_TRUE(android::base::WriteFully(input_fd.get(), &pid, sizeof(pid))); } @@ -627,7 +628,7 @@ TEST(tombstoned, stress) { pid_t pid = pid_base + dump; unique_fd intercept_fd, output_fd; - tombstoned_intercept(pid, &intercept_fd, &output_fd); + tombstoned_intercept(pid, &intercept_fd, &output_fd, kDebuggerdTombstone); // Pretend to crash, and then immediately close the socket. unique_fd sockfd(socket_local_client(kTombstonedCrashSocketName, @@ -658,11 +659,11 @@ TEST(tombstoned, stress) { pid_t pid = pid_base + dump; unique_fd intercept_fd, output_fd; - tombstoned_intercept(pid, &intercept_fd, &output_fd); + tombstoned_intercept(pid, &intercept_fd, &output_fd, kDebuggerdTombstone); { unique_fd tombstoned_socket, input_fd; - ASSERT_TRUE(tombstoned_connect(pid, &tombstoned_socket, &input_fd)); + ASSERT_TRUE(tombstoned_connect(pid, &tombstoned_socket, &input_fd, kDebuggerdTombstone)); ASSERT_TRUE(android::base::WriteFully(input_fd.get(), &pid, sizeof(pid))); tombstoned_notify_completion(tombstoned_socket.get()); } |