diff options
| author | Josh Gao <jmgao@google.com> | 2019-01-04 13:57:09 -0800 |
|---|---|---|
| committer | Josh Gao <jmgao@google.com> | 2019-01-04 13:57:09 -0800 |
| commit | 4175cee3cc6feda91d0ffaa5301b2119089a24f6 (patch) | |
| tree | c20feee1fe9a2f3e9a27263632c1ac73a8639b7f /debuggerd | |
| parent | 79f304771c34819768c44dd5562024e5db5cd19e (diff) | |
| download | system_core-4175cee3cc6feda91d0ffaa5301b2119089a24f6.tar.gz system_core-4175cee3cc6feda91d0ffaa5301b2119089a24f6.tar.bz2 system_core-4175cee3cc6feda91d0ffaa5301b2119089a24f6.zip | |
debuggerd_client: resolve tid to tgid when dumping Java stacks.
Bug: http://b/121438213
Test: debuggerd_test32
Test: debuggerd_test64
Change-Id: I4d114c8b0c4586ba64de5b45b47b0ec5c10354f8
Diffstat (limited to 'debuggerd')
| -rw-r--r-- | debuggerd/Android.bp | 1 | ||||
| -rw-r--r-- | debuggerd/client/debuggerd_client.cpp | 17 |
2 files changed, 16 insertions, 2 deletions
diff --git a/debuggerd/Android.bp b/debuggerd/Android.bp index 516748176..10f52f45f 100644 --- a/debuggerd/Android.bp +++ b/debuggerd/Android.bp @@ -150,6 +150,7 @@ cc_library { shared_libs: [ "libbase", "libcutils", + "libprocinfo", ], export_header_lib_headers: ["libdebuggerd_common_headers"], diff --git a/debuggerd/client/debuggerd_client.cpp b/debuggerd/client/debuggerd_client.cpp index 77f3515a4..785df99c5 100644 --- a/debuggerd/client/debuggerd_client.cpp +++ b/debuggerd/client/debuggerd_client.cpp @@ -33,6 +33,7 @@ #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <cutils/sockets.h> +#include <procinfo/process.h> #include "debuggerd/handler.h" #include "protocol.h" @@ -62,8 +63,20 @@ static void populate_timeval(struct timeval* tv, const Duration& duration) { tv->tv_usec = static_cast<long>(microseconds.count()); } -bool debuggerd_trigger_dump(pid_t pid, DebuggerdDumpType dump_type, unsigned int timeout_ms, +bool debuggerd_trigger_dump(pid_t tid, DebuggerdDumpType dump_type, unsigned int timeout_ms, unique_fd output_fd) { + pid_t pid = tid; + if (dump_type == kDebuggerdJavaBacktrace) { + // Java dumps always get sent to the tgid, so we need to resolve our tid to a tgid. + android::procinfo::ProcessInfo procinfo; + std::string error; + if (!android::procinfo::GetProcessInfo(tid, &procinfo, &error)) { + LOG(ERROR) << "libdebugged_client: failed to get process info: " << error; + return -1; + } + pid = procinfo.pid; + } + LOG(INFO) << "libdebuggerd_client: started dumping process " << pid; unique_fd sockfd; const auto end = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeout_ms); @@ -162,7 +175,7 @@ bool debuggerd_trigger_dump(pid_t pid, DebuggerdDumpType dump_type, unsigned int return false; } - if (!send_signal(pid, dump_type)) { + if (!send_signal(tid, dump_type)) { return false; } |
