From 8b164abbfd6b72bdcd87516fe1db4bc56be354cf Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Wed, 10 Oct 2007 17:06:30 +0000 Subject: [PATCH] 2007-10-10 Markus Deuling * rs6000-nat.c (fetch_register, store_register) (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers): Use get_regcache_arch to get at the current architecture by regcache. * rs6000-tdep.c (rs6000_push_dummy_call, rs6000_return_value) (rs6000_register_reggroup_p, e500_move_ev_registe, rs6000_unwind_pc) (rs6000_unwind_dummy_id, rs6000_frame_cache, rs6000_dump_tdep): Replace current_gdbarch by gdbarch. (rs6000_skip_trampoline_code, rs6000_register_to_value) (rs6000_value_to_register): Use get_frame_arch to get at the current architecture by frame_info. --- gdb/ChangeLog | 14 +++++++++++++ gdb/rs6000-nat.c | 22 +++++++++++--------- gdb/rs6000-tdep.c | 51 ++++++++++++++++++++++++----------------------- 3 files changed, 53 insertions(+), 34 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a8b4d2de974..617e0bdb583 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,17 @@ +2007-10-10 Markus Deuling + + * rs6000-nat.c (fetch_register, store_register) + (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers): Use + get_regcache_arch to get at the current architecture by regcache. + + * rs6000-tdep.c (rs6000_push_dummy_call, rs6000_return_value) + (rs6000_register_reggroup_p, e500_move_ev_registe, rs6000_unwind_pc) + (rs6000_unwind_dummy_id, rs6000_frame_cache, rs6000_dump_tdep): Replace + current_gdbarch by gdbarch. + (rs6000_skip_trampoline_code, rs6000_register_to_value) + (rs6000_value_to_register): Use get_frame_arch to get at the current + architecture by frame_info. + 2007-10-10 Markus Deuling * sparc-tdep.c (sparc_supply_rwindow, sparc_collect_rwindow): Use diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index 3d51b3be49b..8361e900e14 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -211,6 +211,7 @@ rs6000_ptrace64 (int req, int id, long long addr, int data, void *buf) static void fetch_register (struct regcache *regcache, int regno) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); int addr[MAX_REGISTER_SIZE]; int nr, isfloat; @@ -226,7 +227,7 @@ fetch_register (struct regcache *regcache, int regno) /* Bogus register number. */ else if (nr < 0) { - if (regno >= gdbarch_num_regs (current_gdbarch)) + if (regno >= gdbarch_num_regs (gdbarch)) fprintf_unfiltered (gdb_stderr, "gdb error: register no %d not implemented.\n", regno); @@ -244,7 +245,7 @@ fetch_register (struct regcache *regcache, int regno) even if the register is really only 32 bits. */ long long buf; rs6000_ptrace64 (PT_READ_GPR, PIDGET (inferior_ptid), nr, 0, &buf); - if (register_size (current_gdbarch, regno) == 8) + if (register_size (gdbarch, regno) == 8) memcpy (addr, &buf, 8); else *addr = buf; @@ -268,6 +269,7 @@ fetch_register (struct regcache *regcache, int regno) static void store_register (const struct regcache *regcache, int regno) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); int addr[MAX_REGISTER_SIZE]; int nr, isfloat; @@ -286,7 +288,7 @@ store_register (const struct regcache *regcache, int regno) /* Bogus register number. */ else if (nr < 0) { - if (regno >= gdbarch_num_regs (current_gdbarch)) + if (regno >= gdbarch_num_regs (gdbarch)) fprintf_unfiltered (gdb_stderr, "gdb error: register no %d not implemented.\n", regno); @@ -295,7 +297,7 @@ store_register (const struct regcache *regcache, int regno) /* Fixed-point registers. */ else { - if (regno == gdbarch_sp_regnum (current_gdbarch)) + if (regno == gdbarch_sp_regnum (gdbarch)) /* Execute one dummy instruction (which is a breakpoint) in inferior process to give kernel a chance to do internal housekeeping. Otherwise the following ptrace(2) calls will mess up user stack @@ -313,7 +315,7 @@ store_register (const struct regcache *regcache, int regno) /* PT_WRITE_GPR requires the buffer parameter to point to an 8-byte area, even if the register is really only 32 bits. */ long long buf; - if (register_size (current_gdbarch, regno) == 8) + if (register_size (gdbarch, regno) == 8) memcpy (&buf, addr, 8); else buf = *addr; @@ -334,12 +336,13 @@ store_register (const struct regcache *regcache, int regno) static void rs6000_fetch_inferior_registers (struct regcache *regcache, int regno) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); if (regno != -1) fetch_register (regcache, regno); else { - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); /* Read 32 general purpose registers. */ for (regno = tdep->ppc_gp0_regnum; @@ -355,7 +358,7 @@ rs6000_fetch_inferior_registers (struct regcache *regcache, int regno) fetch_register (regcache, tdep->ppc_fp0_regnum + regno); /* Read special registers. */ - fetch_register (regcache, gdbarch_pc_regnum (current_gdbarch)); + fetch_register (regcache, gdbarch_pc_regnum (gdbarch)); fetch_register (regcache, tdep->ppc_ps_regnum); fetch_register (regcache, tdep->ppc_cr_regnum); fetch_register (regcache, tdep->ppc_lr_regnum); @@ -375,12 +378,13 @@ rs6000_fetch_inferior_registers (struct regcache *regcache, int regno) static void rs6000_store_inferior_registers (struct regcache *regcache, int regno) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); if (regno != -1) store_register (regcache, regno); else { - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); /* Write general purpose registers first. */ for (regno = tdep->ppc_gp0_regnum; @@ -396,7 +400,7 @@ rs6000_store_inferior_registers (struct regcache *regcache, int regno) store_register (regcache, tdep->ppc_fp0_regnum + regno); /* Write special registers. */ - store_register (regcache, gdbarch_pc_regnum (current_gdbarch)); + store_register (regcache, gdbarch_pc_regnum (gdbarch)); store_register (regcache, tdep->ppc_ps_regnum); store_register (regcache, tdep->ppc_cr_regnum); store_register (regcache, tdep->ppc_lr_regnum); diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 352843471c7..0f51356b62e 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -1682,14 +1682,14 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); int ii; int len = 0; int argno; /* current argument number */ int argbytes; /* current argument byte */ gdb_byte tmp_buffer[50]; int f_argno = 0; /* current floating point argno */ - int wordsize = gdbarch_tdep (current_gdbarch)->wordsize; + int wordsize = gdbarch_tdep (gdbarch)->wordsize; CORE_ADDR func_addr = find_function_addr (function, NULL); struct value *arg = 0; @@ -1700,7 +1700,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* The calling convention this function implements assumes the processor has floating-point registers. We shouldn't be using it on PPC variants that lack them. */ - gdb_assert (ppc_floating_point_unit_p (current_gdbarch)); + gdb_assert (ppc_floating_point_unit_p (gdbarch)); /* The first eight words of ther arguments are passed in registers. Copy them appropriately. */ @@ -1738,7 +1738,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (argno = 0, argbytes = 0; argno < nargs && ii < 8; ++ii) { - int reg_size = register_size (current_gdbarch, ii + 3); + int reg_size = register_size (gdbarch, ii + 3); arg = args[argno]; type = check_typedef (value_type (arg)); @@ -1785,7 +1785,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, else { /* Argument can fit in one register. No problem. */ - int adj = gdbarch_byte_order (current_gdbarch) + int adj = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? reg_size - len : 0; gdb_byte word[MAX_REGISTER_SIZE]; @@ -1799,7 +1799,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, ran_out_of_registers_for_arguments: regcache_cooked_read_unsigned (regcache, - gdbarch_sp_regnum (current_gdbarch), + gdbarch_sp_regnum (gdbarch), &saved_sp); /* Location for 8 parameters are always reserved. */ @@ -1843,7 +1843,7 @@ ran_out_of_registers_for_arguments: else. */ regcache_raw_write_signed (regcache, - gdbarch_sp_regnum (current_gdbarch), sp); + gdbarch_sp_regnum (gdbarch), sp); /* If the last argument copied into the registers didn't fit there completely, push the rest of it into stack. */ @@ -1890,7 +1890,7 @@ ran_out_of_registers_for_arguments: Not doing this can lead to conflicts with the kernel which thinks that it still has control over this not-yet-allocated stack region. */ - regcache_raw_write_signed (regcache, gdbarch_sp_regnum (current_gdbarch), sp); + regcache_raw_write_signed (regcache, gdbarch_sp_regnum (gdbarch), sp); /* Set back chain properly. */ store_unsigned_integer (tmp_buffer, wordsize, saved_sp); @@ -1917,13 +1917,13 @@ rs6000_return_value (struct gdbarch *gdbarch, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); gdb_byte buf[8]; /* The calling convention this function implements assumes the processor has floating-point registers. We shouldn't be using it on PowerPC variants that lack them. */ - gdb_assert (ppc_floating_point_unit_p (current_gdbarch)); + gdb_assert (ppc_floating_point_unit_p (gdbarch)); /* AltiVec extension: Functions that declare a vector data type as a return value place that return value in VR2. */ @@ -2124,7 +2124,8 @@ rs6000_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) return 0; } ii = get_frame_register_unsigned (frame, 11); /* r11 holds destination addr */ - pc = read_memory_addr (ii, gdbarch_tdep (current_gdbarch)->wordsize); /* (r11) value */ + pc = read_memory_addr (ii, + gdbarch_tdep (get_frame_arch (frame))->wordsize); /* (r11) value */ return pc; } @@ -2279,8 +2280,8 @@ rs6000_register_reggroup_p (struct gdbarch *gdbarch, int regnum, int vector_p; int general_p; - if (gdbarch_register_name (current_gdbarch, regnum) == NULL - || *gdbarch_register_name (current_gdbarch, regnum) == '\0') + if (gdbarch_register_name (gdbarch, regnum) == NULL + || *gdbarch_register_name (gdbarch, regnum) == '\0') return 0; if (group == all_reggroup) return 1; @@ -2314,7 +2315,7 @@ rs6000_register_reggroup_p (struct gdbarch *gdbarch, int regnum, || regnum == tdep->ppc_lr_regnum || regnum == tdep->ppc_ctr_regnum || regnum == tdep->ppc_xer_regnum - || regnum == gdbarch_pc_regnum (current_gdbarch)); + || regnum == gdbarch_pc_regnum (gdbarch)); if (group == general_reggroup) return general_p; @@ -2343,7 +2344,7 @@ rs6000_register_to_value (struct frame_info *frame, struct type *type, gdb_byte *to) { - const struct reg *reg = gdbarch_tdep (current_gdbarch)->regs + regnum; + const struct reg *reg = gdbarch_tdep (get_frame_arch (frame))->regs + regnum; gdb_byte from[MAX_REGISTER_SIZE]; gdb_assert (reg->fpr); @@ -2359,7 +2360,7 @@ rs6000_value_to_register (struct frame_info *frame, struct type *type, const gdb_byte *from) { - const struct reg *reg = gdbarch_tdep (current_gdbarch)->regs + regnum; + const struct reg *reg = gdbarch_tdep (get_frame_arch (frame))->regs + regnum; gdb_byte to[MAX_REGISTER_SIZE]; gdb_assert (reg->fpr); @@ -2408,7 +2409,7 @@ e500_move_ev_register (void (*move) (struct regcache *regcache, reg_index = ev_reg - tdep->ppc_ev0_regnum; - if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG) { move (regcache, tdep->ppc_ev0_upper_regnum + reg_index, byte_buffer); move (regcache, tdep->ppc_gp0_regnum + reg_index, byte_buffer + 4); @@ -3224,14 +3225,14 @@ static CORE_ADDR rs6000_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { return frame_unwind_register_unsigned (next_frame, - gdbarch_pc_regnum (current_gdbarch)); + gdbarch_pc_regnum (gdbarch)); } static struct frame_id rs6000_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame) { return frame_id_build (frame_unwind_register_unsigned - (next_frame, gdbarch_sp_regnum (current_gdbarch)), + (next_frame, gdbarch_sp_regnum (gdbarch)), frame_pc_unwind (next_frame)); } @@ -3270,7 +3271,7 @@ rs6000_frame_cache (struct frame_info *next_frame, void **this_cache) the mean time, the address of the prev frame is used as the base address of this frame. */ cache->base = frame_unwind_register_unsigned - (next_frame, gdbarch_sp_regnum (current_gdbarch)); + (next_frame, gdbarch_sp_regnum (gdbarch)); /* If the function appears to be frameless, check a couple of likely indicators that we have simply failed to find the frame setup. @@ -3309,7 +3310,7 @@ rs6000_frame_cache (struct frame_info *next_frame, void **this_cache) cache->base = read_memory_addr (cache->base, wordsize); trad_frame_set_value (cache->saved_regs, - gdbarch_sp_regnum (current_gdbarch), cache->base); + gdbarch_sp_regnum (gdbarch), cache->base); /* if != -1, fdata.saved_fpr is the smallest number of saved_fpr. All fpr's from saved_fpr to fp31 are saved. */ @@ -3388,7 +3389,7 @@ rs6000_frame_cache (struct frame_info *next_frame, void **this_cache) if (fdata.lr_offset != 0) cache->saved_regs[tdep->ppc_lr_regnum].addr = cache->base + fdata.lr_offset; /* The PC is found in the link register. */ - cache->saved_regs[gdbarch_pc_regnum (current_gdbarch)] = + cache->saved_regs[gdbarch_pc_regnum (gdbarch)] = cache->saved_regs[tdep->ppc_lr_regnum]; /* If != 0, fdata.vrsave_offset is the offset from the frame that @@ -3400,7 +3401,7 @@ rs6000_frame_cache (struct frame_info *next_frame, void **this_cache) /* If no alloca register used, then fi->frame is the value of the %sp for this frame, and it is good enough. */ cache->initial_sp = frame_unwind_register_unsigned - (next_frame, gdbarch_sp_regnum (current_gdbarch)); + (next_frame, gdbarch_sp_regnum (gdbarch)); else cache->initial_sp = frame_unwind_register_unsigned (next_frame, fdata.alloca_reg); @@ -3814,9 +3815,9 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } static void -rs6000_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file) +rs6000_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) { - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (tdep == NULL) return; -- 2.30.2