From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19204 invoked by alias); 6 May 2007 19:39:20 -0000 Received: (qmail 19194 invoked by uid 22791); 6 May 2007 19:39:18 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate1.de.ibm.com (HELO mtagate1.de.ibm.com) (195.212.29.150) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 06 May 2007 19:39:14 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate1.de.ibm.com (8.13.8/8.13.8) with ESMTP id l46JdBRF181350 for ; Sun, 6 May 2007 19:39:11 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v8.3) with ESMTP id l46JdBUJ3866790 for ; Sun, 6 May 2007 21:39:11 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l46JdBBP014405 for ; Sun, 6 May 2007 21:39:11 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id l46JdBbF014402 for ; Sun, 6 May 2007 21:39:11 +0200 Message-Id: <200705061939.l46JdBbF014402@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Sun, 6 May 2007 21:39:11 +0200 Subject: [commit] Eliminate register_cached, set_register_cached, deprecated_registers_fetched To: gdb-patches@sourceware.org Date: Sun, 06 May 2007 19:39:00 -0000 From: "Ulrich Weigand" X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-05/txt/msg00064.txt.bz2 Hello, this is another follow-on regcache cleanup. The three functions register_cached, set_register_cached, and deprecated_registers_fetched did not have a regcache argument. However, they're obsolete anyway: - register_cached was only used at three places, and each of these uses was actually incorrect (as already noted by Andrew Cagney). value_of_register, frame_register, and tui_get_register really operate on *frame* registers, and register_cached doesn't apply to those. I've simply removed those checks. - set_register_cached was never used with argument 1; it was used in remote.c and remote-sim.c with argument -1 -- this was supposed to indicate a register that cannot be fetched, but that is already indicated by the regcache_raw_supply (..., NULL) call, so I've remove those calls. However, set_register_cached calls with argument 0 *do* have an effect: they force the register to be re-fetched from the target. I've added a new regcache_invalidate routine (*with* regcache argument) to parallel regcache_valid_p, and use that in mt-tdep.c and sh-tdep.c instead of the set_register_cached calls. - deprecated_registers_fetched was solely used in get_core_registers to indicate that registers not provided in the core file cannot be fetched otherwise. I've replaced this by a loop of regcache_raw_supply calls with NULL argument. Tested on s390-ibm-linux and s390x-ibm-linux. Committed to mainline. Bye, Ulrich ChangeLog: * regcache.c (regcache_invalidate): New function. (register_cached): Remove. (set_register_cached): Remove. (deprecated_registers_fetched): Remove. (registers_changed): Use regcache_invalidate instead of set_register_cached. (regcache_raw_read): Update comment. * regcache.h (regcache_invalidate): Add prototype. (register_cached): Remove. (set_register_cached): Remove. (deprecated_registers_fetched): Remove. * findvar.c (value_of_register): Do not call register_cached. * frame.c (frame_register): Likewise. * tui/tui-regs.c (tui_get_register): Likewise. * remote.c (fetch_register_using_p): Do not call set_register_cached. (process_g_packet): Likewise. (remote_fetch_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. * mt-tdep.c (mt_select_coprocessor): Replace set_register_cached call by regcache_invalidate. (mt_pseudo_register_write): Likewise. * sh-tdep.c (sh_pseudo_register_write): Likewise. * corelow.c (get_core_registers): Replace deprecated_registers_fetched call by loop over regcache_raw_supply (..., NULL). diff -urNp gdb-orig/gdb/corelow.c gdb-head/gdb/corelow.c --- gdb-orig/gdb/corelow.c 2007-05-06 16:33:43.074924000 +0200 +++ gdb-head/gdb/corelow.c 2007-05-06 21:06:21.077812791 +0200 @@ -485,7 +485,7 @@ get_core_register_section (struct regcac static void get_core_registers (struct regcache *regcache, int regno) { - int status; + int i; if (!(core_gdbarch && gdbarch_regset_from_core_section_p (core_gdbarch)) && (core_vec == NULL || core_vec->core_read_registers == NULL)) @@ -502,7 +502,10 @@ get_core_registers (struct regcache *reg get_core_register_section (regcache, ".reg-xfp", 3, "extended floating-point", 0); - deprecated_registers_fetched (); + /* Supply dummy value for all registers not found in the core. */ + for (i = 0; i < NUM_REGS; i++) + if (!regcache_valid_p (regcache, i)) + regcache_raw_supply (regcache, i, NULL); } static void diff -urNp gdb-orig/gdb/findvar.c gdb-head/gdb/findvar.c --- gdb-orig/gdb/findvar.c 2007-05-05 00:37:09.000000000 +0200 +++ gdb-head/gdb/findvar.c 2007-05-06 21:06:21.083811929 +0200 @@ -250,10 +250,7 @@ store_typed_address (gdb_byte *buf, stru /* Return a `value' with the contents of (virtual or cooked) register REGNUM as found in the specified FRAME. The register's type is - determined by register_type(). - - NOTE: returns NULL if register value is not available. Caller will - check return value or die! */ + determined by register_type(). */ struct value * value_of_register (int regnum, struct frame_info *frame) @@ -272,16 +269,6 @@ value_of_register (int regnum, struct fr frame_register (frame, regnum, &optim, &lval, &addr, &realnum, raw_buffer); - /* FIXME: cagney/2002-05-15: This test is just bogus. - - It indicates that the target failed to supply a value for a - register because it was "not available" at this time. Problem - is, the target still has the register and so get saved_register() - may be returning a value saved on the stack. */ - - if (register_cached (regnum) < 0) - return NULL; /* register value not available */ - reg_val = allocate_value (register_type (current_gdbarch, regnum)); memcpy (value_contents_raw (reg_val), raw_buffer, diff -urNp gdb-orig/gdb/frame.c gdb-head/gdb/frame.c --- gdb-orig/gdb/frame.c 2007-05-05 00:37:09.000000000 +0200 +++ gdb-head/gdb/frame.c 2007-05-06 21:06:21.089811067 +0200 @@ -738,16 +738,6 @@ frame_register_read (struct frame_info * int realnum; frame_register (frame, regnum, &optimized, &lval, &addr, &realnum, myaddr); - /* FIXME: cagney/2002-05-15: This test is just bogus. - - It indicates that the target failed to supply a value for a - register because it was "not available" at this time. Problem - is, the target still has the register and so get saved_register() - may be returning a value saved on the stack. */ - - if (register_cached (regnum) < 0) - return 0; /* register value not available */ - return !optimized; } diff -urNp gdb-orig/gdb/mt-tdep.c gdb-head/gdb/mt-tdep.c --- gdb-orig/gdb/mt-tdep.c 2007-05-05 00:37:09.000000000 +0200 +++ gdb-head/gdb/mt-tdep.c 2007-05-06 21:06:21.134804601 +0200 @@ -495,7 +495,7 @@ mt_select_coprocessor (struct gdbarch *g /* We must flush the cache, as it is now invalid. */ for (ix = MT_NUM_CPU_REGS; ix != MT_NUM_REGS; ix++) - set_register_cached (ix, 0); + regcache_invalidate (regcache, ix); } return index; @@ -573,7 +573,7 @@ mt_pseudo_register_write (struct gdbarch case MT_COPRO_PSEUDOREG_REGNUM: regcache_raw_write (regcache, MT_COPRO_REGNUM, buf); for (i = MT_NUM_CPU_REGS; i < MT_NUM_REGS; i++) - set_register_cached (i, 0); + regcache_invalidate (regcache, i); break; case MT_MAC_REGNUM: case MT_MAC_PSEUDOREG_REGNUM: diff -urNp gdb-orig/gdb/regcache.c gdb-head/gdb/regcache.c --- gdb-orig/gdb/regcache.c 2007-05-06 16:59:24.360649000 +0200 +++ gdb-head/gdb/regcache.c 2007-05-06 21:07:06.428209241 +0200 @@ -393,6 +393,17 @@ regcache_valid_p (const struct regcache return regcache->register_valid_p[regnum]; } +void +regcache_invalidate (struct regcache *regcache, int regnum) +{ + gdb_assert (regcache != NULL); + gdb_assert (regnum >= 0); + gdb_assert (!regcache->readonly_p); + gdb_assert (regnum < regcache->descr->nr_raw_registers); + regcache->register_valid_p[regnum] = 0; +} + + /* Global structure containing the current regcache. */ /* FIXME: cagney/2002-05-11: The two global arrays registers[] and deprecated_register_valid[] currently point into this structure. */ @@ -407,33 +418,6 @@ struct regcache *current_regcache; static ptid_t registers_ptid; -/* - * FUNCTIONS: - */ - -/* REGISTER_CACHED() - - Returns 0 if the value is not in the cache (needs fetch). - >0 if the value is in the cache. - <0 if the value is permanently unavailable (don't ask again). */ - -int -register_cached (int regnum) -{ - return current_regcache->register_valid_p[regnum]; -} - -/* Record that REGNUM's value is cached if STATE is >0, uncached but - fetchable if STATE is 0, and uncached and unfetchable if STATE is <0. */ - -void -set_register_cached (int regnum, int state) -{ - gdb_assert (regnum >= 0); - gdb_assert (regnum < current_regcache->descr->nr_raw_registers); - current_regcache->register_valid_p[regnum] = state; -} - /* Observer for the target_changed event. */ void @@ -468,28 +452,9 @@ registers_changed (void) alloca (0); for (i = 0; i < current_regcache->descr->nr_raw_registers; i++) - set_register_cached (i, 0); + regcache_invalidate (current_regcache, i); } -/* DEPRECATED_REGISTERS_FETCHED () - - Indicate that all registers have been fetched, so mark them all valid. */ - -/* FIXME: cagney/2001-12-04: This function is DEPRECATED. The target - code was blatting the registers[] array and then calling this. - Since targets should only be using regcache_raw_supply() the need for - this function/hack is eliminated. */ - -void -deprecated_registers_fetched (void) -{ - int i; - - for (i = 0; i < NUM_REGS; i++) - set_register_cached (i, 1); - /* Do not assume that the pseudo-regs have also been fetched. - Fetching all real regs NEVER accounts for pseudo-regs. */ -} void regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf) @@ -517,7 +482,7 @@ regcache_raw_read (struct regcache *regc that a register is in one of the possible states: valid, undefined, unknown. The last of which isn't yet possible. */ - gdb_assert (register_cached (regnum)); + gdb_assert (regcache_valid_p (regcache, regnum)); #endif } /* Copy the value directly into the register cache. */ diff -urNp gdb-orig/gdb/regcache.h gdb-head/gdb/regcache.h --- gdb-orig/gdb/regcache.h 2007-05-05 00:37:10.000000000 +0200 +++ gdb-head/gdb/regcache.h 2007-05-06 21:06:21.156801440 +0200 @@ -61,6 +61,8 @@ void regcache_raw_write_part (struct reg int regcache_valid_p (const struct regcache *regcache, int regnum); +void regcache_invalidate (struct regcache *regcache, int regnum); + /* Transfer a cooked register [0..NUM_REGS+NUM_PSEUDO_REGS). */ void regcache_cooked_read (struct regcache *regcache, int rawnum, gdb_byte *buf); @@ -157,14 +159,6 @@ extern struct regcache *regcache_dup_no_ extern void regcache_cpy (struct regcache *dest, struct regcache *src); extern void regcache_cpy_no_passthrough (struct regcache *dest, struct regcache *src); -/* NOTE: cagney/2002-11-05: This function has been superseeded by - regcache_raw_supply(). */ -extern void deprecated_registers_fetched (void); - -extern int register_cached (int regnum); - -extern void set_register_cached (int regnum, int state); - extern void registers_changed (void); diff -urNp gdb-orig/gdb/remote.c gdb-head/gdb/remote.c --- gdb-orig/gdb/remote.c 2007-05-06 16:47:19.821102000 +0200 +++ gdb-head/gdb/remote.c 2007-05-06 21:06:21.169799572 +0200 @@ -3522,7 +3522,6 @@ fetch_register_using_p (struct regcache if (buf[0] == 'x') { regcache_raw_supply (regcache, reg->regnum, NULL); - set_register_cached (reg->regnum, -1); return 1; } @@ -3661,7 +3660,6 @@ process_g_packet (struct regcache *regca /* The register isn't available, mark it as such (at the same time setting the value to zero). */ regcache_raw_supply (regcache, r->regnum, NULL); - set_register_cached (i, -1); } else regcache_raw_supply (regcache, r->regnum, @@ -3708,7 +3706,6 @@ remote_fetch_registers (struct regcache /* This register is not available. */ regcache_raw_supply (regcache, reg->regnum, NULL); - set_register_cached (reg->regnum, -1); return; } @@ -3721,7 +3718,6 @@ remote_fetch_registers (struct regcache { /* This register is not available. */ regcache_raw_supply (regcache, i, NULL); - set_register_cached (i, -1); } } diff -urNp gdb-orig/gdb/remote-sim.c gdb-head/gdb/remote-sim.c --- gdb-orig/gdb/remote-sim.c 2007-05-06 16:47:53.175347000 +0200 +++ gdb-head/gdb/remote-sim.c 2007-05-06 21:06:21.214793106 +0200 @@ -300,7 +300,6 @@ gdbsim_fetch_register (struct regcache * int nr_bytes; memset (buf, 0, MAX_REGISTER_SIZE); regcache_raw_supply (regcache, regno, buf); - set_register_cached (regno, -1); break; } diff -urNp gdb-orig/gdb/sh-tdep.c gdb-head/gdb/sh-tdep.c --- gdb-orig/gdb/sh-tdep.c 2007-05-05 00:37:10.000000000 +0200 +++ gdb-head/gdb/sh-tdep.c 2007-05-06 21:06:21.233790376 +0200 @@ -2055,7 +2055,7 @@ sh_pseudo_register_write (struct gdbarch regcache_raw_write (regcache, BANK_REGNUM, buffer); for (bregnum = R0_BANK0_REGNUM; bregnum < MACLB_REGNUM; ++bregnum) - set_register_cached (bregnum, 0); + regcache_invalidate (regcache, bregnum); } else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM) { diff -urNp gdb-orig/gdb/tui/tui-regs.c gdb-head/gdb/tui/tui-regs.c --- gdb-orig/gdb/tui/tui-regs.c 2007-05-05 00:37:10.000000000 +0200 +++ gdb-head/gdb/tui/tui-regs.c 2007-05-06 21:06:21.239789514 +0200 @@ -710,32 +710,27 @@ tui_get_register (struct gdbarch *gdbarc if (target_has_registers) { gdb_byte buf[MAX_REGISTER_SIZE]; - get_frame_register (frame, regnum, buf); - /* NOTE: cagney/2003-03-13: This is bogus. It is refering to - the register cache and not the frame which could have pulled - the register value off the stack. */ - if (register_cached (regnum) >= 0) - { - if (changedp) - { - int size = register_size (gdbarch, regnum); - char *old = (char*) data->value; - int i; - - for (i = 0; i < size; i++) - if (buf[i] != old[i]) - { - *changedp = TRUE; - old[i] = buf[i]; - } - } - - /* Reformat the data content if the value changed. */ - if (changedp == 0 || *changedp == TRUE) - tui_register_format (gdbarch, frame, data, regnum); - ret = TUI_SUCCESS; - } + + if (changedp) + { + int size = register_size (gdbarch, regnum); + char *old = (char*) data->value; + int i; + + for (i = 0; i < size; i++) + if (buf[i] != old[i]) + { + *changedp = TRUE; + old[i] = buf[i]; + } + } + + /* Reformat the data content if the value changed. */ + if (changedp == 0 || *changedp == TRUE) + tui_register_format (gdbarch, frame, data, regnum); + + ret = TUI_SUCCESS; } return ret; } -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com