| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#include "fns.h" |
| 23 |
#include "msg.h" |
| 24 |
#include "print.h" |
| 25 |
#include "stack.h" |
| 26 |
#include "commands.h" |
| 27 |
|
| 28 |
int i_stack_pos = 0; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
target_stack_node_t *p_stack = NULL; |
| 34 |
floc_stack_node_t *p_floc_stack = NULL; |
| 35 |
|
| 36 |
|
| 37 |
unsigned int dbg_stack_size() |
| 38 |
{ |
| 39 |
int i=0; |
| 40 |
|
| 41 |
if (p_stack_top) { |
| 42 |
for ( p_stack=p_stack_top; p_stack ; p_stack = p_stack->p_parent ) { |
| 43 |
i++; |
| 44 |
} |
| 45 |
return i; |
| 46 |
} else if (p_stack_floc_top) { |
| 47 |
|
| 48 |
for ( p_floc_stack=p_stack_floc_top; |
| 49 |
p_floc_stack ; p_floc_stack = p_floc_stack->p_parent ) { |
| 50 |
i++; |
| 51 |
} |
| 52 |
|
| 53 |
} |
| 54 |
return i; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
debug_return_t |
| 59 |
dbg_adjust_frame(int i_amount, int b_absolute) |
| 60 |
{ |
| 61 |
int i=0; |
| 62 |
int i_try_frame_pos; |
| 63 |
|
| 64 |
if (b_absolute) { |
| 65 |
if (i_amount < 0) |
| 66 |
i_try_frame_pos = dbg_stack_size() + i_amount; |
| 67 |
else |
| 68 |
i_try_frame_pos = i_amount; |
| 69 |
} else |
| 70 |
i_try_frame_pos = i_stack_pos + i_amount; |
| 71 |
|
| 72 |
if (i_try_frame_pos < 0) { |
| 73 |
dbg_errmsg(_("Moving target would go beyond bottom-most target position.")); |
| 74 |
return debug_cmd_error; |
| 75 |
} |
| 76 |
|
| 77 |
i = i_try_frame_pos + 1; |
| 78 |
|
| 79 |
if (p_stack_top) { |
| 80 |
for ( p_stack=p_stack_top; p_stack ; p_stack = p_stack->p_parent ) { |
| 81 |
i--; |
| 82 |
if (0 == i) |
| 83 |
break; |
| 84 |
} |
| 85 |
|
| 86 |
if (0 != i) { |
| 87 |
dbg_errmsg(_("Can't set frame to position %d; " |
| 88 |
"%d is the highest target position."), |
| 89 |
i_try_frame_pos, i_try_frame_pos - i); |
| 90 |
return debug_cmd_error; |
| 91 |
} |
| 92 |
|
| 93 |
i_stack_pos = i_try_frame_pos; |
| 94 |
p_target_loc = &(p_stack->p_target->floc); |
| 95 |
|
| 96 |
print_target_stack_entry(p_stack->p_target, i_stack_pos, i_stack_pos); |
| 97 |
print_debugger_location(p_stack->p_target, DEBUG_STACK_CHANGING, NULL); |
| 98 |
} else if (p_stack_floc_top) { |
| 99 |
|
| 100 |
for ( p_floc_stack=p_stack_floc_top; |
| 101 |
p_floc_stack ; p_floc_stack = p_floc_stack->p_parent ) { |
| 102 |
i--; |
| 103 |
if (0 == i) |
| 104 |
break; |
| 105 |
} |
| 106 |
|
| 107 |
if (0 != i) { |
| 108 |
dbg_errmsg(_("Can't set frame to position %d; " |
| 109 |
"%d is the highest target position."), |
| 110 |
i_try_frame_pos, i_try_frame_pos - i); |
| 111 |
return debug_cmd_error; |
| 112 |
} |
| 113 |
i_stack_pos = i_try_frame_pos; |
| 114 |
|
| 115 |
print_debugger_location(NULL, DEBUG_NOT_GIVEN, p_floc_stack); |
| 116 |
} |
| 117 |
|
| 118 |
return debug_readloop; |
| 119 |
} |
| 120 |
|