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 | |
| 18 | #ifndef __utility_h |
| 19 | #define __utility_h |
| 20 | |
| 21 | #include <stddef.h> |
| 22 | #include <stdbool.h> |
| 23 | |
Meng Hu | ae7b91b | 2009-11-05 16:10:50 -0600 | [diff] [blame] | 24 | #include "symbol_table.h" |
| 25 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 26 | #ifndef PT_ARM_EXIDX |
| 27 | #define PT_ARM_EXIDX 0x70000001 /* .ARM.exidx segment */ |
| 28 | #endif |
| 29 | |
| 30 | #define STACK_CONTENT_DEPTH 32 |
| 31 | |
| 32 | typedef struct mapinfo { |
| 33 | struct mapinfo *next; |
| 34 | unsigned start; |
| 35 | unsigned end; |
| 36 | unsigned exidx_start; |
| 37 | unsigned exidx_end; |
Meng Hu | ae7b91b | 2009-11-05 16:10:50 -0600 | [diff] [blame] | 38 | struct symbol_table *symbols; |
Andy McFadden | 136dcc5 | 2011-09-22 16:37:06 -0700 | [diff] [blame] | 39 | bool isExecutable; |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 40 | char name[]; |
| 41 | } mapinfo; |
| 42 | |
| 43 | /* Get a word from pid using ptrace. The result is the return value. */ |
| 44 | extern int get_remote_word(int pid, void *src); |
| 45 | |
| 46 | /* Handy routine to read aggregated data from pid using ptrace. The read |
| 47 | * values are written to the dest locations directly. |
| 48 | */ |
| 49 | extern void get_remote_struct(int pid, void *src, void *dst, size_t size); |
| 50 | |
| 51 | /* Find the containing map for the pc */ |
| 52 | const mapinfo *pc_to_mapinfo (mapinfo *mi, unsigned pc, unsigned *rel_pc); |
| 53 | |
| 54 | /* Map a pc address to the name of the containing ELF file */ |
| 55 | const char *map_to_name(mapinfo *mi, unsigned pc, const char* def); |
| 56 | |
| 57 | /* Log information onto the tombstone */ |
| 58 | extern void _LOG(int tfd, bool in_tombstone_only, const char *fmt, ...); |
| 59 | |
Andy McFadden | 136dcc5 | 2011-09-22 16:37:06 -0700 | [diff] [blame] | 60 | /* Determine whether si_addr is valid for this signal */ |
| 61 | bool signal_has_address(int sig); |
| 62 | |
Bruce Beare | 8492490 | 2010-10-13 14:21:30 -0700 | [diff] [blame] | 63 | #define LOG(fmt...) _LOG(-1, 0, fmt) |
David 'Digit' Turner | 2c25991 | 2011-01-26 15:11:04 +0100 | [diff] [blame] | 64 | |
| 65 | /* Set to 1 for normal debug traces */ |
Bruce Beare | 8492490 | 2010-10-13 14:21:30 -0700 | [diff] [blame] | 66 | #if 0 |
| 67 | #define XLOG(fmt...) _LOG(-1, 0, fmt) |
| 68 | #else |
| 69 | #define XLOG(fmt...) do {} while(0) |
| 70 | #endif |
| 71 | |
David 'Digit' Turner | 2c25991 | 2011-01-26 15:11:04 +0100 | [diff] [blame] | 72 | /* Set to 1 for chatty debug traces. Includes all resolved dynamic symbols */ |
| 73 | #if 0 |
| 74 | #define XLOG2(fmt...) _LOG(-1, 0, fmt) |
| 75 | #else |
| 76 | #define XLOG2(fmt...) do {} while(0) |
| 77 | #endif |
| 78 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 79 | #endif |