ppc-macosx-frameops.c [plain text]
#include "ppc-macosx-regs.h"
#include "ppc-macosx-frameops.h"
#include "ppc-macosx-frameinfo.h"
#include "ppc-macosx-tdep.h"
#include "defs.h"
#include "frame.h"
#include "inferior.h"
#include "symtab.h"
#include "target.h"
#include "gdbcore.h"
#include "symfile.h"
#include "objfiles.h"
#include "regcache.h"
#include <string.h>
void
ppc_frame_cache_saved_regs (struct frame_info *frame)
{
if (frame->saved_regs) {
return;
}
frame_saved_regs_zalloc (frame);
ppc_frame_saved_regs (frame, frame->saved_regs);
}
void
ppc_frame_saved_regs (struct frame_info *frame, CORE_ADDR *saved_regs)
{
CORE_ADDR prev_sp = 0;
ppc_function_properties *props;
int i;
if (ppc_frame_cache_properties (frame, NULL)) {
ppc_debug ("frame_initial_stack_address: unable to find properties of "
"function containing 0x%lx\n", (unsigned long) frame->pc);
return;
}
props = frame->extra_info->props;
CHECK_FATAL (props != NULL);
if (! props->frameless) {
prev_sp = saved_regs[SP_REGNUM] = read_memory_unsigned_integer (frame->frame, 4);
} else {
prev_sp = saved_regs[SP_REGNUM] = frame->frame;
}
if (get_frame_type (frame) == SIGTRAMP_FRAME)
{
CORE_ADDR psp = read_memory_unsigned_integer (frame->frame, 4);
saved_regs[PC_REGNUM] = psp + PPC_SIGCONTEXT_PC_OFFSET;
}
else
{
if (prev_sp == 0)
saved_regs[PC_REGNUM] = 0;
else
{
saved_regs[PC_REGNUM] = prev_sp + props->lr_offset;
}
}
if (props->cr_saved) {
saved_regs[CR_REGNUM] = prev_sp + props->cr_offset;
}
if (props->lr_saved) {
saved_regs[LR_REGNUM] = prev_sp + props->lr_offset;
}
if (props->frameless && ((props->saved_fpr != -1) || (props->saved_gpr != -1))) {
ppc_debug ("frame_find_saved_regs: "
"registers marked as saved in frameless function; ignoring\n");
return;
}
if (props->saved_fpr >= 0) {
for (i = props->saved_fpr; i < 32; i++) {
long offset = props->fpr_offset + ((i - props->saved_fpr) * sizeof (FP_REGISTER_TYPE));
saved_regs[FP0_REGNUM + i] = prev_sp + offset;
}
}
if (props->saved_gpr >= 0) {
for (i = props->saved_gpr; i < 32; i++) {
long offset = props->gpr_offset + ((i - props->saved_gpr) * sizeof (REGISTER_TYPE));
saved_regs[GP0_REGNUM + i] = prev_sp + offset;
}
}
}