2002-11-19 Andrew Cagney <ac131313@redhat.com>

* frame.h (FRAME_FP): Delete macro.
	(get_frame_base): New function declaration.
	* frame.c (get_frame_base): New function.
	(get_frame_id): Use ->frame.
	(frame_find_by_id): Rewrite to use get_frame_id.
	* blockframe.c: Use get_frame_base instead of FRAME_FP.
	* cris-tdep.c, d10v-tdep.c, findvar.c, h8500-tdep.c: Ditto.
	* hppa-tdep.c, i386-tdep.c, infcmd.c, infrun.c: Ditto.
	* m68hc11-tdep.c, m68k-tdep.c, mcore-tdep.c, mips-tdep.c: Ditto.
	* mn10200-tdep.c, mn10300-tdep.c, rs6000-tdep.c: Ditto.
	* sh-tdep.c, sparc-tdep.c, stack.c, tracepoint.c: Ditto.
	* v850-tdep.c, valops.c, z8k-tdep.c: Ditto.
This commit is contained in:
Andrew Cagney 2002-11-24 19:48:13 +00:00
parent e5d2af146b
commit c193f6ac9c
25 changed files with 128 additions and 73 deletions

View file

@ -1,3 +1,18 @@
2002-11-19 Andrew Cagney <ac131313@redhat.com>
* frame.h (FRAME_FP): Delete macro.
(get_frame_base): New function declaration.
* frame.c (get_frame_base): New function.
(get_frame_id): Use ->frame.
(frame_find_by_id): Rewrite to use get_frame_id.
* blockframe.c: Use get_frame_base instead of FRAME_FP.
* cris-tdep.c, d10v-tdep.c, findvar.c, h8500-tdep.c: Ditto.
* hppa-tdep.c, i386-tdep.c, infcmd.c, infrun.c: Ditto.
* m68hc11-tdep.c, m68k-tdep.c, mcore-tdep.c, mips-tdep.c: Ditto.
* mn10200-tdep.c, mn10300-tdep.c, rs6000-tdep.c: Ditto.
* sh-tdep.c, sparc-tdep.c, stack.c, tracepoint.c: Ditto.
* v850-tdep.c, valops.c, z8k-tdep.c: Ditto.
2002-11-24 Andrew Cagney <ac131313@redhat.com>
* arm-tdep.c (arm_gdbarch_init): Do not set get_saved_register.

View file

