#include "ppc-tdep.h"
#include "gdb_assert.h"
+#include "dis-asm.h"
/* If the kernel has to deliver a signal, it pushes a sigcontext
structure on the stack and then calls the signal handler, passing
flush_cached_frames ();
}
-/* Fixup the call sequence of a dummy function, with the real function
- address. Its arguments will be passed by gdb. */
-
-static void
-rs6000_fix_call_dummy (char *dummyname, CORE_ADDR pc, CORE_ADDR fun,
- int nargs, struct value **args, struct type *type,
- int gcc_p)
-{
- int ii;
- CORE_ADDR target_addr;
-
- if (rs6000_find_toc_address_hook != NULL)
- {
- CORE_ADDR tocvalue = (*rs6000_find_toc_address_hook) (fun);
- write_register (gdbarch_tdep (current_gdbarch)->ppc_toc_regnum,
- tocvalue);
- }
-}
-
/* All the ABI's require 16 byte alignment. */
static CORE_ADDR
rs6000_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
starting from r4. */
static CORE_ADDR
-rs6000_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
- int struct_return, CORE_ADDR struct_addr)
+rs6000_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+ struct regcache *regcache, CORE_ADDR bp_addr,
+ int nargs, struct value **args, CORE_ADDR sp,
+ int struct_return, CORE_ADDR struct_addr)
{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
int ii;
int len = 0;
int argno; /* current argument number */
CORE_ADDR saved_sp;
/* The first eight words of ther arguments are passed in registers.
- Copy them appropriately.
-
- If the function is returning a `struct', then the first word (which
- will be passed in r3) is used for struct return address. In that
- case we should advance one word and start from r4 register to copy
- parameters. */
-
- ii = struct_return ? 1 : 0;
+ Copy them appropriately. */
+ ii = 0;
+
+ /* If the function is returning a `struct', then the first word
+ (which will be passed in r3) is used for struct return address.
+ In that case we should advance one word and start from r4
+ register to copy parameters. */
+ if (struct_return)
+ {
+ regcache_raw_write_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
+ struct_addr);
+ ii++;
+ }
/*
effectively indirect call... gcc does...
space = (space + 15) & -16;
sp -= space;
- /* This is another instance we need to be concerned about
- securing our stack space. If we write anything underneath %sp
- (r1), we might conflict with the kernel who thinks he is free
- to use this area. So, update %sp first before doing anything
- else. */
-
- write_register (SP_REGNUM, sp);
-
/* If the last argument copied into the registers didn't fit there
completely, push the rest of it into stack. */
ii += ((len + 3) & -4) / 4;
}
}
- else
- /* Secure stack areas first, before doing anything else. */
- write_register (SP_REGNUM, sp);
/* set back chain properly */
store_unsigned_integer (tmp_buffer, 4, saved_sp);
write_memory (sp, tmp_buffer, 4);
- target_store_registers (-1);
- return sp;
-}
+ /* Set the stack pointer. According to the ABI, the SP is ment to
+ be set _before_ the corresponding stack space is used. No need
+ for that here though - the target has been completly stopped - it
+ isn't possible for an exception handler to stomp on the stack. */
+ regcache_raw_write_signed (regcache, SP_REGNUM, sp);
-/* Function: ppc_push_return_address (pc, sp)
- Set up the return address for the inferior function call. */
+ /* Point the inferior function call's return address at the dummy's
+ breakpoint. */
+ regcache_raw_write_signed (regcache, tdep->ppc_lr_regnum, bp_addr);
-static CORE_ADDR
-ppc_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
-{
- write_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum,
- CALL_DUMMY_ADDRESS ());
+ /* Set the TOC register, get the value from the objfile reader
+ which, in turn, gets it from the VMAP table. */
+ if (rs6000_find_toc_address_hook != NULL)
+ {
+ CORE_ADDR tocvalue = (*rs6000_find_toc_address_hook) (func_addr);
+ regcache_raw_write_signed (regcache, tdep->ppc_toc_regnum, tocvalue);
+ }
+
+ target_store_registers (-1);
return sp;
}
CORE_ADDR
rs6000_skip_trampoline_code (CORE_ADDR pc)
{
- register unsigned int ii, op;
+ unsigned int ii, op;
int rel;
CORE_ADDR solib_target_pc;
struct minimal_symbol *msymbol;
frame. */
return read_memory_addr (get_frame_base (thisframe), wordsize);
- if (inside_entry_file (get_frame_pc (thisframe))
+ if (deprecated_inside_entry_file (get_frame_pc (thisframe))
|| get_frame_pc (thisframe) == entry_point_address ())
return 0;
return regnum;
}
-/* Store the address of the place in which to copy the structure the
- subroutine will return. */
-
-static void
-rs6000_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
-{
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
- write_register (tdep->ppc_gp0_regnum + 3, addr);
-}
-
/* Write into appropriate registers a function return value
of type TYPE, given in virtual format. */
static void
set_gdbarch_print_insn (gdbarch, gdb_print_insn_powerpc);
set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
- set_gdbarch_deprecated_dummy_write_sp (gdbarch, deprecated_write_sp);
set_gdbarch_num_regs (gdbarch, v->nregs);
set_gdbarch_num_pseudo_regs (gdbarch, v->npregs);
set_gdbarch_deprecated_register_bytes (gdbarch, off);
set_gdbarch_deprecated_register_byte (gdbarch, rs6000_register_byte);
set_gdbarch_deprecated_register_raw_size (gdbarch, rs6000_register_raw_size);
- set_gdbarch_deprecated_max_register_raw_size (gdbarch, 16);
- set_gdbarch_deprecated_register_virtual_size (gdbarch, generic_register_size);
- set_gdbarch_deprecated_max_register_virtual_size (gdbarch, 16);
set_gdbarch_deprecated_register_virtual_type (gdbarch, rs6000_register_virtual_type);
set_gdbarch_ptr_bit (gdbarch, wordsize * TARGET_CHAR_BIT);
set_gdbarch_long_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
set_gdbarch_char_signed (gdbarch, 0);
- set_gdbarch_deprecated_fix_call_dummy (gdbarch, rs6000_fix_call_dummy);
set_gdbarch_frame_align (gdbarch, rs6000_frame_align);
+ if (sysv_abi && wordsize == 8)
+ /* PPC64 SYSV. */
+ set_gdbarch_frame_red_zone_size (gdbarch, 288);
+ else if (!sysv_abi && wordsize == 4)
+ /* PowerOpen / AIX 32 bit. */
+ set_gdbarch_frame_red_zone_size (gdbarch, 220);
set_gdbarch_deprecated_save_dummy_frame_tos (gdbarch, generic_save_dummy_frame_tos);
- set_gdbarch_deprecated_push_return_address (gdbarch, ppc_push_return_address);
set_gdbarch_believe_pcc_promotion (gdbarch, 1);
set_gdbarch_deprecated_register_convertible (gdbarch, rs6000_register_convertible);
64-bit code. At some point in the future, this matter needs to be
revisited. */
if (sysv_abi && wordsize == 4)
- set_gdbarch_deprecated_push_arguments (gdbarch, ppc_sysv_abi_push_arguments);
+ set_gdbarch_push_dummy_call (gdbarch, ppc_sysv_abi_push_dummy_call);
else
- set_gdbarch_deprecated_push_arguments (gdbarch, rs6000_push_arguments);
+ set_gdbarch_push_dummy_call (gdbarch, rs6000_push_dummy_call);
- set_gdbarch_deprecated_store_struct_return (gdbarch, rs6000_store_struct_return);
set_gdbarch_extract_struct_value_address (gdbarch, rs6000_extract_struct_value_address);
set_gdbarch_deprecated_pop_frame (gdbarch, rs6000_pop_frame);
set_gdbarch_convert_from_func_ptr_addr (gdbarch,
rs6000_convert_from_func_ptr_addr);
}
- set_gdbarch_frame_args_address (gdbarch, rs6000_frame_args_address);
- set_gdbarch_frame_locals_address (gdbarch, rs6000_frame_args_address);
+ set_gdbarch_deprecated_frame_args_address (gdbarch, rs6000_frame_args_address);
+ set_gdbarch_deprecated_frame_locals_address (gdbarch, rs6000_frame_args_address);
set_gdbarch_deprecated_saved_pc_after_call (gdbarch, rs6000_saved_pc_after_call);
/* Helpers for function argument information. */