blob: 879c8b43f963296b851350369208863df76e591e [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
21#include <stddef.h>
22#include <stdbool.h>
Jeff Brown13e715b2011-10-21 12:14:56 -070023#include <sys/types.h>
24#include <corkscrew/backtrace.h>
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080025
Jeff Brown13e715b2011-10-21 12:14:56 -070026/* Log information onto the tombstone. */
27void _LOG(int tfd, bool in_tombstone_only, const char *fmt, ...)
28 __attribute__ ((format(printf, 3, 4)));
Andy McFadden136dcc52011-09-22 16:37:06 -070029
Bruce Beare84924902010-10-13 14:21:30 -070030#define LOG(fmt...) _LOG(-1, 0, fmt)
David 'Digit' Turner2c259912011-01-26 15:11:04 +010031
32/* Set to 1 for normal debug traces */
Bruce Beare84924902010-10-13 14:21:30 -070033#if 0
34#define XLOG(fmt...) _LOG(-1, 0, fmt)
35#else
36#define XLOG(fmt...) do {} while(0)
37#endif
38
David 'Digit' Turner2c259912011-01-26 15:11:04 +010039/* 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 Brown13e715b2011-10-21 12:14:56 -070046/*
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(ptrace_context_t* context, int tfd, pid_t pid, 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(ptrace_context_t* context, int tfd, pid_t tid);
70
71
72#endif // _DEBUGGERD_UTILITY_H