@ -681,29 +681,29 @@ cris_examine (CORE_ADDR ip, CORE_ADDR limit, struct frame_info *fi,
if (have_fp)
{
fi->saved_regs[FP_REGNUM] = FRAME_FP (fi);
fi->saved_regs[FP_REGNUM] = get_frame_base (fi);
/* Calculate the addresses. */
for (regno = regsave; regno >= 0; regno--)
{
fi->saved_regs[regno] = FRAME_FP (fi) - val;
fi->saved_regs[regno] = get_frame_base (fi) - val;
val -= 4;
}
if (fi->extra_info->leaf_function)
{
/* Set the register SP to contain the stack pointer of
the caller. */
fi->saved_regs[SP_REGNUM] = FRAME_FP (fi) + 4;
fi->saved_regs[SP_REGNUM] = get_frame_base (fi) + 4;
}
else
{
/* Set the register SP to contain the stack pointer of
the caller. */
fi->saved_regs[SP_REGNUM] = FRAME_FP (fi) + 8;
fi->saved_regs[SP_REGNUM] = get_frame_base (fi) + 8;
/* Set the register SRP to contain the return address of
the caller. */
fi->saved_regs[SRP_REGNUM] = FRAME_FP (fi) + 4;
fi->saved_regs[SRP_REGNUM] = get_frame_base (fi) + 4;
}
}
return ip;
@ -1260,7 +1260,7 @@ cris_frame_chain (struct frame_info *fi)
}
else if (!inside_entry_file (fi->pc))
{
return read_memory_unsigned_integer (FRAME_FP (fi), 4);
return read_memory_unsigned_integer (get_frame_base (fi), 4);
}
else
{

View file

@ -547,7 +547,7 @@ do_d10v_pop_frame (struct frame_info *fi)
int regnum;
char raw_buffer[8];
fp = FRAME_FP (fi);
fp = get_frame_base (fi);
/* fill out fsr with the address of where each */
/* register was stored in the frame */
d10v_frame_init_saved_regs (fi);

View file

@ -786,7 +786,7 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
for some good purpose. */
{
VALUE_LVAL (v) = lval_reg_frame_relative;
VALUE_FRAME (v) = FRAME_FP (frame);
VALUE_FRAME (v) = get_frame_base (frame);
VALUE_FRAME_REGNUM (v) = regnum;
}
else if (mem_stor)

View file

@ -47,7 +47,7 @@ get_frame_id (struct frame_info *fi, struct frame_id *id)
}
else
{
id->base = FRAME_FP (fi);
id->base = fi->frame;
id->pc = fi->pc;
}
}
@ -66,19 +66,21 @@ frame_find_by_id (struct frame_id id)
frame != NULL;
frame = get_prev_frame (frame))
{
if (INNER_THAN (FRAME_FP (frame), id.base))
struct frame_id this;
get_frame_id (frame, &this);
if (INNER_THAN (this.base, id.base))
/* ``inner/current < frame < id.base''. Keep looking along
the frame chain. */
continue;
if (INNER_THAN (id.base, FRAME_FP (frame)))
if (INNER_THAN (id.base, this.base))
/* ``inner/current < id.base < frame''. Oops, gone past it.
Just give up. */
return NULL;
/* FIXME: cagney/2002-04-21: This isn't sufficient. It should
use id.pc to check that the two frames belong to the same
function. Otherwise we'll do things like match dummy frames
or mis-match frameless functions. However, until someone
notices, stick with the existing behavour. */
use id.pc / this.pc to check that the two frames belong to
the same function. Otherwise we'll do things like match
dummy frames or mis-match frameless functions. However,
until someone notices, stick with the existing behavour. */
return frame;
}
return NULL;
@ -826,7 +828,7 @@ get_prev_frame (struct frame_info *next_frame)
/* FIXME: 2002-11-09: There isn't any reason to special case this
edge condition. Instead the per-architecture code should hande
it locally. */
address = FRAME_FP (next_frame);
address = get_frame_base (next_frame);
else
{
/* Two macros defined in tm.h specify the machine-dependent
@ -1018,6 +1020,14 @@ get_frame_pc (struct frame_info *frame)
return frame->pc;
}
/* Per "frame.h", return the ``address'' of the frame. Code should
really be using get_frame_id(). */
CORE_ADDR
get_frame_base (struct frame_info *fi)
{
return fi->frame;
}
/* Level of the selected frame: 0 for innermost, 1 for its caller, ...
or -1 for a NULL frame. */

View file

@ -85,6 +85,49 @@ extern struct frame_info *frame_find_by_id (struct frame_id id);
this frame. */
extern CORE_ADDR get_frame_pc (struct frame_info *);
/* Return the frame address from FI. Except in the machine-dependent
*FRAME* macros, a frame address has no defined meaning other than
as a magic cookie which identifies a frame over calls to the
inferior (um, SEE NOTE BELOW). The only known exception is
inferior.h (PC_IN_CALL_DUMMY) [ON_STACK]; see comments there. You
cannot assume that a frame address contains enough information to
reconstruct the frame; if you want more than just to identify the
frame (e.g. be able to fetch variables relative to that frame),
then save the whole struct frame_info (and the next struct
frame_info, since the latter is used for fetching variables on some
machines) (um, again SEE NOTE BELOW).
NOTE: cagney/2002-11-18: Actually, the frame address isn't
sufficient for identifying a frame, and the counter examples are
wrong!
Code that needs to (re)identify a frame must use get_frame_id() and
frame_find_by_id() (and in the future, a frame_compare() function
instead of INNER_THAN()). Two reasons: an architecture (e.g.,
ia64) can have more than one frame address (due to multiple stack
pointers) (frame ID is going to be expanded to accomodate this);
successive frameless function calls can only be differientated by
comparing both the frame's base and the frame's enclosing function
(frame_find_by_id() is going to be modified to perform this test).
The generic dummy frame version of PC_IN_CALL_DUMMY() is able to
identify a dummy frame using only the PC value. So the frame
address is not needed. In fact, most PC_IN_CALL_DUMMY() calls now
pass zero as the frame/sp values as the caller knows that those
values won't be used. Once all architectures are using generic
dummy frames, PC_IN_CALL_DUMMY() can drop the sp/frame parameters.
When it comes to finding a dummy frame, the next frame's frame ID
(with out duing an unwind) can be used (ok, could if it wasn't for
the need to change the way the PPC defined frame base in a strange
way).
Modern architectures should be using something like dwarf2's
location expression to describe where a variable lives. Such
expressions specify their own debug info centric frame address.
Consequently, a generic frame address is pretty meaningless. */
extern CORE_ADDR get_frame_base (struct frame_info *);
/* Return the per-frame unique identifer. Can be used to relocate a
frame after a frame cache flush (and other similar operations). */
extern void get_frame_id (struct frame_info *fi, struct frame_id *id);
@ -235,9 +278,10 @@ struct frame_saved_regs
struct frame_info
{
/* Nominal address of the frame described. See comments at FRAME_FP
about what this means outside the *FRAME* macros; in the *FRAME*
macros, it can mean whatever makes most sense for this machine. */
/* Nominal address of the frame described. See comments at
get_frame_base() about what this means outside the *FRAME*
macros; in the *FRAME* macros, it can mean whatever makes most
sense for this machine. */
CORE_ADDR frame;
/* Address at which execution is occurring in this frame.
@ -334,20 +378,6 @@ enum print_what
extern void *frame_obstack_alloc (unsigned long size);
extern void frame_saved_regs_zalloc (struct frame_info *);
/* Return the frame address from FI. Except in the machine-dependent
*FRAME* macros, a frame address has no defined meaning other than
as a magic cookie which identifies a frame over calls to the
inferior. The only known exception is inferior.h
(PC_IN_CALL_DUMMY) [ON_STACK]; see comments there. You cannot
assume that a frame address contains enough information to
reconstruct the frame; if you want more than just to identify the
frame (e.g. be able to fetch variables relative to that frame),
then save the whole struct frame_info (and the next struct
frame_info, since the latter is used for fetching variables on some
machines). */
#define FRAME_FP(fi) ((fi)->frame)
/* Define a default FRAME_CHAIN_VALID, in the form that is suitable for most
targets. If FRAME_CHAIN_VALID returns zero it means that the given frame
is the outermost one and has no caller.

View file

@ -117,7 +117,7 @@ CORE_ADDR
h8500_frame_chain (struct frame_info *thisframe)
{
if (!inside_entry_file (thisframe->pc))
return (read_memory_integer (FRAME_FP (thisframe), PTR_SIZE));
return (read_memory_integer (get_frame_base (thisframe), PTR_SIZE));
else
return 0;
}
@ -154,7 +154,7 @@ NEXT_PROLOGUE_INSN (CORE_ADDR addr, CORE_ADDR lim, char *pword1)
CORE_ADDR
frame_saved_pc (struct frame_info *frame)
{
return read_memory_integer (FRAME_FP (frame) + 2, PTR_SIZE);
return read_memory_integer (get_frame_base (frame) + 2, PTR_SIZE);
}
void

View file

@ -1532,7 +1532,7 @@ hppa_pop_frame (void)
struct frame_saved_regs fsr;
double freg_buffer;
fp = FRAME_FP (frame);
fp = get_frame_base (frame);
get_frame_saved_regs (frame, &fsr);
#ifndef NO_PC_SPACE_QUEUE_RESTORE

View file

@ -860,7 +860,7 @@ i386_do_pop_frame (struct frame_info *frame)
int regnum;
char regbuf[I386_MAX_REGISTER_SIZE];
fp = FRAME_FP (frame);
fp = get_frame_base (frame);
i386_frame_init_saved_regs (frame);
for (regnum = 0; regnum < NUM_REGS; regnum++)

View file

@ -618,7 +618,7 @@ step_1 (int skip_subroutines, int single_inst, char *count_string)
frame = get_current_frame ();
if (!frame) /* Avoid coredump here. Why tho? */
error ("No current frame");
step_frame_address = FRAME_FP (frame);
step_frame_address = get_frame_base (frame);
step_sp = read_sp ();
if (!single_inst)
@ -733,7 +733,7 @@ step_once (int skip_subroutines, int single_inst, int count)
frame = get_current_frame ();
if (!frame) /* Avoid coredump here. Why tho? */
error ("No current frame");
step_frame_address = FRAME_FP (frame);
step_frame_address = get_frame_base (frame);
step_sp = read_sp ();
if (!single_inst)
@ -1096,7 +1096,7 @@ until_next_command (int from_tty)
}
step_over_calls = STEP_OVER_ALL;
step_frame_address = FRAME_FP (frame);
step_frame_address = get_frame_base (frame);
step_sp = read_sp ();
step_multi = 0; /* Only one call to proceed */

View file

@ -2053,7 +2053,7 @@ handle_inferior_event (struct execution_control_state *ecs)
|| trap_expected
|| (!CALL_DUMMY_BREAKPOINT_OFFSET_P
&& PC_IN_CALL_DUMMY (stop_pc, read_sp (),
FRAME_FP (get_current_frame ())))
get_frame_base (get_current_frame ())))
|| (step_range_end && step_resume_breakpoint == NULL));
else
@ -2064,7 +2064,7 @@ handle_inferior_event (struct execution_control_state *ecs)
check here as well as above. */
|| (!CALL_DUMMY_BREAKPOINT_OFFSET_P
&& PC_IN_CALL_DUMMY (stop_pc, read_sp (),
FRAME_FP
get_frame_base
(get_current_frame
()))));
if (!ecs->random_signal)
@ -2255,7 +2255,7 @@ process_event_stop_test:
#if 0
/* FIXME - Need to implement nested temporary breakpoints */
if (step_over_calls
&& (INNER_THAN (FRAME_FP (get_current_frame ()),
&& (INNER_THAN (get_frame_base (get_current_frame ()),
step_frame_address)))
{
ecs->another_trap = 1;
@ -2466,7 +2466,7 @@ process_event_stop_test:
case she'd better know what she's doing. */
if (CALL_DUMMY_HAS_COMPLETED (stop_pc, read_sp (),
FRAME_FP (get_current_frame ()))
get_frame_base (get_current_frame ()))
&& !step_range_end)
{
stop_print_frame = 0;
@ -2567,7 +2567,7 @@ process_event_stop_test:
{
CORE_ADDR current_frame = FRAME_FP (get_current_frame ());
CORE_ADDR current_frame = get_frame_base (get_current_frame ());
if (INNER_THAN (current_frame, step_frame_address))
{
@ -2838,7 +2838,7 @@ process_event_stop_test:
}
step_range_start = ecs->sal.pc;
step_range_end = ecs->sal.end;
step_frame_address = FRAME_FP (get_current_frame ());
step_frame_address = get_frame_base (get_current_frame ());
ecs->current_line = ecs->sal.line;
ecs->current_symtab = ecs->sal.symtab;
@ -2846,7 +2846,7 @@ process_event_stop_test:
of a line of the caller, continue stepping, but step_frame_address
must be modified to current frame */
{
CORE_ADDR current_frame = FRAME_FP (get_current_frame ());
CORE_ADDR current_frame = get_frame_base (get_current_frame ());
if (!(INNER_THAN (current_frame, step_frame_address)))
step_frame_address = current_frame;
}
@ -3353,7 +3353,7 @@ normal_stop (void)
{
case PRINT_UNKNOWN:
if (stop_step
&& step_frame_address == FRAME_FP (get_current_frame ())
&& step_frame_address == get_frame_base (get_current_frame ())
&& step_start_function == find_pc_function (stop_pc))
source_flag = SRC_LINE; /* finished step, just print source line */
else

View file

@ -438,7 +438,7 @@ m68hc11_pop_frame (void)
generic_pop_dummy_frame ();
else
{
fp = FRAME_FP (frame);
fp = get_frame_base (frame);
FRAME_INIT_SAVED_REGS (frame);
/* Copy regs from where they were saved in the frame. */

View file

@ -472,7 +472,7 @@ m68k_pop_frame (void)
register int regnum;
char raw_buffer[12];
fp = FRAME_FP (frame);
fp = get_frame_base (frame);
m68k_frame_init_saved_regs (frame);
for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--)
{

View file

@ -810,7 +810,7 @@ mcore_pop_frame (void)
}
/* Actually cut back the stack. */
write_register (SP_REGNUM, FRAME_FP (fi));
write_register (SP_REGNUM, get_frame_base (fi));
}
/* Finally, throw away any cached frame information. */

View file

@ -3813,7 +3813,7 @@ mips_pop_frame (void)
{
register int regnum;
struct frame_info *frame = get_current_frame ();
CORE_ADDR new_sp = FRAME_FP (frame);
CORE_ADDR new_sp = get_frame_base (frame);
mips_extra_func_info_t proc_desc = frame->extra_info->proc_desc;
if (USE_GENERIC_DUMMY_FRAMES

View file

@ -703,7 +703,7 @@ mn10200_pop_frame (struct frame_info *frame)
}
/* Actually cut back the stack. */
write_register (SP_REGNUM, FRAME_FP (frame));
write_register (SP_REGNUM, get_frame_base (frame));
/* Don't we need to set the PC?!? XXX FIXME. */
}

View file

@ -738,7 +738,7 @@ mn10300_pop_frame_regular (struct frame_info *frame)
}
/* Actually cut back the stack. */
write_register (SP_REGNUM, FRAME_FP (frame));
write_register (SP_REGNUM, get_frame_base (frame));
/* Don't we need to set the PC?!? XXX FIXME. */
}

View file

@ -956,7 +956,7 @@ rs6000_pop_frame (void)
int ii, wordsize;
pc = read_pc ();
sp = FRAME_FP (frame);
sp = get_frame_base (frame);
if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
{
@ -1761,7 +1761,7 @@ rs6000_frame_chain (struct frame_info *thisframe)
&& FRAMELESS_FUNCTION_INVOCATION (thisframe))
/* A frameless function interrupted by a signal did not change the
frame pointer. */
fp = FRAME_FP (thisframe);
fp = get_frame_base (thisframe);
else
fp = read_memory_addr ((thisframe)->frame, wordsize);
return fp;

View file

@ -930,7 +930,7 @@ sh_frame_chain (struct frame_info *frame)
if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
return frame->frame; /* dummy frame same as caller's frame */
if (frame->pc && !inside_entry_file (frame->pc))
return read_memory_integer (FRAME_FP (frame) + frame->extra_info->f_offset, 4);
return read_memory_integer (get_frame_base (frame) + frame->extra_info->f_offset, 4);
else
return 0;
}
@ -975,7 +975,7 @@ sh64_frame_chain (struct frame_info *frame)
size = 4;
else
size = REGISTER_RAW_SIZE (translate_insn_rn (FP_REGNUM, media_mode));
return read_memory_integer (FRAME_FP (frame) + frame->extra_info->f_offset, size);
return read_memory_integer (get_frame_base (frame) + frame->extra_info->f_offset, size);
}
else
return 0;
@ -1912,7 +1912,7 @@ sh_pop_frame (void)
generic_pop_dummy_frame ();
else
{
fp = FRAME_FP (frame);
fp = get_frame_base (frame);
FRAME_INIT_SAVED_REGS (frame);
/* Copy regs from where they were saved in the frame */
@ -1942,7 +1942,7 @@ sh64_pop_frame (void)
generic_pop_dummy_frame ();
else
{
fp = FRAME_FP (frame);
fp = get_frame_base (frame);
FRAME_INIT_SAVED_REGS (frame);
/* Copy regs from where they were saved in the frame */

View file

@ -320,7 +320,7 @@ sparc_init_extra_frame_info (int fromleaf, struct frame_info *fi)
{
/* A frameless function interrupted by a signal did not change
the frame pointer, fix up frame pointer accordingly. */
fi->frame = FRAME_FP (fi->next);
fi->frame = get_frame_base (fi->next);
fi->extra_info->bottom = fi->next->extra_info->bottom;
}
else
@ -848,7 +848,7 @@ sparc_get_saved_register (char *raw_buffer, int *optimized, CORE_ADDR *addrp,
if (frame1->pc >= (frame1->extra_info->bottom ?
frame1->extra_info->bottom : read_sp ())
&& frame1->pc <= FRAME_FP (frame1))
&& frame1->pc <= get_frame_base (frame1))
{
/* Dummy frame. All but the window regs are in there somewhere.
The window registers are saved on the stack, just like in a
@ -1112,7 +1112,7 @@ static void
sparc_frame_find_saved_regs (struct frame_info *fi, CORE_ADDR *saved_regs_addr)
{
register int regnum;
CORE_ADDR frame_addr = FRAME_FP (fi);
CORE_ADDR frame_addr = get_frame_base (fi);
if (!fi)
internal_error (__FILE__, __LINE__,
@ -1122,7 +1122,7 @@ sparc_frame_find_saved_regs (struct frame_info *fi, CORE_ADDR *saved_regs_addr)
if (fi->pc >= (fi->extra_info->bottom ?
fi->extra_info->bottom : read_sp ())
&& fi->pc <= FRAME_FP (fi))
&& fi->pc <= get_frame_base (fi))
{
/* Dummy frame. All but the window regs are in there somewhere. */
for (regnum = G1_REGNUM; regnum < G1_REGNUM + 7; regnum++)
@ -1205,7 +1205,7 @@ sparc_frame_find_saved_regs (struct frame_info *fi, CORE_ADDR *saved_regs_addr)
}
/* Otherwise, whatever we would get from ptrace(GETREGS) is accurate */
/* FIXME -- should this adjust for the sparc64 offset? */
saved_regs_addr[SP_REGNUM] = FRAME_FP (fi);
saved_regs_addr[SP_REGNUM] = get_frame_base (fi);
}
/* Discard from the stack the innermost frame, restoring all saved registers.

View file

@ -1737,7 +1737,7 @@ return_command (char *retval_exp, int from_tty)
if (selected_frame == NULL)
error ("No selected frame.");
thisfun = get_frame_function (selected_frame);
selected_frame_addr = FRAME_FP (selected_frame);
selected_frame_addr = get_frame_base (selected_frame);
selected_frame_pc = selected_frame->pc;
/* Compute the return value (if any -- possibly getting errors here). */
@ -1799,7 +1799,7 @@ return_command (char *retval_exp, int from_tty)
/* If we are at the end of a call dummy now, pop the dummy frame too. */
if (CALL_DUMMY_HAS_COMPLETED (read_pc(), read_sp (),
FRAME_FP (get_current_frame ())))
get_frame_base (get_current_frame ())))
POP_FRAME;
/* If interactive, print the frame that is now current. */

