The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1 | /* 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 Brown | 13e715b | 2011-10-21 12:14:56 -0700 | [diff] [blame] | 18 | #ifndef _DEBUGGERD_UTILITY_H |
| 19 | #define _DEBUGGERD_UTILITY_H |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 20 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 21 | #include <stdbool.h> |
Pavel Chupin | c6c194c | 2013-11-21 23:17:20 +0400 | [diff] [blame] | 22 | #include <sys/types.h> |
Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 23 | |
| 24 | typedef struct { |
| 25 | /* tombstone file descriptor */ |
| 26 | int tfd; |
Christopher Tate | ded2e5a | 2013-03-19 13:12:23 -0700 | [diff] [blame] | 27 | /* Activity Manager socket file descriptor */ |
| 28 | int amfd; |
| 29 | /* if true, does not log anything to the Android logcat or Activity Manager */ |
Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 30 | bool quiet; |
Brigid Smith | 62ba489 | 2014-06-10 11:53:08 -0700 | [diff] [blame^] | 31 | // The tid of the thread that crashed. |
| 32 | pid_t crashed_tid; |
| 33 | // The tid of the thread we are currently working with. |
| 34 | pid_t current_tid; |
Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 35 | } log_t; |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 36 | |
Brigid Smith | 62ba489 | 2014-06-10 11:53:08 -0700 | [diff] [blame^] | 37 | // List of types of logs to simplify the logging decision in _LOG |
| 38 | enum logtype { |
| 39 | ERROR, |
| 40 | HEADER, |
| 41 | THREAD, |
| 42 | REGISTERS, |
| 43 | BACKTRACE, |
| 44 | MAPS, |
| 45 | MEMORY, |
| 46 | STACK, |
| 47 | LOGS |
| 48 | }; |
| 49 | |
| 50 | /* Log information onto the tombstone. */ |
| 51 | void _LOG(log_t* log, logtype ltype, const char *fmt, ...) |
Jeff Brown | 13e715b | 2011-10-21 12:14:56 -0700 | [diff] [blame] | 52 | __attribute__ ((format(printf, 3, 4))); |
Andy McFadden | 136dcc5 | 2011-09-22 16:37:06 -0700 | [diff] [blame] | 53 | |
Christopher Tate | 7716aef | 2013-04-02 14:00:27 -0700 | [diff] [blame] | 54 | /* Further helpful macros */ |
Brigid Smith | 62ba489 | 2014-06-10 11:53:08 -0700 | [diff] [blame^] | 55 | #define LOG_ERROR(fmt...) _LOG(NULL, logtype::ERROR, fmt) |
Bruce Beare | 8492490 | 2010-10-13 14:21:30 -0700 | [diff] [blame] | 56 | #define XLOG(fmt...) do {} while(0) |
David 'Digit' Turner | 2c25991 | 2011-01-26 15:11:04 +0100 | [diff] [blame] | 57 | |
Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 58 | int wait_for_signal(pid_t tid, int* total_sleep_time_usec); |
| 59 | void wait_for_stop(pid_t tid, int* total_sleep_time_usec); |
Jeff Brown | 13e715b | 2011-10-21 12:14:56 -0700 | [diff] [blame] | 60 | |
Brigid Smith | 62ba489 | 2014-06-10 11:53:08 -0700 | [diff] [blame^] | 61 | void dump_memory(log_t* log, pid_t tid, uintptr_t addr); |
Kévin PETIT | 4bb4772 | 2013-12-18 16:44:24 +0000 | [diff] [blame] | 62 | |
Jeff Brown | 13e715b | 2011-10-21 12:14:56 -0700 | [diff] [blame] | 63 | #endif // _DEBUGGERD_UTILITY_H |