From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23953 invoked by alias); 25 Jul 2002 13:38:11 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 23941 invoked from network); 25 Jul 2002 13:38:10 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 25 Jul 2002 13:38:10 -0000 Received: by localhost.redhat.com (Postfix, from userid 469) id D76DA108C9; Thu, 25 Jul 2002 09:36:31 -0400 (EDT) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15679.65247.570968.415011@localhost.redhat.com> Date: Thu, 25 Jul 2002 06:57:00 -0000 To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: [patch/rfc/rfa:sh] gdbarch_register_read() -> gdbarch_cooked_register_read() In-Reply-To: <3D3F34BF.3080902@ges.redhat.com> References: <3D3F34BF.3080902@ges.redhat.com> X-SW-Source: 2002-07/txt/msg00507.txt.bz2 Andrew Cagney writes: > Hello, > > The attached patch replaces the architecture vector interface: > > void gdbarch_register_read (struct gdbarch *gdbarch, int regnum, char > *buf); > > with the new interface: > > void gdbarch_cooked_register_read (struct gdbarch *gdbarch, struct > regcache *regcache, int regnum, void *buf) > > and then fixes the consequnces (all syntatic). > > > One NB. The parameter set is technically redundant. The assertion: > > gdbarch == regcache_gdbarch (regcache) > > always holds so the gdbarch parameter isn't strictly needed. I figured > that it is more convenient to include the gdbarch as a parameter and > save everyone the hassle of including the above line in their *-tdep code. > > The SH stuff should be reviewed. I think its on the right track since > sh-tdep.c no longer refers to current_regcache!!! > > comments? sh ok? OK. Elena > Andrew > 2002-07-24 Andrew Cagney > > * gdbarch.sh (cooked_register_read, cooked_register_write): > Replace the architecture methods register_read and register_write. > * gdbarch.h, gdbarch.c: Regenerate. > * sh-tdep.c (sh_gdbarch_init): Update. > (sh4_cooked_register_write): Replace sh4_register_write. > (sh4_cooked_register_read): Replace sh4_register_read. > (sh64_cooked_register_read): Replace sh64_register_read. > (sh64_cooked_register_write): Replace sh64_register_write. > (sh_pseudo_register_read, sh64_pseudo_register_read): Add `tdep' > and `regcache' parameters, use. > (sh_pseudo_register_write, sh64_pseudo_register_write): Add `tdep' > and `regcache' parameters, use. Make `buffer' parameter a > constaint pointer. > (sh_sh4_register_convert_to_raw) > (sh_sh64_register_convert_to_raw): Make `from' parameter a > constant void pointer. Make `to' parameter a void pointer. > * regcache.c (init_regcache_descr): Update. > (read_register_gen): Update. > (write_register_gen): Update. > (supply_register): Update comment. > > Index: gdbarch.sh > =================================================================== > RCS file: /cvs/src/src/gdb/gdbarch.sh,v > retrieving revision 1.149 > diff -u -r1.149 gdbarch.sh > --- gdbarch.sh 11 Jul 2002 13:50:49 -0000 1.149 > +++ gdbarch.sh 24 Jul 2002 23:00:30 -0000 > @@ -428,8 +428,8 @@ > # serious shakedown. > f::TARGET_VIRTUAL_FRAME_POINTER:void:virtual_frame_pointer:CORE_ADDR pc, int *frame_regnum, LONGEST *frame_offset:pc, frame_regnum, frame_offset::0:legacy_virtual_frame_pointer::0 > # > -M:::void:register_read:int regnum, char *buf:regnum, buf: > -M:::void:register_write:int regnum, char *buf:regnum, buf: > +M:::void:cooked_register_read:struct regcache *regcache, int regnum, void *buf:regcache, regnum, buf: > +M:::void:cooked_register_write:struct regcache *regcache, int regnum, const void *buf:regcache, regnum, buf: > # > v:2:NUM_REGS:int:num_regs::::0:-1 > # This macro gives the number of pseudo-registers that live in the > Index: regcache.c > =================================================================== > RCS file: /cvs/src/src/gdb/regcache.c,v > retrieving revision 1.42 > diff -u -r1.42 regcache.c > --- regcache.c 24 Jul 2002 19:43:43 -0000 1.42 > +++ regcache.c 24 Jul 2002 23:00:30 -0000 > @@ -140,8 +140,8 @@ > > /* If an old style architecture, construct the register cache > description using all the register macros. */ > - if (!gdbarch_register_read_p (gdbarch) > - && !gdbarch_register_write_p (gdbarch)) > + if (!gdbarch_cooked_register_read_p (gdbarch) > + && !gdbarch_cooked_register_write_p (gdbarch)) > return init_legacy_regcache_descr (gdbarch); > > descr = XMALLOC (struct regcache_descr); > @@ -716,7 +716,8 @@ > legacy_read_register_gen (regnum, buf); > return; > } > - gdbarch_register_read (current_gdbarch, regnum, buf); > + gdbarch_cooked_register_read (current_gdbarch, current_regcache, > + regnum, buf); > } > > > @@ -825,7 +826,8 @@ > legacy_write_register_gen (regnum, buf); > return; > } > - gdbarch_register_write (current_gdbarch, regnum, buf); > + gdbarch_cooked_register_write (current_gdbarch, current_regcache, > + regnum, buf); > } > > /* Copy INLEN bytes of consecutive data from memory at MYADDR > @@ -1011,7 +1013,7 @@ > /* NOTE: cagney/2001-03-16: The macro CLEAN_UP_REGISTER_VALUE is > going to be deprecated. Instead architectures will leave the raw > register value as is and instead clean things up as they pass > - through the method gdbarch_register_read() clean up the > + through the method gdbarch_cooked_register_read() clean up the > values. */ > > #ifdef DEPRECATED_CLEAN_UP_REGISTER_VALUE > Index: sh-tdep.c > =================================================================== > RCS file: /cvs/src/src/gdb/sh-tdep.c,v > retrieving revision 1.67 > diff -u -r1.67 sh-tdep.c > --- sh-tdep.c 24 Jul 2002 14:38:55 -0000 1.67 > +++ sh-tdep.c 24 Jul 2002 23:00:32 -0000 > @@ -3332,7 +3332,7 @@ > > static void > sh_sh4_register_convert_to_raw (struct type *type, int regnum, > - char *from, char *to) > + const void *from, void *to) > { > struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); > > @@ -3348,7 +3348,7 @@ > > void > sh_sh64_register_convert_to_raw (struct type *type, int regnum, > - char *from, char *to) > + const void *from, void *to) > { > struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); > > @@ -3372,11 +3372,11 @@ > } > > void > -sh_pseudo_register_read (int reg_nr, char *buffer) > +sh_pseudo_register_read (struct gdbarch_tdep *tdep, struct regcache *regcache, > + int reg_nr, char *buffer) > { > int base_regnum, portion; > char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE); > - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); > > if (reg_nr >= tdep->DR0_REGNUM > && reg_nr <= tdep->DR_LAST_REGNUM) > @@ -3386,7 +3386,7 @@ > /* Build the value in the provided buffer. */ > /* Read the real regs for which this one is an alias. */ > for (portion = 0; portion < 2; portion++) > - regcache_raw_read (current_regcache, base_regnum + portion, > + regcache_raw_read (regcache, base_regnum + portion, > (temp_buffer > + REGISTER_RAW_SIZE (base_regnum) * portion)); > /* We must pay attention to the endiannes. */ > @@ -3401,30 +3401,33 @@ > > /* Read the real regs for which this one is an alias. */ > for (portion = 0; portion < 4; portion++) > - regcache_raw_read (current_regcache, base_regnum + portion, > + regcache_raw_read (regcache, base_regnum + portion, > buffer + REGISTER_RAW_SIZE (base_regnum) * portion); > } > } > > static void > -sh4_register_read (struct gdbarch *gdbarch, int reg_nr, char *buffer) > +sh4_cooked_register_read (struct gdbarch *gdbarch, struct regcache *regcache, > + int reg_nr, void *buffer) > { > - if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM) > + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); > + if (reg_nr >= 0 && reg_nr < tdep->DR0_REGNUM) > /* It is a regular register. */ > - regcache_raw_read (current_regcache, reg_nr, buffer); > + regcache_raw_read (regcache, reg_nr, buffer); > else > /* It is a pseudo register and we need to construct its value */ > - sh_pseudo_register_read (reg_nr, buffer); > + sh_pseudo_register_read (tdep, regcache, reg_nr, buffer); > } > > static void > -sh64_pseudo_register_read (int reg_nr, char *buffer) > +sh64_pseudo_register_read (struct gdbarch_tdep *tdep, > + struct regcache *regcache, > + int reg_nr, char *buffer) > { > int base_regnum; > int portion; > int offset = 0; > char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE); > - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); > > if (reg_nr >= tdep->DR0_REGNUM > && reg_nr <= tdep->DR_LAST_REGNUM) > @@ -3435,7 +3438,7 @@ > /* DR regs are double precision registers obtained by > concatenating 2 single precision floating point registers. */ > for (portion = 0; portion < 2; portion++) > - regcache_raw_read (current_regcache, base_regnum + portion, > + regcache_raw_read (regcache, base_regnum + portion, > (temp_buffer > + REGISTER_RAW_SIZE (base_regnum) * portion)); > > @@ -3454,7 +3457,7 @@ > /* FPP regs are pairs of single precision registers obtained by > concatenating 2 single precision floating point registers. */ > for (portion = 0; portion < 2; portion++) > - regcache_raw_read (current_regcache, base_regnum + portion, > + regcache_raw_read (regcache, base_regnum + portion, > (buffer > + REGISTER_RAW_SIZE (base_regnum) * portion)); > } > @@ -3468,7 +3471,7 @@ > /* FV regs are vectors of single precision registers obtained by > concatenating 4 single precision floating point registers. */ > for (portion = 0; portion < 4; portion++) > - regcache_raw_read (current_regcache, base_regnum + portion, > + regcache_raw_read (regcache, base_regnum + portion, > (buffer > + REGISTER_RAW_SIZE (base_regnum) * portion)); > } > @@ -3480,7 +3483,7 @@ > base_regnum = sh64_compact_reg_base_num (reg_nr); > > /* Build the value in the provided buffer. */ > - regcache_raw_read (current_regcache, base_regnum, temp_buffer); > + regcache_raw_read (regcache, base_regnum, temp_buffer); > if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) > offset = 4; > memcpy (buffer, temp_buffer + offset, 4); /* get LOWER 32 bits only????*/ > @@ -3494,7 +3497,7 @@ > /* Build the value in the provided buffer. */ > /* Floating point registers map 1-1 to the media fp regs, > they have the same size and endienness. */ > - regcache_raw_read (current_regcache, base_regnum, buffer); > + regcache_raw_read (regcache, base_regnum, buffer); > } > > else if (reg_nr >= tdep->DR0_C_REGNUM > @@ -3505,7 +3508,7 @@ > /* DR_C regs are double precision registers obtained by > concatenating 2 single precision floating point registers. */ > for (portion = 0; portion < 2; portion++) > - regcache_raw_read (current_regcache, base_regnum + portion, > + regcache_raw_read (regcache, base_regnum + portion, > (temp_buffer > + REGISTER_RAW_SIZE (base_regnum) * portion)); > > @@ -3523,7 +3526,7 @@ > /* FV_C regs are vectors of single precision registers obtained by > concatenating 4 single precision floating point registers. */ > for (portion = 0; portion < 4; portion++) > - regcache_raw_read (current_regcache, base_regnum + portion, > + regcache_raw_read (regcache, base_regnum + portion, > (buffer > + REGISTER_RAW_SIZE (base_regnum) * portion)); > } > @@ -3556,11 +3559,11 @@ > */ > /* *INDENT-ON* */ > /* Get FPSCR into a local buffer */ > - regcache_raw_read (current_regcache, fpscr_base_regnum, temp_buffer); > + regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer); > /* Get value as an int. */ > fpscr_value = extract_unsigned_integer (temp_buffer, 4); > /* Get SR into a local buffer */ > - regcache_raw_read (current_regcache, sr_base_regnum, temp_buffer); > + regcache_raw_read (regcache, sr_base_regnum, temp_buffer); > /* Get value as an int. */ > sr_value = extract_unsigned_integer (temp_buffer, 4); > /* Build the new value. */ > @@ -3578,28 +3581,29 @@ > > /* FPUL_C register is floating point register 32, > same size, same endianness. */ > - regcache_raw_read (current_regcache, base_regnum, buffer); > + regcache_raw_read (regcache, base_regnum, buffer); > } > } > > static void > -sh64_register_read (struct gdbarch *gdbarch, int reg_nr, char *buffer) > +sh64_cooked_register_read (struct gdbarch *gdbarch, struct regcache *regcache, > + int reg_nr, void *buffer) > { > - > - if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM) > + struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); > + if (reg_nr >= 0 && reg_nr < tdep->DR0_REGNUM) > /* It is a regular register. */ > - regcache_raw_read (current_regcache, reg_nr, buffer); > + regcache_raw_read (regcache, reg_nr, buffer); > else > /* It is a pseudo register and we need to construct its value */ > - sh64_pseudo_register_read (reg_nr, buffer); > + sh64_pseudo_register_read (tdep, regcache, reg_nr, buffer); > } > > void > -sh_pseudo_register_write (int reg_nr, char *buffer) > +sh_pseudo_register_write (struct gdbarch_tdep *tdep, struct regcache *regcache, > + int reg_nr, const char *buffer) > { > int base_regnum, portion; > char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE); > - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); > > if (reg_nr >= tdep->DR0_REGNUM > && reg_nr <= tdep->DR_LAST_REGNUM) > @@ -3612,7 +3616,7 @@ > > /* Write the real regs for which this one is an alias. */ > for (portion = 0; portion < 2; portion++) > - regcache_raw_write (current_regcache, base_regnum + portion, > + regcache_raw_write (regcache, base_regnum + portion, > (temp_buffer > + REGISTER_RAW_SIZE (base_regnum) * portion)); > } > @@ -3623,30 +3627,33 @@ > > /* Write the real regs for which this one is an alias. */ > for (portion = 0; portion < 4; portion++) > - regcache_raw_write (current_regcache, base_regnum + portion, > + regcache_raw_write (regcache, base_regnum + portion, > (buffer > + REGISTER_RAW_SIZE (base_regnum) * portion)); > } > } > > static void > -sh4_register_write (struct gdbarch *gdbarch, int reg_nr, char *buffer) > +sh4_cooked_register_write (struct gdbarch *gdbarch, struct regcache *regcache, > + int reg_nr, const void *buffer) > { > - if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM) > + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); > + if (reg_nr >= 0 && reg_nr < tdep->DR0_REGNUM) > /* It is a regular register. */ > - regcache_raw_write (current_regcache, reg_nr, buffer); > + regcache_raw_write (regcache, reg_nr, buffer); > else > /* It is a pseudo register and we need to construct its value */ > - sh_pseudo_register_write (reg_nr, buffer); > + sh_pseudo_register_write (tdep, regcache, reg_nr, buffer); > } > > void > -sh64_pseudo_register_write (int reg_nr, char *buffer) > +sh64_pseudo_register_write (struct gdbarch_tdep *tdep, > + struct regcache *regcache, > + int reg_nr, const char *buffer) > { > int base_regnum, portion; > int offset; > char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE); > - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); > > if (reg_nr >= tdep->DR0_REGNUM > && reg_nr <= tdep->DR_LAST_REGNUM) > @@ -3659,7 +3666,7 @@ > > /* Write the real regs for which this one is an alias. */ > for (portion = 0; portion < 2; portion++) > - regcache_raw_write (current_regcache, base_regnum + portion, > + regcache_raw_write (regcache, base_regnum + portion, > (temp_buffer > + REGISTER_RAW_SIZE (base_regnum) * portion)); > } > @@ -3671,7 +3678,7 @@ > > /* Write the real regs for which this one is an alias. */ > for (portion = 0; portion < 2; portion++) > - regcache_raw_write (current_regcache, base_regnum + portion, > + regcache_raw_write (regcache, base_regnum + portion, > (buffer > + REGISTER_RAW_SIZE (base_regnum) * portion)); > } > @@ -3683,7 +3690,7 @@ > > /* Write the real regs for which this one is an alias. */ > for (portion = 0; portion < 4; portion++) > - regcache_raw_write (current_regcache, base_regnum + portion, > + regcache_raw_write (regcache, base_regnum + portion, > (buffer > + REGISTER_RAW_SIZE (base_regnum) * portion)); > } > @@ -3702,10 +3709,10 @@ > /* Let's read the value of the base register into a temporary > buffer, so that overwriting the last four bytes with the new > value of the pseudo will leave the upper 4 bytes unchanged. */ > - regcache_raw_read (current_regcache, base_regnum, temp_buffer); > + regcache_raw_read (regcache, base_regnum, temp_buffer); > /* Write as an 8 byte quantity */ > memcpy (temp_buffer + offset, buffer, 4); > - regcache_raw_write (current_regcache, base_regnum, temp_buffer); > + regcache_raw_write (regcache, base_regnum, temp_buffer); > } > > /* sh floating point compact pseudo registers. 1-to-1 with a shmedia > @@ -3714,7 +3721,7 @@ > && reg_nr <= tdep->FP_LAST_C_REGNUM) > { > base_regnum = sh64_compact_reg_base_num (reg_nr); > - regcache_raw_write (current_regcache, base_regnum, buffer); > + regcache_raw_write (regcache, base_regnum, buffer); > } > > else if (reg_nr >= tdep->DR0_C_REGNUM > @@ -3727,7 +3734,7 @@ > sh_sh64_register_convert_to_raw (REGISTER_VIRTUAL_TYPE (reg_nr), reg_nr, > buffer, temp_buffer); > > - regcache_raw_write (current_regcache, base_regnum + portion, > + regcache_raw_write (regcache, base_regnum + portion, > (temp_buffer > + REGISTER_RAW_SIZE (base_regnum) * portion)); > } > @@ -3740,7 +3747,7 @@ > > for (portion = 0; portion < 4; portion++) > { > - regcache_raw_write (current_regcache, base_regnum + portion, > + regcache_raw_write (regcache, base_regnum + portion, > (buffer > + REGISTER_RAW_SIZE (base_regnum) * portion)); > } > @@ -3784,37 +3791,39 @@ > fpscr_value = fpscr_c_value & fpscr_mask; > sr_value = (fpscr_value & sr_mask) >> 6; > > - regcache_raw_read (current_regcache, fpscr_base_regnum, temp_buffer); > + regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer); > old_fpscr_value = extract_unsigned_integer (temp_buffer, 4); > old_fpscr_value &= 0xfffc0002; > fpscr_value |= old_fpscr_value; > store_unsigned_integer (temp_buffer, 4, fpscr_value); > - regcache_raw_write (current_regcache, fpscr_base_regnum, temp_buffer); > + regcache_raw_write (regcache, fpscr_base_regnum, temp_buffer); > > - regcache_raw_read (current_regcache, sr_base_regnum, temp_buffer); > + regcache_raw_read (regcache, sr_base_regnum, temp_buffer); > old_sr_value = extract_unsigned_integer (temp_buffer, 4); > old_sr_value &= 0xffff8fff; > sr_value |= old_sr_value; > store_unsigned_integer (temp_buffer, 4, sr_value); > - regcache_raw_write (current_regcache, sr_base_regnum, temp_buffer); > + regcache_raw_write (regcache, sr_base_regnum, temp_buffer); > } > > else if (reg_nr == tdep->FPUL_C_REGNUM) > { > base_regnum = sh64_compact_reg_base_num (reg_nr); > - regcache_raw_write (current_regcache, base_regnum, buffer); > + regcache_raw_write (regcache, base_regnum, buffer); > } > } > > static void > -sh64_register_write (struct gdbarch *gdbarch, int reg_nr, char *buffer) > +sh64_cooked_register_write (struct gdbarch *gdbarch, struct regcache *regcache, > + int reg_nr, const void *buffer) > { > - if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM) > + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); > + if (reg_nr >= 0 && reg_nr < tdep->DR0_REGNUM) > /* It is a regular register. */ > - regcache_raw_write (current_regcache, reg_nr, buffer); > + regcache_raw_write (regcache, reg_nr, buffer); > else > /* It is a pseudo register and we need to construct its value */ > - sh64_pseudo_register_write (reg_nr, buffer); > + sh64_pseudo_register_write (tdep, regcache, reg_nr, buffer); > } > > /* Floating point vector of 4 float registers. */ > @@ -4449,8 +4458,8 @@ > set_gdbarch_num_pseudo_regs (gdbarch, 12); > set_gdbarch_max_register_raw_size (gdbarch, 4 * 4); > set_gdbarch_max_register_virtual_size (gdbarch, 4 * 4); > - set_gdbarch_register_read (gdbarch, sh4_register_read); > - set_gdbarch_register_write (gdbarch, sh4_register_write); > + set_gdbarch_cooked_register_read (gdbarch, sh4_cooked_register_read); > + set_gdbarch_cooked_register_write (gdbarch, sh4_cooked_register_write); > tdep->FPUL_REGNUM = 23; > tdep->FPSCR_REGNUM = 24; > tdep->FP_LAST_REGNUM = 40; > @@ -4541,8 +4550,8 @@ > /* Or should that go in the virtual_size? */ > /*set_gdbarch_max_register_virtual_size (gdbarch, 8);*/ > set_gdbarch_max_register_virtual_size (gdbarch, 4 * 4); > - set_gdbarch_register_read (gdbarch, sh64_register_read); > - set_gdbarch_register_write (gdbarch, sh64_register_write); > + set_gdbarch_cooked_register_read (gdbarch, sh64_cooked_register_read); > + set_gdbarch_cooked_register_write (gdbarch, sh64_cooked_register_write); > > set_gdbarch_do_registers_info (gdbarch, sh64_do_registers_info); > set_gdbarch_frame_init_saved_regs (gdbarch, sh64_nofp_frame_init_saved_regs);