Deleted Added
full compact
uwx_step.c (129059) uwx_step.c (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:

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

61int uwx_lookupip_hook(int request, uint64_t ip, intptr_t tok, uint64_t **vecp,
62 size_t uvecsize)
63{
64 return UWX_LKUP_NOTFOUND;
65}
66
67
68/* uwx_get_frame_info: Gets unwind info for current frame */
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:

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

61int uwx_lookupip_hook(int request, uint64_t ip, intptr_t tok, uint64_t **vecp,
62 size_t uvecsize)
63{
64 return UWX_LKUP_NOTFOUND;
65}
66
67
68/* uwx_get_frame_info: Gets unwind info for current frame */
69static
69
70int uwx_get_frame_info(struct uwx_env *env)
71{
72 int i;
73 int status;
74 int cbstatus;
75 int cbcalled = 0;
76 uint64_t ip;
77 uint64_t *uvec;
78 uint64_t *rstate;
79 struct uwx_utable_entry uentry;
70int uwx_get_frame_info(struct uwx_env *env)
71{
72 int i;
73 int status;
74 int cbstatus;
75 int cbcalled = 0;
76 uint64_t ip;
77 uint64_t *uvec;
78 uint64_t *rstate;
79 struct uwx_utable_entry uentry;
80 uint64_t uinfop;
80 uint64_t uvecout[UVECSIZE];
81
82 if (env->copyin == 0 || env->lookupip == 0)
83 return UWX_ERR_NOCALLBACKS;
84
81 uint64_t uvecout[UVECSIZE];
82
83 if (env->copyin == 0 || env->lookupip == 0)
84 return UWX_ERR_NOCALLBACKS;
85
86 env->ptr_size = DWORDSZ;
87 env->code_start = 0;
85 env->function_offset = -1LL;
86 env->function_name = 0;
87 env->module_name = 0;
88 env->function_offset = -1LL;
89 env->function_name = 0;
90 env->module_name = 0;
91 env->abi_context = 0;
88 uwx_reset_str_pool(env);
89
90 /* Use the lookup IP callback routine to find out about the */
91 /* current IP. If the predicate registers are valid, pass them */
92 /* in the uvec. */
93
94 /* When self-unwinding, we call a hook routine before the */
95 /* callback. If the application is running under control of */

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

165 /* associated with that unwind table entry, and store the */
166 /* resulting register state array in the unwind environment */
167 /* block. */
168
169 else if (cbstatus == UWX_LKUP_UTABLE) {
170 status = uwx_search_utable(env, ip, uvec, &uentry);
171 if (cbcalled)
172 (void) (*env->lookupip)(UWX_LKUP_FREE, 0, env->cb_token, &uvec);
92 uwx_reset_str_pool(env);
93
94 /* Use the lookup IP callback routine to find out about the */
95 /* current IP. If the predicate registers are valid, pass them */
96 /* in the uvec. */
97
98 /* When self-unwinding, we call a hook routine before the */
99 /* callback. If the application is running under control of */

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

169 /* associated with that unwind table entry, and store the */
170 /* resulting register state array in the unwind environment */
171 /* block. */
172
173 else if (cbstatus == UWX_LKUP_UTABLE) {
174 status = uwx_search_utable(env, ip, uvec, &uentry);
175 if (cbcalled)
176 (void) (*env->lookupip)(UWX_LKUP_FREE, 0, env->cb_token, &uvec);
173 if (status == UWX_OK)
177 if (status == UWX_OK) {
178 env->ptr_size = uentry.ptr_size;
179 env->code_start = uentry.code_start;
174 status = uwx_decode_uinfo(env, &uentry, &rstate);
180 status = uwx_decode_uinfo(env, &uentry, &rstate);
175 else if (status == UWX_ERR_NOUENTRY)
181 }
182 if (status == UWX_ERR_NOUENTRY || status == UWX_ERR_NOUDESC)
176 status = uwx_default_rstate(env, &rstate);
177 if (status == UWX_OK)
178 env->rstate = rstate;
179 }
180
181 /* If the callback returns an unwind info block, we can */
182 /* proceed directly to decoding the unwind information. */
183
184 else if (cbstatus == UWX_LKUP_UINFO) {
183 status = uwx_default_rstate(env, &rstate);
184 if (status == UWX_OK)
185 env->rstate = rstate;
186 }
187
188 /* If the callback returns an unwind info block, we can */
189 /* proceed directly to decoding the unwind information. */
190
191 else if (cbstatus == UWX_LKUP_UINFO) {
192 uentry.ptr_size = DWORDSZ;
185 uentry.code_start = 0;
186 uentry.code_end = 0;
187 uentry.unwind_info = 0;
188 uentry.unwind_flags = 0;
189 for (i = 0; uvec[i] != UWX_KEY_END; i += 2) {
190 switch ((int)uvec[i]) {
191 case UWX_KEY_UFLAGS:
192 uentry.unwind_flags = uvec[i+1];
193 uentry.code_start = 0;
194 uentry.code_end = 0;
195 uentry.unwind_info = 0;
196 uentry.unwind_flags = 0;
197 for (i = 0; uvec[i] != UWX_KEY_END; i += 2) {
198 switch ((int)uvec[i]) {
199 case UWX_KEY_UFLAGS:
200 uentry.unwind_flags = uvec[i+1];
201 if (uentry.unwind_flags & UNWIND_TBL_32BIT)
202 uentry.ptr_size = WORDSZ;
193 break;
194 case UWX_KEY_UINFO:
195 uentry.unwind_info = uvec[i+1];
196 break;
203 break;
204 case UWX_KEY_UINFO:
205 uentry.unwind_info = uvec[i+1];
206 break;
207 case UWX_KEY_GP:
208 uwx_set_reg(env, UWX_REG_GP, uvec[i+1]);
209 break;
197 case UWX_KEY_MODULE:
198 env->module_name =
210 case UWX_KEY_MODULE:
211 env->module_name =
199 uwx_alloc_str(env, (char *)(uvec[i+1]));
212 uwx_alloc_str(env, (char *)(intptr_t)(uvec[i+1]));
200 break;
201 case UWX_KEY_FUNC:
202 env->function_name =
213 break;
214 case UWX_KEY_FUNC:
215 env->function_name =
203 uwx_alloc_str(env, (char *)(uvec[i+1]));
216 uwx_alloc_str(env, (char *)(intptr_t)(uvec[i+1]));
204 break;
205 case UWX_KEY_FUNCSTART:
206 uentry.code_start = uvec[i+1];
217 break;
218 case UWX_KEY_FUNCSTART:
219 uentry.code_start = uvec[i+1];
220 env->code_start = uentry.code_start;
207 break;
208 }
209 }
221 break;
222 }
223 }
224 env->ptr_size = uentry.ptr_size;
210 if (cbcalled)
211 (void) (*env->lookupip)(UWX_LKUP_FREE, 0, env->cb_token, &uvec);
212 status = uwx_decode_uinfo(env, &uentry, &rstate);
225 if (cbcalled)
226 (void) (*env->lookupip)(UWX_LKUP_FREE, 0, env->cb_token, &uvec);
227 status = uwx_decode_uinfo(env, &uentry, &rstate);
228 if (status == UWX_ERR_NOUDESC)
229 status = uwx_default_rstate(env, &rstate);
213 if (status == UWX_OK)
214 env->rstate = rstate;
215 }
216
217 /* If the callback returns a frame description (in the form */
218 /* of an update vector), convert the update vector into a */
219 /* register state array, then invoke the callback again to */
220 /* let it free any memory it allocated. */

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

286 env->history.special[UWX_REG_PFS] = hist;
287 env->context.valid_regs |= 1 << UWX_REG_PFS;
288 TRACE_S_RESTORE_REG("PFS", env->rstate[SBREG_PFS], val)
289 }
290
291 return UWX_OK;
292}
293
230 if (status == UWX_OK)
231 env->rstate = rstate;
232 }
233
234 /* If the callback returns a frame description (in the form */
235 /* of an update vector), convert the update vector into a */
236 /* register state array, then invoke the callback again to */
237 /* let it free any memory it allocated. */

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

303 env->history.special[UWX_REG_PFS] = hist;
304 env->context.valid_regs |= 1 << UWX_REG_PFS;
305 TRACE_S_RESTORE_REG("PFS", env->rstate[SBREG_PFS], val)
306 }
307
308 return UWX_OK;
309}
310
311/* uwx_get_module_info: Gets module name and text base for current frame */
312
313int uwx_get_module_info(
314 struct uwx_env *env,
315 char **modp,
316 uint64_t *text_base)
317{
318 int i;
319 int status;
320 int cbstatus;
321 uint64_t ip;
322 uint64_t *uvec;
323 uint64_t uvecout[UVECSIZE];
324
325 if (env == 0)
326 return UWX_ERR_NOENV;
327
328 /* If we haven't already obtained the frame info for the */
329 /* current frame, get it now. */
330
331 if (env->rstate == 0) {
332 status = uwx_get_frame_info(env);
333 if (status != UWX_OK)
334 return status;
335 }
336
337 /* Get the module name from the lookup IP callback. */
338 if (env->module_name == 0) {
339 ip = env->remapped_ip;
340 i = 0;
341 if (env->function_offset >= 0) {
342 uvecout[i++] = UWX_KEY_FUNCSTART;
343 uvecout[i++] = ip - env->function_offset;
344 }
345 uvecout[i++] = UWX_KEY_END;
346 uvecout[i++] = 0;
347 uvec = uvecout;
348 cbstatus = (*env->lookupip)(UWX_LKUP_MODULE, ip, env->cb_token, &uvec);
349
350 if (cbstatus == UWX_LKUP_SYMINFO) {
351 for (i = 0; uvec[i] != UWX_KEY_END; i += 2) {
352 switch ((int)uvec[i]) {
353 case UWX_KEY_TBASE:
354 env->text_base = uvec[i+1];
355 break;
356 case UWX_KEY_MODULE:
357 env->module_name =
358 uwx_alloc_str(env, (char *)(intptr_t)(uvec[i+1]));
359 break;
360 case UWX_KEY_FUNC:
361 env->function_name =
362 uwx_alloc_str(env, (char *)(intptr_t)(uvec[i+1]));
363 break;
364 case UWX_KEY_FUNCSTART:
365 env->function_offset = ip - uvec[i+1];
366 break;
367 }
368 }
369 (void) (*env->lookupip)(UWX_LKUP_FREE, 0, env->cb_token, &uvec);
370 }
371 }
372
373 *modp = env->module_name;
374 *text_base = env->text_base;
375
376 return UWX_OK;
377}
378
379/* uwx_get_funcstart: Gets start address of function from current frame */
380
381int uwx_get_funcstart(
382 struct uwx_env *env,
383 uint64_t *funcstart)
384{
385 int status;
386 uint64_t *uvec;
387 uint64_t uvecout[UVECSIZE];
388
389 if (env == 0)
390 return UWX_ERR_NOENV;
391
392 /* If we haven't already obtained the frame info for the */
393 /* current frame, get it now. */
394
395 if (env->rstate == 0) {
396 status = uwx_get_frame_info(env);
397 if (status != UWX_OK)
398 return status;
399 }
400
401 *funcstart = env->remapped_ip - env->function_offset;
402
403 return UWX_OK;
404}
405
294/* uwx_get_sym_info: Gets symbolic info from current frame */
406/* uwx_get_sym_info: Gets symbolic info from current frame */
407/* (Will make a UWX_LKUP_SYMBOLS callback if info */
408/* was not provided by UWX_LKUP_LOOKUP callback) */
295
296int uwx_get_sym_info(
297 struct uwx_env *env,
298 char **modp,
299 char **symp,
300 uint64_t *offsetp)
301{
302 int status;
303 int cbstatus;
304 uint64_t ip;
305 uint64_t *uvec;
409
410int uwx_get_sym_info(
411 struct uwx_env *env,
412 char **modp,
413 char **symp,
414 uint64_t *offsetp)
415{
416 int status;
417 int cbstatus;
418 uint64_t ip;
419 uint64_t *uvec;
306 uint64_t uvecout[2];
420 uint64_t uvecout[UVECSIZE];
307 int i;
308
309 if (env == 0)
310 return UWX_ERR_NOENV;
311
312 /* If we haven't already obtained the frame info for the */
313 /* current frame, get it now. */
314

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

331 uvec = uvecout;
332 cbstatus = (*env->lookupip)(UWX_LKUP_SYMBOLS, ip, env->cb_token, &uvec);
333
334 if (cbstatus == UWX_LKUP_SYMINFO) {
335 for (i = 0; uvec[i] != UWX_KEY_END; i += 2) {
336 switch ((int)uvec[i]) {
337 case UWX_KEY_MODULE:
338 env->module_name =
421 int i;
422
423 if (env == 0)
424 return UWX_ERR_NOENV;
425
426 /* If we haven't already obtained the frame info for the */
427 /* current frame, get it now. */
428

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

445 uvec = uvecout;
446 cbstatus = (*env->lookupip)(UWX_LKUP_SYMBOLS, ip, env->cb_token, &uvec);
447
448 if (cbstatus == UWX_LKUP_SYMINFO) {
449 for (i = 0; uvec[i] != UWX_KEY_END; i += 2) {
450 switch ((int)uvec[i]) {
451 case UWX_KEY_MODULE:
452 env->module_name =
339 uwx_alloc_str(env, (char *)(uvec[i+1]));
453 uwx_alloc_str(env, (char *)(intptr_t)(uvec[i+1]));
340 break;
341 case UWX_KEY_FUNC:
342 env->function_name =
454 break;
455 case UWX_KEY_FUNC:
456 env->function_name =
343 uwx_alloc_str(env, (char *)(uvec[i+1]));
457 uwx_alloc_str(env, (char *)(intptr_t)(uvec[i+1]));
344 break;
345 case UWX_KEY_FUNCSTART:
346 env->function_offset = ip - uvec[i+1];
347 break;
348 }
349 }
350 (void) (*env->lookupip)(UWX_LKUP_FREE, 0, env->cb_token, &uvec);
351 }

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

567 return status;
568
569 for (i = 0; uvec[i] != UWX_KEY_END; i += 2) {
570 switch ((int)uvec[i]) {
571 case UWX_KEY_CONTEXT:
572 env->abi_context = (int)(uvec[i+1]);
573 status = UWX_ABI_FRAME;
574 break;
458 break;
459 case UWX_KEY_FUNCSTART:
460 env->function_offset = ip - uvec[i+1];
461 break;
462 }
463 }
464 (void) (*env->lookupip)(UWX_LKUP_FREE, 0, env->cb_token, &uvec);
465 }

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

681 return status;
682
683 for (i = 0; uvec[i] != UWX_KEY_END; i += 2) {
684 switch ((int)uvec[i]) {
685 case UWX_KEY_CONTEXT:
686 env->abi_context = (int)(uvec[i+1]);
687 status = UWX_ABI_FRAME;
688 break;
689 case UWX_KEY_GP:
690 uwx_set_reg(env, UWX_REG_GP, uvec[i+1]);
691 break;
575 case UWX_KEY_MODULE:
576 env->module_name =
692 case UWX_KEY_MODULE:
693 env->module_name =
577 uwx_alloc_str(env, (char *)(uvec[i+1]));
694 uwx_alloc_str(env, (char *)(intptr_t)(uvec[i+1]));
578 break;
579 case UWX_KEY_FUNC:
580 env->function_name =
695 break;
696 case UWX_KEY_FUNC:
697 env->function_name =
581 uwx_alloc_str(env, (char *)(uvec[i+1]));
698 uwx_alloc_str(env, (char *)(intptr_t)(uvec[i+1]));
582 break;
583 case UWX_KEY_FUNCSTART:
584 env->function_offset = env->remapped_ip - uvec[i+1];
585 break;
586 default:
587 return UWX_ERR_CANTUNWIND;
588 }
589 }
590 return status;
591}
592
593
594/* uwx_restore_reg: Restores a register according to the scoreboard */
595
596#define COPYIN_MSTACK_8(dest, src) \
597 (env->remote? \
598 (*env->copyin)(UWX_COPYIN_MSTACK, (dest), (src), \
599 DWORDSZ, env->cb_token) : \
699 break;
700 case UWX_KEY_FUNCSTART:
701 env->function_offset = env->remapped_ip - uvec[i+1];
702 break;
703 default:
704 return UWX_ERR_CANTUNWIND;
705 }
706 }
707 return status;
708}
709
710
711/* uwx_restore_reg: Restores a register according to the scoreboard */
712
713#define COPYIN_MSTACK_8(dest, src) \
714 (env->remote? \
715 (*env->copyin)(UWX_COPYIN_MSTACK, (dest), (src), \
716 DWORDSZ, env->cb_token) : \
600 (*(uint64_t *)(dest) = *(uint64_t *)(src), DWORDSZ) )
717 (*(uint64_t *)(intptr_t)(dest) = \
718 *(uint64_t *)(intptr_t)(src), DWORDSZ) )
601
602int uwx_restore_reg(struct uwx_env *env, uint64_t rstate,
603 uint64_t *valp, uint64_t *histp)
604{
605 int status;
606 uint64_t p;
607 int n;
608 int regid;

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

639 }
640 return status;
641}
642
643#define COPYIN_MSTACK_16(dest, src) \
644 (env->remote? \
645 (*env->copyin)(UWX_COPYIN_MSTACK, (dest), (src), \
646 2*DWORDSZ, env->cb_token) : \
719
720int uwx_restore_reg(struct uwx_env *env, uint64_t rstate,
721 uint64_t *valp, uint64_t *histp)
722{
723 int status;
724 uint64_t p;
725 int n;
726 int regid;

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

757 }
758 return status;
759}
760
761#define COPYIN_MSTACK_16(dest, src) \
762 (env->remote? \
763 (*env->copyin)(UWX_COPYIN_MSTACK, (dest), (src), \
764 2*DWORDSZ, env->cb_token) : \
647 (*(uint64_t *)(dest) = *(uint64_t *)(src), \
648 *(uint64_t *)((dest)+8) = *(uint64_t *)((src)+8), \
649 2*DWORDSZ) )
765 (*(uint64_t *)(intptr_t)(dest) = *(uint64_t *)(intptr_t)(src), \
766 *(uint64_t *)(intptr_t)((dest)+8) = \
767 *(uint64_t *)(intptr_t)((src)+8), \
768 2*DWORDSZ) )
650
651int uwx_restore_freg(struct uwx_env *env, uint64_t rstate,
652 uint64_t *valp, uint64_t *histp)
653{
654 int status;
655 uint64_t p;
656 int n;
657 int regid;

--- 55 unchanged lines hidden ---
769
770int uwx_restore_freg(struct uwx_env *env, uint64_t rstate,
771 uint64_t *valp, uint64_t *histp)
772{
773 int status;
774 uint64_t p;
775 int n;
776 int regid;

--- 55 unchanged lines hidden ---