Deleted Added
full compact
uwx.h (129059) uwx.h (160157)
1/*
1/*
2Copyright (c) 2003 Hewlett-Packard Development Company, L.P.
2Copyright (c) 2003-2006 Hewlett-Packard Development Company, L.P.
3Permission is hereby granted, free of charge, to any person
4obtaining a copy of this software and associated documentation
5files (the "Software"), to deal in the Software without
6restriction, including without limitation the rights to use,
7copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the
9Software is furnished to do so, subject to the following
10conditions:

--- 9 unchanged lines hidden (view full) ---

20WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22OTHER DEALINGS IN THE SOFTWARE.
23*/
24
25#ifndef __UWX_INCLUDED
26#define __UWX_INCLUDED 1
27
3Permission is hereby granted, free of charge, to any person
4obtaining a copy of this software and associated documentation
5files (the "Software"), to deal in the Software without
6restriction, including without limitation the rights to use,
7copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the
9Software is furnished to do so, subject to the following
10conditions:

--- 9 unchanged lines hidden (view full) ---

20WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22OTHER DEALINGS IN THE SOFTWARE.
23*/
24
25#ifndef __UWX_INCLUDED
26#define __UWX_INCLUDED 1
27
28#ifndef _KERNEL
29#include <stdlib.h>
30#include <inttypes.h>
28#include <stdlib.h>
29#include <inttypes.h>
31#else
32#include <sys/param.h>
33#include <sys/systm.h>
34#endif
35
36#if defined(__cplusplus)
37#define __EXTERN_C extern "C"
38#else
39#define __EXTERN_C extern
40#endif
41
30
31#if defined(__cplusplus)
32#define __EXTERN_C extern "C"
33#else
34#define __EXTERN_C extern
35#endif
36
42#define UWX_VERSION 1 /* Version id for callback interfaces */
37#define UWX_VERSION 3 /* Version id for callback interfaces */
43
44/* Unwind environment structure (opaque) */
45struct uwx_env;
46
38
39/* Unwind environment structure (opaque) */
40struct uwx_env;
41
42/* Symbol Cache for uwx_find_symbol (opaque) */
43struct uwx_symbol_cache;
44
47/* Allocate and free callbacks */
48typedef void *(*alloc_cb)(size_t size);
49typedef void (*free_cb)(void *ptr);
50__EXTERN_C int uwx_register_alloc_cb(alloc_cb alloc, free_cb free);
51
52/* Allocate and initialize an unwind environment */
53__EXTERN_C struct uwx_env *uwx_init(void);
54
55/* Free an unwind environment */
56__EXTERN_C int uwx_free(struct uwx_env *env);
57
58/* Put unwind express into cross-process mode */
59__EXTERN_C int uwx_set_remote(struct uwx_env *env, int is_big_endian_target);
60
45/* Allocate and free callbacks */
46typedef void *(*alloc_cb)(size_t size);
47typedef void (*free_cb)(void *ptr);
48__EXTERN_C int uwx_register_alloc_cb(alloc_cb alloc, free_cb free);
49
50/* Allocate and initialize an unwind environment */
51__EXTERN_C struct uwx_env *uwx_init(void);
52
53/* Free an unwind environment */
54__EXTERN_C int uwx_free(struct uwx_env *env);
55
56/* Put unwind express into cross-process mode */
57__EXTERN_C int uwx_set_remote(struct uwx_env *env, int is_big_endian_target);
58
59/* Put unwind express into reduced-context mode (no floating-point regs) */
60__EXTERN_C int uwx_set_nofr(struct uwx_env *env);
61
61/* Copy-in callback */
62typedef int (*copyin_cb)(
63 int request, /* request code (see below) */
64 char *loc, /* local (destination) address */
65 uint64_t rem, /* remote (source) address */
66 int len, /* number of bytes to copy */
67 intptr_t tok); /* callback token */
68

--- 33 unchanged lines hidden (view full) ---

102 /* (memory spill format) */
103
104/* Initialize the unwind history */
105__EXTERN_C int uwx_init_history(struct uwx_env *env);
106
107/* Step one frame */
108__EXTERN_C int uwx_step(struct uwx_env *env);
109
62/* Copy-in callback */
63typedef int (*copyin_cb)(
64 int request, /* request code (see below) */
65 char *loc, /* local (destination) address */
66 uint64_t rem, /* remote (source) address */
67 int len, /* number of bytes to copy */
68 intptr_t tok); /* callback token */
69

--- 33 unchanged lines hidden (view full) ---

