From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4984 invoked by alias); 28 Apr 2007 21:54:15 -0000 Received: (qmail 4956 invoked by uid 22791); 28 Apr 2007 21:54:12 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate6.de.ibm.com (HELO mtagate6.de.ibm.com) (195.212.29.155) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 28 Apr 2007 22:54:07 +0100 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate6.de.ibm.com (8.13.8/8.13.8) with ESMTP id l3SLs4g1331142 for ; Sat, 28 Apr 2007 21:54:04 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 l3SLs4tc3784840 for ; Sat, 28 Apr 2007 23:54:04 +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 l3SLs3fe007281 for ; Sat, 28 Apr 2007 23:54:03 +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 l3SLs3wu007278 for ; Sat, 28 Apr 2007 23:54:03 +0200 Message-Id: <200704282154.l3SLs3wu007278@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Sat, 28 Apr 2007 23:54:03 +0200 Subject: [commit] Eliminate DEPRECATED_REGISTER_BYTE To: gdb-patches@sourceware.org Date: Sat, 28 Apr 2007 22:40: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-04/txt/msg00384.txt.bz2 Hello, this gets rid of the DEPRECATED_REGISTER_BYTE gdbarch callback. There was just a single remaining user, mi_cmd_data_list_changed_registers. This routine was using it to maintain a copy of the registers at the time it was last called, in order to be able to compare with the current frame register contents. The patch changes this to simply use a read-only register cache to hold the past values. This obsoletes a bunch of machinery involved in maintaining the "old_regs" array across gdbarch changes. This did require a small change to regcache.c: I'm now allowing use of regcache_valid_p on *cooked* registers for read-only register caches. This makes sense as the register_valid_p array is in fact maintained for all cooked registers in this case (it is valid only for raw registers in the read-write regcache). Also, the regcache parameter to regcache_valid_p should be const. Tested on s390-ibm-linux. Committed to mainline. Bye, Ulrich ChangeLog: * gdbarch.sh: Remove deprecated_register_byte. * gdbarch.c, gdbarch.h: Regenerate. * arch-utils.h (generic_register_size, generic_register_byte): Remove. * arch-utils.c (generic_register_size, generic_register_byte): Remove. * regcache.h (regcache_valid_p): Make REGCACHE parameter const. * regcache.c (regcache_valid_p): Allow to query cooked registers in read-only register caches. Make REGCACHE parameter const. (regcache_dump): Do not check DEPRECATED_REGISTER_BYTE. * mi/mi-main.c (old_regs): Remove. (mi_setup_architecture_data, _initialize_mi_main): Remove. (register_changed_p): Reimplement to compare two register caches. (mi_cmd_data_list_changed_registers): Update caller. * mi/mi-main.h (mi_setup_architecture_data): Remove. * mi/mi-interp.c (mi_interpreter_init): Do not call mi_setup_architecture_data. diff -urNp gdb-orig/gdb/arch-utils.c gdb-head/gdb/arch-utils.c --- gdb-orig/gdb/arch-utils.c 2007-04-28 22:17:42.708344000 +0200 +++ gdb-head/gdb/arch-utils.c 2007-04-28 23:30:19.993033560 +0200 @@ -207,32 +207,6 @@ legacy_virtual_frame_pointer (CORE_ADDR *frame_offset = 0; } -/* Assume the world is sane, every register's virtual and real size - is identical. */ - -int -generic_register_size (int regnum) -{ - gdb_assert (regnum >= 0 && regnum < NUM_REGS + NUM_PSEUDO_REGS); - return TYPE_LENGTH (register_type (current_gdbarch, regnum)); -} - -/* Assume all registers are adjacent. */ - -int -generic_register_byte (int regnum) -{ - int byte; - int i; - gdb_assert (regnum >= 0 && regnum < NUM_REGS + NUM_PSEUDO_REGS); - byte = 0; - for (i = 0; i < regnum; i++) - { - byte += generic_register_size (i); - } - return byte; -} - int generic_convert_register_p (int regnum, struct type *type) diff -urNp gdb-orig/gdb/arch-utils.h gdb-head/gdb/arch-utils.h --- gdb-orig/gdb/arch-utils.h 2007-04-28 22:17:42.712343000 +0200 +++ gdb-head/gdb/arch-utils.h 2007-04-28 23:30:19.997032994 +0200 @@ -89,14 +89,6 @@ extern int generic_in_solib_return_tramp extern int generic_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc); -/* Assume that the world is sane, a registers raw and virtual size - both match its type. */ - -extern int generic_register_size (int regnum); - -/* Assume that the world is sane, the registers are all adjacent. */ -extern int generic_register_byte (int regnum); - /* By default, registers are not convertible. */ extern int generic_convert_register_p (int regnum, struct type *type); diff -urNp gdb-orig/gdb/gdbarch.c gdb-head/gdb/gdbarch.c --- gdb-orig/gdb/gdbarch.c 2007-04-28 22:17:42.724342000 +0200 +++ gdb-head/gdb/gdbarch.c 2007-04-28 23:30:20.011031015 +0200 @@ -165,7 +165,6 @@ struct gdbarch gdbarch_dwarf2_reg_to_regnum_ftype *dwarf2_reg_to_regnum; gdbarch_register_name_ftype *register_name; gdbarch_register_type_ftype *register_type; - gdbarch_deprecated_register_byte_ftype *deprecated_register_byte; gdbarch_unwind_dummy_id_ftype *unwind_dummy_id; int deprecated_fp_regnum; gdbarch_push_dummy_call_ftype *push_dummy_call; @@ -293,7 +292,6 @@ struct gdbarch startup_gdbarch = 0, /* dwarf2_reg_to_regnum */ 0, /* register_name */ 0, /* register_type */ - generic_register_byte, /* deprecated_register_byte */ 0, /* unwind_dummy_id */ -1, /* deprecated_fp_regnum */ 0, /* push_dummy_call */ @@ -426,7 +424,6 @@ gdbarch_alloc (const struct gdbarch_info current_gdbarch->dwarf_reg_to_regnum = no_op_reg_to_regnum; current_gdbarch->sdb_reg_to_regnum = no_op_reg_to_regnum; current_gdbarch->dwarf2_reg_to_regnum = no_op_reg_to_regnum; - current_gdbarch->deprecated_register_byte = generic_register_byte; current_gdbarch->deprecated_fp_regnum = -1; current_gdbarch->call_dummy_location = AT_ENTRY_POINT; current_gdbarch->print_registers_info = default_print_registers_info; @@ -552,7 +549,6 @@ verify_gdbarch (struct gdbarch *current_ /* Skip verify of sdb_reg_to_regnum, invalid_p == 0 */ /* Skip verify of dwarf2_reg_to_regnum, invalid_p == 0 */ /* Skip verify of register_type, has predicate */ - /* Skip verify of deprecated_register_byte, has predicate */ /* Skip verify of unwind_dummy_id, has predicate */ /* Skip verify of deprecated_fp_regnum, invalid_p == 0 */ /* Skip verify of push_dummy_call, has predicate */ @@ -893,24 +889,6 @@ gdbarch_dump (struct gdbarch *current_gd fprintf_unfiltered (file, "gdbarch_dump: deprecated_reg_struct_has_addr = <0x%lx>\n", (long) current_gdbarch->deprecated_reg_struct_has_addr); -#ifdef DEPRECATED_REGISTER_BYTE_P - fprintf_unfiltered (file, - "gdbarch_dump: %s # %s\n", - "DEPRECATED_REGISTER_BYTE_P()", - XSTRING (DEPRECATED_REGISTER_BYTE_P ())); -#endif - fprintf_unfiltered (file, - "gdbarch_dump: gdbarch_deprecated_register_byte_p() = %d\n", - gdbarch_deprecated_register_byte_p (current_gdbarch)); -#ifdef DEPRECATED_REGISTER_BYTE - fprintf_unfiltered (file, - "gdbarch_dump: %s # %s\n", - "DEPRECATED_REGISTER_BYTE(reg_nr)", - XSTRING (DEPRECATED_REGISTER_BYTE (reg_nr))); -#endif - fprintf_unfiltered (file, - "gdbarch_dump: deprecated_register_byte = <0x%lx>\n", - (long) current_gdbarch->deprecated_register_byte); #ifdef DEPRECATED_REGISTER_SIZE fprintf_unfiltered (file, "gdbarch_dump: DEPRECATED_REGISTER_SIZE # %s\n", @@ -2260,31 +2238,6 @@ set_gdbarch_register_type (struct gdbarc } int -gdbarch_deprecated_register_byte_p (struct gdbarch *gdbarch) -{ - gdb_assert (gdbarch != NULL); - return gdbarch->deprecated_register_byte != generic_register_byte; -} - -int -gdbarch_deprecated_register_byte (struct gdbarch *gdbarch, int reg_nr) -{ - gdb_assert (gdbarch != NULL); - gdb_assert (gdbarch->deprecated_register_byte != NULL); - /* Do not check predicate: gdbarch->deprecated_register_byte != generic_register_byte, allow call. */ - if (gdbarch_debug >= 2) - fprintf_unfiltered (gdb_stdlog, "gdbarch_deprecated_register_byte called\n"); - return gdbarch->deprecated_register_byte (reg_nr); -} - -void -set_gdbarch_deprecated_register_byte (struct gdbarch *gdbarch, - gdbarch_deprecated_register_byte_ftype deprecated_register_byte) -{ - gdbarch->deprecated_register_byte = deprecated_register_byte; -} - -int gdbarch_unwind_dummy_id_p (struct gdbarch *gdbarch) { gdb_assert (gdbarch != NULL); diff -urNp gdb-orig/gdb/gdbarch.h gdb-head/gdb/gdbarch.h --- gdb-orig/gdb/gdbarch.h 2007-04-28 22:17:42.768336000 +0200 +++ gdb-head/gdb/gdbarch.h 2007-04-28 23:30:20.021029601 +0200 @@ -481,39 +481,6 @@ typedef struct type * (gdbarch_register_ extern struct type * gdbarch_register_type (struct gdbarch *gdbarch, int reg_nr); extern void set_gdbarch_register_type (struct gdbarch *gdbarch, gdbarch_register_type_ftype *register_type); -/* If the value returned by DEPRECATED_REGISTER_BYTE agrees with the - register offsets computed using just REGISTER_TYPE, this can be - deleted. See: maint print registers. NOTE: cagney/2002-05-02: This - function with predicate has a valid (callable) initial value. As a - consequence, even when the predicate is false, the corresponding - function works. This simplifies the migration process - old code, - calling DEPRECATED_REGISTER_BYTE, doesn't need to be modified. */ - -#if defined (DEPRECATED_REGISTER_BYTE) -/* Legacy for systems yet to multi-arch DEPRECATED_REGISTER_BYTE */ -#if !defined (DEPRECATED_REGISTER_BYTE_P) -#define DEPRECATED_REGISTER_BYTE_P() (1) -#endif -#endif - -extern int gdbarch_deprecated_register_byte_p (struct gdbarch *gdbarch); -#if !defined (GDB_TM_FILE) && defined (DEPRECATED_REGISTER_BYTE_P) -#error "Non multi-arch definition of DEPRECATED_REGISTER_BYTE" -#endif -#if !defined (DEPRECATED_REGISTER_BYTE_P) -#define DEPRECATED_REGISTER_BYTE_P() (gdbarch_deprecated_register_byte_p (current_gdbarch)) -#endif - -typedef int (gdbarch_deprecated_register_byte_ftype) (int reg_nr); -extern int gdbarch_deprecated_register_byte (struct gdbarch *gdbarch, int reg_nr); -extern void set_gdbarch_deprecated_register_byte (struct gdbarch *gdbarch, gdbarch_deprecated_register_byte_ftype *deprecated_register_byte); -#if !defined (GDB_TM_FILE) && defined (DEPRECATED_REGISTER_BYTE) -#error "Non multi-arch definition of DEPRECATED_REGISTER_BYTE" -#endif -#if !defined (DEPRECATED_REGISTER_BYTE) -#define DEPRECATED_REGISTER_BYTE(reg_nr) (gdbarch_deprecated_register_byte (current_gdbarch, reg_nr)) -#endif - /* See gdbint.texinfo, and PUSH_DUMMY_CALL. */ extern int gdbarch_unwind_dummy_id_p (struct gdbarch *gdbarch); diff -urNp gdb-orig/gdb/gdbarch.sh gdb-head/gdb/gdbarch.sh --- gdb-orig/gdb/gdbarch.sh 2007-04-28 22:17:42.815329000 +0200 +++ gdb-head/gdb/gdbarch.sh 2007-04-28 23:30:20.031028187 +0200 @@ -461,14 +461,6 @@ f:=:const char *:register_name:int regnr # the register cache should call this function directly; others should # use "register_type". M::struct type *:register_type:int reg_nr:reg_nr -# If the value returned by DEPRECATED_REGISTER_BYTE agrees with the -# register offsets computed using just REGISTER_TYPE, this can be -# deleted. See: maint print registers. NOTE: cagney/2002-05-02: This -# function with predicate has a valid (callable) initial value. As a -# consequence, even when the predicate is false, the corresponding -# function works. This simplifies the migration process - old code, -# calling DEPRECATED_REGISTER_BYTE, doesn't need to be modified. -F:=:int:deprecated_register_byte:int reg_nr:reg_nr:generic_register_byte:generic_register_byte # See gdbint.texinfo, and PUSH_DUMMY_CALL. M::struct frame_id:unwind_dummy_id:struct frame_info *info:info diff -urNp gdb-orig/gdb/mi/mi-interp.c gdb-head/gdb/mi/mi-interp.c --- gdb-orig/gdb/mi/mi-interp.c 2007-04-28 22:17:42.862322000 +0200 +++ gdb-head/gdb/mi/mi-interp.c 2007-04-28 23:30:20.048025783 +0200 @@ -70,10 +70,6 @@ mi_interpreter_init (void) { struct mi_interp *mi = XMALLOC (struct mi_interp); - /* Why is this a part of the mi architecture? */ - - mi_setup_architecture_data (); - /* HACK: We need to force stdout/stderr to point at the console. This avoids any potential side effects caused by legacy code that is still using the TUI / fputs_unfiltered_hook. So we set up output channels for diff -urNp gdb-orig/gdb/mi/mi-main.c gdb-head/gdb/mi/mi-main.c --- gdb-orig/gdb/mi/mi-main.c 2007-04-28 22:17:42.869321000 +0200 +++ gdb-head/gdb/mi/mi-main.c 2007-04-28 23:30:20.057024511 +0200 @@ -99,7 +99,6 @@ static int do_timings = 0; static char *last_async_command; static char *previous_async_command; char *mi_error_message; -static char *old_regs; extern void _initialize_mi_main (void); static enum mi_cmd_result mi_cmd_execute (struct mi_parse *parse); @@ -110,7 +109,8 @@ static enum mi_cmd_result mi_execute_asy static void mi_exec_async_cli_cmd_continuation (struct continuation_arg *arg); -static int register_changed_p (int regnum); +static int register_changed_p (int regnum, struct regcache *, + struct regcache *); static int get_register (int regnum, int format); /* Command implementations. FIXME: Is this libgdb? No. This is the MI @@ -332,10 +332,20 @@ mi_cmd_data_list_register_names (char *c enum mi_cmd_result mi_cmd_data_list_changed_registers (char *command, char **argv, int argc) { + static struct regcache *this_regs = NULL; + struct regcache *prev_regs; int regnum, numregs, changed; int i; struct cleanup *cleanup; + /* The last time we visited this function, the current frame's register + contents were saved in THIS_REGS. Move THIS_REGS over to PREV_REGS, + and refresh THIS_REGS with the now-current register contents. */ + + prev_regs = this_regs; + this_regs = frame_save_as_regcache (get_selected_frame (NULL)); + cleanup = make_cleanup_regcache_xfree (prev_regs); + /* Note that the test for a valid register must include checking the REGISTER_NAME because NUM_REGS may be allocated for the union of the register sets within a family of related processors. In this @@ -344,7 +354,7 @@ mi_cmd_data_list_changed_registers (char numregs = NUM_REGS + NUM_PSEUDO_REGS; - cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changed-registers"); + make_cleanup_ui_out_list_begin_end (uiout, "changed-registers"); if (argc == 0) /* No args, just do all the regs. */ { @@ -355,7 +365,7 @@ mi_cmd_data_list_changed_registers (char if (REGISTER_NAME (regnum) == NULL || *(REGISTER_NAME (regnum)) == '\0') continue; - changed = register_changed_p (regnum); + changed = register_changed_p (regnum, prev_regs, this_regs); if (changed < 0) { do_cleanups (cleanup); @@ -377,7 +387,7 @@ mi_cmd_data_list_changed_registers (char && REGISTER_NAME (regnum) != NULL && *REGISTER_NAME (regnum) != '\000') { - changed = register_changed_p (regnum); + changed = register_changed_p (regnum, prev_regs, this_regs); if (changed < 0) { do_cleanups (cleanup); @@ -399,23 +409,29 @@ mi_cmd_data_list_changed_registers (char } static int -register_changed_p (int regnum) +register_changed_p (int regnum, struct regcache *prev_regs, + struct regcache *this_regs) { - gdb_byte raw_buffer[MAX_REGISTER_SIZE]; - - if (! frame_register_read (get_selected_frame (NULL), regnum, raw_buffer)) - return -1; + struct gdbarch *gdbarch = get_regcache_arch (this_regs); + gdb_byte prev_buffer[MAX_REGISTER_SIZE]; + gdb_byte this_buffer[MAX_REGISTER_SIZE]; - if (memcmp (&old_regs[DEPRECATED_REGISTER_BYTE (regnum)], raw_buffer, - register_size (current_gdbarch, regnum)) == 0) + /* Registers not valid in this frame return count as unchanged. */ + if (!regcache_valid_p (this_regs, regnum)) return 0; - /* Found a changed register. Return 1. */ - - memcpy (&old_regs[DEPRECATED_REGISTER_BYTE (regnum)], raw_buffer, - register_size (current_gdbarch, regnum)); + /* First time through or after gdbarch change consider all registers as + changed. Same for registers not valid in the previous frame. */ + if (!prev_regs || get_regcache_arch (prev_regs) != gdbarch + || !regcache_valid_p (prev_regs, regnum)) + return 1; + + /* Get register contents and compare. */ + regcache_cooked_read (prev_regs, regnum, prev_buffer); + regcache_cooked_read (this_regs, regnum, this_buffer); - return 1; + return memcmp (prev_buffer, this_buffer, + register_size (gdbarch, regnum)) != 0; } /* Return a list of register number and value pairs. The valid @@ -1506,20 +1522,6 @@ mi_load_progress (const char *section_na uiout = saved_uiout; } -void -mi_setup_architecture_data (void) -{ - old_regs = xmalloc ((NUM_REGS + NUM_PSEUDO_REGS) * MAX_REGISTER_SIZE + 1); - memset (old_regs, 0, (NUM_REGS + NUM_PSEUDO_REGS) * MAX_REGISTER_SIZE + 1); -} - -void -_initialize_mi_main (void) -{ - DEPRECATED_REGISTER_GDBARCH_SWAP (old_regs); - deprecated_register_gdbarch_swap (NULL, 0, mi_setup_architecture_data); -} - static void timestamp (struct mi_timestamp *tv) { diff -urNp gdb-orig/gdb/mi/mi-main.h gdb-head/gdb/mi/mi-main.h --- gdb-orig/gdb/mi/mi-main.h 2007-04-28 22:17:42.873321000 +0200 +++ gdb-head/gdb/mi/mi-main.h 2007-04-28 23:30:20.061023945 +0200 @@ -22,8 +22,6 @@ #ifndef MI_MAIN_H #define MI_MAIN_H -extern void mi_setup_architecture_data (void); - extern void mi_load_progress (const char *section_name, unsigned long sent_so_far, unsigned long total_section, diff -urNp gdb-orig/gdb/regcache.c gdb-head/gdb/regcache.c --- gdb-orig/gdb/regcache.c 2007-04-28 22:17:42.857323000 +0200 +++ gdb-head/gdb/regcache.c 2007-04-28 23:30:20.039027056 +0200 @@ -381,10 +381,15 @@ regcache_dup_no_passthrough (struct regc } int -regcache_valid_p (struct regcache *regcache, int regnum) +regcache_valid_p (const struct regcache *regcache, int regnum) { gdb_assert (regcache != NULL); - gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers); + gdb_assert (regnum >= 0); + if (regcache->readonly_p) + gdb_assert (regnum < regcache->descr->nr_cooked_registers); + else + gdb_assert (regnum < regcache->descr->nr_raw_registers); + return regcache->register_valid_p[regnum]; } @@ -1107,7 +1112,6 @@ regcache_dump (struct regcache *regcache fprintf_unfiltered (file, " %6ld", regcache->descr->register_offset[regnum]); if (register_offset != regcache->descr->register_offset[regnum] - || register_offset != DEPRECATED_REGISTER_BYTE (regnum) || (regnum > 0 && (regcache->descr->register_offset[regnum] != (regcache->descr->register_offset[regnum - 1] diff -urNp gdb-orig/gdb/regcache.h gdb-head/gdb/regcache.h --- gdb-orig/gdb/regcache.h 2007-02-27 22:13:38.000000000 +0100 +++ gdb-head/gdb/regcache.h 2007-04-28 23:30:20.043026490 +0200 @@ -59,7 +59,7 @@ void regcache_raw_read_part (struct regc void regcache_raw_write_part (struct regcache *regcache, int regnum, int offset, int len, const gdb_byte *buf); -int regcache_valid_p (struct regcache *regcache, int regnum); +int regcache_valid_p (const struct regcache *regcache, int regnum); /* Transfer a cooked register [0..NUM_REGS+NUM_PSEUDO_REGS). */ void regcache_cooked_read (struct regcache *regcache, int rawnum, -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com