From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17410 invoked by alias); 19 Aug 2002 00:38:40 -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 17380 invoked from network); 19 Aug 2002 00:38:35 -0000 Received: from unknown (HELO localhost.redhat.com) (24.112.240.27) by sources.redhat.com with SMTP; 19 Aug 2002 00:38:35 -0000 Received: from ges.redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id B8E2A3CFA; Sun, 18 Aug 2002 20:38:23 -0400 (EDT) Message-ID: <3D603DFF.4050401@ges.redhat.com> Date: Sun, 18 Aug 2002 17:38:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.0) Gecko/20020810 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Andrew Cagney Cc: Mark Kettenis , gdb-patches@sources.redhat.com Subject: Re: [PATCH] regcache raw read/write partial; Was: [PATCH] Remove some write_register_bytes occurences from i386-tdep.c References: <200208181718.g7IHIrg6029437@elgar.kettenis.dyndns.org> <3D5FDD69.7000102@ges.redhat.com> <3D5FFEA6.9000306@ges.redhat.com> <200208182019.g7IKJGLp000325@elgar.kettenis.dyndns.org> <3D60050F.3020508@ges.redhat.com> Content-Type: multipart/mixed; boundary="------------080100050405040904070605" X-SW-Source: 2002-08/txt/msg00535.txt.bz2 This is a multi-part message in MIME format. --------------080100050405040904070605 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 61 This is what I've checked in. Testing continues ... Andrew --------------080100050405040904070605 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 5065 2002-08-18 Andrew Cagney * regcache.c (regcache_xfer_part): New function. (regcache_raw_read_part): New function. (regcache_raw_write_part): New function. (regcache_cooked_read_part): New function. (regcache_cooked_write_part): New function. * regcache.h (regcache_raw_read_part): Declare. (regcache_raw_write_part): Declare. (regcache_cooked_read_part): Declare. (regcache_cooked_write_part): Declare. Index: regcache.c =================================================================== RCS file: /cvs/src/src/gdb/regcache.c,v retrieving revision 1.53 diff -u -r1.53 regcache.c --- regcache.c 13 Aug 2002 23:06:40 -0000 1.53 +++ regcache.c 19 Aug 2002 00:32:53 -0000 @@ -916,6 +916,86 @@ } } +/* Perform a partial register transfer using a read, modify, write + operation. */ + +typedef void (regcache_read_ftype) (struct regcache *regcache, int regnum, + void *buf); +typedef void (regcache_write_ftype) (struct regcache *regcache, int regnum, + const void *buf); + +void +regcache_xfer_part (struct regcache *regcache, int regnum, + int offset, int len, void *in, const void *out, + regcache_read_ftype *read, regcache_write_ftype *write) +{ + struct regcache_descr *descr = regcache->descr; + bfd_byte *reg = alloca (descr->max_register_size); + gdb_assert (offset >= 0 && offset <= descr->sizeof_register[regnum]); + gdb_assert (len >= 0 && offset + len <= descr->sizeof_register[regnum]); + /* Something to do? */ + if (offset + len == 0) + return; + /* Read (when needed) ... */ + if (in != NULL + || offset > 0 + || offset + len < descr->sizeof_register[regnum]) + { + gdb_assert (read != NULL); + read (regcache, regnum, reg); + } + /* ... modify ... */ + if (in != NULL) + memcpy (in, reg + offset, len); + if (out != NULL) + memcpy (reg + offset, out, len); + /* ... write (when needed). */ + if (out != NULL) + { + gdb_assert (write != NULL); + write (regcache, regnum, reg); + } +} + +void +regcache_raw_read_part (struct regcache *regcache, int regnum, + int offset, int len, void *buf) +{ + struct regcache_descr *descr = regcache->descr; + gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers); + regcache_xfer_part (regcache, regnum, offset, len, buf, NULL, + regcache_raw_read, regcache_raw_write); +} + +void +regcache_raw_write_part (struct regcache *regcache, int regnum, + int offset, int len, const void *buf) +{ + struct regcache_descr *descr = regcache->descr; + gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers); + regcache_xfer_part (regcache, regnum, offset, len, NULL, buf, + regcache_raw_read, regcache_raw_write); +} + +void +regcache_cooked_read_part (struct regcache *regcache, int regnum, + int offset, int len, void *buf) +{ + struct regcache_descr *descr = regcache->descr; + gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers); + regcache_xfer_part (regcache, regnum, offset, len, buf, NULL, + regcache_cooked_read, regcache_cooked_write); +} + +void +regcache_cooked_write_part (struct regcache *regcache, int regnum, + int offset, int len, const void *buf) +{ + struct regcache_descr *descr = regcache->descr; + gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers); + regcache_xfer_part (regcache, regnum, offset, len, NULL, buf, + regcache_cooked_read, regcache_cooked_write); +} /* Return the contents of register REGNUM as an unsigned integer. */ Index: regcache.h =================================================================== RCS file: /cvs/src/src/gdb/regcache.h,v retrieving revision 1.14 diff -u -r1.14 regcache.h --- regcache.h 13 Aug 2002 14:32:28 -0000 1.14 +++ regcache.h 19 Aug 2002 00:32:54 -0000 @@ -42,6 +42,15 @@ int regnum, LONGEST *val); extern void regcache_raw_read_unsigned (struct regcache *regcache, int regnum, ULONGEST *val); + +/* Partial transfer of a raw registers. These perform read, modify, + write style operations. */ + +void regcache_raw_read_part (struct regcache *regcache, int regnum, + int offset, int len, void *buf); +void regcache_raw_write_part (struct regcache *regcache, int regnum, + int offset, int len, const void *buf); + int regcache_valid_p (struct regcache *regcache, int regnum); /* Transfer a cooked register [0..NUM_REGS+NUM_PSEUDO_REGS). */ @@ -62,6 +71,14 @@ int regnum, LONGEST *val); extern void regcache_cooked_read_unsigned (struct regcache *regcache, int regnum, ULONGEST *val); + +/* Partial transfer of a cooked register. These perform read, modify, + write style operations. */ + +void regcache_cooked_read_part (struct regcache *regcache, int regnum, + int offset, int len, void *buf); +void regcache_cooked_write_part (struct regcache *regcache, int regnum, + int offset, int len, const void *buf); /* Transfer a raw register [0..NUM_REGS) between the regcache and the target. These functions are called by the target in response to a --------------080100050405040904070605--