blob: f2e2d29590e5f338ce4127bc5ed5365782fc1c28 [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001/* system/debuggerd/utility.h
2**
3** Copyright 2008, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
Jeff Brown13e715b2011-10-21 12:14:56 -070018#ifndef _DEBUGGERD_UTILITY_H
19#define _DEBUGGERD_UTILITY_H
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080020
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080021#include <stdbool.h>
Pavel Chupinc6c194c2013-11-21 23:17:20 +040022#include <sys/types.h>
Jeff Brown053b8652012-06-06 16:25:03 -070023
Michael Wright80f59692014-06-20 16:19:58 -070024// Figure out the abi based on defined macros.
25#if defined(__arm__)
26#define ABI_STRING "arm"
27#elif defined(__aarch64__)
28#define ABI_STRING "arm64"
29#elif defined(__mips__)
30#define ABI_STRING "mips"
31#elif defined(__i386__)
32#define ABI_STRING "x86"
33#elif defined(__x86_64__)
34#define ABI_STRING "x86_64"
35#else
36#error "Unsupported ABI"
37#endif
38
39
Jeff Brown053b8652012-06-06 16:25:03 -070040typedef struct {
41 /* tombstone file descriptor */
42 int tfd;
Christopher Tateded2e5a2013-03-19 13:12:23 -070043 /* Activity Manager socket file descriptor */
44 int amfd;
Brigid Smith62ba4892014-06-10 11:53:08 -070045 // The tid of the thread that crashed.
46 pid_t crashed_tid;
47 // The tid of the thread we are currently working with.
48 pid_t current_tid;
Jeff Brown053b8652012-06-06 16:25:03 -070049} log_t;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080050
Brigid Smith62ba4892014-06-10 11:53:08 -070051// List of types of logs to simplify the logging decision in _LOG
52enum logtype {
53 ERROR,
54 HEADER,
55 THREAD,
56 REGISTERS,
57 BACKTRACE,
58 MAPS,
59 MEMORY,
60 STACK,
61 LOGS
62};
63
64/* Log information onto the tombstone. */
65void _LOG(log_t* log, logtype ltype, const char *fmt, ...)
Jeff Brown13e715b2011-10-21 12:14:56 -070066 __attribute__ ((format(printf, 3, 4)));
Andy McFadden136dcc52011-09-22 16:37:06 -070067
Jeff Brown053b8652012-06-06 16:25:03 -070068int wait_for_signal(pid_t tid, int* total_sleep_time_usec);
69void wait_for_stop(pid_t tid, int* total_sleep_time_usec);
Jeff Brown13e715b2011-10-21 12:14:56 -070070
Brigid Smith62ba4892014-06-10 11:53:08 -070071void dump_memory(log_t* log, pid_t tid, uintptr_t addr);
Kévin PETIT4bb47722013-12-18 16:44:24 +000072
Jeff Brown13e715b2011-10-21 12:14:56 -070073#endif // _DEBUGGERD_UTILITY_H