View file

@ -1862,7 +1862,7 @@ finish_tfind_command (char *msg,
struct symbol *old_func;
char *reply;
old_frame_addr = FRAME_FP (get_current_frame ());
old_frame_addr = get_frame_base (get_current_frame ());
old_func = find_pc_function (read_pc ());
putpkt (msg);
@ -1948,8 +1948,8 @@ finish_tfind_command (char *msg,
if (old_func == find_pc_function (read_pc ()) &&
(old_frame_addr == 0 ||
FRAME_FP (get_current_frame ()) == 0 ||
old_frame_addr == FRAME_FP (get_current_frame ())))
get_frame_base (get_current_frame ()) == 0 ||
old_frame_addr == get_frame_base (get_current_frame ())))
source_only = -1;
else
source_only = 1;

View file

@ -895,7 +895,7 @@ v850_pop_frame (void)
read_memory_unsigned_integer (frame->saved_regs[regnum],
v850_register_raw_size (regnum)));
write_register (E_SP_REGNUM, FRAME_FP (frame));
write_register (E_SP_REGNUM, get_frame_base (frame));
}
flush_cached_frames ();

View file

@ -660,7 +660,7 @@ value_assign (struct value *toval, struct value *fromval)
else
{
for (frame = get_current_frame ();
frame && FRAME_FP (frame) != VALUE_FRAME (toval);
frame && get_frame_base (frame) != VALUE_FRAME (toval);
frame = get_prev_frame (frame))
;
value_reg = VALUE_FRAME_REGNUM (toval);

View file

@ -249,7 +249,7 @@ frame_find_saved_regs (struct frame_info *fip, struct frame_saved_regs *fsrp)
pc = skip_adjust (get_pc_function_start (fip->pc), &locals);
{
adr = FRAME_FP (fip) - locals;
adr = get_frame_base (fip) - locals;
for (i = 0; i < 8; i++)
{
int word = read_memory_short (pc);