diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 14 | ||||
-rw-r--r-- | gdb/m68k-tdep.c | 48 | ||||
-rw-r--r-- | gdb/m68klinux-nat.c | 47 | ||||
-rw-r--r-- | gdb/m68klinux-tdep.c | 2 |
4 files changed, 67 insertions, 44 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fe96c4d..b2a86e6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,19 @@ 2007-10-08 Markus Deuling <deuling@de.ibm.com> + * m68k-tdep.c (m68k_register_to_value, m68k_value_to_register) + (m68k_svr4_extract_return_value, m68k_svr4_store_return_value) + (m68k_frame_prev_register, m68k_get_longjmp_target): Use + get_regcache_arch or get_frame_arch to get at the current architecture + by regcache or by frame, respectively. + * m68klinux-tdep.c (m68k_linux_sigtramp_frame_cache): Likewise. + * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers) + (store_register, old_store_inferior_registers, supply_gregset) + (supply_fpregset, fill_fpregset): Likewise. + * m68k-tdep.c (m68k_register_type, m68k_unwind_pc, m68k_dump_tdep): + Replace current_gdbarch by gdbarch. + +2007-10-08 Markus Deuling <deuling@de.ibm.com> + * irix5-nat.c (supply_gregset, fill_gregset, supply_fpregset) (fill_fpregset, fetch_core_registers): Use get_regcache_arch or get_frame_arch to get at the current architecture by regcache or by diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index f26e1a6..6095015 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -105,12 +105,12 @@ m68k_init_types (void) static struct type * m68k_register_type (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (tdep->fpregs_present) { - if (regnum >= gdbarch_fp0_regnum (current_gdbarch) - && regnum <= gdbarch_fp0_regnum (current_gdbarch) + 7) + if (regnum >= gdbarch_fp0_regnum (gdbarch) + && regnum <= gdbarch_fp0_regnum (gdbarch) + 7) { if (tdep->flavour == m68k_coldfire_flavour) return builtin_type (gdbarch)->builtin_double; @@ -130,7 +130,7 @@ m68k_register_type (struct gdbarch *gdbarch, int regnum) return builtin_type_int0; } - if (regnum == gdbarch_pc_regnum (current_gdbarch)) + if (regnum == gdbarch_pc_regnum (gdbarch)) return builtin_type_void_func_ptr; if (regnum >= M68K_A0_REGNUM && regnum <= M68K_A0_REGNUM + 7) @@ -182,7 +182,8 @@ m68k_register_to_value (struct frame_info *frame, int regnum, struct type *type, gdb_byte *to) { gdb_byte from[M68K_MAX_REGISTER_SIZE]; - struct type *fpreg_type = register_type (current_gdbarch, M68K_FP0_REGNUM); + struct type *fpreg_type = register_type (get_frame_arch (frame), + M68K_FP0_REGNUM); /* We only support floating-point values. */ if (TYPE_CODE (type) != TYPE_CODE_FLT) @@ -206,7 +207,8 @@ m68k_value_to_register (struct frame_info *frame, int regnum, struct type *type, const gdb_byte *from) { gdb_byte to[M68K_MAX_REGISTER_SIZE]; - struct type *fpreg_type = register_type (current_gdbarch, M68K_FP0_REGNUM); + struct type *fpreg_type = register_type (get_frame_arch (frame), + M68K_FP0_REGNUM); /* We only support floating-point values. */ if (TYPE_CODE (type) != TYPE_CODE_FLT) @@ -284,12 +286,12 @@ m68k_svr4_extract_return_value (struct type *type, struct regcache *regcache, { int len = TYPE_LENGTH (type); gdb_byte buf[M68K_MAX_REGISTER_SIZE]; - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (tdep->float_return && TYPE_CODE (type) == TYPE_CODE_FLT) { - struct type *fpreg_type = register_type - (current_gdbarch, M68K_FP0_REGNUM); + struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM); regcache_raw_read (regcache, M68K_FP0_REGNUM, buf); convert_typed_floating (buf, fpreg_type, valbuf, type); } @@ -325,12 +327,12 @@ m68k_svr4_store_return_value (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { int len = TYPE_LENGTH (type); - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (tdep->float_return && TYPE_CODE (type) == TYPE_CODE_FLT) { - struct type *fpreg_type = register_type - (current_gdbarch, M68K_FP0_REGNUM); + struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM); gdb_byte buf[M68K_MAX_REGISTER_SIZE]; convert_typed_floating (valbuf, type, buf, fpreg_type); regcache_raw_write (regcache, M68K_FP0_REGNUM, buf); @@ -829,7 +831,7 @@ m68k_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { gdb_byte buf[8]; - frame_unwind_register (next_frame, gdbarch_pc_regnum (current_gdbarch), buf); + frame_unwind_register (next_frame, gdbarch_pc_regnum (gdbarch), buf); return extract_typed_address (buf, builtin_type_void_func_ptr); } @@ -944,7 +946,7 @@ m68k_frame_prev_register (struct frame_info *next_frame, void **this_cache, { /* Read the value in from memory. */ read_memory (*addrp, valuep, - register_size (current_gdbarch, regnum)); + register_size (get_frame_arch (next_frame), regnum)); } return; } @@ -1010,6 +1012,7 @@ m68k_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) { gdb_byte *buf; CORE_ADDR sp, jb_addr; + struct gdbarch *gdbarch = get_frame_arch (frame); struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame)); if (tdep->jb_pc < 0) @@ -1019,22 +1022,21 @@ m68k_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) return 0; } - buf = alloca (gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT); - sp = get_frame_register_unsigned (frame, gdbarch_sp_regnum (current_gdbarch)); + buf = alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT); + sp = get_frame_register_unsigned (frame, gdbarch_sp_regnum (gdbarch)); if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack */ - buf, - gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT)) + buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT)) return 0; - jb_addr = extract_unsigned_integer (buf, gdbarch_ptr_bit (current_gdbarch) + jb_addr = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT); if (target_read_memory (jb_addr + tdep->jb_pc * tdep->jb_elt_size, buf, - gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT)) + gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT)) return 0; - *pc = extract_unsigned_integer (buf, gdbarch_ptr_bit (current_gdbarch) + *pc = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT); return 1; } @@ -1262,9 +1264,9 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) static void -m68k_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file) +m68k_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; diff --git a/gdb/m68klinux-nat.c b/gdb/m68klinux-nat.c index 848acda..a9d167d 100644 --- a/gdb/m68klinux-nat.c +++ b/gdb/m68klinux-nat.c @@ -115,6 +115,7 @@ int have_ptrace_getregs = static void fetch_register (struct regcache *regcache, int regno) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); /* This isn't really an address. But ptrace thinks of it as one. */ CORE_ADDR regaddr; char mess[128]; /* For messages */ @@ -122,9 +123,9 @@ fetch_register (struct regcache *regcache, int regno) char buf[MAX_REGISTER_SIZE]; int tid; - if (gdbarch_cannot_fetch_register (current_gdbarch, regno)) + if (gdbarch_cannot_fetch_register (gdbarch, regno)) { - memset (buf, '\0', register_size (current_gdbarch, regno)); /* Supply zeroes */ + memset (buf, '\0', register_size (gdbarch, regno)); /* Supply zeroes */ regcache_raw_supply (regcache, regno, buf); return; } @@ -135,7 +136,7 @@ fetch_register (struct regcache *regcache, int regno) tid = PIDGET (inferior_ptid); /* no thread id, just use process id */ regaddr = 4 * regmap[regno]; - for (i = 0; i < register_size (current_gdbarch, regno); + for (i = 0; i < register_size (gdbarch, regno); i += sizeof (PTRACE_TYPE_RET)) { errno = 0; @@ -145,7 +146,7 @@ fetch_register (struct regcache *regcache, int regno) if (errno != 0) { sprintf (mess, "reading register %s (#%d)", - gdbarch_register_name (current_gdbarch, regno), regno); + gdbarch_register_name (gdbarch, regno), regno); perror_with_name (mess); } } @@ -165,7 +166,9 @@ old_fetch_inferior_registers (struct regcache *regcache, int regno) } else { - for (regno = 0; regno < gdbarch_num_regs (current_gdbarch); regno++) + for (regno = 0; + regno < gdbarch_num_regs (get_regcache_arch (regcache)); + regno++) { fetch_register (regcache, regno); } @@ -177,6 +180,7 @@ old_fetch_inferior_registers (struct regcache *regcache, int regno) static void store_register (const struct regcache *regcache, int regno) { + struct gdbarch *gdbarch = reg_regcache_arch (regcache); /* This isn't really an address. But ptrace thinks of it as one. */ CORE_ADDR regaddr; char mess[128]; /* For messages */ @@ -184,7 +188,7 @@ store_register (const struct regcache *regcache, int regno) int tid; char buf[MAX_REGISTER_SIZE]; - if (gdbarch_cannot_store_register (current_gdbarch, regno)) + if (gdbarch_cannot_store_register (gdbarch, regno)) return; /* Overload thread id onto process id */ @@ -198,7 +202,7 @@ store_register (const struct regcache *regcache, int regno) regcache_raw_collect (regcache, regno, buf); /* Store the local buffer into the inferior a chunk at the time. */ - for (i = 0; i < register_size (current_gdbarch, regno); + for (i = 0; i < register_size (gdbarch, regno); i += sizeof (PTRACE_TYPE_RET)) { errno = 0; @@ -208,7 +212,7 @@ store_register (const struct regcache *regcache, int regno) if (errno != 0) { sprintf (mess, "writing register %s (#%d)", - gdbarch_register_name (current_gdbarch, regno), regno); + gdbarch_register_name (gdbarch, regno), regno); perror_with_name (mess); } } @@ -227,7 +231,9 @@ old_store_inferior_registers (const struct regcache *regcache, int regno) } else { - for (regno = 0; regno < gdbarch_num_regs (current_gdbarch); regno++) + for (regno = 0; + regno < gdbarch_num_regs (get_regcache_arch (regcache)); + regno++) { store_register (regcache, regno); } @@ -241,17 +247,18 @@ old_store_inferior_registers (const struct regcache *regcache, int regno) void supply_gregset (struct regcache *regcache, const elf_gregset_t *gregsetp) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); const elf_greg_t *regp = (const elf_greg_t *) gregsetp; int regi; for (regi = M68K_D0_REGNUM; - regi <= gdbarch_sp_regnum (current_gdbarch); + regi <= gdbarch_sp_regnum (gdbarch); regi++) regcache_raw_supply (regcache, regi, ®p[regmap[regi]]); - regcache_raw_supply (regcache, gdbarch_ps_regnum (current_gdbarch), + regcache_raw_supply (regcache, gdbarch_ps_regnum (gdbarch), ®p[PT_SR]); regcache_raw_supply (regcache, - gdbarch_pc_regnum (current_gdbarch), ®p[PT_PC]); + gdbarch_pc_regnum (gdbarch), ®p[PT_PC]); } /* Fill register REGNO (if it is a general-purpose register) in @@ -331,14 +338,14 @@ static void store_regs (const struct regcache *regcache, int tid, int regno) {} void supply_fpregset (struct regcache *regcache, const elf_fpregset_t *fpregsetp) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); int regi; - for (regi = gdbarch_fp0_regnum (current_gdbarch); - regi < gdbarch_fp0_regnum (current_gdbarch) + 8; regi++) + for (regi = gdbarch_fp0_regnum (gdbarch); + regi < gdbarch_fp0_regnum (gdbarch) + 8; regi++) regcache_raw_supply (regcache, regi, FPREG_ADDR (fpregsetp, - regi - gdbarch_fp0_regnum - (current_gdbarch))); + regi - gdbarch_fp0_regnum (gdbarch))); regcache_raw_supply (regcache, M68K_FPC_REGNUM, &fpregsetp->fpcntl[0]); regcache_raw_supply (regcache, M68K_FPS_REGNUM, &fpregsetp->fpcntl[1]); regcache_raw_supply (regcache, M68K_FPI_REGNUM, &fpregsetp->fpcntl[2]); @@ -352,16 +359,16 @@ void fill_fpregset (const struct regcache *regcache, elf_fpregset_t *fpregsetp, int regno) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); int i; /* Fill in the floating-point registers. */ - for (i = gdbarch_fp0_regnum (current_gdbarch); - i < gdbarch_fp0_regnum (current_gdbarch) + 8; i++) + for (i = gdbarch_fp0_regnum (gdbarch); + i < gdbarch_fp0_regnum (gdbarch) + 8; i++) if (regno == -1 || regno == i) regcache_raw_collect (regcache, i, FPREG_ADDR (fpregsetp, - i - gdbarch_fp0_regnum - (current_gdbarch))); + i - gdbarch_fp0_regnum (gdbarch))); /* Fill in the floating-point control registers. */ for (i = M68K_FPC_REGNUM; i <= M68K_FPI_REGNUM; i++) diff --git a/gdb/m68klinux-tdep.c b/gdb/m68klinux-tdep.c index 335a650..8677a12 100644 --- a/gdb/m68klinux-tdep.c +++ b/gdb/m68klinux-tdep.c @@ -260,7 +260,7 @@ m68k_linux_sigtramp_frame_cache (struct frame_info *next_frame, { struct frame_id this_id; struct trad_frame_cache *cache; - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (next_frame)); struct m68k_linux_sigtramp_info info; char buf[4]; int i; |