diff options
Diffstat (limited to 'arch/tile/include/asm/backtrace.h')
-rw-r--r-- | arch/tile/include/asm/backtrace.h | 82 |
1 files changed, 23 insertions, 59 deletions
diff --git a/arch/tile/include/asm/backtrace.h b/arch/tile/include/asm/backtrace.h index f18887d82399..bd5399a69edf 100644 --- a/arch/tile/include/asm/backtrace.h +++ b/arch/tile/include/asm/backtrace.h | |||
@@ -12,80 +12,41 @@ | |||
12 | * more details. | 12 | * more details. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #ifndef _TILE_BACKTRACE_H | 15 | #ifndef _ASM_TILE_BACKTRACE_H |
16 | #define _TILE_BACKTRACE_H | 16 | #define _ASM_TILE_BACKTRACE_H |
17 | |||
18 | |||
19 | 17 | ||
20 | #include <linux/types.h> | 18 | #include <linux/types.h> |
21 | 19 | ||
22 | #include <arch/chip.h> | 20 | /* Reads 'size' bytes from 'address' and writes the data to 'result'. |
23 | |||
24 | #if defined(__tile__) | ||
25 | typedef unsigned long VirtualAddress; | ||
26 | #elif CHIP_VA_WIDTH() > 32 | ||
27 | typedef unsigned long long VirtualAddress; | ||
28 | #else | ||
29 | typedef unsigned int VirtualAddress; | ||
30 | #endif | ||
31 | |||
32 | |||
33 | /** Reads 'size' bytes from 'address' and writes the data to 'result'. | ||
34 | * Returns true if successful, else false (e.g. memory not readable). | 21 | * Returns true if successful, else false (e.g. memory not readable). |
35 | */ | 22 | */ |
36 | typedef bool (*BacktraceMemoryReader)(void *result, | 23 | typedef bool (*BacktraceMemoryReader)(void *result, |
37 | VirtualAddress address, | 24 | unsigned long address, |
38 | unsigned int size, | 25 | unsigned int size, |
39 | void *extra); | 26 | void *extra); |
40 | 27 | ||
41 | typedef struct { | 28 | typedef struct { |
42 | /** Current PC. */ | 29 | /* Current PC. */ |
43 | VirtualAddress pc; | 30 | unsigned long pc; |
44 | 31 | ||
45 | /** Current stack pointer value. */ | 32 | /* Current stack pointer value. */ |
46 | VirtualAddress sp; | 33 | unsigned long sp; |
47 | 34 | ||
48 | /** Current frame pointer value (i.e. caller's stack pointer) */ | 35 | /* Current frame pointer value (i.e. caller's stack pointer) */ |
49 | VirtualAddress fp; | 36 | unsigned long fp; |
50 | 37 | ||
51 | /** Internal use only: caller's PC for first frame. */ | 38 | /* Internal use only: caller's PC for first frame. */ |
52 | VirtualAddress initial_frame_caller_pc; | 39 | unsigned long initial_frame_caller_pc; |
53 | 40 | ||
54 | /** Internal use only: callback to read memory. */ | 41 | /* Internal use only: callback to read memory. */ |
55 | BacktraceMemoryReader read_memory_func; | 42 | BacktraceMemoryReader read_memory_func; |
56 | 43 | ||
57 | /** Internal use only: arbitrary argument to read_memory_func. */ | 44 | /* Internal use only: arbitrary argument to read_memory_func. */ |
58 | void *read_memory_func_extra; | 45 | void *read_memory_func_extra; |
59 | 46 | ||
60 | } BacktraceIterator; | 47 | } BacktraceIterator; |
61 | 48 | ||
62 | 49 | ||
63 | /** Initializes a backtracer to start from the given location. | ||
64 | * | ||
65 | * If the frame pointer cannot be determined it is set to -1. | ||
66 | * | ||
67 | * @param state The state to be filled in. | ||
68 | * @param read_memory_func A callback that reads memory. If NULL, a default | ||
69 | * value is provided. | ||
70 | * @param read_memory_func_extra An arbitrary argument to read_memory_func. | ||
71 | * @param pc The current PC. | ||
72 | * @param lr The current value of the 'lr' register. | ||
73 | * @param sp The current value of the 'sp' register. | ||
74 | * @param r52 The current value of the 'r52' register. | ||
75 | */ | ||
76 | extern void backtrace_init(BacktraceIterator *state, | ||
77 | BacktraceMemoryReader read_memory_func, | ||
78 | void *read_memory_func_extra, | ||
79 | VirtualAddress pc, VirtualAddress lr, | ||
80 | VirtualAddress sp, VirtualAddress r52); | ||
81 | |||
82 | |||
83 | /** Advances the backtracing state to the calling frame, returning | ||
84 | * true iff successful. | ||
85 | */ | ||
86 | extern bool backtrace_next(BacktraceIterator *state); | ||
87 | |||
88 | |||
89 | typedef enum { | 50 | typedef enum { |
90 | 51 | ||
91 | /* We have no idea what the caller's pc is. */ | 52 | /* We have no idea what the caller's pc is. */ |
@@ -138,7 +99,7 @@ enum { | |||
138 | }; | 99 | }; |
139 | 100 | ||
140 | 101 | ||
141 | /** Internal constants used to define 'info' operands. */ | 102 | /* Internal constants used to define 'info' operands. */ |
142 | enum { | 103 | enum { |
143 | /* 0 and 1 are reserved, as are all negative numbers. */ | 104 | /* 0 and 1 are reserved, as are all negative numbers. */ |
144 | 105 | ||
@@ -147,13 +108,10 @@ enum { | |||
147 | CALLER_SP_IN_R52_BASE = 4, | 108 | CALLER_SP_IN_R52_BASE = 4, |
148 | 109 | ||
149 | CALLER_SP_OFFSET_BASE = 8, | 110 | CALLER_SP_OFFSET_BASE = 8, |
150 | |||
151 | /* Marks the entry point of certain functions. */ | ||
152 | ENTRY_POINT_INFO_OP = 16 | ||
153 | }; | 111 | }; |
154 | 112 | ||
155 | 113 | ||
156 | /** Current backtracer state describing where it thinks the caller is. */ | 114 | /* Current backtracer state describing where it thinks the caller is. */ |
157 | typedef struct { | 115 | typedef struct { |
158 | /* | 116 | /* |
159 | * Public fields | 117 | * Public fields |
@@ -192,7 +150,13 @@ typedef struct { | |||
192 | 150 | ||
193 | } CallerLocation; | 151 | } CallerLocation; |
194 | 152 | ||
153 | extern void backtrace_init(BacktraceIterator *state, | ||
154 | BacktraceMemoryReader read_memory_func, | ||
155 | void *read_memory_func_extra, | ||
156 | unsigned long pc, unsigned long lr, | ||
157 | unsigned long sp, unsigned long r52); | ||
195 | 158 | ||
196 | 159 | ||
160 | extern bool backtrace_next(BacktraceIterator *state); | ||
197 | 161 | ||
198 | #endif /* _TILE_BACKTRACE_H */ | 162 | #endif /* _ASM_TILE_BACKTRACE_H */ |