system/corennnnn
Revisão | e6784dcee14eaa54bafb49a6e495b670827076b8 (tree) |
---|---|
Hora | 2016-09-02 02:58:54 |
Autor | Linux Build Service Account <lnxbuild@loca...> |
Commiter | Linux Build Service Account |
Promotion of android-framework.lnx.2.0-00005.
CRs Change ID Subject
1054828 I754f912c409fdf29f427b11763927405fbf877b4 debuggerd: Set timeout on native proc trace collection
Change-Id: I4f77ff306772f0a614cd6325a557d17deac81de2
CRs-Fixed: 1054828
@@ -671,7 +671,8 @@ static void worker_process(int fd, debugger_request_t& request) { | ||
671 | 671 | } |
672 | 672 | |
673 | 673 | static void monitor_worker_process(int child_pid, const debugger_request_t& request) { |
674 | - struct timespec timeout = {.tv_sec = 10, .tv_nsec = 0 }; | |
674 | + // set the timeout to 3 sec, for trace collection | |
675 | + struct timespec timeout = {.tv_sec = 3, .tv_nsec = 0 }; | |
675 | 676 | if (should_attach_gdb(request)) { |
676 | 677 | // If wait_for_gdb is enabled, set the timeout to something large. |
677 | 678 | timeout.tv_sec = INT_MAX; |
@@ -76,7 +76,9 @@ static int make_dump_request(debugger_action_t action, pid_t tid, int timeout_se | ||
76 | 76 | } |
77 | 77 | |
78 | 78 | int dump_backtrace_to_file(pid_t tid, int fd) { |
79 | - return dump_backtrace_to_file_timeout(tid, fd, 0); | |
79 | + // Kind of a hack; | |
80 | + // Use a timeout of 5 seconds for a given native proc | |
81 | + return dump_backtrace_to_file_timeout(tid, fd, 5); | |
80 | 82 | } |
81 | 83 | |
82 | 84 | int dump_backtrace_to_file_timeout(pid_t tid, int fd, int timeout_secs) { |
@@ -89,13 +91,23 @@ int dump_backtrace_to_file_timeout(pid_t tid, int fd, int timeout_secs) { | ||
89 | 91 | int result = 0; |
90 | 92 | char buffer[1024]; |
91 | 93 | ssize_t n; |
94 | + int flag = 0; | |
95 | + | |
92 | 96 | while ((n = TEMP_FAILURE_RETRY(read(sock_fd, buffer, sizeof(buffer)))) > 0) { |
97 | + flag = 1; | |
93 | 98 | if (TEMP_FAILURE_RETRY(write(fd, buffer, n)) != n) { |
94 | 99 | result = -1; |
95 | 100 | break; |
96 | 101 | } |
97 | 102 | } |
98 | 103 | close(sock_fd); |
104 | + | |
105 | + if (flag == 0) { | |
106 | + ALOGE("Not even a single byte was read from debuggerd, for pid: %d", tid); | |
107 | + } | |
108 | + if (result == -1) { | |
109 | + ALOGE("Failure(probably timeout) while reading data from debuggerd, for pid: %d", tid); | |
110 | + } | |
99 | 111 | return result; |
100 | 112 | } |
101 | 113 |