From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10056 invoked by alias); 11 Nov 2001 17:57:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.cygnus.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 10035 invoked from network); 11 Nov 2001 17:57:22 -0000 Received: from unknown (HELO localhost.cygnus.com) (24.114.42.213) by sourceware.cygnus.com with SMTP; 11 Nov 2001 17:57:22 -0000 Received: from cygnus.com (localhost [127.0.0.1]) by localhost.cygnus.com (Postfix) with ESMTP id 0D4563D86 for ; Sun, 11 Nov 2001 12:57:22 -0500 (EST) Message-ID: <3BEEBC01.30409@cygnus.com> Date: Thu, 01 Nov 2001 07:19:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:0.9.3) Gecko/20011020 X-Accept-Language: en-us MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [rfc] replace register_buffer() with regcache_collect() Content-Type: multipart/mixed; boundary="------------020700050409020702050403" X-SW-Source: 2001-11/txt/msg00002.txt.bz2 This is a multi-part message in MIME format. --------------020700050409020702050403 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 848 Hello, The attached patch replaces the function register_buffer(regnum) with regcache_collect(regnum, buffer). regcache_collect() is the counter-part to supply_register(). It extracts a single raw register from the register cache as part of processing a target_store_registers() request. Unlike register_buffer() this interface doesn't make assumptions about the underlying register cache. Targets that are directly manipulating the registers[] and register_valid[] arrays should consider themselves as being ``on notice''. Potential follow-ons to this patch are: add a ``struct regcache'' parameter; and add ``struct regcache'' to ``struct thread_info''; and parameterise target_{fetch,store}_registers() with ``struct regcache'' or ``struct thread_info''. Testing continues... Eli, note the tweek to go32-nat.c. thoughts? Andrew --------------020700050409020702050403 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 6804 2001-11-11 Andrew Cagney * TODO (register_buffer): Delete. * regcache.c (register_buffer): Make static. (regcache_collect): New function. * regcache.h (register_buffer): Delete declaration. (regcache_collect): Declare. * remote.c (store_register_using_P): Rewrite using regcache_collect. (remote_store_registers): Ditto. * go32-nat.c (store_register): Ditto. Index: TODO =================================================================== RCS file: /cvs/src/src/gdb/TODO,v retrieving revision 1.93 diff -p -r1.93 TODO *** TODO 2001/07/10 22:38:38 1.93 --- TODO 2001/11/11 17:00:36 *************** Deprecate, if not delete, the following: *** 136,142 **** register[] register_valid[] - register_buffer() REGISTER_BYTE() Replaced by, on the target side supply_register() --- 136,141 ---- Index: go32-nat.c =================================================================== RCS file: /cvs/src/src/gdb/go32-nat.c,v retrieving revision 1.23 diff -p -r1.23 go32-nat.c *** go32-nat.c 2001/08/24 05:00:05 1.23 --- go32-nat.c 2001/11/11 17:00:38 *************** static void *** 493,499 **** store_register (int regno) { void *rp; ! void *v = (void *) register_buffer (regno); if (regno < FP0_REGNUM) memcpy ((char *) &a_tss + regno_mapping[regno].tss_ofs, --- 493,500 ---- store_register (int regno) { void *rp; ! void *v = alloca (MAX_REGISTER_RAW_SIZE); ! regcache_collect (regno, v); if (regno < FP0_REGNUM) memcpy ((char *) &a_tss + regno_mapping[regno].tss_ofs, Index: regcache.c =================================================================== RCS file: /cvs/src/src/gdb/regcache.c,v retrieving revision 1.26 diff -p -r1.26 regcache.c *** regcache.c 2001/08/24 05:11:07 1.26 --- regcache.c 2001/11/11 17:00:41 *************** register_changed (int regnum) *** 90,96 **** /* If REGNUM >= 0, return a pointer to register REGNUM's cache buffer area, else return a pointer to the start of the cache buffer. */ ! char * register_buffer (int regnum) { if (regnum < 0) --- 90,96 ---- /* 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 (int regnum) { if (regnum < 0) *************** supply_register (int regnum, char *val) *** 567,572 **** --- 567,579 ---- CLEAN_UP_REGISTER_VALUE (regnum, register_buffer (regnum)); #endif } + + void + regcache_collect (int regnum, void *buf) + { + memcpy (buf, register_buffer (regnum), REGISTER_RAW_SIZE (regnum)); + } + /* read_pc, write_pc, read_sp, write_sp, read_fp, write_fp, etc. Special handling for registers PC, SP, and FP. */ Index: regcache.h =================================================================== RCS file: /cvs/src/src/gdb/regcache.h,v retrieving revision 1.5 diff -p -r1.5 regcache.h *** regcache.h 2001/05/04 04:15:26 1.5 --- regcache.h 2001/11/11 17:00:42 *************** *** 28,33 **** --- 28,41 ---- void regcache_read (int rawnum, char *buf); void regcache_write (int rawnum, char *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 + target_fetch_registers() or target_store_registers(). */ + + extern void supply_register (int regnum, char *val); + extern void regcache_collect (int regnum, void *buf); + + /* DEPRECATED: Character array containing an image of the inferior programs' registers for the most recently referenced thread. */ *************** extern void set_register_cached (int reg *** 45,55 **** extern void register_changed (int regnum); - /* DEPRECATED: Functional interface returning pointer into registers[] - array. */ - - extern char *register_buffer (int regnum); - extern void registers_changed (void); extern void registers_fetched (void); --- 53,58 ---- *************** extern LONGEST read_signed_register_pid *** 75,81 **** extern void write_register (int regnum, LONGEST val); extern void write_register_pid (int regnum, CORE_ADDR val, ptid_t ptid); - - extern void supply_register (int regnum, char *val); #endif /* REGCACHE_H */ --- 78,82 ---- Index: remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.64 diff -p -r1.64 remote.c *** remote.c 2001/10/21 17:19:37 1.64 --- remote.c 2001/11/11 17:00:51 *************** store_register_using_P (int regno) *** 3402,3414 **** { /* Try storing a single register. */ char *buf = alloca (PBUFSIZ); ! char *regp; char *p; int i; sprintf (buf, "P%x=", regno); p = buf + strlen (buf); ! regp = register_buffer (regno); bin2hex (regp, p, REGISTER_RAW_SIZE (regno)); remote_send (buf, PBUFSIZ); --- 3402,3414 ---- { /* Try storing a single register. */ char *buf = alloca (PBUFSIZ); ! char *regp = alloca (MAX_REGISTER_RAW_SIZE); char *p; int i; sprintf (buf, "P%x=", regno); p = buf + strlen (buf); ! regcache_collect (regno, regp); bin2hex (regp, p, REGISTER_RAW_SIZE (regno)); remote_send (buf, PBUFSIZ); *************** store_register_using_P (int regno) *** 3422,3431 **** static void remote_store_registers (int regno) { ! char *buf = alloca (PBUFSIZ); int i; char *p; - char *regs; set_thread (PIDGET (inferior_ptid), 1); --- 3422,3431 ---- static void remote_store_registers (int regno) { ! char *buf; ! char *regs; int i; char *p; set_thread (PIDGET (inferior_ptid), 1); *************** remote_store_registers (int regno) *** 3458,3470 **** } } ! buf[0] = 'G'; /* Command describes registers byte by byte, each byte encoded as two hex characters. */ ! ! regs = register_buffer (-1); ! p = buf + 1; /* remote_prepare_to_store insures that register_bytes_found gets set. */ bin2hex (regs, p, register_bytes_found); remote_send (buf, PBUFSIZ); --- 3458,3480 ---- } } ! /* Extract all the registers in the regcache copying them into a ! local buffer. */ ! { ! int i; ! regs = alloca (REGISTER_BYTES); ! memset (regs, REGISTER_BYTES, 0); ! for (i = 0; i < NUM_REGS; i++) ! { ! regcache_collect (i, regs + REGISTER_BYTE (i)); ! } ! } /* Command describes registers byte by byte, each byte encoded as two hex characters. */ ! buf = alloca (PBUFSIZ); ! p = buf; ! *p++ = 'G'; /* remote_prepare_to_store insures that register_bytes_found gets set. */ bin2hex (regs, p, register_bytes_found); remote_send (buf, PBUFSIZ); --------------020700050409020702050403--