CARP: Mechanism to replace EXTRA_FRAME_INFO.

Add two pointers (saved_regs, extra_info) to struct frame_info.
Introduce new macro FRAME_INIT_SAVED_REGS which replaces
FRAME_FIND_SAVED_REGS.

Document.

Use in mn10300 and rs6000 targets. Fix side effects on ALPHA, MIPS,
Z8K and SPARC targets.
This commit is contained in:
Andrew Cagney 1998-12-12 02:50:39 +00:00
parent 7381ab4534
commit 86a51f415d
16 changed files with 269 additions and 237 deletions

View file

@ -1,3 +1,61 @@
Sat Dec 12 09:28:13 1998 Andrew Cagney <cagney@b1.cygnus.com>
* frame.h (struct frame_info): Add CORE_ADDR *saved_regs and
struct frame_extra_info *extra_info.
(frame_obstack_alloc, frame_saved_regs_zalloc): Prototype.
(SIZEOF_FRAME_SAVED_REGS): Provide default.
(FRAME_INIT_SAVED_REGS): Provide default.
(struct frame_saved_regs): Deprecate.
(EXTRA_FRAME_INFO): Deprecate.
* blockframe.c (frame_obstack_alloc, frame_saved_regs_zalloc): New
function.
(generic_get_saved_register): Use FRAME_INIT_SAVED_REGS and
frame->saved_regs.
(frame_cache_obstack): Make static.
(get_frame_saved_regs): Deprecate. Copy the saved regs into the
frame buffer.
* stack.c (frame_info): Rewrite using frame->saved_regs and
FRAME_INIT_SAVED_REGS.
* findvar.c (find_saved_register): Ditto.
* config/mn10300/tm-mn10300.h (EXTRA_FRAME_INFO): Delete.
(FRAME_FIND_SAVED_REGS): Replace with FRAME_INIT_SAVED_REGS. No-op.
* mn10300-tdep.c: Update.
(analyze_dummy_frame): New function.
(struct frame_extra_info): Define.
(mn10300_init_extra_frame_info): Update.
* config/rs6000/tm-rs6000.h: (EXTRA_FRAME_INFO): Delete.
(FRAME_FIND_SAVED_REGS): Replace with FRAME_INIT_SAVED_REGS.
(FRAME_ARGS_ADDRESS): Replace with function.
* rs6000-tdep.c (frame_get_saved_regs): Rename from
frame_get_cache_fsr.
(rs6000_init_extra_frame_info): New function.
(rs6000_frame_init_saved_regs): Call frame_get_saved_regs.
(FUNCTION_START_OFFSET): Delete references, was ZERO.
(rs6000_frame_args_address): New function.
(frame_initial_stack_address): Update
* config/mips/tm-mips.h (EXTRA_FRAME_INFO): Remove saved_regs.
(FRAME_INIT_SAVED_REGS): Rename FRAME_FIND_SAVED_REGS, update.
* mips-tdep.c (mips_find_saved_regs, read_next_frame_reg,
init_extra_frame_info, mips_pop_frame): Update.
* config/alpha/tm-alpha.h (FRAME_INIT_SAVED_REGS,
EXTRA_FRAME_INFO), alpha-tdep.c (alpha_find_saved_regs,
alpha_pop_frame, init_extra_frame_info): Ditto.
* i960-tdep.c, m88k-tdep.c, h8300-tdep.c: Update.
* config/sparc/tm-sparc.h, config/a29k/tm-a29k.h: Define
FRAME_INIT_SAVED_REGS as no-op.
* z8k-tdep.c (z8k_init_frame_saved_regs): Rename
get_frame_saved_regs.
(examine_frame, z8k_skip_prologue): Update.
* config/z8k/tm-z8k.h (FRAME_INIT_SAVED_REGS): Define.
1998-12-11 Fernando Nasser <fnasser@totem.to.cygnus.com> 1998-12-11 Fernando Nasser <fnasser@totem.to.cygnus.com>
From J.T. Conklin <jtc@redbacknetworks.com>: From J.T. Conklin <jtc@redbacknetworks.com>:
@ -32,8 +90,8 @@ Fri Dec 11 09:52:04 1998 Andrew Cagney <cagney@chook>
* gdbtk-cmds.c, mipsm3-nat.c, hppah-nat.c, infptrace.c, * gdbtk-cmds.c, mipsm3-nat.c, hppah-nat.c, infptrace.c,
i386gnu-nat.c, hppab-nat.c, core-aout.c, arm-xdep.c, alpha-nat.c, i386gnu-nat.c, hppab-nat.c, core-aout.c, arm-xdep.c, alpha-nat.c,
altos-xdep.c, pyr-xdep.c, remote-st.c, remote-os9k.c, altos-xdep.c, pyr-xdep.c, remote-st.c, remote-os9k.c,
tahoe-tdep.c, pyr-tdep.c, v850ice.c, vax-tdep.c: Replace reg_name tahoe-tdep.c, pyr-tdep.c, vax-tdep.c: Replace reg_name with
with REGISTER_NAME. REGISTER_NAME.
Thu Dec 10 15:19:40 1998 David Taylor <taylor@texas.cygnus.com> Thu Dec 10 15:19:40 1998 David Taylor <taylor@texas.cygnus.com>
@ -322,8 +380,8 @@ Fri Nov 27 11:00:25 1998 Andrew Cagney <cagney@chook>
start-sanitize-sky start-sanitize-sky
* config/mips/tm-txvu.h (STEP_SKIPS_DELAY), txvu-tdep.c * config/mips/tm-txvu.h (STEP_SKIPS_DELAY), txvu-tdep.c
(txvu_step_skips_delay): Change macro to function. (txvu_step_skips_delay): Change macro to function.
end-sanitize-sky
end-sanitize-sky
Thu Nov 26 11:19:15 1998 Andrew Cagney <cagney@amy.cygnus.com> Thu Nov 26 11:19:15 1998 Andrew Cagney <cagney@amy.cygnus.com>
* config/alpha/tm-alpha.h (ABOUT_TO_RETURN): Replace macro. * config/alpha/tm-alpha.h (ABOUT_TO_RETURN): Replace macro.

View file

