From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7574 invoked by alias); 30 Jul 2002 14:18:42 -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 7563 invoked from network); 30 Jul 2002 14:18:40 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 30 Jul 2002 14:18:40 -0000 Received: from ges.redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 8AB3C3C9E for ; Tue, 30 Jul 2002 10:18:37 -0400 (EDT) Message-ID: <3D46A03D.8090003@ges.redhat.com> Date: Tue, 30 Jul 2002 07:45:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.0) Gecko/20020708 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [patch/rfc;rfa:sh] gdbarch_register_read() -> gdbarch_pseudo_register_read() Content-Type: multipart/mixed; boundary="------------020700070209020908070607" X-SW-Source: 2002-07/txt/msg00583.txt.bz2 This is a multi-part message in MIME format. --------------020700070209020908070607 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1070 Hello, This revises my earlier patch that replaced gdbarch_register_read() with regarch_cooked_register_read(). Reviewing the doco discussion, think it is clear that the term ``pseudo'' is pretty entrenched in GDB. Even the presence of the word triggers certain assumptions :-) The change makes use of this. The attached patch replaces the function: void gdbarch_register_read (int regnum, char *buf); with void gdbarch_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache, int regnum, void *buf); It is called by (well will be once I add it) regcache_cooked_read() to map a cooked register in the range [NUM_REGS .. NUM_REGS + NUM_PSEUDO_REGS) (which are often refered to as pseudo registers) onto raw registers and/or memory. (Remember, cooked registers in the range [0 .. NUM_REGS) are 1:1 mapped onto raw registers.) Ditto for the write side. I'm also revising my WIP doco. For the SH, I've made use of this tightend specification (it doesn't get called for raw registers). Ok? I'll look to commit in a few days. Andrew --------------020700070209020908070607 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 18663 2002-07-30 Andrew Cagney * gdbarch.sh (pseudo_register_read, pseudo_register_write): Replace the architecture methods register_read and register_write. * gdbarch.h, gdbarch.c: Regenerate. * regcache.c (init_regcache_descr): Update. (read_register_gen): Update. (write_register_gen): Update. (supply_register): Update comment. * sh-tdep.c (sh_gdbarch_init): Update. (sh_pseudo_register_read, sh64_pseudo_register_read): Add `regcache' and `gdbarch' parameters. Make `buffer' a void pointer. Update code. (sh_pseudo_register_write, sh64_pseudo_register_write): Add `regcache' and `gdbarch' parameters. Make `buffer' a constant void pointer. Update code. (sh64_register_write): Delete. (sh4_register_read): Delete. (sh64_register_read): Delete. (sh4_register_write): Delete. (sh_sh4_register_convert_to_raw): Make `from' parameter a constant void pointer, `to' parameter a void pointer. (sh_sh64_register_convert_to_raw): Ditto. 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 30 Jul 2002 13:48:46 -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:pseudo_register_read:struct regcache *regcache, int cookednum, void *buf:regcache, cookednum, buf: +M:::void:pseudo_register_write:struct regcache *regcache, int cookednum, const void *buf:regcache, cookednum, 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.43 diff -u -r1.43 regcache.c --- regcache.c 29 Jul 2002 19:54:42 -0000 1.43 +++ regcache.c 30 Jul 2002 13:48:46 -0000 @@ -143,8 +143,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_pseudo_register_read_p (gdbarch) + && !gdbarch_pseudo_register_write_p (gdbarch)) return init_legacy_regcache_descr (gdbarch); descr = XMALLOC (struct regcache_descr); @@ -724,7 +724,8 @@ if (regnum < current_regcache->descr->nr_raw_registers) regcache_raw_read (current_regcache, regnum, buf); else - gdbarch_register_read (current_gdbarch, regnum, buf); + gdbarch_pseudo_register_read (current_gdbarch, current_regcache, + regnum, buf); } @@ -838,7 +839,8 @@ if (regnum < current_regcache->descr->nr_raw_registers) regcache_raw_write (current_regcache, regnum, buf); else - gdbarch_register_write (current_gdbarch, regnum, buf); + gdbarch_pseudo_register_write (current_gdbarch, current_regcache, + regnum, buf); } /* Copy INLEN bytes of consecutive data from memory at MYADDR @@ -1024,7 +1026,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_pseudo_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.68 diff -u -r1.68 sh-tdep.c --- sh-tdep.c 29 Jul 2002 16:34:06 -0000 1.68 +++ sh-tdep.c 30 Jul 2002 13:48:48 -0000 @@ -3331,7 +3331,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); @@ -3347,7 +3347,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); @@ -3371,11 +3371,12 @@ } void -sh_pseudo_register_read (int reg_nr, char *buffer) +sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache, + int reg_nr, void *buffer) { int base_regnum, portion; char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE); - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (reg_nr >= tdep->DR0_REGNUM && reg_nr <= tdep->DR_LAST_REGNUM) @@ -3385,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. */ @@ -3400,30 +3401,21 @@ /* 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, - buffer + REGISTER_RAW_SIZE (base_regnum) * portion); + regcache_raw_read (regcache, base_regnum + portion, + ((char *) buffer + + REGISTER_RAW_SIZE (base_regnum) * portion)); } } static void -sh4_register_read (struct gdbarch *gdbarch, int reg_nr, char *buffer) -{ - if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM) - /* It is a regular register. */ - regcache_raw_read (current_regcache, reg_nr, buffer); - else - /* It is a pseudo register and we need to construct its value */ - sh_pseudo_register_read (reg_nr, buffer); -} - -static void -sh64_pseudo_register_read (int reg_nr, char *buffer) +sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache, + int reg_nr, void *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); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (reg_nr >= tdep->DR0_REGNUM && reg_nr <= tdep->DR_LAST_REGNUM) @@ -3434,7 +3426,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)); @@ -3453,8 +3445,8 @@ /* 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, - (buffer + regcache_raw_read (regcache, base_regnum + portion, + ((char *) buffer + REGISTER_RAW_SIZE (base_regnum) * portion)); } @@ -3467,8 +3459,8 @@ /* 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, - (buffer + regcache_raw_read (regcache, base_regnum + portion, + ((char *) buffer + REGISTER_RAW_SIZE (base_regnum) * portion)); } @@ -3479,7 +3471,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????*/ @@ -3493,7 +3485,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 @@ -3504,7 +3496,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)); @@ -3522,8 +3514,8 @@ /* 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, - (buffer + regcache_raw_read (regcache, base_regnum + portion, + ((char *) buffer + REGISTER_RAW_SIZE (base_regnum) * portion)); } @@ -3555,11 +3547,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. */ @@ -3577,28 +3569,17 @@ /* 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) -{ - - if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM) - /* It is a regular register. */ - regcache_raw_read (current_regcache, reg_nr, buffer); - else - /* It is a pseudo register and we need to construct its value */ - sh64_pseudo_register_read (reg_nr, buffer); -} - void -sh_pseudo_register_write (int reg_nr, char *buffer) +sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, + int reg_nr, const void *buffer) { int base_regnum, portion; char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE); - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (reg_nr >= tdep->DR0_REGNUM && reg_nr <= tdep->DR_LAST_REGNUM) @@ -3611,7 +3592,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)); } @@ -3622,30 +3603,20 @@ /* 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, - (buffer + regcache_raw_write (regcache, base_regnum + portion, + ((char *) buffer + REGISTER_RAW_SIZE (base_regnum) * portion)); } } -static void -sh4_register_write (struct gdbarch *gdbarch, int reg_nr, char *buffer) -{ - if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM) - /* It is a regular register. */ - regcache_raw_write (current_regcache, reg_nr, buffer); - else - /* It is a pseudo register and we need to construct its value */ - sh_pseudo_register_write (reg_nr, buffer); -} - void -sh64_pseudo_register_write (int reg_nr, char *buffer) +sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, + int reg_nr, const void *buffer) { int base_regnum, portion; int offset; char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE); - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (reg_nr >= tdep->DR0_REGNUM && reg_nr <= tdep->DR_LAST_REGNUM) @@ -3658,7 +3629,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)); } @@ -3670,8 +3641,8 @@ /* 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, - (buffer + regcache_raw_write (regcache, base_regnum + portion, + ((char *) buffer + REGISTER_RAW_SIZE (base_regnum) * portion)); } @@ -3682,8 +3653,8 @@ /* 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, - (buffer + regcache_raw_write (regcache, base_regnum + portion, + ((char *) buffer + REGISTER_RAW_SIZE (base_regnum) * portion)); } @@ -3701,10 +3672,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 @@ -3713,7 +3684,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 @@ -3726,7 +3697,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)); } @@ -3739,8 +3710,8 @@ for (portion = 0; portion < 4; portion++) { - regcache_raw_write (current_regcache, base_regnum + portion, - (buffer + regcache_raw_write (regcache, base_regnum + portion, + ((char *) buffer + REGISTER_RAW_SIZE (base_regnum) * portion)); } } @@ -3783,39 +3754,28 @@ 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) -{ - if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM) - /* It is a regular register. */ - regcache_raw_write (current_regcache, reg_nr, buffer); - else - /* It is a pseudo register and we need to construct its value */ - sh64_pseudo_register_write (reg_nr, buffer); -} - /* Floating point vector of 4 float registers. */ static void do_fv_register_info (int fv_regnum) @@ -4448,8 +4408,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_pseudo_register_read (gdbarch, sh_pseudo_register_read); + set_gdbarch_pseudo_register_write (gdbarch, sh_pseudo_register_write); tdep->FPUL_REGNUM = 23; tdep->FPSCR_REGNUM = 24; tdep->FP_LAST_REGNUM = 40; @@ -4540,8 +4500,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_pseudo_register_read (gdbarch, sh64_pseudo_register_read); + set_gdbarch_pseudo_register_write (gdbarch, sh64_pseudo_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); --------------020700070209020908070607--