2004-06-30 Jim Blandy Support the new E500 raw regcache layout on the simulator. * rs6000-tdep.c: #include "sim-regno.h". (e500_register_sim_regno, e500_sim_supply_register, e500_sim_collect_register): New functions. (rs6000_gdbarch_init): Register them. * Makefile.in (rs6000-tdep.o): Update dependencies. diff -crp -x '*~' -x CVS gdb/rs6000-tdep.c gdb/rs6000-tdep.c *** gdb/rs6000-tdep.c 2004-06-30 10:54:01.000000000 -0500 --- gdb/rs6000-tdep.c 2004-06-30 11:13:57.000000000 -0500 *************** *** 37,42 **** --- 37,43 ---- #include "parser-defs.h" #include "osabi.h" #include "infcall.h" + #include "sim-regno.h" #include "reggroups.h" #include "libbfd.h" /* for bfd_default_set_arch_mach */ *************** e500_register_reggroup_p (struct gdbarch *** 1876,1881 **** --- 1877,1979 ---- return default_register_reggroup_p (gdbarch, regnum, group); } + static int + e500_register_sim_regno (int gdb_regno) + { + struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + + /* Only makes sense to supply raw registers. */ + gdb_assert (gdb_regno >= 0 && gdb_regno < NUM_REGS); + + /* We access general-purpose registers in the sim via the ev + registers. The sim_collect_register and sim_supply_register + functions take care of piecing together / taking apart the + two halves. */ + if (tdep->ppc_gp0_regnum <= gdb_regno + && gdb_regno < tdep->ppc_gp0_regnum + ppc_num_gprs) + return gdb_regno - tdep->ppc_gp0_regnum + tdep->ppc_ev0_regnum; + + /* Same for the upper halves. */ + else if (tdep->ppc_ev0_upper_regnum <= gdb_regno + && gdb_regno < tdep->ppc_ev0_upper_regnum + ppc_num_gprs) + return gdb_regno - tdep->ppc_ev0_upper_regnum + tdep->ppc_ev0_regnum; + + /* Skip registers that have no names. */ + else if (REGISTER_NAME (gdb_regno) == NULL + || REGISTER_NAME (gdb_regno)[0] == '\0') + return LEGACY_SIM_REGNO_IGNORE; + else + return gdb_regno; + } + + static void + e500_sim_supply_register (struct regcache *regcache, + int gdb_regnum, + const void *buffer) + { + struct gdbarch *arch = get_regcache_arch (regcache); + struct gdbarch_tdep *tdep = gdbarch_tdep (arch); + + /* If the GDB register number is a general-purpose register number, + then the value we actually got from the sim is a 64-bit EV + register value. Supply both halves, even though the caller only + asked for one. */ + if (tdep->ppc_gp0_regnum <= gdb_regnum + && gdb_regnum < tdep->ppc_gp0_regnum + ppc_num_gprs) + e500_move_ev_register + ((void (*) (struct regcache *, int, void *)) regcache_raw_supply, + regcache, + gdb_regnum - tdep->ppc_gp0_regnum + tdep->ppc_ev0_regnum, + (void *) buffer); + + /* Similarly for the upper-half registers. */ + else if (tdep->ppc_ev0_upper_regnum <= gdb_regnum + && gdb_regnum < tdep->ppc_ev0_upper_regnum + ppc_num_gprs) + e500_move_ev_register + ((void (*) (struct regcache *, int, void *)) regcache_raw_supply, + regcache, + gdb_regnum - tdep->ppc_ev0_upper_regnum + tdep->ppc_ev0_regnum, + (void *) buffer); + + /* Everything else we pass through undisturbed. */ + else + regcache_raw_supply (regcache, gdb_regnum, buffer); + } + + static void + e500_sim_collect_register (const struct regcache *regcache, + int gdb_regnum, + void *buffer) + { + struct gdbarch *arch = get_regcache_arch (regcache); + struct gdbarch_tdep *tdep = gdbarch_tdep (arch); + + /* If the GDB register number is a general-purpose register number, + then the value we actually got from the sim is a 64-bit EV + register value. Collect both halves, even though the caller only + asked for one. */ + if (tdep->ppc_gp0_regnum <= gdb_regnum + && gdb_regnum < tdep->ppc_gp0_regnum + ppc_num_gprs) + e500_move_ev_register + ((void (*) (struct regcache *, int, void *)) regcache_raw_collect, + (struct regcache *) regcache, + gdb_regnum - tdep->ppc_gp0_regnum + tdep->ppc_ev0_regnum, + buffer); + + /* Similarly for the upper-half registers. */ + else if (tdep->ppc_ev0_upper_regnum <= gdb_regnum + && gdb_regnum < tdep->ppc_ev0_upper_regnum + ppc_num_gprs) + e500_move_ev_register + ((void (*) (struct regcache *, int, void *)) regcache_raw_collect, + (struct regcache *) regcache, + gdb_regnum - tdep->ppc_ev0_upper_regnum + tdep->ppc_ev0_regnum, + (void *) buffer); + + /* Everything else we pass through undisturbed. */ + else + regcache_raw_collect ((struct regcache *) regcache, gdb_regnum, buffer); + } + /* Convert a DBX STABS register number to a GDB register number. */ static int rs6000_stab_reg_to_regnum (int num) *************** rs6000_gdbarch_init (struct gdbarch_info *** 3025,3030 **** --- 3123,3131 ---- set_gdbarch_pseudo_register_read (gdbarch, e500_pseudo_register_read); set_gdbarch_pseudo_register_write (gdbarch, e500_pseudo_register_write); set_gdbarch_register_reggroup_p (gdbarch, e500_register_reggroup_p); + set_gdbarch_register_sim_regno (gdbarch, e500_register_sim_regno); + set_gdbarch_sim_supply_register (gdbarch, e500_sim_supply_register); + set_gdbarch_sim_collect_register (gdbarch, e500_sim_collect_register); break; } diff -crp -x '*~' -x CVS gdb/Makefile.in gdb/Makefile.in *** gdb/Makefile.in 2004-06-30 10:56:08.000000000 -0500 --- gdb/Makefile.in 2004-06-30 11:14:36.000000000 -0500 *************** rs6000-tdep.o: rs6000-tdep.c $(defs_h) $ *** 2320,2326 **** $(osabi_h) $(libbfd_h) $(coff_internal_h) $(libcoff_h) \ $(coff_xcoff_h) $(libxcoff_h) $(elf_bfd_h) $(solib_svr4_h) \ $(ppc_tdep_h) $(gdb_assert_h) $(dis_asm_h) $(trad_frame_h) \ ! $(frame_unwind_h) $(frame_base_h) $(infcall_h) $(reggroups_h) s390-nat.o: s390-nat.c $(defs_h) $(tm_h) $(regcache_h) $(inferior_h) \ $(s390_tdep_h) s390-tdep.o: s390-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) $(inferior_h) \ --- 2320,2327 ---- $(osabi_h) $(libbfd_h) $(coff_internal_h) $(libcoff_h) \ $(coff_xcoff_h) $(libxcoff_h) $(elf_bfd_h) $(solib_svr4_h) \ $(ppc_tdep_h) $(gdb_assert_h) $(dis_asm_h) $(trad_frame_h) \ ! $(frame_unwind_h) $(frame_base_h) $(infcall_h) $(sim_regno_h) \ ! $(reggroups_h) s390-nat.o: s390-nat.c $(defs_h) $(tm_h) $(regcache_h) $(inferior_h) \ $(s390_tdep_h) s390-tdep.o: s390-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) $(inferior_h) \