From c113ed0ca238bbcbc161f059ffe9b064e3ece333 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Wed, 21 Feb 2018 11:20:03 +0000 Subject: [PATCH] Pass readable_regcache to gdbarch method read_pc We can pass readable_regcache to gdbarch method read_pc where it is allowed to do read from regcache. gdb: 2018-02-21 Yao Qi * avr-tdep.c (avr_read_pc): Change parameter type to readable_regcache. * gdbarch.sh (read_pc): Likewise. * gdbarch.c: Re-generated. * gdbarch.h: Re-generated. * hppa-tdep.c (hppa_read_pc): Change parameter type to readable_regcache. * ia64-tdep.c (ia64_read_pc): Likewise. * mips-tdep.c (mips_read_pc): Likewise. * spu-tdep.c (spu_read_pc): Likewise. --- gdb/ChangeLog | 13 +++++++++++++ gdb/avr-tdep.c | 5 +++-- gdb/gdbarch.c | 2 +- gdb/gdbarch.h | 4 ++-- gdb/gdbarch.sh | 2 +- gdb/hppa-tdep.c | 6 +++--- gdb/ia64-tdep.c | 6 +++--- gdb/mips-tdep.c | 4 ++-- gdb/spu-tdep.c | 5 +++-- 9 files changed, 31 insertions(+), 16 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c1b1d485e8c..e58bc386e3e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2018-02-21 Yao Qi + + * avr-tdep.c (avr_read_pc): Change parameter type to + readable_regcache. + * gdbarch.sh (read_pc): Likewise. + * gdbarch.c: Re-generated. + * gdbarch.h: Re-generated. + * hppa-tdep.c (hppa_read_pc): Change parameter type to + readable_regcache. + * ia64-tdep.c (ia64_read_pc): Likewise. + * mips-tdep.c (mips_read_pc): Likewise. + * spu-tdep.c (spu_read_pc): Likewise. + 2018-02-21 Yao Qi * Makefile.in (COMMON_SFILES): Add regcache-dump.c diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 7f88e8f5fdb..c44a3aa9677 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -367,10 +367,11 @@ avr_integer_to_address (struct gdbarch *gdbarch, } static CORE_ADDR -avr_read_pc (struct regcache *regcache) +avr_read_pc (readable_regcache *regcache) { ULONGEST pc; - regcache_cooked_read_unsigned (regcache, AVR_PC_REGNUM, &pc); + + regcache->cooked_read (AVR_PC_REGNUM, &pc); return avr_make_iaddr (pc); } diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 705a6d36b0b..62cb9a5d88a 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -1906,7 +1906,7 @@ gdbarch_read_pc_p (struct gdbarch *gdbarch) } CORE_ADDR -gdbarch_read_pc (struct gdbarch *gdbarch, struct regcache *regcache) +gdbarch_read_pc (struct gdbarch *gdbarch, readable_regcache *regcache) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->read_pc != NULL); diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 249ad614fc8..30c2bf3af3a 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -245,8 +245,8 @@ extern void set_gdbarch_char_signed (struct gdbarch *gdbarch, int char_signed); extern int gdbarch_read_pc_p (struct gdbarch *gdbarch); -typedef CORE_ADDR (gdbarch_read_pc_ftype) (struct regcache *regcache); -extern CORE_ADDR gdbarch_read_pc (struct gdbarch *gdbarch, struct regcache *regcache); +typedef CORE_ADDR (gdbarch_read_pc_ftype) (readable_regcache *regcache); +extern CORE_ADDR gdbarch_read_pc (struct gdbarch *gdbarch, readable_regcache *regcache); extern void set_gdbarch_read_pc (struct gdbarch *gdbarch, gdbarch_read_pc_ftype *read_pc); extern int gdbarch_write_pc_p (struct gdbarch *gdbarch); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 8477dd7e91e..10a2aa9f6f2 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -422,7 +422,7 @@ v;int;dwarf2_addr_size;;;sizeof (void*);0;gdbarch_ptr_bit (gdbarch) / TARGET_CHA # One if \`char' acts like \`signed char', zero if \`unsigned char'. v;int;char_signed;;;1;-1;1 # -F;CORE_ADDR;read_pc;struct regcache *regcache;regcache +F;CORE_ADDR;read_pc;readable_regcache *regcache;regcache F;void;write_pc;struct regcache *regcache, CORE_ADDR val;regcache, val # Function for getting target's idea of a frame pointer. FIXME: GDB's # whole scheme for dealing with "frames" and "frame pointers" needs a diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index cc9434e14eb..84dbd667485 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -1304,13 +1304,13 @@ hppa64_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr) } CORE_ADDR -hppa_read_pc (struct regcache *regcache) +hppa_read_pc (readable_regcache *regcache) { ULONGEST ipsw; ULONGEST pc; - regcache_cooked_read_unsigned (regcache, HPPA_IPSW_REGNUM, &ipsw); - regcache_cooked_read_unsigned (regcache, HPPA_PCOQ_HEAD_REGNUM, &pc); + regcache->cooked_read (HPPA_IPSW_REGNUM, &ipsw); + regcache->cooked_read (HPPA_PCOQ_HEAD_REGNUM, &pc); /* If the current instruction is nullified, then we are effectively still executing the previous instruction. Pretend we are still diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 6c9b341af80..4f02f053758 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -876,13 +876,13 @@ ia64_breakpoint_from_pc (struct gdbarch *gdbarch, } static CORE_ADDR -ia64_read_pc (struct regcache *regcache) +ia64_read_pc (readable_regcache *regcache) { ULONGEST psr_value, pc_value; int slot_num; - regcache_cooked_read_unsigned (regcache, IA64_PSR_REGNUM, &psr_value); - regcache_cooked_read_unsigned (regcache, IA64_IP_REGNUM, &pc_value); + regcache->cooked_read (IA64_PSR_REGNUM, &psr_value); + regcache->cooked_read (IA64_IP_REGNUM, &pc_value); slot_num = (psr_value >> 41) & 3; return pc_value | (slot_num * SLOT_MULTIPLIER); diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 2c1a8f0d9e5..05f27a516c9 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -1362,12 +1362,12 @@ mips_in_frame_stub (CORE_ADDR pc) all registers should be sign extended for simplicity? */ static CORE_ADDR -mips_read_pc (struct regcache *regcache) +mips_read_pc (readable_regcache *regcache) { int regnum = gdbarch_pc_regnum (regcache->arch ()); LONGEST pc; - regcache_cooked_read_signed (regcache, regnum, &pc); + regcache->cooked_read (regnum, &pc); return pc; } diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c index a632c0656e9..695b5cca0dc 100644 --- a/gdb/spu-tdep.c +++ b/gdb/spu-tdep.c @@ -1176,11 +1176,12 @@ spu_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame) } static CORE_ADDR -spu_read_pc (struct regcache *regcache) +spu_read_pc (readable_regcache *regcache) { struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); ULONGEST pc; - regcache_cooked_read_unsigned (regcache, SPU_PC_REGNUM, &pc); + + regcache->cooked_read (SPU_PC_REGNUM, &pc); /* Mask off interrupt enable bit. */ return SPUADDR (tdep->id, pc & -4); } -- 2.30.2