• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/cdefs.h>
21 #include <sys/types.h>
22 
23 __BEGIN_DECLS
24 
25 #define DEBUGGER_SOCKET_NAME "android:debuggerd"
26 #define DEBUGGER32_SOCKET_NAME "android:debuggerd32"
27 #define DEBUGGER64_SOCKET_NAME DEBUGGER_SOCKET_NAME
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 
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;
44     pid_t tid;
45     uint64_t abort_msg_address;
46     int32_t original_si_code;
47 } debugger_msg_t;
48 
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 
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 
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 
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 
75 __END_DECLS
76 
77 #endif /* __CUTILS_DEBUGGER_H */
78