From 3a4f97862f047c2b299e3f04ca652142c7032ded Mon Sep 17 00:00:00 2001 From: Michael Tiemann Date: Sun, 10 Sep 1995 17:37:22 +0000 Subject: [PATCH] Sun Sep 10 10:24:48 1995 Michael Tiemann * tm-ppc-eabi.h (PC_IN_CALL_DUMMY): Redefine this to work with the simulator. FIXME. * rs6000-tdep.c (push_dummy_frame): Calculate the correct link register offset from the current frame (don't assume it is always 8). (push_dummy_frame): Add comment about having only 4096 bytes of stack space in the simulator (by default). * remote-sim.c (gdbsim_create_inferior): Call `add_text_to_loadinfo' so that gdb can find TOC entries when calling functions in the inferior. With this changes, it is now possible to correctly call inferior functions in the PPC simulator. --- gdb/ChangeLog | 14 ++++++++++++++ gdb/remote-sim.c | 6 ++++++ gdb/rs6000-tdep.c | 14 ++++++++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7234d7b79a2..2129a32f61f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,17 @@ +Sun Sep 10 10:24:48 1995 Michael Tiemann + + * tm-ppc-eabi.h (PC_IN_CALL_DUMMY): Redefine this to work with the + simulator. FIXME. + + * rs6000-tdep.c (push_dummy_frame): Calculate the correct link + register offset from the current frame (don't assume it is always 8). + (push_dummy_frame): Add comment about having only 4096 bytes of + stack space in the simulator (by default). + + * remote-sim.c (gdbsim_create_inferior): Call + `add_text_to_loadinfo' so that gdb can find TOC entries when + calling functions in the inferior. + Sun Sep 10 09:00:28 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) * sparc-tdep.c (fill_fpregset): Fix incorrect FP_MAX_REGNUM diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 813f2128149..f2df37a48e7 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -200,6 +200,12 @@ gdbsim_create_inferior (exec_file, args, env) inferior_pid = 42; insert_breakpoints (); /* Needed to get correct instruction in cache */ + + /* FIXME: This needs to be done in a target-specific fashion. + What you see here works for the PPC simulator tiemann 9/9/1995. + Also, the fact that we can find the addresses for breakpoints without + this mechanism suggests some redundant code that could be merged. */ + add_text_to_loadinfo (entry_pt, entry_pt+exec_bfd->sections->_cooked_size); proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0); } diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index faade77349c..ca4bb72a0d0 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -445,6 +445,10 @@ push_dummy_frame () /* Same thing, target byte order. */ char pc_targ[4]; + /* Needed to figure out where to save the dummy link area. + FIXME: There should be an easier way to do this, no? tiemann 9/9/95. */ + struct rs6000_framedata fdata; + int ii; target_fetch_registers (-1); @@ -463,6 +467,8 @@ push_dummy_frame () pc = read_register(PC_REGNUM); store_address (pc_targ, 4, pc); + (void) skip_prologue (get_pc_function_start (pc) + FUNCTION_START_OFFSET, &fdata); + dummy_frame_addr [dummy_frame_count++] = sp; /* Be careful! If the stack pointer is not decremented first, then kernel @@ -471,6 +477,10 @@ push_dummy_frame () before writing register values into the new frame, decrement and update %sp first in order to secure your frame. */ + /* FIXME: We don't check if the stack really has this much space. + This is a problem on the ppc simulator (which only grants one page + (4096 bytes) by default. */ + write_register (SP_REGNUM, sp-DUMMY_FRAME_SIZE); /* gdb relies on the state of current_frame. We'd better update it, @@ -479,7 +489,7 @@ push_dummy_frame () flush_cached_frames (); /* save program counter in link register's space. */ - write_memory (sp+8, pc_targ, 4); + write_memory (sp+fdata.lr_offset, pc_targ, 4); /* save all floating point and general purpose registers here. */ @@ -550,7 +560,7 @@ pop_dummy_frame () ®isters[REGISTER_BYTE (FPLAST_REGNUM + ii)], 4); read_memory (sp-(DUMMY_FRAME_SIZE-8), - ®isters [REGISTER_BYTE(PC_REGNUM)], 4); + ®isters [REGISTER_BYTE(PC_REGNUM)], 4); /* when a dummy frame was being pushed, we had to decrement %sp first, in order to secure astack space. Thus, saved %sp (or %r1) value, is not the -- 2.30.2