103 /* (memory spill format) */
104
105/* Initialize the unwind history */
106__EXTERN_C int uwx_init_history(struct uwx_env *env);
107
108/* Step one frame */
109__EXTERN_C int uwx_step(struct uwx_env *env);
110
111/* Get module name and text base, if available, for current frame */
112__EXTERN_C int uwx_get_module_info(
113 struct uwx_env *env, /* unwind environment */
114 char **modp, /* load module name (out) */
115 uint64_t *text_base); /* base address of text segment (out) */
116
117/* Get function start address for current frame */
118__EXTERN_C int uwx_get_funcstart(
119 struct uwx_env *env, /* unwind environment */
120 uint64_t *funcstart); /* function start address (out) */
121
110/* Get symbol information, if available, for current frame */
111__EXTERN_C int uwx_get_sym_info(
112 struct uwx_env *env, /* unwind environment */
113 char **modp, /* load module name (out) */
114 char **symp, /* function name (out) */
115 uint64_t *offsetp); /* offset from start of function (out) */
116
122/* Get symbol information, if available, for current frame */
123__EXTERN_C int uwx_get_sym_info(
124 struct uwx_env *env, /* unwind environment */
125 char **modp, /* load module name (out) */
126 char **symp, /* function name (out) */
127 uint64_t *offsetp); /* offset from start of function (out) */
128
129/* Get symbol information, given module name and IP */
130__EXTERN_C int uwx_find_symbol(
131 struct uwx_env *env, /* unwind environment */
132 struct uwx_symbol_cache **cachep,
133 /* ptr to symbol cache ptr (in/out) */
134 char *mod, /* load module name */
135 uint64_t relip, /* IP, relative to text segment */
136 char **symp, /* function name (out) */
137 uint64_t *offsetp); /* offset from start of function (out) */
138
139/* Release memory used by symbol cache */
140__EXTERN_C void uwx_release_symbol_cache(
141 struct uwx_env *env, /* unwind environment */
142 struct uwx_symbol_cache *symbol_cache);
143 /* symbol cache ptr */
144
117/* Get the value of a register from the current context */
118__EXTERN_C int uwx_get_reg(
119 struct uwx_env *env, /* unwind environment */
120 int regid, /* register id (see below) */
121 uint64_t *valp); /* register value (out) */
122
123/* Get the NaT bit of a GR from the current context */
124__EXTERN_C int uwx_get_nat(

--- 5 unchanged lines hidden (view full) ---

130__EXTERN_C int uwx_get_spill_loc(
131 struct uwx_env *env, /* unwind environment */
132 int regid, /* register id (see below) */
133 uint64_t *dispp); /* disposition code (see below) (out) */
134
135/* Get the ABI context code (if uwx_step returned UWX_ABI_FRAME) */
136__EXTERN_C int uwx_get_abi_context_code(struct uwx_env *env);
137
145/* Get the value of a register from the current context */
146__EXTERN_C int uwx_get_reg(
147 struct uwx_env *env, /* unwind environment */
148 int regid, /* register id (see below) */
149 uint64_t *valp); /* register value (out) */
150
151/* Get the NaT bit of a GR from the current context */
152__EXTERN_C int uwx_get_nat(

--- 5 unchanged lines hidden (view full) ---

158__EXTERN_C int uwx_get_spill_loc(
159 struct uwx_env *env, /* unwind environment */
160 int regid, /* register id (see below) */
161 uint64_t *dispp); /* disposition code (see below) (out) */
162
163/* Get the ABI context code (if uwx_step returned UWX_ABI_FRAME) */
164__EXTERN_C int uwx_get_abi_context_code(struct uwx_env *env);
165
166/* Increment/Decrement the bsp by a number of slots */
167/* (accounts for NaT collections) */
168__EXTERN_C uint64_t uwx_add_to_bsp(uint64_t bsp, int nslots);
169
138/* Return status codes for uwx_ APIs */
139#define UWX_OK 0
140#define UWX_BOTTOM 1 /* Hit bottom of stack */
141#define UWX_ABI_FRAME 2 /* Hit ABI-dependent frame */
142#define UWX_ERR_NOENV (-1) /* No uwx_env allocated */
143#define UWX_ERR_IPNOTFOUND (-2) /* Lookup IP c/b returned NOTFOUND */
144#define UWX_ERR_LOOKUPERR (-3) /* Lookup IP c/b returned ERR */
145#define UWX_ERR_BADKEY (-4) /* Bad result vector key */

--- 7 unchanged lines hidden (view full) ---

153#define UWX_ERR_BADUDESC (-12) /* Bad unwind descriptor */
154#define UWX_ERR_NOMEM (-13) /* Out of memory */
155#define UWX_ERR_PROLOG_UF (-14) /* Prologue underflow */
156#define UWX_ERR_UNDEFLABEL (-15) /* Undefined label in copy_state */
157#define UWX_ERR_BADREGID (-16) /* Bad register identifier */
158#define UWX_ERR_CANTUNWIND (-17) /* Can't unwind */
159#define UWX_ERR_NOCALLBACKS (-18) /* No callbacks registered */
160#define UWX_ERR_NOCONTEXT (-19) /* Context not initialized */
170/* Return status codes for uwx_ APIs */
171#define UWX_OK 0
172#define UWX_BOTTOM 1 /* Hit bottom of stack */
173#define UWX_ABI_FRAME 2 /* Hit ABI-dependent frame */
174#define UWX_ERR_NOENV (-1) /* No uwx_env allocated */
175#define UWX_ERR_IPNOTFOUND (-2) /* Lookup IP c/b returned NOTFOUND */
176#define UWX_ERR_LOOKUPERR (-3) /* Lookup IP c/b returned ERR */
177#define UWX_ERR_BADKEY (-4) /* Bad result vector key */

--- 7 unchanged lines hidden (view full) ---

185#define UWX_ERR_BADUDESC (-12) /* Bad unwind descriptor */
186#define UWX_ERR_NOMEM (-13) /* Out of memory */
187#define UWX_ERR_PROLOG_UF (-14) /* Prologue underflow */
188#define UWX_ERR_UNDEFLABEL (-15) /* Undefined label in copy_state */
189#define UWX_ERR_BADREGID (-16) /* Bad register identifier */
190#define UWX_ERR_CANTUNWIND (-17) /* Can't unwind */
191#define UWX_ERR_NOCALLBACKS (-18) /* No callbacks registered */
192#define UWX_ERR_NOCONTEXT (-19) /* Context not initialized */
193#define UWX_ERR_UCACCESS (-20) /* Failure in libuca */
194#define UWX_ERR_NOSYM (-21) /* Symbol not found */
161
162/* Request codes for copyin callback */
163#define UWX_COPYIN_UINFO 1 /* Reading unwind info */
164#define UWX_COPYIN_MSTACK 2 /* Reading memory stack */
165#define UWX_COPYIN_RSTACK 3 /* Reading RSE backing store */
166#define UWX_COPYIN_REG 4 /* Reading initial register state */
167
168/* Request codes for lookup IP callback */
169#define UWX_LKUP_LOOKUP 1 /* Lookup IP */
170#define UWX_LKUP_FREE 2 /* Free result vector */
171#define UWX_LKUP_SYMBOLS 3 /* Lookup symbolic information */
195
196/* Request codes for copyin callback */
197#define UWX_COPYIN_UINFO 1 /* Reading unwind info */
198#define UWX_COPYIN_MSTACK 2 /* Reading memory stack */
199#define UWX_COPYIN_RSTACK 3 /* Reading RSE backing store */
200#define UWX_COPYIN_REG 4 /* Reading initial register state */
201
202/* Request codes for lookup IP callback */
203#define UWX_LKUP_LOOKUP 1 /* Lookup IP */
204#define UWX_LKUP_FREE 2 /* Free result vector */
205#define UWX_LKUP_SYMBOLS 3 /* Lookup symbolic information */
206#define UWX_LKUP_MODULE 4 /* Get module name */
172
173/* Return status codes for lookup IP callback */
174#define UWX_LKUP_NOTFOUND 0 /* IP not found */
175#define UWX_LKUP_ERR 1 /* Other error */
176#define UWX_LKUP_UTABLE 2 /* Returned ref to unwind table */
177#define UWX_LKUP_FDESC 3 /* Returned frame description */
178#define UWX_LKUP_SYMINFO 4 /* Returned symbolic information */
179#define UWX_LKUP_REMAP 5 /* Returned remapped IP */

--- 14 unchanged lines hidden (view full) ---

194
195/* Keys returned with UWX_LKUP_UTABLE */
196/* These key/value pairs describe the unwind table corresponding */
197/* to the load module in which the current IP resides. */
198#define UWX_KEY_TBASE 1 /* Base address of text seg */
199#define UWX_KEY_UFLAGS 2 /* Unwind flags (optional) */
200#define UWX_KEY_USTART 3 /* Base of unwind tbl */
201#define UWX_KEY_UEND 4 /* End of unwind tbl */
207
208/* Return status codes for lookup IP callback */
209#define UWX_LKUP_NOTFOUND 0 /* IP not found */
210#define UWX_LKUP_ERR 1 /* Other error */
211#define UWX_LKUP_UTABLE 2 /* Returned ref to unwind table */
212#define UWX_LKUP_FDESC 3 /* Returned frame description */
213#define UWX_LKUP_SYMINFO 4 /* Returned symbolic information */
214#define UWX_LKUP_REMAP 5 /* Returned remapped IP */

--- 14 unchanged lines hidden (view full) ---

229
230/* Keys returned with UWX_LKUP_UTABLE */
231/* These key/value pairs describe the unwind table corresponding */
232/* to the load module in which the current IP resides. */
233#define UWX_KEY_TBASE 1 /* Base address of text seg */
234#define UWX_KEY_UFLAGS 2 /* Unwind flags (optional) */
235#define UWX_KEY_USTART 3 /* Base of unwind tbl */
236#define UWX_KEY_UEND 4 /* End of unwind tbl */
237#define UWX_KEY_GP 7 /* GP value for module */
202
203/* Keys returned with UWX_LKUP_FDESC */
204/* These key/value pairs describe the state of the frame at the */
205/* given IP. They are typically used for dynamically-generated code. */
206/* If UWX_KEY_CONTEXT is returned, it must be the only key returned. */
238
239/* Keys returned with UWX_LKUP_FDESC */
240/* These key/value pairs describe the state of the frame at the */
241/* given IP. They are typically used for dynamically-generated code. */
242/* If UWX_KEY_CONTEXT is returned, it must be the only key returned. */
243/* Use UWX_KEY_GP for the module's gp value. */
207#define UWX_KEY_FSIZE 1 /* Frame size */
208#define UWX_KEY_SPILL(reg_id) (2 | ((reg_id) << 4)) /* Reg spilled */
209#define UWX_KEY_CONTEXT 3 /* ABI-dep. context */
210
211/* Keys returned with UWX_LKUP_REMAP */
212#define UWX_KEY_NEWIP 5 /* Remapped IP */
213
214/* Keys returned with UWX_LKUP_UINFO */
244#define UWX_KEY_FSIZE 1 /* Frame size */
245#define UWX_KEY_SPILL(reg_id) (2 | ((reg_id) << 4)) /* Reg spilled */
246#define UWX_KEY_CONTEXT 3 /* ABI-dep. context */
247
248/* Keys returned with UWX_LKUP_REMAP */
249#define UWX_KEY_NEWIP 5 /* Remapped IP */
250
251/* Keys returned with UWX_LKUP_UINFO */
252/* Use UWX_KEY_GP for the module's gp value. */
215/* Use UWX_KEY_FUNCSTART for the start address of the function */
216/* Use UWX_KEY_UFLAGS for the unwind flags (optional) */
217#define UWX_KEY_UINFO 6 /* Address of unwind info block */
218
219/* Keys returned with UWX_LKUP_SYMINFO */
220/* These keys may be returned with UWX_LKUP_FDESC or UWX_LKUP_UINFO, */
221/* if the information is cheap to obtain. */
253/* Use UWX_KEY_FUNCSTART for the start address of the function */
254/* Use UWX_KEY_UFLAGS for the unwind flags (optional) */
255#define UWX_KEY_UINFO 6 /* Address of unwind info block */
256
257/* Keys returned with UWX_LKUP_SYMINFO */
258/* These keys may be returned with UWX_LKUP_FDESC or UWX_LKUP_UINFO, */
259/* if the information is cheap to obtain. */
260/* Use UWX_KEY_TBASE for the base of the text segment */
222#define UWX_KEY_MODULE 17 /* Name of load module */
223#define UWX_KEY_FUNC 18 /* Name of function */
224#define UWX_KEY_FUNCSTART 19 /* Address of start of function */
225
226/* Register identifiers */
227/* For use in UWX_LKUP_FDESC result vectors and context access APIs. */
228/* "no spill info": These regs aren't spilled directly, so */
229/* result vectors must not describe these registers. */

--- 11 unchanged lines hidden (view full) ---

241#define UWX_REG_PREDS 7 /* p0 - p63 */
242#define UWX_REG_PRIUNAT 8 /* primary unat (pseudo-register) */
243#define UWX_REG_AR_BSPSTORE 9 /* ar.bspstore */
244#define UWX_REG_AR_RNAT 10 /* ar.rnat */
245#define UWX_REG_AR_UNAT 11 /* ar.unat */
246#define UWX_REG_AR_FPSR 12 /* ar.fpsr */
247#define UWX_REG_AR_LC 13 /* ar.lc */
248#define UWX_REG_AR_PFS 14 /* ar.pfs */
261#define UWX_KEY_MODULE 17 /* Name of load module */
262#define UWX_KEY_FUNC 18 /* Name of function */
263#define UWX_KEY_FUNCSTART 19 /* Address of start of function */
264
265/* Register identifiers */
266/* For use in UWX_LKUP_FDESC result vectors and context access APIs. */
267/* "no spill info": These regs aren't spilled directly, so */
268/* result vectors must not describe these registers. */

--- 11 unchanged lines hidden (view full) ---

280#define UWX_REG_PREDS 7 /* p0 - p63 */
281#define UWX_REG_PRIUNAT 8 /* primary unat (pseudo-register) */
282#define UWX_REG_AR_BSPSTORE 9 /* ar.bspstore */
283#define UWX_REG_AR_RNAT 10 /* ar.rnat */
284#define UWX_REG_AR_UNAT 11 /* ar.unat */
285#define UWX_REG_AR_FPSR 12 /* ar.fpsr */
286#define UWX_REG_AR_LC 13 /* ar.lc */
287#define UWX_REG_AR_PFS 14 /* ar.pfs */
288#define UWX_REG_GP 15 /* gp (pseudo-register) */
249#define UWX_REG_GR(gr) (0x100 | (gr))
250#define UWX_REG_FR(fr) (0x200 | (fr))
251#define UWX_REG_BR(br) (0x300 | (br))
252
253/* for backwards compatibility with previous releases... */
254#define UWX_REG_BSPSTORE UWX_REG_AR_BSPSTORE
255#define UWX_REG_RNAT UWX_REG_AR_RNAT
256#define UWX_REG_UNAT UWX_REG_AR_UNAT

--- 59 unchanged lines hidden (view full) ---

316 int set_fr(int regid, uint64_t *valp) {
317 return uwx_set_fr(env, regid, valp);
318 }
319
320 int step() {
321 return uwx_step(env);
322 }
323
289#define UWX_REG_GR(gr) (0x100 | (gr))
290#define UWX_REG_FR(fr) (0x200 | (fr))
291#define UWX_REG_BR(br) (0x300 | (br))
292
293/* for backwards compatibility with previous releases... */
294#define UWX_REG_BSPSTORE UWX_REG_AR_BSPSTORE
295#define UWX_REG_RNAT UWX_REG_AR_RNAT
296#define UWX_REG_UNAT UWX_REG_AR_UNAT

--- 59 unchanged lines hidden (view full) ---

356 int set_fr(int regid, uint64_t *valp) {
357 return uwx_set_fr(env, regid, valp);
358 }
359
360 int step() {
361 return uwx_step(env);
362 }
363
364 int get_module_info(char **modp, uint64_t *text_base_p) {
365 return uwx_get_module_info(env, modp, text_base_p);
366 }
367
368 int get_funcstart(uint64_t *funcstart) {
369 return uwx_get_funcstart(env, funcstart);
370 }
371
324 int get_sym_info(char **modp, char **symp, uint64_t *offsetp) {
325 return uwx_get_sym_info(env, modp, symp, offsetp);
326 }
327
372 int get_sym_info(char **modp, char **symp, uint64_t *offsetp) {
373 return uwx_get_sym_info(env, modp, symp, offsetp);
374 }
375
376 int find_symbol(struct uwx_symbol_cache **cachep,
377 char *mod, uint64_t relip, char **symp, uint64_t *offsetp) {
378 return uwx_find_symbol(env, cachep, mod, relip, symp, offsetp);
379 }
380
381 void release_symbol_cache(struct uwx_symbol_cache *symbol_cache) {
382 uwx_release_symbol_cache(env, symbol_cache);
383 }
384
328 int get_reg(int regid, uint64_t *valp) {
329 return uwx_get_reg(env, regid, valp);
330 }
331
332 int get_nat(int regid, int *natp) {
333 return uwx_get_nat(env, regid, natp);
334 }
335

--- 21 unchanged lines hidden ---
385 int get_reg(int regid, uint64_t *valp) {
386 return uwx_get_reg(env, regid, valp);
387 }
388
389 int get_nat(int regid, int *natp) {
390 return uwx_get_nat(env, regid, natp);
391 }
392

--- 21 unchanged lines hidden ---