@ -31,10 +31,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* FIXME: Some of this code should perhaps be merged with mips-tdep.c. */ /* FIXME: Some of this code should perhaps be merged with mips-tdep.c. */
/* FIXME: Put this declaration in frame.h. */
extern struct obstack frame_cache_obstack;
/* Prototypes for local functions. */ /* Prototypes for local functions. */
static alpha_extra_func_info_t push_sigtramp_desc PARAMS ((CORE_ADDR low_addr)); static alpha_extra_func_info_t push_sigtramp_desc PARAMS ((CORE_ADDR low_addr));
@ -254,9 +250,7 @@ alpha_find_saved_regs (frame)
alpha_extra_func_info_t proc_desc; alpha_extra_func_info_t proc_desc;
int returnreg; int returnreg;
frame->saved_regs = (struct frame_saved_regs *) frame_saved_regs_zalloc (frame);
obstack_alloc (&frame_cache_obstack, sizeof(struct frame_saved_regs));
memset (frame->saved_regs, 0, sizeof (struct frame_saved_regs));
/* If it is the frame for __sigtramp, the saved registers are located /* If it is the frame for __sigtramp, the saved registers are located
in a sigcontext structure somewhere on the stack. __sigtramp in a sigcontext structure somewhere on the stack. __sigtramp
@ -276,14 +270,14 @@ alpha_find_saved_regs (frame)
for (ireg = 0; ireg < 32; ireg++) for (ireg = 0; ireg < 32; ireg++)
{ {
reg_position = sigcontext_addr + SIGFRAME_REGSAVE_OFF + ireg * 8; reg_position = sigcontext_addr + SIGFRAME_REGSAVE_OFF + ireg * 8;
frame->saved_regs->regs[ireg] = reg_position; frame->saved_regs[ireg] = reg_position;
} }
for (ireg = 0; ireg < 32; ireg++) for (ireg = 0; ireg < 32; ireg++)
{ {
reg_position = sigcontext_addr + SIGFRAME_FPREGSAVE_OFF + ireg * 8; reg_position = sigcontext_addr + SIGFRAME_FPREGSAVE_OFF + ireg * 8;
frame->saved_regs->regs[FP0_REGNUM + ireg] = reg_position; frame->saved_regs[FP0_REGNUM + ireg] = reg_position;
} }
frame->saved_regs->regs[PC_REGNUM] = sigcontext_addr + SIGFRAME_PC_OFF; frame->saved_regs[PC_REGNUM] = sigcontext_addr + SIGFRAME_PC_OFF;
return; return;
} }
@ -306,7 +300,7 @@ alpha_find_saved_regs (frame)
register number. */ register number. */
if (mask & (1 << returnreg)) if (mask & (1 << returnreg))
{ {
frame->saved_regs->regs[returnreg] = reg_position; frame->saved_regs[returnreg] = reg_position;
reg_position += 8; reg_position += 8;
mask &= ~(1 << returnreg); /* Clear bit for RA so we mask &= ~(1 << returnreg); /* Clear bit for RA so we
don't save again later. */ don't save again later. */
@ -315,7 +309,7 @@ alpha_find_saved_regs (frame)
for (ireg = 0; ireg <= 31 ; ++ireg) for (ireg = 0; ireg <= 31 ; ++ireg)
if (mask & (1 << ireg)) if (mask & (1 << ireg))
{ {
frame->saved_regs->regs[ireg] = reg_position; frame->saved_regs[ireg] = reg_position;
reg_position += 8; reg_position += 8;
} }
@ -328,11 +322,11 @@ alpha_find_saved_regs (frame)
for (ireg = 0; ireg <= 31 ; ++ireg) for (ireg = 0; ireg <= 31 ; ++ireg)
if (mask & (1 << ireg)) if (mask & (1 << ireg))
{ {
frame->saved_regs->regs[FP0_REGNUM+ireg] = reg_position; frame->saved_regs[FP0_REGNUM+ireg] = reg_position;
reg_position += 8; reg_position += 8;
} }
frame->saved_regs->regs[PC_REGNUM] = frame->saved_regs->regs[returnreg]; frame->saved_regs[PC_REGNUM] = frame->saved_regs[returnreg];
} }
static CORE_ADDR static CORE_ADDR
@ -350,8 +344,8 @@ read_next_frame_reg(fi, regno)
{ {
if (fi->saved_regs == NULL) if (fi->saved_regs == NULL)
alpha_find_saved_regs (fi); alpha_find_saved_regs (fi);
if (fi->saved_regs->regs[regno]) if (fi->saved_regs[regno])
return read_memory_integer(fi->saved_regs->regs[regno], 8); return read_memory_integer(fi->saved_regs[regno], 8);
} }
} }
return read_register(regno); return read_register(regno);
@ -855,12 +849,11 @@ init_extra_frame_info (frame)
(CORE_ADDR *)NULL,(CORE_ADDR *)NULL); (CORE_ADDR *)NULL,(CORE_ADDR *)NULL);
if (!IN_SIGTRAMP (frame->pc, name)) if (!IN_SIGTRAMP (frame->pc, name))
{ {
frame->saved_regs = (struct frame_saved_regs*) frame->saved_regs = (CORE_ADDR*)
obstack_alloc (&frame_cache_obstack, frame_obstack_alloc (SIZEOF_FRAME_SAVED_REGS);
sizeof (struct frame_saved_regs)); memcpy (frame->saved_regs, temp_saved_regs.regs, SIZEOF_FRAME_SAVED_REGS);
*frame->saved_regs = temp_saved_regs; frame->saved_regs[PC_REGNUM]
frame->saved_regs->regs[PC_REGNUM] = frame->saved_regs[RA_REGNUM];
= frame->saved_regs->regs[RA_REGNUM];
} }
} }
} }
@ -1116,12 +1109,12 @@ alpha_pop_frame()
for (regnum = 32; --regnum >= 0; ) for (regnum = 32; --regnum >= 0; )
if (PROC_REG_MASK(proc_desc) & (1 << regnum)) if (PROC_REG_MASK(proc_desc) & (1 << regnum))
write_register (regnum, write_register (regnum,
read_memory_integer (frame->saved_regs->regs[regnum], read_memory_integer (frame->saved_regs[regnum],
8)); 8));
for (regnum = 32; --regnum >= 0; ) for (regnum = 32; --regnum >= 0; )
if (PROC_FREG_MASK(proc_desc) & (1 << regnum)) if (PROC_FREG_MASK(proc_desc) & (1 << regnum))
write_register (regnum + FP0_REGNUM, write_register (regnum + FP0_REGNUM,
read_memory_integer (frame->saved_regs->regs[regnum + FP0_REGNUM], 8)); read_memory_integer (frame->saved_regs[regnum + FP0_REGNUM], 8));
} }
write_register (SP_REGNUM, new_sp); write_register (SP_REGNUM, new_sp);
flush_cached_frames (); flush_cached_frames ();

View file

@ -415,6 +415,8 @@ extern use_struct_convention_fn a29k_use_struct_convention;
void read_register_stack (); void read_register_stack ();
long read_register_stack_integer (); long read_register_stack_integer ();
#define FRAME_INIT_SAVED_REGS(fi) /*no-op*/
#define EXTRA_FRAME_INFO \ #define EXTRA_FRAME_INFO \
CORE_ADDR saved_msp; \ CORE_ADDR saved_msp; \
unsigned int rsize; \ unsigned int rsize; \

View file

