* 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.
This commit is contained in:
Ulrich Weigand
2007-04-28 21:52:38 +00:00
parent efc72ef5c0
commit 6ed7ea50e8
11 changed files with 60 additions and 162 deletions

View File

@ -1,3 +1,23 @@
2007-04-28 Ulrich Weigand <uweigand@de.ibm.com>
* 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.
2007-04-28 Ulrich Weigand <uweigand@de.ibm.com> 2007-04-28 Ulrich Weigand <uweigand@de.ibm.com>
* alpha-nat.c (ALPHA_REGSET_BASE, ALPHA_REGSET_UNIQUE): Do not define, * alpha-nat.c (ALPHA_REGSET_BASE, ALPHA_REGSET_UNIQUE): Do not define,

View File

@ -207,32 +207,6 @@ legacy_virtual_frame_pointer (CORE_ADDR pc,
*frame_offset = 0; *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 int
generic_convert_register_p (int regnum, struct type *type) generic_convert_register_p (int regnum, struct type *type)

View File

@ -89,14 +89,6 @@ extern int generic_in_solib_return_trampoline (CORE_ADDR pc, char *name);
extern int generic_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc); 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. */ /* By default, registers are not convertible. */
extern int generic_convert_register_p (int regnum, struct type *type); extern int generic_convert_register_p (int regnum, struct type *type);

View File

