diff options
author | Narayan Kamath | 2017-05-24 09:07:25 -0500 |
---|---|---|
committer | Narayan Kamath | 2017-05-31 04:35:32 -0500 |
commit | a73df601b7fe192001f4b9b5ddeb17b8efe3981b (patch) | |
tree | 268e9df211bc6e81391f8e121e9ccde25c70b26c /debuggerd/crash_dump.cpp | |
parent | 844940d751be6cf6078c9e816fc09356034c1b26 (diff) | |
download | platform-system-core-a73df601b7fe192001f4b9b5ddeb17b8efe3981b.tar.gz platform-system-core-a73df601b7fe192001f4b9b5ddeb17b8efe3981b.tar.xz platform-system-core-a73df601b7fe192001f4b9b5ddeb17b8efe3981b.zip |
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/crash_dump.cpp')
-rw-r--r-- | debuggerd/crash_dump.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp index be2807914..cc7824219 100644 --- a/debuggerd/crash_dump.cpp +++ b/debuggerd/crash_dump.cpp | |||
@@ -150,13 +150,13 @@ static void signal_handler(int) { | |||
150 | _exit(1); | 150 | _exit(1); |
151 | } | 151 | } |
152 | 152 | ||
153 | static void abort_handler(pid_t target, const bool& tombstoned_connected, | 153 | static void abort_handler(pid_t target, const bool tombstoned_connected, |
154 | unique_fd& tombstoned_socket, unique_fd& output_fd, | 154 | unique_fd& tombstoned_socket, unique_fd& output_fd, |
155 | const char* abort_msg) { | 155 | const char* abort_msg) { |
156 | // If we abort before we get an output fd, contact tombstoned to let any | 156 | // If we abort before we get an output fd, contact tombstoned to let any |
157 | // potential listeners know that we failed. | 157 | // potential listeners know that we failed. |
158 | if (!tombstoned_connected) { | 158 | if (!tombstoned_connected) { |
159 | if (!tombstoned_connect(target, &tombstoned_socket, &output_fd)) { | 159 | if (!tombstoned_connect(target, &tombstoned_socket, &output_fd, kDebuggerdAnyIntercept)) { |
160 | // We failed to connect, not much we can do. | 160 | // We failed to connect, not much we can do. |
161 | LOG(ERROR) << "failed to connected to tombstoned to report failure"; | 161 | LOG(ERROR) << "failed to connected to tombstoned to report failure"; |
162 | _exit(1); | 162 | _exit(1); |
@@ -207,12 +207,14 @@ int main(int argc, char** argv) { | |||
207 | action.sa_handler = signal_handler; | 207 | action.sa_handler = signal_handler; |
208 | debuggerd_register_handlers(&action); | 208 | debuggerd_register_handlers(&action); |
209 | 209 | ||
210 | if (argc != 3) { | 210 | if (argc != 4) { |
211 | LOG(FATAL) << "Wrong number of args: " << argc << " (expected 4)"; | ||
211 | return 1; | 212 | return 1; |
212 | } | 213 | } |
213 | 214 | ||
214 | pid_t main_tid; | 215 | pid_t main_tid; |
215 | pid_t pseudothread_tid; | 216 | pid_t pseudothread_tid; |
217 | int dump_type; | ||
216 | 218 | ||
217 | if (!android::base::ParseInt(argv[1], &main_tid, 1, std::numeric_limits<pid_t>::max())) { | 219 | if (!android::base::ParseInt(argv[1], &main_tid, 1, std::numeric_limits<pid_t>::max())) { |
218 | LOG(FATAL) << "invalid main tid: " << argv[1]; | 220 | LOG(FATAL) << "invalid main tid: " << argv[1]; |
@@ -222,6 +224,10 @@ int main(int argc, char** argv) { | |||
222 | LOG(FATAL) << "invalid pseudothread tid: " << argv[2]; | 224 | LOG(FATAL) << "invalid pseudothread tid: " << argv[2]; |
223 | } | 225 | } |
224 | 226 | ||
227 | if (!android::base::ParseInt(argv[3], &dump_type, 0, 1)) { | ||
228 | LOG(FATAL) << "invalid requested dump type: " << argv[3]; | ||
229 | } | ||
230 | |||
225 | if (target == 1) { | 231 | if (target == 1) { |
226 | LOG(FATAL) << "target died before we could attach (received main tid = " << main_tid << ")"; | 232 | LOG(FATAL) << "target died before we could attach (received main tid = " << main_tid << ")"; |
227 | } | 233 | } |
@@ -305,8 +311,9 @@ int main(int argc, char** argv) { | |||
305 | // Drop our capabilities now that we've attached to the threads we care about. | 311 | // Drop our capabilities now that we've attached to the threads we care about. |
306 | drop_capabilities(); | 312 | drop_capabilities(); |
307 | 313 | ||
308 | LOG(INFO) << "obtaining output fd from tombstoned"; | 314 | const DebuggerdDumpType dump_type_enum = static_cast<DebuggerdDumpType>(dump_type); |
309 | tombstoned_connected = tombstoned_connect(target, &tombstoned_socket, &output_fd); | 315 | LOG(INFO) << "obtaining output fd from tombstoned, type: " << dump_type_enum; |
316 | tombstoned_connected = tombstoned_connect(target, &tombstoned_socket, &output_fd, dump_type_enum); | ||
310 | 317 | ||
311 | // Write a '\1' to stdout to tell the crashing process to resume. | 318 | // Write a '\1' to stdout to tell the crashing process to resume. |
312 | // It also restores the value of PR_SET_DUMPABLE at this point. | 319 | // It also restores the value of PR_SET_DUMPABLE at this point. |