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 | |
| 21 | #include <stddef.h> |
| 22 | #include <stdbool.h> |
Jeff Brown | 13e715b | 2011-10-21 12:14:56 -0700 | [diff] [blame] | 23 | #include <sys/types.h> |
| 24 | #include <corkscrew/backtrace.h> |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 25 | |
Jeff Brown | 13e715b | 2011-10-21 12:14:56 -0700 | [diff] [blame] | 26 | /* Log information onto the tombstone. */ |
| 27 | void _LOG(int tfd, bool in_tombstone_only, const char *fmt, ...) |
| 28 | __attribute__ ((format(printf, 3, 4))); |
Andy McFadden | 136dcc5 | 2011-09-22 16:37:06 -0700 | [diff] [blame] | 29 | |
Bruce Beare | 8492490 | 2010-10-13 14:21:30 -0700 | [diff] [blame] | 30 | #define LOG(fmt...) _LOG(-1, 0, fmt) |
David 'Digit' Turner | 2c25991 | 2011-01-26 15:11:04 +0100 | [diff] [blame] | 31 | |
| 32 | /* Set to 1 for normal debug traces */ |
Bruce Beare | 8492490 | 2010-10-13 14:21:30 -0700 | [diff] [blame] | 33 | #if 0 |
| 34 | #define XLOG(fmt...) _LOG(-1, 0, fmt) |
| 35 | #else |
| 36 | #define XLOG(fmt...) do {} while(0) |
| 37 | #endif |
| 38 | |
David 'Digit' Turner | 2c25991 | 2011-01-26 15:11:04 +0100 | [diff] [blame] | 39 | /* Set to 1 for chatty debug traces. Includes all resolved dynamic symbols */ |
| 40 | #if 0 |
| 41 | #define XLOG2(fmt...) _LOG(-1, 0, fmt) |
| 42 | #else |
| 43 | #define XLOG2(fmt...) do {} while(0) |
| 44 | #endif |
| 45 | |
Jeff Brown | 13e715b | 2011-10-21 12:14:56 -0700 | [diff] [blame] | 46 | /* |
| 47 | * Returns true if the specified signal has an associated address. |
| 48 | * (i.e. it sets siginfo_t.si_addr). |
| 49 | */ |
| 50 | bool signal_has_address(int sig); |
| 51 | |
| 52 | /* |
| 53 | * Dumps the backtrace and contents of the stack. |
| 54 | */ |
Jeff Brown | f0c5872 | 2011-11-03 17:58:44 -0700 | [diff] [blame] | 55 | void dump_backtrace_and_stack(const ptrace_context_t* context, int tfd, pid_t tid, bool at_fault); |
Jeff Brown | 13e715b | 2011-10-21 12:14:56 -0700 | [diff] [blame] | 56 | |
| 57 | /* |
| 58 | * Dumps a few bytes of memory, starting a bit before and ending a bit |
| 59 | * after the specified address. |
| 60 | */ |
| 61 | void dump_memory(int tfd, pid_t tid, uintptr_t addr, bool at_fault); |
| 62 | |
| 63 | /* |
| 64 | * If this isn't clearly a null pointer dereference, dump the |
| 65 | * /proc/maps entries near the fault address. |
| 66 | * |
| 67 | * This only makes sense to do on the thread that crashed. |
| 68 | */ |
Jeff Brown | f0c5872 | 2011-11-03 17:58:44 -0700 | [diff] [blame] | 69 | void dump_nearby_maps(const ptrace_context_t* context, int tfd, pid_t tid); |
Jeff Brown | 13e715b | 2011-10-21 12:14:56 -0700 | [diff] [blame] | 70 | |
| 71 | |
| 72 | #endif // _DEBUGGERD_UTILITY_H |