blob: 0682b85543b0c3e8489dbf4b629b63aec232858a [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
18#ifndef __utility_h
19#define __utility_h
20
21#include <stddef.h>
22#include <stdbool.h>
23
Meng Huae7b91b2009-11-05 16:10:50 -060024#include "symbol_table.h"
25
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080026#ifndef PT_ARM_EXIDX
27#define PT_ARM_EXIDX 0x70000001 /* .ARM.exidx segment */
28#endif
29
30#define STACK_CONTENT_DEPTH 32
31
32typedef struct mapinfo {
33 struct mapinfo *next;
34 unsigned start;
35 unsigned end;
36 unsigned exidx_start;
37 unsigned exidx_end;
Meng Huae7b91b2009-11-05 16:10:50 -060038 struct symbol_table *symbols;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080039 char name[];
40} mapinfo;
41
42/* Get a word from pid using ptrace. The result is the return value. */
43extern int get_remote_word(int pid, void *src);
44
45/* Handy routine to read aggregated data from pid using ptrace. The read
46 * values are written to the dest locations directly.
47 */
48extern void get_remote_struct(int pid, void *src, void *dst, size_t size);
49
50/* Find the containing map for the pc */
51const mapinfo *pc_to_mapinfo (mapinfo *mi, unsigned pc, unsigned *rel_pc);
52
53/* Map a pc address to the name of the containing ELF file */
54const char *map_to_name(mapinfo *mi, unsigned pc, const char* def);
55
56/* Log information onto the tombstone */
57extern void _LOG(int tfd, bool in_tombstone_only, const char *fmt, ...);
58
Bruce Beare84924902010-10-13 14:21:30 -070059#define LOG(fmt...) _LOG(-1, 0, fmt)
60#if 0
61#define XLOG(fmt...) _LOG(-1, 0, fmt)
62#else
63#define XLOG(fmt...) do {} while(0)
64#endif
65
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080066#endif