@ -380,12 +380,11 @@ extern int mips_frame_num_args PARAMS ((struct frame_info *));
ways in the stack frame. sp is even more special: ways in the stack frame. sp is even more special:
the address we return for it IS the sp for the next frame. */ the address we return for it IS the sp for the next frame. */
#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ #define FRAME_INIT_SAVED_REGS(frame_info) \
do { \ do { \
if ((frame_info)->saved_regs == NULL) \ if ((frame_info)->saved_regs == NULL) \
mips_find_saved_regs (frame_info); \ mips_find_saved_regs (frame_info); \
(frame_saved_regs) = *(frame_info)->saved_regs; \ (frame_info)->saved_regs[SP_REGNUM] = (frame_info)->frame; \
(frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame; \
} while (0) } while (0)
extern void mips_find_saved_regs PARAMS ((struct frame_info *)); extern void mips_find_saved_regs PARAMS ((struct frame_info *));
@ -455,8 +454,7 @@ typedef struct mips_extra_func_info {
#define EXTRA_FRAME_INFO \ #define EXTRA_FRAME_INFO \
mips_extra_func_info_t proc_desc; \ mips_extra_func_info_t proc_desc; \
int num_args;\ int num_args;
struct frame_saved_regs *saved_regs;
#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci) #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci)
extern void init_extra_frame_info PARAMS ((struct frame_info *)); extern void init_extra_frame_info PARAMS ((struct frame_info *));

View file

@ -73,20 +73,15 @@ extern breakpoint_from_pc_fn mn10300_breakpoint_from_pc;
#ifdef __STDC__ #ifdef __STDC__
struct frame_info; struct frame_info;
struct frame_saved_regs;
struct type; struct type;
struct value; struct value;
#endif #endif
#define EXTRA_FRAME_INFO struct frame_saved_regs fsr; int status; int stack_size;
extern void mn10300_init_extra_frame_info PARAMS ((struct frame_info *)); extern void mn10300_init_extra_frame_info PARAMS ((struct frame_info *));
#define INIT_EXTRA_FRAME_INFO(fromleaf, fi) mn10300_init_extra_frame_info (fi) #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) mn10300_init_extra_frame_info (fi)
#define INIT_FRAME_PC /* Not necessary */ #define INIT_FRAME_PC /* Not necessary */
extern void mn10300_frame_find_saved_regs PARAMS ((struct frame_info *, #define FRAME_INIT_SAVED_REGS(fi) /* handled by init_extra_frame_info */
struct frame_saved_regs *));
#define FRAME_FIND_SAVED_REGS(fi, regaddr) regaddr = fi->fsr
extern CORE_ADDR mn10300_frame_chain PARAMS ((struct frame_info *)); extern CORE_ADDR mn10300_frame_chain PARAMS ((struct frame_info *));
#define FRAME_CHAIN(fi) mn10300_frame_chain (fi) #define FRAME_CHAIN(fi) mn10300_frame_chain (fi)

View file

@ -388,31 +388,12 @@ CORE_ADDR rs6000_frame_chain PARAMS ((struct frame_info *));
extern int frameless_function_invocation PARAMS((struct frame_info *)); extern int frameless_function_invocation PARAMS((struct frame_info *));
/* Functions calling alloca() change the value of the stack pointer. We
need to use initial stack pointer (which is saved in r31 by gcc) in
such cases. If a compiler emits traceback table, then we should use the
alloca register specified in traceback table. FIXME. */
/* Also, it is a good idea to cache information about frame's saved registers
in the frame structure to speed things up. See tm-m88k.h. FIXME. */
#define EXTRA_FRAME_INFO \
CORE_ADDR initial_sp; /* initial stack pointer. */ \
struct frame_saved_regs *cache_fsr; /* saved registers */
#define INIT_FRAME_PC_FIRST(fromleaf, prev) \ #define INIT_FRAME_PC_FIRST(fromleaf, prev) \
prev->pc = (fromleaf ? SAVED_PC_AFTER_CALL (prev->next) : \ prev->pc = (fromleaf ? SAVED_PC_AFTER_CALL (prev->next) : \
prev->next ? FRAME_SAVED_PC (prev->next) : read_pc ()); prev->next ? FRAME_SAVED_PC (prev->next) : read_pc ());
#define INIT_FRAME_PC(fromleaf, prev) /* nothing */ #define INIT_FRAME_PC(fromleaf, prev) /* nothing */
#define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \ extern void rs6000_init_extra_frame_info (int fromleaf, struct frame_info *);
fi->initial_sp = 0; \ #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) rs6000_init_extra_frame_info (fromleaf, fi)
fi->cache_fsr = 0; \
if (fi->next != (CORE_ADDR)0 \
&& fi->pc < TEXT_SEGMENT_BASE) \
/* We're in get_prev_frame_info */ \
/* and this is a special signal frame. */ \
/* (fi->pc will be some low address in the kernel, */ \
/* to which the signal handler returns). */ \
fi->signal_handler_caller = 1;
/* If the kernel has to deliver a signal, it pushes a sigcontext /* If the kernel has to deliver a signal, it pushes a sigcontext
structure on the stack and then calls the signal handler, passing structure on the stack and then calls the signal handler, passing
@ -433,11 +414,8 @@ extern int frameless_function_invocation PARAMS((struct frame_info *));
extern unsigned long frame_saved_pc PARAMS ((struct frame_info *)); extern unsigned long frame_saved_pc PARAMS ((struct frame_info *));
#define FRAME_ARGS_ADDRESS(FI) \ extern CORE_ADDR rs6000_frame_args_address PARAMS ((struct frame_info *));
(((struct frame_info*)(FI))->initial_sp ? \ #define FRAME_ARGS_ADDRESS(FI) rs6000_frame_args_address (FI)
((struct frame_info*)(FI))->initial_sp : \
frame_initial_stack_address (FI))
extern CORE_ADDR frame_initial_stack_address PARAMS ((struct frame_info *));
#define FRAME_LOCALS_ADDRESS(FI) FRAME_ARGS_ADDRESS(FI) #define FRAME_LOCALS_ADDRESS(FI) FRAME_ARGS_ADDRESS(FI)
@ -463,66 +441,9 @@ extern CORE_ADDR frame_initial_stack_address PARAMS ((struct frame_info *));
not sure if it will be needed. The following macro takes care of gpr's not sure if it will be needed. The following macro takes care of gpr's
and fpr's only. */ and fpr's only. */
#define FRAME_FIND_SAVED_REGS(FRAME_INFO, FRAME_SAVED_REGS) \ extern void rs6000_frame_init_saved_regs PARAMS ((struct frame_info *));
{ \ #define FRAME_INIT_SAVED_REGS(FI) rs6000_frame_init_saved_regs (FI)
int ii; \
CORE_ADDR frame_addr, func_start; \
struct rs6000_framedata fdata; \
\
/* find the start of the function and collect info about its frame. */ \
\
func_start = get_pc_function_start ((FRAME_INFO)->pc) + FUNCTION_START_OFFSET; \
(void) skip_prologue (func_start, &fdata); \
memset (&(FRAME_SAVED_REGS), '\0', sizeof (FRAME_SAVED_REGS)); \
\
/* if there were any saved registers, figure out parent's stack pointer. */ \
/* the following is true only if the frame doesn't have a call to alloca(), \
FIXME. */ \
if (fdata.saved_fpr == 0 && fdata.saved_gpr == 0 && \
fdata.lr_offset == 0 && fdata.cr_offset == 0) { \
frame_addr = 0; \
\
} else if ((FRAME_INFO)->prev && (FRAME_INFO)->prev->frame) { \
frame_addr = (FRAME_INFO)->prev->frame; \
\
} else { \
frame_addr = read_memory_integer ((FRAME_INFO)->frame, 4); \
} \
\
/* if != -1, fdata.saved_fpr is the smallest number of saved_fpr. All \
fpr's from saved_fpr to f31 are saved. */ \
if (fdata.saved_fpr >= 0) { \
int fpr_offset = frame_addr + fdata.fpr_offset; \
for (ii = fdata.saved_fpr; ii < 32; ii++) { \
(FRAME_SAVED_REGS).regs [FP0_REGNUM + ii] = fpr_offset; \
fpr_offset += 8; \
} \
} \
\
/* if != -1, fdata.saved_gpr is the smallest number of saved_gpr. All \
gpr's from saved_gpr to r31 are saved. */ \
if (fdata.saved_gpr >= 0) { \
int gpr_offset = frame_addr + fdata.gpr_offset; \
for (ii = fdata.saved_gpr; ii < 32; ii++) { \
(FRAME_SAVED_REGS).regs [ii] = gpr_offset; \
gpr_offset += 4; \
} \
} \
\
/* If != 0, fdata.cr_offset is the offset from the frame that holds \
the CR */ \
if (fdata.cr_offset != 0) { \
(FRAME_SAVED_REGS).regs [CR_REGNUM] = frame_addr + fdata.cr_offset; \
} \
\
/* If != 0, fdata.cr_offset is the offset from the frame that holds \
the LR */ \
if (fdata.lr_offset != 0) { \
(FRAME_SAVED_REGS).regs [LR_REGNUM] = frame_addr + fdata.lr_offset; \
} \
}
/* Things needed for making the inferior call functions. */ /* Things needed for making the inferior call functions. */
/* Push an empty stack frame, to record the current PC, etc. */ /* Push an empty stack frame, to record the current PC, etc. */

View file

@ -330,6 +330,8 @@ sparc_extract_struct_value_address PARAMS ((char [REGISTER_BYTES]));
/* time of the register saves. */ \ /* time of the register saves. */ \
int sp_offset; int sp_offset;
#define FRAME_INIT_SAVED_REGS(fp) /*no-op*/
#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) \ #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) \
sparc_init_extra_frame_info (fromleaf, fci) sparc_init_extra_frame_info (fromleaf, fci)
extern void sparc_init_extra_frame_info PARAMS((int, struct frame_info *)); extern void sparc_init_extra_frame_info PARAMS((int, struct frame_info *));

View file

@ -197,6 +197,11 @@ extern CORE_ADDR mz8k_skip_prologue PARAMS ((CORE_ADDR ip));
#define FRAME_ARGS_SKIP 8 #define FRAME_ARGS_SKIP 8
#ifdef __STDC__
struct frame_info;
#endif
extern void z8k_frame_init_saved_regs PARAMS ((struct frame_info *));
#define FRAME_INIT_SAVED_REGS(fi) z8k_frame_init_saved_regs (fi)
/* Things needed for making the inferior call functions. /* Things needed for making the inferior call functions.

View file

@ -1,3 +1,7 @@
Thu Dec 10 16:07:09 1998 Andrew Cagney <cagney@b1.cygnus.com>
* gdbint.texinfo (FRAME_FIND_SAVED_REGS): Document.
Wed Dec 9 21:13:57 1998 Andrew Cagney <cagney@chook> Wed Dec 9 21:13:57 1998 Andrew Cagney <cagney@chook>
* gdbint.texinfo (REGISTER_NAME): Replace REGISTER_NAMES. * gdbint.texinfo (REGISTER_NAME): Replace REGISTER_NAMES.

View file

@ -1288,10 +1288,6 @@ register state, the address in which a function should return its
structure value, as a CORE_ADDR (or an expression that can be used as structure value, as a CORE_ADDR (or an expression that can be used as
one). one).
@item EXTRA_FRAME_INFO
If defined, this must be a list of slots that may be inserted into the
@code{frame_info} structure defined in @code{frame.h}.
@item FLOAT_INFO @item FLOAT_INFO
If defined, then the `info float' command will print information about If defined, then the `info float' command will print information about
the processor's floating point unit. the processor's floating point unit.
@ -1326,8 +1322,14 @@ is not inside the startup file (such as @file{crt0.o}).
nonzero and the given frame's PC is not in @code{main()} or a known nonzero and the given frame's PC is not in @code{main()} or a known
entry point function (such as @code{_start()}). entry point function (such as @code{_start()}).
@item FRAME_FIND_SAVED_REGS @item FRAME_INIT_SAVED_REGS(frame)
stack.c See @file{frame.h}. Determines the address of all registers in the
current stack frame storing each in @code{frame->saved_regs}. Space for
@code{frame->saved_regs} shall be allocated by
@code{FRAME_INIT_SAVED_REGS} using either
@code{frame_saved_regs_zalloc} or @code{frame_obstack_alloc}.
@var{FRAME_FIND_SAVED_REGS} and @var{EXTRA_FRAME_INFO} are deprecated.
@item FRAME_NUM_ARGS (val, fi) @item FRAME_NUM_ARGS (val, fi)
For the frame described by @var{fi}, set @var{val} to the number of arguments For the frame described by @var{fi}, set @var{val} to the number of arguments
@ -1390,9 +1392,10 @@ repenting at leisure.
@item IEEE_FLOAT @item IEEE_FLOAT
Define this if the target system uses IEEE-format floating point numbers. Define this if the target system uses IEEE-format floating point numbers.
@item INIT_EXTRA_FRAME_INFO (fromleaf, fci) @item INIT_EXTRA_FRAME_INFO (fromleaf, frame)
If defined, this should be a C expression or statement that fills in the If additional information about the frame is required this should be
@code{EXTRA_FRAME_INFO} slots of the given frame @var{fci}. stored in @code{frame->extra_info}. Space for @code{frame->extra_info}
is allocated using @code{frame_obstack_alloc}.
@item INIT_FRAME_PC (fromleaf, prev) @item INIT_FRAME_PC (fromleaf, prev)
This is a C statement that sets the pc of the frame pointed to by This is a C statement that sets the pc of the frame pointed to by

View file

@ -169,8 +169,8 @@ h8300_frame_chain (thisframe)
ways in the stack frame. sp is even more special: ways in the stack frame. sp is even more special:
the address we return for it IS the sp for the next frame. the address we return for it IS the sp for the next frame.
We cache the result of doing this in the frame_cache_obstack, since We cache the result of doing this in the frame_obstack, since it is
it is fairly expensive. */ fairly expensive. */
void void
h8300_frame_find_saved_regs (fi, fsr) h8300_frame_find_saved_regs (fi, fsr)
@ -178,7 +178,6 @@ h8300_frame_find_saved_regs (fi, fsr)
struct frame_saved_regs *fsr; struct frame_saved_regs *fsr;
{ {
register struct frame_saved_regs *cache_fsr; register struct frame_saved_regs *cache_fsr;
extern struct obstack frame_cache_obstack;
CORE_ADDR ip; CORE_ADDR ip;
struct symtab_and_line sal; struct symtab_and_line sal;
CORE_ADDR limit; CORE_ADDR limit;
@ -186,8 +185,7 @@ h8300_frame_find_saved_regs (fi, fsr)
if (!fi->fsr) if (!fi->fsr)
{ {
cache_fsr = (struct frame_saved_regs *) cache_fsr = (struct frame_saved_regs *)
obstack_alloc (&frame_cache_obstack, frame_obstack_alloc (sizeof (struct frame_saved_regs));
sizeof (struct frame_saved_regs));
memset (cache_fsr, '\0', sizeof (struct frame_saved_regs)); memset (cache_fsr, '\0', sizeof (struct frame_saved_regs));
fi->fsr = cache_fsr; fi->fsr = cache_fsr;

View file

@ -331,8 +331,8 @@ skip_prologue (ip)
ways in the stack frame. sp is even more special: ways in the stack frame. sp is even more special:
the address we return for it IS the sp for the next frame. the address we return for it IS the sp for the next frame.
We cache the result of doing this in the frame_cache_obstack, since We cache the result of doing this in the frame_obstack, since it is
it is fairly expensive. */ fairly expensive. */
void void
frame_find_saved_regs (fi, fsr) frame_find_saved_regs (fi, fsr)
@ -343,7 +343,6 @@ frame_find_saved_regs (fi, fsr)
register CORE_ADDR *saved_regs; register CORE_ADDR *saved_regs;
register int regnum; register int regnum;
register struct frame_saved_regs *cache_fsr; register struct frame_saved_regs *cache_fsr;
extern struct obstack frame_cache_obstack;
CORE_ADDR ip; CORE_ADDR ip;
struct symtab_and_line sal; struct symtab_and_line sal;
CORE_ADDR limit; CORE_ADDR limit;
@ -351,8 +350,7 @@ frame_find_saved_regs (fi, fsr)
if (!fi->fsr) if (!fi->fsr)
{ {
cache_fsr = (struct frame_saved_regs *) cache_fsr = (struct frame_saved_regs *)
obstack_alloc (&frame_cache_obstack, frame_obstack_alloc (sizeof (struct frame_saved_regs));
sizeof (struct frame_saved_regs));
memset (cache_fsr, '\0', sizeof (struct frame_saved_regs)); memset (cache_fsr, '\0', sizeof (struct frame_saved_regs));
fi->fsr = cache_fsr; fi->fsr = cache_fsr;

View file

@ -421,8 +421,8 @@ skip_prologue (ip)
ways in the stack frame. sp is even more special: ways in the stack frame. sp is even more special:
the address we return for it IS the sp for the next frame. the address we return for it IS the sp for the next frame.
We cache the result of doing this in the frame_cache_obstack, since We cache the result of doing this in the frame_obstack, since it is
it is fairly expensive. */ fairly expensive. */
void void
frame_find_saved_regs (fi, fsr) frame_find_saved_regs (fi, fsr)
@ -430,7 +430,6 @@ frame_find_saved_regs (fi, fsr)
struct frame_saved_regs *fsr; struct frame_saved_regs *fsr;
{ {
register struct frame_saved_regs *cache_fsr; register struct frame_saved_regs *cache_fsr;
extern struct obstack frame_cache_obstack;
CORE_ADDR ip; CORE_ADDR ip;
struct symtab_and_line sal; struct symtab_and_line sal;
CORE_ADDR limit; CORE_ADDR limit;
@ -438,8 +437,7 @@ frame_find_saved_regs (fi, fsr)
if (!fi->fsr) if (!fi->fsr)
{ {
cache_fsr = (struct frame_saved_regs *) cache_fsr = (struct frame_saved_regs *)
obstack_alloc (&frame_cache_obstack, frame_obstack_alloc (sizeof (struct frame_saved_regs));
sizeof (struct frame_saved_regs));
memset (cache_fsr, '\0', sizeof (struct frame_saved_regs)); memset (cache_fsr, '\0', sizeof (struct frame_saved_regs));
fi->fsr = cache_fsr; fi->fsr = cache_fsr;

View file

@ -41,9 +41,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Do not use "TARGET_IS_MIPS64" to test the size of floating point registers */ /* Do not use "TARGET_IS_MIPS64" to test the size of floating point registers */
#define FP_REGISTER_DOUBLE (REGISTER_VIRTUAL_SIZE(FP0_REGNUM) == 8) #define FP_REGISTER_DOUBLE (REGISTER_VIRTUAL_SIZE(FP0_REGNUM) == 8)
/* FIXME: Put this declaration in frame.h. */
extern struct obstack frame_cache_obstack;
#if 0 #if 0
static int mips_in_lenient_prologue PARAMS ((CORE_ADDR, CORE_ADDR)); static int mips_in_lenient_prologue PARAMS ((CORE_ADDR, CORE_ADDR));
#endif #endif
@ -829,9 +826,7 @@ mips_find_saved_regs (fci)
mips_extra_func_info_t proc_desc; mips_extra_func_info_t proc_desc;
t_inst inst; t_inst inst;
fci->saved_regs = (struct frame_saved_regs *) frame_saved_regs_zalloc (fci);
obstack_alloc (&frame_cache_obstack, sizeof(struct frame_saved_regs));
memset (fci->saved_regs, 0, sizeof (struct frame_saved_regs));
/* If it is the frame for sigtramp, the saved registers are located /* If it is the frame for sigtramp, the saved registers are located
in a sigcontext structure somewhere on the stack. in a sigcontext structure somewhere on the stack.
@ -857,15 +852,15 @@ mips_find_saved_regs (fci)
{ {
reg_position = fci->frame + SIGFRAME_REGSAVE_OFF reg_position = fci->frame + SIGFRAME_REGSAVE_OFF
+ ireg * SIGFRAME_REG_SIZE; + ireg * SIGFRAME_REG_SIZE;
fci->saved_regs->regs[ireg] = reg_position; fci->saved_regs[ireg] = reg_position;
} }
for (ireg = 0; ireg < MIPS_NUMREGS; ireg++) for (ireg = 0; ireg < MIPS_NUMREGS; ireg++)
{ {
reg_position = fci->frame + SIGFRAME_FPREGSAVE_OFF reg_position = fci->frame + SIGFRAME_FPREGSAVE_OFF
+ ireg * SIGFRAME_REG_SIZE; + ireg * SIGFRAME_REG_SIZE;
fci->saved_regs->regs[FP0_REGNUM + ireg] = reg_position; fci->saved_regs[FP0_REGNUM + ireg] = reg_position;
} }
fci->saved_regs->regs[PC_REGNUM] = fci->frame + SIGFRAME_PC_OFF; fci->saved_regs[PC_REGNUM] = fci->frame + SIGFRAME_PC_OFF;
return; return;
} }
@ -935,7 +930,7 @@ mips_find_saved_regs (fci)
for (ireg= MIPS_NUMREGS-1; gen_mask; --ireg, gen_mask <<= 1) for (ireg= MIPS_NUMREGS-1; gen_mask; --ireg, gen_mask <<= 1)
if (gen_mask & 0x80000000) if (gen_mask & 0x80000000)
{ {
fci->saved_regs->regs[ireg] = reg_position; fci->saved_regs[ireg] = reg_position;
reg_position -= MIPS_REGSIZE; reg_position -= MIPS_REGSIZE;
/* start-sanitize-r5900 */ /* start-sanitize-r5900 */
#ifdef R5900_128BIT_GPR_HACK #ifdef R5900_128BIT_GPR_HACK
@ -968,7 +963,7 @@ mips_find_saved_regs (fci)
/* Check if the s0 and s1 registers were pushed on the stack. */ /* Check if the s0 and s1 registers were pushed on the stack. */
for (reg = 16; reg < sreg_count+16; reg++) for (reg = 16; reg < sreg_count+16; reg++)
{ {
fci->saved_regs->regs[reg] = reg_position; fci->saved_regs[reg] = reg_position;
reg_position -= MIPS_REGSIZE; reg_position -= MIPS_REGSIZE;
} }
} }
@ -988,11 +983,11 @@ mips_find_saved_regs (fci)
for (ireg = MIPS_NUMREGS-1; float_mask; --ireg, float_mask <<= 1) for (ireg = MIPS_NUMREGS-1; float_mask; --ireg, float_mask <<= 1)
if (float_mask & 0x80000000) if (float_mask & 0x80000000)
{ {
fci->saved_regs->regs[FP0_REGNUM+ireg] = reg_position; fci->saved_regs[FP0_REGNUM+ireg] = reg_position;
reg_position -= MIPS_REGSIZE; reg_position -= MIPS_REGSIZE;
} }
fci->saved_regs->regs[PC_REGNUM] = fci->saved_regs->regs[RA_REGNUM]; fci->saved_regs[PC_REGNUM] = fci->saved_regs[RA_REGNUM];
} }
static CORE_ADDR static CORE_ADDR
@ -1010,8 +1005,8 @@ read_next_frame_reg(fi, regno)
{ {
if (fi->saved_regs == NULL) if (fi->saved_regs == NULL)
mips_find_saved_regs (fi); mips_find_saved_regs (fi);
if (fi->saved_regs->regs[regno]) if (fi->saved_regs[regno])
return read_memory_integer(fi->saved_regs->regs[regno], MIPS_REGSIZE); return read_memory_integer(fi->saved_regs[regno], MIPS_REGSIZE);
} }
} }
return read_register (regno); return read_register (regno);
@ -1716,12 +1711,11 @@ init_extra_frame_info(fci)
(CORE_ADDR *)NULL,(CORE_ADDR *)NULL); (CORE_ADDR *)NULL,(CORE_ADDR *)NULL);
if (!IN_SIGTRAMP (fci->pc, name)) if (!IN_SIGTRAMP (fci->pc, name))
{ {
fci->saved_regs = (struct frame_saved_regs*) fci->saved_regs = (CORE_ADDR*)
obstack_alloc (&frame_cache_obstack, frame_obstack_alloc (SIZEOF_FRAME_SAVED_REGS);
sizeof (struct frame_saved_regs)); memcpy (fci->saved_regs, temp_saved_regs.regs, SIZEOF_FRAME_SAVED_REGS);
*fci->saved_regs = temp_saved_regs; fci->saved_regs[PC_REGNUM]
fci->saved_regs->regs[PC_REGNUM] = fci->saved_regs[RA_REGNUM];
= fci->saved_regs->regs[RA_REGNUM];
} }
} }
@ -2107,9 +2101,9 @@ mips_pop_frame()
for (regnum = 0; regnum < NUM_REGS; regnum++) for (regnum = 0; regnum < NUM_REGS; regnum++)
{ {
if (regnum != SP_REGNUM && regnum != PC_REGNUM if (regnum != SP_REGNUM && regnum != PC_REGNUM
&& frame->saved_regs->regs[regnum]) && frame->saved_regs[regnum])
write_register (regnum, write_register (regnum,
read_memory_integer (frame->saved_regs->regs[regnum], read_memory_integer (frame->saved_regs[regnum],
MIPS_REGSIZE)); MIPS_REGSIZE));
} }
write_register (SP_REGNUM, new_sp); write_register (SP_REGNUM, new_sp);

View file

@ -28,8 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "objfiles.h" #include "objfiles.h"
#include "xcoffsolib.h" #include "xcoffsolib.h"
extern struct obstack frame_cache_obstack;
extern int errno; extern int errno;
/* Breakpoint shadows for the single step instructions will be kept here. */ /* Breakpoint shadows for the single step instructions will be kept here. */
@ -52,11 +50,61 @@ CORE_ADDR (*find_toc_address_hook) PARAMS ((CORE_ADDR)) = NULL;
static CORE_ADDR branch_dest PARAMS ((int opcode, int instr, CORE_ADDR pc, static CORE_ADDR branch_dest PARAMS ((int opcode, int instr, CORE_ADDR pc,
CORE_ADDR safety)); CORE_ADDR safety));
static void frame_get_cache_fsr PARAMS ((struct frame_info *fi, static void frame_get_saved_regs PARAMS ((struct frame_info *fi,
struct rs6000_framedata *fdatap)); struct rs6000_framedata *fdatap));
static void pop_dummy_frame PARAMS ((void)); static void pop_dummy_frame PARAMS ((void));
static CORE_ADDR frame_initial_stack_address PARAMS ((struct frame_info *));
/* Fill in fi->saved_regs */
struct frame_extra_info
{
/* Functions calling alloca() change the value of the stack
pointer. We need to use initial stack pointer (which is saved in
r31 by gcc) in such cases. If a compiler emits traceback table,
then we should use the alloca register specified in traceback
table. FIXME. */
CORE_ADDR initial_sp; /* initial stack pointer. */ \
};
void
rs6000_init_extra_frame_info (fromleaf, fi)
int fromleaf;
struct frame_info *fi;
{
fi->extra_info = (struct frame_extra_info*)
frame_obstack_alloc (sizeof (struct frame_extra_info));
fi->extra_info->initial_sp = 0;
if (fi->next != (CORE_ADDR) 0
&& fi->pc < TEXT_SEGMENT_BASE)
/* We're in get_prev_frame_info */
/* and this is a special signal frame. */
/* (fi->pc will be some low address in the kernel, */
/* to which the signal handler returns). */
fi->signal_handler_caller = 1;
}
void
rs6000_frame_init_saved_regs (fi)
struct frame_info *fi;
{
frame_get_saved_regs (fi, NULL);
}
CORE_ADDR
rs6000_frame_args_address (fi)
struct frame_info *fi;
{
if (fi->extra_info->initial_sp != 0)
return fi->extra_info->initial_sp;
else
return frame_initial_stack_address (fi);
}
/* Calculate the destination of a branch/jump. Return -1 if not a branch. */ /* Calculate the destination of a branch/jump. Return -1 if not a branch. */
static CORE_ADDR static CORE_ADDR
@ -509,7 +557,7 @@ push_dummy_frame ()
pc = read_register(PC_REGNUM); pc = read_register(PC_REGNUM);
store_address (pc_targ, 4, pc); store_address (pc_targ, 4, pc);
skip_prologue (get_pc_function_start (pc) + FUNCTION_START_OFFSET, &fdata); skip_prologue (get_pc_function_start (pc), &fdata);
dummy_frame_addr [dummy_frame_count++] = sp; dummy_frame_addr [dummy_frame_count++] = sp;
@ -653,7 +701,7 @@ pop_frame ()
still in the link register, otherwise walk the frames and retrieve the still in the link register, otherwise walk the frames and retrieve the
saved %pc value in the previous frame. */ saved %pc value in the previous frame. */
addr = get_pc_function_start (frame->pc) + FUNCTION_START_OFFSET; addr = get_pc_function_start (frame->pc);
(void) skip_prologue (addr, &fdata); (void) skip_prologue (addr, &fdata);
if (fdata.frameless) if (fdata.frameless)
@ -1081,7 +1129,6 @@ frameless_function_invocation (fi)
return 0; return 0;
} }
func_start += FUNCTION_START_OFFSET;
(void) skip_prologue (func_start, &fdata); (void) skip_prologue (func_start, &fdata);
return fdata.frameless; return fdata.frameless;
} }
@ -1103,7 +1150,7 @@ frame_saved_pc (fi)
return generic_read_register_dummy(fi->pc, fi->frame, PC_REGNUM); return generic_read_register_dummy(fi->pc, fi->frame, PC_REGNUM);
#endif /* GENERIC_DUMMY_FRAMES */ #endif /* GENERIC_DUMMY_FRAMES */
func_start = get_pc_function_start (fi->pc) + FUNCTION_START_OFFSET; func_start = get_pc_function_start (fi->pc);
/* If we failed to find the start of the function, it is a mistake /* If we failed to find the start of the function, it is a mistake
to inspect the instructions. */ to inspect the instructions. */
@ -1132,7 +1179,7 @@ frame_saved_pc (fi)
in which case the framedata are read. */ in which case the framedata are read. */
static void static void
frame_get_cache_fsr (fi, fdatap) frame_get_saved_regs (fi, fdatap)
struct frame_info *fi; struct frame_info *fi;
struct rs6000_framedata *fdatap; struct rs6000_framedata *fdatap;
{ {
@ -1140,19 +1187,26 @@ frame_get_cache_fsr (fi, fdatap)
CORE_ADDR frame_addr; CORE_ADDR frame_addr;
struct rs6000_framedata work_fdata; struct rs6000_framedata work_fdata;
if (fi->cache_fsr) if (fi->saved_regs)
return; return;
if (fdatap == NULL) { if (fdatap == NULL)
fdatap = &work_fdata; {
(void) skip_prologue (get_pc_function_start (fi->pc), fdatap); fdatap = &work_fdata;
} (void) skip_prologue (get_pc_function_start (fi->pc), fdatap);
}
fi->cache_fsr = (struct frame_saved_regs *) frame_saved_regs_zalloc (fi);
obstack_alloc (&frame_cache_obstack, sizeof (struct frame_saved_regs));
memset (fi->cache_fsr, '\0', sizeof (struct frame_saved_regs));
if (fi->prev && fi->prev->frame) /* If there were any saved registers, figure out parent's stack
pointer. */
/* The following is true only if the frame doesn't have a call to
alloca(), FIXME. */
if (fdatap->saved_fpr == 0 && fdatap->saved_gpr == 0
&& fdatap->lr_offset == 0 && fdatap->cr_offset == 0)
frame_addr = 0;
else if (fi->prev && fi->prev->frame)
frame_addr = fi->prev->frame; frame_addr = fi->prev->frame;
else else
frame_addr = read_memory_integer (fi->frame, 4); frame_addr = read_memory_integer (fi->frame, 4);
@ -1160,41 +1214,47 @@ frame_get_cache_fsr (fi, fdatap)
/* if != -1, fdatap->saved_fpr is the smallest number of saved_fpr. /* if != -1, fdatap->saved_fpr is the smallest number of saved_fpr.
All fpr's from saved_fpr to fp31 are saved. */ All fpr's from saved_fpr to fp31 are saved. */
if (fdatap->saved_fpr >= 0) { if (fdatap->saved_fpr >= 0)
int fpr_offset = frame_addr + fdatap->fpr_offset; {
for (ii = fdatap->saved_fpr; ii < 32; ii++) { int i;
fi->cache_fsr->regs [FP0_REGNUM + ii] = fpr_offset; int fpr_offset = frame_addr + fdatap->fpr_offset;
fpr_offset += 8; for (i = fdatap->saved_fpr; i < 32; i++)
{
fi->saved_regs [FP0_REGNUM + i] = fpr_offset;
fpr_offset += 8;
}
} }
}
/* if != -1, fdatap->saved_gpr is the smallest number of saved_gpr. /* if != -1, fdatap->saved_gpr is the smallest number of saved_gpr.
All gpr's from saved_gpr to gpr31 are saved. */ All gpr's from saved_gpr to gpr31 are saved. */
if (fdatap->saved_gpr >= 0) { if (fdatap->saved_gpr >= 0)
int gpr_offset = frame_addr + fdatap->gpr_offset; {
for (ii = fdatap->saved_gpr; ii < 32; ii++) { int i;
fi->cache_fsr->regs [ii] = gpr_offset; int gpr_offset = frame_addr + fdatap->gpr_offset;
gpr_offset += 4; for (i = fdatap->saved_gpr; i < 32; i++)
{
fi->saved_regs [i] = gpr_offset;
gpr_offset += 4;
}
} }
}
/* If != 0, fdatap->cr_offset is the offset from the frame that holds /* If != 0, fdatap->cr_offset is the offset from the frame that holds
the CR. */ the CR. */
if (fdatap->cr_offset != 0) if (fdatap->cr_offset != 0)
fi->cache_fsr->regs [CR_REGNUM] = frame_addr + fdatap->cr_offset; fi->saved_regs [CR_REGNUM] = frame_addr + fdatap->cr_offset;
/* If != 0, fdatap->lr_offset is the offset from the frame that holds /* If != 0, fdatap->lr_offset is the offset from the frame that holds
the LR. */ the LR. */
if (fdatap->lr_offset != 0) if (fdatap->lr_offset != 0)
fi->cache_fsr->regs [LR_REGNUM] = frame_addr + fdatap->lr_offset; fi->saved_regs [LR_REGNUM] = frame_addr + fdatap->lr_offset;
} }
/* Return the address of a frame. This is the inital %sp value when the frame /* Return the address of a frame. This is the inital %sp value when the frame
was first allocated. For functions calling alloca(), it might be saved in was first allocated. For functions calling alloca(), it might be saved in
an alloca register. */ an alloca register. */
CORE_ADDR static CORE_ADDR
frame_initial_stack_address (fi) frame_initial_stack_address (fi)
struct frame_info *fi; struct frame_info *fi;
{ {
@ -1205,8 +1265,8 @@ frame_initial_stack_address (fi)
/* if the initial stack pointer (frame address) of this frame is known, /* if the initial stack pointer (frame address) of this frame is known,
just return it. */ just return it. */
if (fi->initial_sp) if (fi->extra_info->initial_sp)
return fi->initial_sp; return fi->extra_info->initial_sp;
/* find out if this function is using an alloca register.. */ /* find out if this function is using an alloca register.. */
@ -1214,22 +1274,23 @@ frame_initial_stack_address (fi)
/* if saved registers of this frame are not known yet, read and cache them. */ /* if saved registers of this frame are not known yet, read and cache them. */
if (!fi->cache_fsr) if (!fi->saved_regs)
frame_get_cache_fsr (fi, &fdata); frame_get_saved_regs (fi, &fdata);
/* If no alloca register used, then fi->frame is the value of the %sp for /* If no alloca register used, then fi->frame is the value of the %sp for
this frame, and it is good enough. */ this frame, and it is good enough. */
if (fdata.alloca_reg < 0) { if (fdata.alloca_reg < 0)
fi->initial_sp = fi->frame; {
return fi->initial_sp; fi->extra_info->initial_sp = fi->frame;
} return fi->extra_info->initial_sp;
}
/* This function has an alloca register. If this is the top-most frame /* This function has an alloca register. If this is the top-most frame
(with the lowest address), the value in alloca register is good. */ (with the lowest address), the value in alloca register is good. */
if (!fi->next) if (!fi->next)
return fi->initial_sp = read_register (fdata.alloca_reg); return fi->extra_info->initial_sp = read_register (fdata.alloca_reg);
/* Otherwise, this is a caller frame. Callee has usually already saved /* Otherwise, this is a caller frame. Callee has usually already saved
registers, but there are exceptions (such as when the callee registers, but there are exceptions (such as when the callee
@ -1238,15 +1299,15 @@ frame_initial_stack_address (fi)
for (callee_fi = fi->next; callee_fi; callee_fi = callee_fi->next) { for (callee_fi = fi->next; callee_fi; callee_fi = callee_fi->next) {
if (!callee_fi->cache_fsr) if (!callee_fi->saved_regs)
frame_get_cache_fsr (callee_fi, NULL); frame_get_saved_regs (callee_fi, NULL);
/* this is the address in which alloca register is saved. */ /* this is the address in which alloca register is saved. */
tmpaddr = callee_fi->cache_fsr->regs [fdata.alloca_reg]; tmpaddr = callee_fi->saved_regs [fdata.alloca_reg];
if (tmpaddr) { if (tmpaddr) {
fi->initial_sp = read_memory_integer (tmpaddr, 4); fi->extra_info->initial_sp = read_memory_integer (tmpaddr, 4);
return fi->initial_sp; return fi->extra_info->initial_sp;
} }
/* Go look into deeper levels of the frame chain to see if any one of /* Go look into deeper levels of the frame chain to see if any one of
@ -1256,7 +1317,8 @@ frame_initial_stack_address (fi)
/* If alloca register was not saved, by the callee (or any of its callees) /* If alloca register was not saved, by the callee (or any of its callees)
then the value in the register is still good. */ then the value in the register is still good. */
return fi->initial_sp = read_register (fdata.alloca_reg); fi->extra_info->initial_sp = read_register (fdata.alloca_reg);
return fi->extra_info->initial_sp;
} }
CORE_ADDR CORE_ADDR

