summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Gao2017-08-21 16:31:17 -0500
committerJosh Gao2017-12-15 16:11:12 -0600
commit2b2ae0c88ef83c4c53297ff54fa601b18c014fa4 (patch)
tree832d3ab764da9a63d4e22001f18045fa13078dd5 /debuggerd/util.cpp
parent385ea22741ed5bad794fb6b1dff2b46481f241c4 (diff)
downloadplatform-system-core-2b2ae0c88ef83c4c53297ff54fa601b18c014fa4.tar.gz
platform-system-core-2b2ae0c88ef83c4c53297ff54fa601b18c014fa4.tar.xz
platform-system-core-2b2ae0c88ef83c4c53297ff54fa601b18c014fa4.zip
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/util.cpp')
-rw-r--r--debuggerd/util.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/debuggerd/util.cpp b/debuggerd/util.cpp
index 0bb07ac1b..50c5efc99 100644
--- a/debuggerd/util.cpp
+++ b/debuggerd/util.cpp
@@ -18,8 +18,12 @@
18 18
19#include <sys/socket.h> 19#include <sys/socket.h>
20 20
21#include <string>
21#include <utility> 22#include <utility>
22 23
24#include <android-base/file.h>
25#include <android-base/stringprintf.h>
26#include <android-base/strings.h>
23#include <android-base/unique_fd.h> 27#include <android-base/unique_fd.h>
24#include <cutils/sockets.h> 28#include <cutils/sockets.h>
25#include "protocol.h" 29#include "protocol.h"
@@ -86,3 +90,15 @@ ssize_t recv_fd(int sockfd, void* _Nonnull data, size_t len, unique_fd* _Nullabl
86 90
87 return result; 91 return result;
88} 92}
93
94std::string get_process_name(pid_t pid) {
95 std::string result = "<unknown>";
96 android::base::ReadFileToString(android::base::StringPrintf("/proc/%d/cmdline", pid), &result);
97 return result;
98}
99
100std::string get_thread_name(pid_t tid) {
101 std::string result = "<unknown>";
102 android::base::ReadFileToString(android::base::StringPrintf("/proc/%d/comm", tid), &result);
103 return android::base::Trim(result);
104}