| Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2012 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | #ifndef __CUTILS_DEBUGGER_H | 
|  | 18 | #define __CUTILS_DEBUGGER_H | 
|  | 19 |  | 
| Christopher Ferris | 9774df6 | 2015-01-15 14:47:36 -0800 | [diff] [blame] | 20 | #include <sys/cdefs.h> | 
| Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 21 | #include <sys/types.h> | 
|  | 22 |  | 
| Christopher Ferris | 9774df6 | 2015-01-15 14:47:36 -0800 | [diff] [blame] | 23 | __BEGIN_DECLS | 
| Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 24 |  | 
| Christopher Ferris | 9774df6 | 2015-01-15 14:47:36 -0800 | [diff] [blame] | 25 | #define DEBUGGER_SOCKET_NAME "android:debuggerd" | 
|  | 26 | #define DEBUGGER32_SOCKET_NAME "android:debuggerd32" | 
|  | 27 | #define DEBUGGER64_SOCKET_NAME DEBUGGER_SOCKET_NAME | 
| Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 28 |  | 
|  | 29 | typedef enum { | 
|  | 30 | // dump a crash | 
|  | 31 | DEBUGGER_ACTION_CRASH, | 
|  | 32 | // dump a tombstone file | 
|  | 33 | DEBUGGER_ACTION_DUMP_TOMBSTONE, | 
|  | 34 | // dump a backtrace only back to the socket | 
|  | 35 | DEBUGGER_ACTION_DUMP_BACKTRACE, | 
|  | 36 | } debugger_action_t; | 
|  | 37 |  | 
| Christopher Ferris | 9774df6 | 2015-01-15 14:47:36 -0800 | [diff] [blame] | 38 | // Make sure that all values have a fixed size so that this structure | 
|  | 39 | // is the same for 32 bit and 64 bit processes. | 
|  | 40 | // NOTE: Any changes to this structure must also be reflected in | 
|  | 41 | //       bionic/linker/debugger.cpp. | 
|  | 42 | typedef struct __attribute__((packed)) { | 
|  | 43 | int32_t action; | 
| Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 44 | pid_t tid; | 
| Christopher Ferris | 9774df6 | 2015-01-15 14:47:36 -0800 | [diff] [blame] | 45 | uint64_t abort_msg_address; | 
| Elliott Hughes | 855fcc3 | 2014-04-25 16:05:34 -0700 | [diff] [blame] | 46 | int32_t original_si_code; | 
| Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 47 | } debugger_msg_t; | 
|  | 48 |  | 
| Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 49 | /* Dumps a process backtrace, registers, and stack to a tombstone file (requires root). | 
|  | 50 | * Stores the tombstone path in the provided buffer. | 
|  | 51 | * Returns 0 on success, -1 on error. | 
|  | 52 | */ | 
|  | 53 | int dump_tombstone(pid_t tid, char* pathbuf, size_t pathlen); | 
|  | 54 |  | 
| Christopher Ferris | fa41e0f | 2015-01-13 19:07:12 -0800 | [diff] [blame] | 55 | /* Dumps a process backtrace, registers, and stack to a tombstone file (requires root). | 
|  | 56 | * Stores the tombstone path in the provided buffer. | 
|  | 57 | * If reading debugger data from debuggerd ever takes longer than timeout_secs | 
|  | 58 | * seconds, then stop and return an error. | 
|  | 59 | * Returns 0 on success, -1 on error. | 
|  | 60 | */ | 
|  | 61 | int dump_tombstone_timeout(pid_t tid, char* pathbuf, size_t pathlen, int timeout_secs); | 
|  | 62 |  | 
| Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 63 | /* Dumps a process backtrace only to the specified file (requires root). | 
|  | 64 | * Returns 0 on success, -1 on error. | 
|  | 65 | */ | 
|  | 66 | int dump_backtrace_to_file(pid_t tid, int fd); | 
|  | 67 |  | 
| Christopher Ferris | fa41e0f | 2015-01-13 19:07:12 -0800 | [diff] [blame] | 68 | /* Dumps a process backtrace only to the specified file (requires root). | 
|  | 69 | * If reading debugger data from debuggerd ever takes longer than timeout_secs | 
|  | 70 | * seconds, then stop and return an error. | 
|  | 71 | * Returns 0 on success, -1 on error. | 
|  | 72 | */ | 
|  | 73 | int dump_backtrace_to_file_timeout(pid_t tid, int fd, int timeout_secs); | 
|  | 74 |  | 
| Christopher Ferris | 9774df6 | 2015-01-15 14:47:36 -0800 | [diff] [blame] | 75 | __END_DECLS | 
| Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 76 |  | 
|  | 77 | #endif /* __CUTILS_DEBUGGER_H */ |