Sun Sep 10 10:24:48 1995 Michael Tiemann <tiemann@axon.cygnus.com>
authorMichael Tiemann <tiemann@cygnus>
Sun, 10 Sep 1995 17:37:22 +0000 (17:37 +0000)
committerMichael Tiemann <tiemann@cygnus>
Sun, 10 Sep 1995 17:37:22 +0000 (17:37 +0000)
* 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
gdb/remote-sim.c
gdb/rs6000-tdep.c

index 7234d7b..2129a32 100644 (file)
@@ -1,3 +1,17 @@
+Sun Sep 10 10:24:48 1995  Michael Tiemann  <tiemann@axon.cygnus.com>
+
+       * 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
index 813f212..f2df37a 100644 (file)
@@ -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);
 }
 
index faade77..ca4bb72 100644 (file)
@@ -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 ()
                &registers[REGISTER_BYTE (FPLAST_REGNUM + ii)], 4);
 
   read_memory (sp-(DUMMY_FRAME_SIZE-8), 
-                               &registers [REGISTER_BYTE(PC_REGNUM)], 4);
+              &registers [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