aboutsummaryrefslogtreecommitdiff
path: root/gdb/stack.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/stack.c')
-rw-r--r--gdb/stack.c124
1 files changed, 79 insertions, 45 deletions
diff --git a/gdb/stack.c b/gdb/stack.c
index 2dab0de..fa58963 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -461,7 +461,7 @@ print_frame (struct frame_info *fi,
stb = ui_out_stream_new (uiout);
old_chain = make_cleanup_ui_out_stream_delete (stb);
- func = find_pc_function (fi->pc);
+ func = find_pc_function (frame_address_in_block (fi));
if (func)
{
/* In certain pathological cases, the symtabs give the wrong
@@ -480,7 +480,7 @@ print_frame (struct frame_info *fi,
ever changed many parts of GDB will need to be changed (and we'll
create a find_pc_minimal_function or some such). */
- struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc);
+ struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (frame_address_in_block (fi));
if (msymbol != NULL
&& (SYMBOL_VALUE_ADDRESS (msymbol)
> BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
@@ -528,7 +528,7 @@ print_frame (struct frame_info *fi,
}
else
{
- struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc);
+ struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (frame_address_in_block (fi));
if (msymbol != NULL)
{
funname = SYMBOL_NAME (msymbol);
@@ -929,39 +929,84 @@ frame_info (char *addr_exp, int from_tty)
}
}
- FRAME_INIT_SAVED_REGS (fi);
- if (fi->saved_regs != NULL)
- {
- /* The sp is special; what's returned isn't the save address, but
- actually the value of the previous frame's sp. */
- printf_filtered (" Previous frame's sp is ");
- print_address_numeric (fi->saved_regs[SP_REGNUM], 1, gdb_stdout);
- printf_filtered ("\n");
- count = 0;
- numregs = NUM_REGS + NUM_PSEUDO_REGS;
- for (i = 0; i < numregs; i++)
- if (fi->saved_regs[i] && i != SP_REGNUM)
+ if (fi->saved_regs == NULL)
+ FRAME_INIT_SAVED_REGS (fi);
+ /* Print as much information as possible on the location of all the
+ registers. */
+ {
+ enum lval_type lval;
+ int optimized;
+ CORE_ADDR addr;
+ int realnum;
+ int count;
+ int i;
+ int need_nl = 1;
+
+ /* The sp is special; what's displayed isn't the save address, but
+ the value of the previous frame's sp. This is a legacy thing,
+ at one stage the frame cached the previous frame's SP instead
+ of its address, hence it was easiest to just display the cached
+ value. */
+ if (SP_REGNUM >= 0)
+ {
+ /* Find out the location of the saved stack pointer with out
+ actually evaluating it. */
+ frame_register_unwind (fi, SP_REGNUM, &optimized, &lval, &addr,
+ &realnum, NULL);
+ if (!optimized && lval == not_lval)
{
- if (count == 0)
- puts_filtered (" Saved registers:\n ");
- else
- puts_filtered (",");
- wrap_here (" ");
- printf_filtered (" %s at ", REGISTER_NAME (i));
- print_address_numeric (fi->saved_regs[i], 1, gdb_stdout);
- count++;
+ void *value = alloca (MAX_REGISTER_RAW_SIZE);
+ CORE_ADDR sp;
+ frame_register_unwind (fi, SP_REGNUM, &optimized, &lval, &addr,
+ &realnum, value);
+ sp = extract_address (value, REGISTER_RAW_SIZE (SP_REGNUM));
+ printf_filtered (" Previous frame's sp is ");
+ print_address_numeric (sp, 1, gdb_stdout);
+ printf_filtered ("\n");
+ need_nl = 0;
}
- if (count)
- puts_filtered ("\n");
- }
- else
- {
- /* We could get some information about saved registers by
- calling get_saved_register on each register. Which info goes
- with which frame is necessarily lost, however, and I suspect
- that the users don't care whether they get the info. */
+ else if (!optimized && lval == lval_memory)
+ {
+ printf_filtered (" Previous frame's sp at ");
+ print_address_numeric (addr, 1, gdb_stdout);
+ printf_filtered ("\n");
+ need_nl = 0;
+ }
+ else if (!optimized && lval == lval_register)
+ {
+ printf_filtered (" Previous frame's sp in %s\n",
+ REGISTER_NAME (realnum));
+ need_nl = 0;
+ }
+ /* else keep quiet. */
+ }
+
+ count = 0;
+ numregs = NUM_REGS + NUM_PSEUDO_REGS;
+ for (i = 0; i < numregs; i++)
+ if (i != SP_REGNUM)
+ {
+ /* Find out the location of the saved register without
+ fetching the corresponding value. */
+ frame_register_unwind (fi, i, &optimized, &lval, &addr, &realnum,
+ NULL);
+ /* For moment, only display registers that were saved on the
+ stack. */
+ if (!optimized && lval == lval_memory)
+ {
+ if (count == 0)
+ puts_filtered (" Saved registers:\n ");
+ else
+ puts_filtered (",");
+ wrap_here (" ");
+ printf_filtered (" %s at ", REGISTER_NAME (i));
+ print_address_numeric (addr, 1, gdb_stdout);
+ count++;
+ }
+ }
+ if (count || need_nl)
puts_filtered ("\n");
- }
+ }
}
#if 0
@@ -1066,7 +1111,7 @@ backtrace_command_1 (char *count_exp, int show_locals, int from_tty)
fi = get_prev_frame (fi))
{
QUIT;
- ps = find_pc_psymtab (fi->pc);
+ ps = find_pc_psymtab (frame_address_in_block (fi));
if (ps)
PSYMTAB_TO_SYMTAB (ps); /* Force syms to come in */
}
@@ -1500,17 +1545,6 @@ select_and_print_frame (struct frame_info *fi)
}
}
-
-/* Store the selected frame and its level into *FRAMEP and *LEVELP.
- If there is no selected frame, *FRAMEP is set to NULL. */
-
-void
-record_selected_frame (CORE_ADDR *frameaddrp, int *levelp)
-{
- *frameaddrp = selected_frame ? selected_frame->frame : 0;
- *levelp = frame_relative_level (selected_frame);
-}
-
/* Return the symbol-block in which the selected frame is executing.
Can return zero under various legitimate circumstances.