- CORE_ADDR sigcontext_addr;
- char *buf;
- int ptrbytes = TYPE_LENGTH (builtin_type_void_func_ptr);
- int sigcontext_offs = (2 * TARGET_INT_BIT) / TARGET_CHAR_BIT;
-
- buf = alloca (ptrbytes);
- /* Get sigcontext address, it is the third parameter on the stack. */
- if (get_next_frame (frame))
- sigcontext_addr = read_memory_typed_address
- (FRAME_ARGS_ADDRESS (get_next_frame (frame))
- + FRAME_ARGS_SKIP + sigcontext_offs,
- builtin_type_void_data_ptr);
- else
- sigcontext_addr = read_memory_typed_address
- (read_register (SP_REGNUM) + sigcontext_offs, builtin_type_void_data_ptr);
-
- /* Don't cause a memory_error when accessing sigcontext in case the stack
- layout has changed or the stack is corrupt. */
- target_read_memory (sigcontext_addr + SIGCONTEXT_PC_OFFSET, buf, ptrbytes);
- return extract_typed_address (buf, builtin_type_void_func_ptr);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ CORE_ADDR fp = sp;
+ gdb_byte buf[4];
+
+ /* Set up the function arguments. */
+ sp = vax_store_arguments (regcache, nargs, args, sp);
+
+ /* Store return value address. */
+ if (return_method == return_method_struct)
+ regcache_cooked_write_unsigned (regcache, VAX_R1_REGNUM, struct_addr);
+
+ /* Store return address in the PC slot. */
+ sp -= 4;
+ store_unsigned_integer (buf, 4, byte_order, bp_addr);
+ write_memory (sp, buf, 4);
+
+ /* Store the (fake) frame pointer in the FP slot. */
+ sp -= 4;
+ store_unsigned_integer (buf, 4, byte_order, fp);
+ write_memory (sp, buf, 4);
+
+ /* Skip the AP slot. */
+ sp -= 4;
+
+ /* Store register save mask and control bits. */
+ sp -= 4;
+ store_unsigned_integer (buf, 4, byte_order, 0);
+ write_memory (sp, buf, 4);
+
+ /* Store condition handler. */
+ sp -= 4;
+ store_unsigned_integer (buf, 4, byte_order, 0);
+ write_memory (sp, buf, 4);
+
+ /* Update the stack pointer and frame pointer. */
+ store_unsigned_integer (buf, 4, byte_order, sp);
+ regcache->cooked_write (VAX_SP_REGNUM, buf);
+ regcache->cooked_write (VAX_FP_REGNUM, buf);
+
+ /* Return the saved (fake) frame pointer. */
+ return fp;