| 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 |  | 
|  | 20 | #include <sys/types.h> | 
|  | 21 |  | 
|  | 22 | #ifdef __cplusplus | 
|  | 23 | extern "C" { | 
|  | 24 | #endif | 
|  | 25 |  | 
| Elliott Hughes | e9edf7a | 2014-01-31 17:15:10 -0800 | [diff] [blame] | 26 | #if __LP64__ | 
|  | 27 | #define DEBUGGER_SOCKET_NAME "android:debuggerd64" | 
|  | 28 | #else | 
| Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 29 | #define DEBUGGER_SOCKET_NAME "android:debuggerd" | 
| Elliott Hughes | e9edf7a | 2014-01-31 17:15:10 -0800 | [diff] [blame] | 30 | #endif | 
| Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 31 |  | 
|  | 32 | typedef enum { | 
|  | 33 | // dump a crash | 
|  | 34 | DEBUGGER_ACTION_CRASH, | 
|  | 35 | // dump a tombstone file | 
|  | 36 | DEBUGGER_ACTION_DUMP_TOMBSTONE, | 
|  | 37 | // dump a backtrace only back to the socket | 
|  | 38 | DEBUGGER_ACTION_DUMP_BACKTRACE, | 
|  | 39 | } debugger_action_t; | 
|  | 40 |  | 
| Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 41 | typedef struct { | 
|  | 42 | debugger_action_t action; | 
|  | 43 | pid_t tid; | 
| Elliott Hughes | 707b8bb | 2013-04-04 13:52:01 -0700 | [diff] [blame] | 44 | uintptr_t abort_msg_address; | 
| Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 45 | } debugger_msg_t; | 
|  | 46 |  | 
|  | 47 | /* Dumps a process backtrace, registers, and stack to a tombstone file (requires root). | 
|  | 48 | * Stores the tombstone path in the provided buffer. | 
|  | 49 | * Returns 0 on success, -1 on error. | 
|  | 50 | */ | 
|  | 51 | int dump_tombstone(pid_t tid, char* pathbuf, size_t pathlen); | 
|  | 52 |  | 
|  | 53 | /* Dumps a process backtrace only to the specified file (requires root). | 
|  | 54 | * Returns 0 on success, -1 on error. | 
|  | 55 | */ | 
|  | 56 | int dump_backtrace_to_file(pid_t tid, int fd); | 
|  | 57 |  | 
|  | 58 | #ifdef __cplusplus | 
|  | 59 | } | 
|  | 60 | #endif | 
|  | 61 |  | 
|  | 62 | #endif /* __CUTILS_DEBUGGER_H */ |