/* Target-dependent code for the ALPHA architecture, for GDB, the GNU Debugger.
- Copyright 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
This file is part of GDB.
/* 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;
-\f
-
-/* Forward declarations. */
+/* Prototypes for local functions. */
static alpha_extra_func_info_t push_sigtramp_desc PARAMS ((CORE_ADDR low_addr));
alpha_extra_func_info_t proc_desc;
int returnreg;
- frame->saved_regs = (struct frame_saved_regs *)
- obstack_alloc (&frame_cache_obstack, sizeof(struct frame_saved_regs));
- memset (frame->saved_regs, 0, sizeof (struct frame_saved_regs));
+ frame_saved_regs_zalloc (frame);
/* If it is the frame for __sigtramp, the saved registers are located
in a sigcontext structure somewhere on the stack. __sigtramp
for (ireg = 0; ireg < 32; ireg++)
{
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++)
{
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;
}
register number. */
if (mask & (1 << returnreg))
{
- frame->saved_regs->regs[returnreg] = reg_position;
+ frame->saved_regs[returnreg] = reg_position;
reg_position += 8;
mask &= ~(1 << returnreg); /* Clear bit for RA so we
don't save again later. */
for (ireg = 0; ireg <= 31 ; ++ireg)
if (mask & (1 << ireg))
{
- frame->saved_regs->regs[ireg] = reg_position;
+ frame->saved_regs[ireg] = reg_position;
reg_position += 8;
}
for (ireg = 0; ireg <= 31 ; ++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;
}
- frame->saved_regs->regs[PC_REGNUM] = frame->saved_regs->regs[returnreg];
+ frame->saved_regs[PC_REGNUM] = frame->saved_regs[returnreg];
}
static CORE_ADDR
{
if (fi->saved_regs == NULL)
alpha_find_saved_regs (fi);
- if (fi->saved_regs->regs[regno])
- return read_memory_integer(fi->saved_regs->regs[regno], 8);
+ if (fi->saved_regs[regno])
+ return read_memory_integer(fi->saved_regs[regno], 8);
}
}
return read_register(regno);
static struct alpha_extra_func_info temp_proc_desc;
static struct frame_saved_regs temp_saved_regs;
+/* Nonzero if instruction at PC is a return instruction. "ret
+ $zero,($ra),1" on alpha. */
+
+static int
+alpha_about_to_return (pc)
+ CORE_ADDR pc;
+{
+ return read_memory_integer (pc, 4) == 0x6bfa8001;
+}
+
+
+
/* This fencepost looks highly suspicious to me. Removing it also
seems suspicious as it could affect remote debugging across serial
lines. */
return 0;
}
- else if (ABOUT_TO_RETURN(start_pc))
- break;
+ else if (alpha_about_to_return (start_pc))
+ break;
start_pc += 4; /* skip return */
return start_pc;
(CORE_ADDR *)NULL,(CORE_ADDR *)NULL);
if (!IN_SIGTRAMP (frame->pc, name))
{
- frame->saved_regs = (struct frame_saved_regs*)
- obstack_alloc (&frame_cache_obstack,
- sizeof (struct frame_saved_regs));
- *frame->saved_regs = temp_saved_regs;
- frame->saved_regs->regs[PC_REGNUM]
- = frame->saved_regs->regs[RA_REGNUM];
+ frame->saved_regs = (CORE_ADDR*)
+ frame_obstack_alloc (SIZEOF_FRAME_SAVED_REGS);
+ memcpy (frame->saved_regs, temp_saved_regs.regs, SIZEOF_FRAME_SAVED_REGS);
+ frame->saved_regs[PC_REGNUM]
+ = frame->saved_regs[RA_REGNUM];
}
}
}
*/
/* MASK(i,j) == (1<<i) + (1<<(i+1)) + ... + (1<<j)). Assume i<=j<31. */
-#define MASK(i,j) (((1L << ((j)+1)) - 1) ^ ((1L << (i)) - 1))
+#define MASK(i,j) ((((LONGEST)1 << ((j)+1)) - 1) ^ (((LONGEST)1 << (i)) - 1))
#define GEN_REG_SAVE_MASK (MASK(0,8) | MASK(16,29))
#define GEN_REG_SAVE_COUNT 24
#define FLOAT_REG_SAVE_MASK (MASK(0,1) | MASK(10,30))
for (regnum = 32; --regnum >= 0; )
if (PROC_REG_MASK(proc_desc) & (1 << regnum))
write_register (regnum,
- read_memory_integer (frame->saved_regs->regs[regnum],
+ read_memory_integer (frame->saved_regs[regnum],
8));
for (regnum = 32; --regnum >= 0; )
if (PROC_FREG_MASK(proc_desc) & (1 << 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);
flush_cached_frames ();