From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24649 invoked by alias); 13 Nov 2002 16:09:13 -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 24642 invoked from network); 13 Nov 2002 16:09:11 -0000 Received: from unknown (HELO localhost.redhat.com) (216.138.202.10) by sources.redhat.com with SMTP; 13 Nov 2002 16:09:11 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 401F93E39 for ; Wed, 13 Nov 2002 11:09:11 -0500 (EST) Message-ID: <3DD27927.70807@redhat.com> Date: Wed, 13 Nov 2002 08:09:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.0) Gecko/20020824 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: Re: [patch/rfc] Overhaul regcache for {save,restore}_reggroup References: <3DCACF5A.6010801@redhat.com> Content-Type: multipart/mixed; boundary="------------060102070207020706090203" X-SW-Source: 2002-11/txt/msg00364.txt.bz2 This is a multi-part message in MIME format. --------------060102070207020706090203 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2353 > Hello, > > This patch brings in the last big change sitting on the reggroups branch. > > It adds regcache save/restore functions to to the regcache. > These functions save/restore a subset of registers determined by the save/restore reggroups (by default REGNUMs in the range [0 .. NUM_REGS) are in both the save_reggroup and restore_reggroup, and hence are saved/restored). > > As part of this, a saved read-only regcache is expanded so that it can hold the saved value of any register in the full [0 .. NUM_REGS+NUM_PSEUDO_REGS) range. This is so that architectures with memory-mapped registers (which fall into the range [NUM_REGS .. NUM_REGS+NUM_PSEUDO_REGS) have somewhere to save them. > > I'll look to commit it in a few days, > > (Oh, and it deletes the last remaining core reference to read_register_bytes() or write_register_bytes()). No comment :-) I found while re-re-merging this that it was a little to chumpy for my liking so I've broken it down further. So far I've committed the attached. It contains strictly mechanical changes. Andrew > 2002-11-07 Andrew Cagney > > * regcache.h (regcache_save, regcache_restore): Declare. > > * regcache.c (struct regcache_descr): Add fields > sizeof_cooked_registers and sizeof_cooked_register_valid_p. > (init_legacy_regcache_descr): Compute sizeof_cooked_registers. > Update comments. > (init_regcache_descr): Compute sizeof_cooked_register_valid_p and > sizeof_cooked_registers. Update comments. > (struct regcache): Replace passthrough_p with readonly_p. Replace > raw_registers and raw_register_valid_p with registers and > register_valid_p. > (regcache_cooked_read): Check for cached cooked values. > (regcache_xmalloc): Update. > (regcache_save): New function. > (regcache_restore): New function. > (regcache_cpy): Rewrite using regcache_save, regcache_restore and > regcache_cpy_no_passthrough. > (regcache_raw_read): Update. > (regcache_raw_write): Update. > (build_regcache): Update. > (regcache_xfree): Update. > (regcache_cpy_no_passthrough): Update. > (regcache_valid_p): Update. > (deprecated_grub_regcache_for_registers): Update. > (deprecated_grub_regcache_for_register_valid): Update. > (register_buffer): Move declaration to start. Update. > (regcache_raw_read): Update. > (regcache_raw_write): Update. > --------------060102070207020706090203 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 5827 2002-11-13 Andrew Cagney * regcache.c (register_buffer): Move to near start of file, update description. (regcache_raw_read): Use. (regcache_raw_write): Use. (struct regcache): Rename raw_registers to registers and raw_register_valid_p to register_valid_p. (regcache_xmalloc): Update. (regcache_xfree): Update. (register_buffer): Update. (regcache_cpy): Update. (regcache_cpy_no_passthrough): Update. (regcache_valid_p): Update. (deprecated_grub_regcache_for_registers): Update. (deprecated_grub_regcache_for_register_valid): Update. (set_register_cached): Update. (regcache_raw_write): Update. Index: regcache.c =================================================================== RCS file: /cvs/src/src/gdb/regcache.c,v retrieving revision 1.63 diff -u -r1.63 regcache.c --- regcache.c 7 Nov 2002 21:43:23 -0000 1.63 +++ regcache.c 13 Nov 2002 15:53:32 -0000 @@ -277,8 +277,11 @@ struct regcache { struct regcache_descr *descr; - char *raw_registers; - char *raw_register_valid_p; + /* The register buffers. A read-only register cache can hold the + full [0 .. NUM_REGS + NUM_PSEUDO_REGS) while a read/write + register cache can only hold [0 .. NUM_REGS). */ + char *registers; + char *register_valid_p; /* If a value isn't in the cache should the corresponding target be queried for a value. */ int passthrough_p; @@ -293,9 +296,9 @@ descr = regcache_descr (gdbarch); regcache = XMALLOC (struct regcache); regcache->descr = descr; - regcache->raw_registers + regcache->registers = XCALLOC (descr->sizeof_raw_registers, char); - regcache->raw_register_valid_p + regcache->register_valid_p = XCALLOC (descr->sizeof_raw_register_valid_p, char); regcache->passthrough_p = 0; return regcache; @@ -306,8 +309,8 @@ { if (regcache == NULL) return; - xfree (regcache->raw_registers); - xfree (regcache->raw_register_valid_p); + xfree (regcache->registers); + xfree (regcache->register_valid_p); xfree (regcache); } @@ -323,6 +326,14 @@ return make_cleanup (do_regcache_xfree, regcache); } +/* Return a pointer to register REGNUM's buffer cache. */ + +static char * +register_buffer (struct regcache *regcache, int regnum) +{ + return regcache->registers + regcache->descr->register_offset[regnum]; +} + void regcache_cpy (struct regcache *dst, struct regcache *src) { @@ -338,7 +349,7 @@ { /* ULGH!!!! Old way. Use REGISTER bytes and let code below untangle fetch. */ - read_register_bytes (0, dst->raw_registers, REGISTER_BYTES); + read_register_bytes (0, dst->registers, REGISTER_BYTES); return; } /* FIXME: cagney/2002-05-17: To say this bit is bad is being polite. @@ -348,7 +359,7 @@ { /* ULGH!!!! Old way. Use REGISTER bytes and let code below untangle fetch. */ - write_register_bytes (0, src->raw_registers, REGISTER_BYTES); + write_register_bytes (0, src->registers, REGISTER_BYTES); return; } buf = alloca (src->descr->max_register_size); @@ -370,9 +381,8 @@ move of data into the current_regcache(). Doing this would be silly - it would mean that valid_p would be completly invalid. */ gdb_assert (dst != current_regcache); - memcpy (dst->raw_registers, src->raw_registers, - dst->descr->sizeof_raw_registers); - memcpy (dst->raw_register_valid_p, src->raw_register_valid_p, + memcpy (dst->registers, src->registers, dst->descr->sizeof_raw_registers); + memcpy (dst->register_valid_p, src->register_valid_p, dst->descr->sizeof_raw_register_valid_p); } @@ -401,19 +411,19 @@ { gdb_assert (regcache != NULL); gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers); - return regcache->raw_register_valid_p[regnum]; + return regcache->register_valid_p[regnum]; } char * deprecated_grub_regcache_for_registers (struct regcache *regcache) { - return regcache->raw_registers; + return regcache->registers; } char * deprecated_grub_regcache_for_register_valid (struct regcache *regcache) { - return regcache->raw_register_valid_p; + return regcache->register_valid_p; } /* Global structure containing the current regcache. */ @@ -471,16 +481,7 @@ { gdb_assert (regnum >= 0); gdb_assert (regnum < current_regcache->descr->nr_raw_registers); - current_regcache->raw_register_valid_p[regnum] = state; -} - -/* If REGNUM >= 0, return a pointer to register REGNUM's cache buffer area, - else return a pointer to the start of the cache buffer. */ - -static char * -register_buffer (struct regcache *regcache, int regnum) -{ - return regcache->raw_registers + regcache->descr->register_offset[regnum]; + current_regcache->register_valid_p[regnum] = state; } /* Return whether register REGNUM is a real register. */ @@ -686,8 +687,7 @@ target_fetch_registers (regnum); } /* Copy the value directly into the register cache. */ - memcpy (buf, (regcache->raw_registers - + regcache->descr->register_offset[regnum]), + memcpy (buf, register_buffer (regcache, regnum), regcache->descr->sizeof_register[regnum]); } @@ -856,10 +856,9 @@ value in cache. */ if (!regcache->passthrough_p) { - memcpy ((regcache->raw_registers - + regcache->descr->register_offset[regnum]), buf, + memcpy (register_buffer (regcache, regnum), buf, regcache->descr->sizeof_register[regnum]); - regcache->raw_register_valid_p[regnum] = 1; + regcache->register_valid_p[regnum] = 1; return; } @@ -881,7 +880,7 @@ target_prepare_to_store (); memcpy (register_buffer (regcache, regnum), buf, regcache->descr->sizeof_register[regnum]); - regcache->raw_register_valid_p[regnum] = 1; + regcache->register_valid_p[regnum] = 1; target_store_registers (regnum); } --------------060102070207020706090203--