diff options
author | Per Bothner <per@bothner.com> | 1992-03-02 06:46:32 +0000 |
---|---|---|
committer | Per Bothner <per@bothner.com> | 1992-03-02 06:46:32 +0000 |
commit | 4ef09e3613ecc3849c0008102fc3871324caf7fd (patch) | |
tree | 9563132e825de12aaa3804c2800eb78b037aea20 /gdb/rs6000-xdep.c | |
parent | cf15d9e97ac5459a911129f1a506fdc3713c27bb (diff) | |
download | gdb-4ef09e3613ecc3849c0008102fc3871324caf7fd.zip gdb-4ef09e3613ecc3849c0008102fc3871324caf7fd.tar.gz gdb-4ef09e3613ecc3849c0008102fc3871324caf7fd.tar.bz2 |
* rs6000-xdep.c (frame_initial_stack_address): Move
code to set frame->cache_fsr into new separate function
frame_get_cacahe_fsr. This allows fixing a fatal error.
* xcoffexec.c: Turn previously suppressed error
message back on, after cleaning up BFD.
Diffstat (limited to 'gdb/rs6000-xdep.c')
-rw-r--r-- | gdb/rs6000-xdep.c | 98 |
1 files changed, 60 insertions, 38 deletions
diff --git a/gdb/rs6000-xdep.c b/gdb/rs6000-xdep.c index afb24c6..2dd170a 100644 --- a/gdb/rs6000-xdep.c +++ b/gdb/rs6000-xdep.c @@ -61,6 +61,7 @@ static int special_regs[] = { extern int one_stepped; extern char register_valid[]; +extern struct obstack frame_cache_obstack; void @@ -242,20 +243,66 @@ struct frame_info *fi; } +/* If saved registers of frame FI are not known yet, read and cache them. + &FDATAP contains aix_framedata; TDATAP can be NULL, + in which case the framedata are read. + */ + +static void +frame_get_cache_fsr (fi, fdatap) + struct frame_info *fi; + struct aix_framedata *fdatap; +{ + int ii; + CORE_ADDR frame_addr; + struct aix_framedata work_fdata; + if (fi->cache_fsr) + return; + + if (fdatap = NULL) { + fdatap = &work_fdata; + function_frame_info (get_pc_function_start (fi->pc), fdatap); + } + + fi->cache_fsr = (struct frame_saved_regs *) + obstack_alloc (&frame_cache_obstack, sizeof (struct frame_saved_regs)); + bzero (fi->cache_fsr, sizeof (struct frame_saved_regs)); + + if (fi->prev && fi->prev->frame) + frame_addr = fi->prev->frame; + else + frame_addr = read_memory_integer (fi->frame, 4); + + /* if != -1, fdatap->saved_fpr is the smallest number of saved_fpr. + All fpr's from saved_fpr to fp31 are saved right underneath caller + stack pointer, starting from fp31 first. */ + + if (fdatap->saved_fpr >= 0) { + for (ii=31; ii >= fdatap->saved_fpr; --ii) + fi->cache_fsr->regs [FP0_REGNUM + ii] = frame_addr - ((32 - ii) * 8); + frame_addr -= (32 - fdatap->saved_fpr) * 8; + } + + /* if != -1, fdatap->saved_gpr is the smallest number of saved_gpr. + All gpr's from saved_gpr to gpr31 are saved right under saved fprs, + starting from r31 first. */ + + if (fdatap->saved_gpr >= 0) + for (ii=31; ii >= fdatap->saved_gpr; --ii) + fi->cache_fsr->regs [ii] = frame_addr - ((32 - ii) * 4); +} + /* 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 an alloca register. */ CORE_ADDR frame_initial_stack_address (fi) -struct frame_info *fi; + struct frame_info *fi; { - CORE_ADDR frame_addr, tmpaddr; + CORE_ADDR tmpaddr; struct aix_framedata fdata; struct frame_info *callee_fi; - int ii; - - extern struct obstack frame_cache_obstack; /* if the initial stack pointer (frame address) of this frame is known, just return it. */ @@ -265,39 +312,12 @@ struct frame_info *fi; /* find out if this function is using an alloca register.. */ - tmpaddr = get_pc_function_start (fi->pc); - function_frame_info (tmpaddr, &fdata); + function_frame_info (get_pc_function_start (fi->pc), &fdata); /* if saved registers of this frame are not known yet, read and cache them. */ - if (!fi->cache_fsr) { - fi->cache_fsr = (struct frame_saved_regs *) - obstack_alloc (&frame_cache_obstack, sizeof (struct frame_saved_regs)); - bzero (fi->cache_fsr, sizeof (struct frame_saved_regs)); - - if (fi->prev && fi->prev->frame) - frame_addr = fi->prev->frame; - else - frame_addr = read_memory_integer (fi->frame, 4); - - /* if != -1, fdata.saved_fpr is the smallest number of saved_fpr. All fpr's - from saved_fpr to fp31 are saved right underneath caller stack pointer, - starting from fp31 first. */ - - if (fdata.saved_fpr >= 0) { - for (ii=31; ii >= fdata.saved_fpr; --ii) - fi->cache_fsr->regs [FP0_REGNUM + ii] = frame_addr - ((32 - ii) * 8); - frame_addr -= (32 - fdata.saved_fpr) * 8; - } - - /* if != -1, fdata.saved_gpr is the smallest number of saved_gpr. All gpr's - from saved_gpr to gpr31 are saved right under saved fprs, starting - from r31 first. */ - - if (fdata.saved_gpr >= 0) - for (ii=31; ii >= fdata.saved_gpr; --ii) - fi->cache_fsr->regs [ii] = frame_addr - ((32 - ii) * 4); - } + if (!fi->cache_fsr) + frame_get_cache_fsr (fi, &fdata); /* If no alloca register used, then fi->frame is the value of the %sp for this frame, and it is good enough. */ @@ -313,13 +333,15 @@ struct frame_info *fi; if (!fi->next) return fi->initial_sp = read_register (fdata.alloca_reg); - /* Otherwise, this is a caller frame. Callee has already saved (???) its - registers. Find the address in which caller's alloca register is saved. */ + /* Otherwise, this is a caller frame. Callee has usually already saved + registers, but there are are exceptions (such as when the callee + has no parameters). Find the address in which caller's alloca + register is saved. */ for (callee_fi = fi->next; callee_fi; callee_fi = callee_fi->next) { if (!callee_fi->cache_fsr) - fatal ("Callee has not saved caller's registers."); + frame_get_cache_fsr (fi, NULL); /* this is the address in which alloca register is saved. */ |