utility.h revision f0c5872637a63e28e3cd314cfc915c07f76df9c6
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 18#ifndef _DEBUGGERD_UTILITY_H 19#define _DEBUGGERD_UTILITY_H 20 21#include <stddef.h> 22#include <stdbool.h> 23#include <sys/types.h> 24#include <corkscrew/backtrace.h> 25 26/* Log information onto the tombstone. */ 27void _LOG(int tfd, bool in_tombstone_only, const char *fmt, ...) 28 __attribute__ ((format(printf, 3, 4))); 29 30#define LOG(fmt...) _LOG(-1, 0, fmt) 31 32/* Set to 1 for normal debug traces */ 33#if 0 34#define XLOG(fmt...) _LOG(-1, 0, fmt) 35#else 36#define XLOG(fmt...) do {} while(0) 37#endif 38 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 46/* 47 * Returns true if the specified signal has an associated address. 48 * (i.e. it sets siginfo_t.si_addr). 49 */ 50bool signal_has_address(int sig); 51 52/* 53 * Dumps the backtrace and contents of the stack. 54 */ 55void dump_backtrace_and_stack(const ptrace_context_t* context, int tfd, pid_t tid, bool at_fault); 56 57/* 58 * Dumps a few bytes of memory, starting a bit before and ending a bit 59 * after the specified address. 60 */ 61void 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 */ 69void dump_nearby_maps(const ptrace_context_t* context, int tfd, pid_t tid); 70 71 72#endif // _DEBUGGERD_UTILITY_H 73