diff -urpN src/gdb/spu-tdep.c dev/gdb/spu-tdep.c --- src/gdb/spu-tdep.c 2007-06-18 05:36:44.000000000 +0200 +++ dev/gdb/spu-tdep.c 2007-08-08 08:39:41.000000000 +0200 @@ -324,6 +324,47 @@ spu_register_reggroup_p (struct gdbarch return default_register_reggroup_p (gdbarch, regnum, group); } +/* Address conversion. */ + +static void +spu_address_to_pointer (struct type *type, gdb_byte *buf, CORE_ADDR addr) +{ + store_unsigned_integer (buf, TYPE_LENGTH (type), addr); +} + +static CORE_ADDR +spu_pointer_to_address (struct type *type, const gdb_byte *buf) +{ + ULONGEST addr = extract_unsigned_integer (buf, TYPE_LENGTH (type)); + ULONGEST lslr = SPU_LS_SIZE - 1; /* Hard-wired LS size. */ + + if (target_has_registers && target_has_stack && target_has_memory) + { + struct frame_info *frame = get_selected_frame (NULL); + lslr = get_frame_register_unsigned (frame, SPU_LSLR_REGNUM); + } + + return addr & lslr; +} + +static CORE_ADDR +spu_integer_to_address (struct gdbarch *gdbarch, + struct type *type, const gdb_byte *buf) +{ + ULONGEST addr = unpack_long (type, buf); + ULONGEST lslr = SPU_LS_SIZE - 1; /* Hard-wired LS size. */ + + if (target_has_registers && target_has_stack && target_has_memory + /* FIXME: Currently needed for dwarf2_read_address to work. */ + && type != builtin_type_uint32) + { + struct frame_info *frame = get_selected_frame (NULL); + lslr = get_frame_register_unsigned (frame, SPU_LSLR_REGNUM); + } + + return addr & lslr; +} + /* Decoding SPU instructions. */ @@ -2008,6 +2049,11 @@ spu_gdbarch_init (struct gdbarch_info in set_gdbarch_double_format (gdbarch, floatformats_ieee_double); set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double); + /* Address conversion. */ + set_gdbarch_address_to_pointer (gdbarch, spu_address_to_pointer); + set_gdbarch_pointer_to_address (gdbarch, spu_pointer_to_address); + set_gdbarch_integer_to_address (gdbarch, spu_integer_to_address); + /* Inferior function calls. */ set_gdbarch_call_dummy_location (gdbarch, ON_STACK); set_gdbarch_frame_align (gdbarch, spu_frame_align);