View file

@ -80,10 +80,11 @@ skip_adjust (pc, size)
return pc; return pc;
} }
int static CORE_ADDR examine_frame PARAMS ((CORE_ADDR, CORE_ADDR *regs, CORE_ADDR));
static CORE_ADDR
examine_frame (pc, regs, sp) examine_frame (pc, regs, sp)
CORE_ADDR pc; CORE_ADDR pc;
struct frame_saved_regs *regs; CORE_ADDR *regs;
CORE_ADDR sp; CORE_ADDR sp;
{ {
int w = read_memory_short (pc); int w = read_memory_short (pc);
@ -91,20 +92,20 @@ examine_frame (pc, regs, sp)
int regno; int regno;
for (regno = 0; regno < NUM_REGS; regno++) for (regno = 0; regno < NUM_REGS; regno++)
regs->regs[regno] = 0; regs[regno] = 0;
while (IS_PUSHW (w) || IS_PUSHL (w)) while (IS_PUSHW (w) || IS_PUSHL (w))
{ {
/* work out which register is being pushed to where */ /* work out which register is being pushed to where */
if (IS_PUSHL (w)) if (IS_PUSHL (w))
{ {
regs->regs[w & 0xf] = offset; regs[w & 0xf] = offset;
regs->regs[(w & 0xf) + 1] = offset + 2; regs[(w & 0xf) + 1] = offset + 2;
offset += 4; offset += 4;
} }
else else
{ {
regs->regs[w & 0xf] = offset; regs[w & 0xf] = offset;
offset += 2; offset += 2;
} }
pc += 2; pc += 2;
@ -121,16 +122,16 @@ examine_frame (pc, regs, sp)
/* Subtracting a value from the sp, so were in a function /* Subtracting a value from the sp, so were in a function
which needs stack space for locals, but has no fp. We fake up which needs stack space for locals, but has no fp. We fake up
the values as if we had an fp */ the values as if we had an fp */
regs->regs[FP_REGNUM] = sp; regs[FP_REGNUM] = sp;
} }
else else
{ {
/* This one didn't have an fp, we'll fake it up */ /* This one didn't have an fp, we'll fake it up */
regs->regs[SP_REGNUM] = sp; regs[SP_REGNUM] = sp;
} }
/* stack pointer contains address of next frame */ /* stack pointer contains address of next frame */
/* regs->regs[fp_regnum()] = fp;*/ /* regs[fp_regnum()] = fp;*/
regs->regs[SP_REGNUM] = sp; regs[SP_REGNUM] = sp;
return pc; return pc;
} }
@ -138,9 +139,9 @@ CORE_ADDR
z8k_skip_prologue (start_pc) z8k_skip_prologue (start_pc)
CORE_ADDR start_pc; CORE_ADDR start_pc;
{ {
struct frame_saved_regs dummy; CORE_ADDR dummy[NUM_REGS];
return examine_frame (start_pc, &dummy, 0); return examine_frame (start_pc, dummy, 0);
} }
CORE_ADDR CORE_ADDR
@ -185,19 +186,17 @@ init_frame_pc ()
the address we return for it IS the sp for the next frame. */ the address we return for it IS the sp for the next frame. */
void void
get_frame_saved_regs (frame_info, frame_saved_regs) z8k_frame_init_saved_regs (frame_info)
struct frame_info *frame_info; struct frame_info *frame_info;
struct frame_saved_regs *frame_saved_regs;
{ {
CORE_ADDR pc; CORE_ADDR pc;
int w; int w;
memset (frame_saved_regs, '\0', sizeof (*frame_saved_regs)); frame_saved_regs_zalloc (frame_info);
pc = get_pc_function_start (frame_info->pc); pc = get_pc_function_start (frame_info->pc);
/* wander down the instruction stream */ /* wander down the instruction stream */
examine_frame (pc, frame_saved_regs, frame_info->frame); examine_frame (pc, frame_info->saved_regs, frame_info->frame);
} }
@ -240,6 +239,7 @@ NEXT_PROLOGUE_INSN (addr, lim, pword1)
return 0; return 0;
} }
#if 0
/* Put here the code to store, into a struct frame_saved_regs, /* Put here the code to store, into a struct frame_saved_regs,
the addresses of the saved registers of frame described by FRAME_INFO. the addresses of the saved registers of frame described by FRAME_INFO.
This includes special registers such as pc and fp saved in special This includes special registers such as pc and fp saved in special
@ -291,6 +291,7 @@ frame_find_saved_regs (fip, fsrp)
fsrp->regs[FP_REGNUM] = fip->frame; fsrp->regs[FP_REGNUM] = fip->frame;
} }
#endif
int int
saved_pc_after_call () saved_pc_after_call ()