@ -165,7 +165,6 @@ struct gdbarch
gdbarch_dwarf2_reg_to_regnum_ftype *dwarf2_reg_to_regnum; gdbarch_dwarf2_reg_to_regnum_ftype *dwarf2_reg_to_regnum;
gdbarch_register_name_ftype *register_name; gdbarch_register_name_ftype *register_name;
gdbarch_register_type_ftype *register_type; gdbarch_register_type_ftype *register_type;
gdbarch_deprecated_register_byte_ftype *deprecated_register_byte;
gdbarch_unwind_dummy_id_ftype *unwind_dummy_id; gdbarch_unwind_dummy_id_ftype *unwind_dummy_id;
int deprecated_fp_regnum; int deprecated_fp_regnum;
gdbarch_push_dummy_call_ftype *push_dummy_call; gdbarch_push_dummy_call_ftype *push_dummy_call;
@ -293,7 +292,6 @@ struct gdbarch startup_gdbarch =
0, /* dwarf2_reg_to_regnum */ 0, /* dwarf2_reg_to_regnum */
0, /* register_name */ 0, /* register_name */
0, /* register_type */ 0, /* register_type */
generic_register_byte, /* deprecated_register_byte */
0, /* unwind_dummy_id */ 0, /* unwind_dummy_id */
-1, /* deprecated_fp_regnum */ -1, /* deprecated_fp_regnum */
0, /* push_dummy_call */ 0, /* push_dummy_call */
@ -426,7 +424,6 @@ gdbarch_alloc (const struct gdbarch_info *info,
current_gdbarch->dwarf_reg_to_regnum = no_op_reg_to_regnum; current_gdbarch->dwarf_reg_to_regnum = no_op_reg_to_regnum;
current_gdbarch->sdb_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->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->deprecated_fp_regnum = -1;
current_gdbarch->call_dummy_location = AT_ENTRY_POINT; current_gdbarch->call_dummy_location = AT_ENTRY_POINT;
current_gdbarch->print_registers_info = default_print_registers_info; current_gdbarch->print_registers_info = default_print_registers_info;
@ -552,7 +549,6 @@ verify_gdbarch (struct gdbarch *current_gdbarch)
/* Skip verify of sdb_reg_to_regnum, invalid_p == 0 */ /* Skip verify of sdb_reg_to_regnum, invalid_p == 0 */
/* Skip verify of dwarf2_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 register_type, has predicate */
/* Skip verify of deprecated_register_byte, has predicate */
/* Skip verify of unwind_dummy_id, has predicate */ /* Skip verify of unwind_dummy_id, has predicate */
/* Skip verify of deprecated_fp_regnum, invalid_p == 0 */ /* Skip verify of deprecated_fp_regnum, invalid_p == 0 */
/* Skip verify of push_dummy_call, has predicate */ /* Skip verify of push_dummy_call, has predicate */
@ -893,24 +889,6 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file)
fprintf_unfiltered (file, fprintf_unfiltered (file,
"gdbarch_dump: deprecated_reg_struct_has_addr = <0x%lx>\n", "gdbarch_dump: deprecated_reg_struct_has_addr = <0x%lx>\n",
(long) current_gdbarch->deprecated_reg_struct_has_addr); (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 #ifdef DEPRECATED_REGISTER_SIZE
fprintf_unfiltered (file, fprintf_unfiltered (file,
"gdbarch_dump: DEPRECATED_REGISTER_SIZE # %s\n", "gdbarch_dump: DEPRECATED_REGISTER_SIZE # %s\n",
@ -2259,31 +2237,6 @@ set_gdbarch_register_type (struct gdbarch *gdbarch,
gdbarch->register_type = register_type; gdbarch->register_type = register_type;
} }
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 int
gdbarch_unwind_dummy_id_p (struct gdbarch *gdbarch) gdbarch_unwind_dummy_id_p (struct gdbarch *gdbarch)
{ {

View File

@ -481,39 +481,6 @@ typedef struct type * (gdbarch_register_type_ftype) (struct gdbarch *gdbarch, in
extern struct type * gdbarch_register_type (struct gdbarch *gdbarch, int reg_nr); 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); 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. */ /* See gdbint.texinfo, and PUSH_DUMMY_CALL. */
extern int gdbarch_unwind_dummy_id_p (struct gdbarch *gdbarch); extern int gdbarch_unwind_dummy_id_p (struct gdbarch *gdbarch);

View File

@ -461,14 +461,6 @@ f:=:const char *:register_name:int regnr:regnr
# the register cache should call this function directly; others should # the register cache should call this function directly; others should
# use "register_type". # use "register_type".
M::struct type *:register_type:int reg_nr:reg_nr 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. # See gdbint.texinfo, and PUSH_DUMMY_CALL.
M::struct frame_id:unwind_dummy_id:struct frame_info *info:info M::struct frame_id:unwind_dummy_id:struct frame_info *info:info

View File

@ -70,10 +70,6 @@ mi_interpreter_init (void)
{ {
struct mi_interp *mi = XMALLOC (struct mi_interp); 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 /* 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 any potential side effects caused by legacy code that is still
using the TUI / fputs_unfiltered_hook. So we set up output channels for using the TUI / fputs_unfiltered_hook. So we set up output channels for

View File

@ -99,7 +99,6 @@ static int do_timings = 0;
static char *last_async_command; static char *last_async_command;
static char *previous_async_command; static char *previous_async_command;
char *mi_error_message; char *mi_error_message;
static char *old_regs;
extern void _initialize_mi_main (void); extern void _initialize_mi_main (void);
static enum mi_cmd_result mi_cmd_execute (struct mi_parse *parse); static enum mi_cmd_result mi_cmd_execute (struct mi_parse *parse);
@ -110,7 +109,8 @@ static enum mi_cmd_result mi_execute_async_cli_command (char *mi, char *args, in
static void mi_exec_async_cli_cmd_continuation (struct continuation_arg *arg); 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); static int get_register (int regnum, int format);
/* Command implementations. FIXME: Is this libgdb? No. This is the MI /* Command implementations. FIXME: Is this libgdb? No. This is the MI
@ -332,10 +332,20 @@ mi_cmd_data_list_register_names (char *command, char **argv, int argc)
enum mi_cmd_result enum mi_cmd_result
mi_cmd_data_list_changed_registers (char *command, char **argv, int argc) 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 regnum, numregs, changed;
int i; int i;
struct cleanup *cleanup; 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 /* Note that the test for a valid register must include checking the
REGISTER_NAME because NUM_REGS may be allocated for the union of REGISTER_NAME because NUM_REGS may be allocated for the union of
the register sets within a family of related processors. In this the register sets within a family of related processors. In this
@ -344,7 +354,7 @@ mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
numregs = NUM_REGS + NUM_PSEUDO_REGS; 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. */ if (argc == 0) /* No args, just do all the regs. */
{ {
@ -355,7 +365,7 @@ mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
if (REGISTER_NAME (regnum) == NULL if (REGISTER_NAME (regnum) == NULL
|| *(REGISTER_NAME (regnum)) == '\0') || *(REGISTER_NAME (regnum)) == '\0')
continue; continue;
changed = register_changed_p (regnum); changed = register_changed_p (regnum, prev_regs, this_regs);
if (changed < 0) if (changed < 0)
{ {
do_cleanups (cleanup); do_cleanups (cleanup);
@ -377,7 +387,7 @@ mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
&& REGISTER_NAME (regnum) != NULL && REGISTER_NAME (regnum) != NULL
&& *REGISTER_NAME (regnum) != '\000') && *REGISTER_NAME (regnum) != '\000')
{ {
changed = register_changed_p (regnum); changed = register_changed_p (regnum, prev_regs, this_regs);
if (changed < 0) if (changed < 0)
{ {
do_cleanups (cleanup); do_cleanups (cleanup);
@ -399,23 +409,29 @@ mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
} }
static int 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]; struct gdbarch *gdbarch = get_regcache_arch (this_regs);
gdb_byte prev_buffer[MAX_REGISTER_SIZE];
gdb_byte this_buffer[MAX_REGISTER_SIZE];
if (! frame_register_read (get_selected_frame (NULL), regnum, raw_buffer)) /* Registers not valid in this frame return count as unchanged. */
return -1; if (!regcache_valid_p (this_regs, regnum))
if (memcmp (&old_regs[DEPRECATED_REGISTER_BYTE (regnum)], raw_buffer,
register_size (current_gdbarch, regnum)) == 0)
return 0; return 0;
/* Found a changed register. Return 1. */ /* First time through or after gdbarch change consider all registers as
changed. Same for registers not valid in the previous frame. */
memcpy (&old_regs[DEPRECATED_REGISTER_BYTE (regnum)], raw_buffer, if (!prev_regs || get_regcache_arch (prev_regs) != gdbarch
register_size (current_gdbarch, regnum)); || !regcache_valid_p (prev_regs, regnum))
return 1; return 1;
/* Get register contents and compare. */
regcache_cooked_read (prev_regs, regnum, prev_buffer);
regcache_cooked_read (this_regs, regnum, this_buffer);
return memcmp (prev_buffer, this_buffer,
register_size (gdbarch, regnum)) != 0;
} }
/* Return a list of register number and value pairs. The valid /* Return a list of register number and value pairs. The valid
@ -1506,20 +1522,6 @@ mi_load_progress (const char *section_name,
uiout = saved_uiout; 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 static void
timestamp (struct mi_timestamp *tv) timestamp (struct mi_timestamp *tv)
{ {

View File

@ -22,8 +22,6 @@
#ifndef MI_MAIN_H #ifndef MI_MAIN_H
#define MI_MAIN_H #define MI_MAIN_H
extern void mi_setup_architecture_data (void);
extern void mi_load_progress (const char *section_name, extern void mi_load_progress (const char *section_name,
unsigned long sent_so_far, unsigned long sent_so_far,
unsigned long total_section, unsigned long total_section,

View File

@ -381,10 +381,15 @@ regcache_dup_no_passthrough (struct regcache *src)
} }
int int
regcache_valid_p (struct regcache *regcache, int regnum) regcache_valid_p (const struct regcache *regcache, int regnum)
{ {
gdb_assert (regcache != NULL); 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]; return regcache->register_valid_p[regnum];
} }
@ -1107,7 +1112,6 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
fprintf_unfiltered (file, " %6ld", fprintf_unfiltered (file, " %6ld",
regcache->descr->register_offset[regnum]); regcache->descr->register_offset[regnum]);
if (register_offset != regcache->descr->register_offset[regnum] if (register_offset != regcache->descr->register_offset[regnum]
|| register_offset != DEPRECATED_REGISTER_BYTE (regnum)
|| (regnum > 0 || (regnum > 0
&& (regcache->descr->register_offset[regnum] && (regcache->descr->register_offset[regnum]
!= (regcache->descr->register_offset[regnum - 1] != (regcache->descr->register_offset[regnum - 1]

View File

@ -59,7 +59,7 @@ void regcache_raw_read_part (struct regcache *regcache, int regnum,
void regcache_raw_write_part (struct regcache *regcache, int regnum, void regcache_raw_write_part (struct regcache *regcache, int regnum,
int offset, int len, const gdb_byte *buf); 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). */ /* Transfer a cooked register [0..NUM_REGS+NUM_PSEUDO_REGS). */
void regcache_cooked_read (struct regcache *regcache, int rawnum, void regcache_cooked_read (struct regcache *regcache, int rawnum,