diff options
author | Andrew Cagney <cagney@redhat.com> | 2002-05-29 01:51:17 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2002-05-29 01:51:17 +0000 |
commit | 8238d0bfe4d770d195cd52f15454835570a53b78 (patch) | |
tree | 84436dd91e32b8f32be8e0ea70fa3b6fe04d513f | |
parent | 4c7aad1c75fd97eaf8b4ea952f59b56b38b133aa (diff) | |
download | fsf-binutils-gdb-8238d0bfe4d770d195cd52f15454835570a53b78.zip fsf-binutils-gdb-8238d0bfe4d770d195cd52f15454835570a53b78.tar.gz fsf-binutils-gdb-8238d0bfe4d770d195cd52f15454835570a53b78.tar.bz2 |
* sim-regno.h: New file.
* Makefile.in (sim_regno_h): Define.
(d10v-tdep.o, remote-sim.o): Add dependency on $(sim_regno_h).
* remote-sim.c: Include "sim-regno.h" and "gdb_assert.h".
(legacy_register_sim_regno): New function.
(one2one_register_sim_regno): New function.
(gdbsim_fetch_register): Rewrite.
(gdbsim_store_register): Only store a register when
REGISTER_SIM_REGNO is valid.
* d10v-tdep.c: Include "sim-regno.h".
(d10v_ts2_register_sim_regno): Add legacy_regiter_sim_regno check.
(d10v_ts3_register_sim_regno): Ditto.
* gdbarch.sh: Include "sim-regno.h".
(REGISTER_SIM_REGNO): Set default to legacy_register_sim_regno.
* gdbarch.h, gdbarch.c: Regenerate.
* arch-utils.h (default_register_sim_regno): Delete declaration.
* arch-utils.c (default_register_sim_regno): Delete function.
-rw-r--r-- | gdb/ChangeLog | 20 | ||||
-rw-r--r-- | gdb/Makefile.in | 7 | ||||
-rw-r--r-- | gdb/arch-utils.c | 7 | ||||
-rw-r--r-- | gdb/arch-utils.h | 5 | ||||
-rw-r--r-- | gdb/d10v-tdep.c | 5 | ||||
-rw-r--r-- | gdb/gdbarch.c | 3 | ||||
-rw-r--r-- | gdb/gdbarch.h | 3 | ||||
-rwxr-xr-x | gdb/gdbarch.sh | 4 | ||||
-rw-r--r-- | gdb/remote-sim.c | 108 | ||||
-rw-r--r-- | gdb/sim-regno.h | 50 |
10 files changed, 164 insertions, 48 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 35913de..abe9826 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,23 @@ +2002-05-28 Andrew Cagney <ac131313@redhat.com> + + * sim-regno.h: New file. + * Makefile.in (sim_regno_h): Define. + (d10v-tdep.o, remote-sim.o): Add dependency on $(sim_regno_h). + * remote-sim.c: Include "sim-regno.h" and "gdb_assert.h". + (legacy_register_sim_regno): New function. + (one2one_register_sim_regno): New function. + (gdbsim_fetch_register): Rewrite. + (gdbsim_store_register): Only store a register when + REGISTER_SIM_REGNO is valid. + * d10v-tdep.c: Include "sim-regno.h". + (d10v_ts2_register_sim_regno): Add legacy_regiter_sim_regno check. + (d10v_ts3_register_sim_regno): Ditto. + * gdbarch.sh: Include "sim-regno.h". + (REGISTER_SIM_REGNO): Set default to legacy_register_sim_regno. + * gdbarch.h, gdbarch.c: Regenerate. + * arch-utils.h (default_register_sim_regno): Delete declaration. + * arch-utils.c (default_register_sim_regno): Delete function. + 2002-05-28 Jason Thorpe <thorpej@wasabisystems.com> * ppcnbsd-nat.c: Rewrite. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index da4e25e..6711ca2 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -652,6 +652,7 @@ remote_utils_h = remote-utils.h $(target_h) ser_unix_h = ser-unix.h serial_h = serial.h sh_tdep_h = sh-tdep.h osabi.h +sim_regno_h = sim-regno.h solist_h = solist.h source_h = source.h stabsread_h = stabsread.h @@ -1405,7 +1406,8 @@ dcache.o: dcache.c $(dcache_h) $(defs_h) $(gdbcmd_h) $(gdb_string_h) \ d10v-tdep.o: d10v-tdep.c $(defs_h) $(frame_h) $(obstack_h) $(symtab_h) \ $(gdbtypes_h) $(gdbcmd_h) $(gdbcore_h) $(gdb_string_h) $(value_h) \ $(inferior_h) $(dis-asm_h) $(symfile_h) $(objfiles_h) $(language_h) \ - $(arch_utils_h) $(regcache_h) $(floatformat_h) $(sim_d10v_h) + $(arch_utils_h) $(regcache_h) $(floatformat_h) $(sim_d10v_h) \ + $(sim_regno_h) dbxread.o: dbxread.c $(breakpoint_h) $(buildsym_h) $(command_h) \ $(complaints_h) $(defs_h) $(expression_h) $(gdb_stabs_h) $(gdbcore_h) \ @@ -1998,7 +2000,8 @@ remote-sds.o: remote-sds.c $(bfd_h) $(defs_h) $(gdbcmd_h) \ remote-sim.o: remote-sim.c $(defs_h) $(inferior_h) $(value_h) $(gdb_string_h) \ $(terminal_h) $(target_h) $(gdbcore_h) $(INCLUDE_DIR)/callback.h \ - $(remote_sim_h) $(remote_utils_h) $(command_h) $(regcache_h) + $(remote_sim_h) $(remote_utils_h) $(command_h) $(regcache_h) \ + $(sim_regno_h) remote-st.o: remote-st.c $(defs_h) $(gdbcore_h) $(serial_h) \ $(target_h) $(gdb_string_h) $(regcache_h) diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index bde89a8..5d13a2d 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -267,13 +267,6 @@ generic_cannot_extract_struct_value_address (char *dummy) return 0; } -int -default_register_sim_regno (int num) -{ - return num; -} - - CORE_ADDR core_addr_identity (CORE_ADDR addr) { diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index 594a832..f4b2d02 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -94,11 +94,6 @@ extern void set_architecture_from_arch_mach (enum bfd_architecture, unsigned lon extern int (*target_architecture_hook) (const struct bfd_arch_info *); - -/* Default raw->sim register re-numbering - does nothing. */ - -extern int default_register_sim_regno (int reg_nr); - /* Identity function on a CORE_ADDR. Just returns its parameter. */ extern CORE_ADDR core_addr_identity (CORE_ADDR addr); diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c index cd260da..9973ac9 100644 --- a/gdb/d10v-tdep.c +++ b/gdb/d10v-tdep.c @@ -41,6 +41,7 @@ #include "floatformat.h" #include "gdb/sim-d10v.h" +#include "sim-regno.h" struct frame_extra_info { @@ -296,6 +297,8 @@ d10v_imap_register (int reg_nr) static int d10v_ts2_register_sim_regno (int nr) { + if (legacy_register_sim_regno (nr) < 0) + return legacy_register_sim_regno (nr); if (nr >= TS2_IMAP0_REGNUM && nr < TS2_IMAP0_REGNUM + NR_IMAP_REGS) return nr - TS2_IMAP0_REGNUM + SIM_D10V_IMAP0_REGNUM; @@ -310,6 +313,8 @@ d10v_ts2_register_sim_regno (int nr) static int d10v_ts3_register_sim_regno (int nr) { + if (legacy_register_sim_regno (nr) < 0) + return legacy_register_sim_regno (nr); if (nr >= TS3_IMAP0_REGNUM && nr < TS3_IMAP0_REGNUM + NR_IMAP_REGS) return nr - TS3_IMAP0_REGNUM + SIM_D10V_IMAP0_REGNUM; diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 6990953..baeea9f 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -39,6 +39,7 @@ #if GDB_MULTI_ARCH #include "gdbcmd.h" #include "inferior.h" /* enum CALL_DUMMY_LOCATION et.al. */ +#include "sim-regno.h" /* For legacy_register_sim_regno(). */ #else /* Just include everything in sight so that the every old definition of macro is visible. */ @@ -488,7 +489,7 @@ gdbarch_alloc (const struct gdbarch_info *info, current_gdbarch->max_register_virtual_size = -1; current_gdbarch->do_registers_info = do_registers_info; current_gdbarch->print_float_info = default_print_float_info; - current_gdbarch->register_sim_regno = default_register_sim_regno; + current_gdbarch->register_sim_regno = legacy_register_sim_regno; current_gdbarch->cannot_fetch_register = cannot_register_not; current_gdbarch->cannot_store_register = cannot_register_not; current_gdbarch->use_generic_dummy_frames = -1; diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 9f45459..6ea86bc 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -40,6 +40,7 @@ /* Pull in function declarations refered to, indirectly, via macros. */ #include "value.h" /* For default_coerce_float_to_double which is referenced by a macro. */ #include "inferior.h" /* For unsigned_address_to_pointer(). */ +#include "sim-regno.h" /* For legacy_register_sim_regno(). */ #endif struct frame_info; @@ -811,7 +812,7 @@ extern void set_gdbarch_print_float_info (struct gdbarch *gdbarch, gdbarch_print /* Default (function) for non- multi-arch platforms. */ #if (!GDB_MULTI_ARCH) && !defined (REGISTER_SIM_REGNO) -#define REGISTER_SIM_REGNO(reg_nr) (default_register_sim_regno (reg_nr)) +#define REGISTER_SIM_REGNO(reg_nr) (legacy_register_sim_regno (reg_nr)) #endif typedef int (gdbarch_register_sim_regno_ftype) (int reg_nr); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index ebcb423..ac42d29 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -471,7 +471,7 @@ f:2:DO_REGISTERS_INFO:void:do_registers_info:int reg_nr, int fpregs:reg_nr, fpre f:2:PRINT_FLOAT_INFO:void:print_float_info:void::::default_print_float_info::0 # MAP a GDB RAW register number onto a simulator register number. See # also include/...-sim.h. -f:2:REGISTER_SIM_REGNO:int:register_sim_regno:int reg_nr:reg_nr:::default_register_sim_regno::0 +f:2:REGISTER_SIM_REGNO:int:register_sim_regno:int reg_nr:reg_nr:::legacy_register_sim_regno::0 F:2:REGISTER_BYTES_OK:int:register_bytes_ok:long nr_bytes:nr_bytes::0:0 f:2:CANNOT_FETCH_REGISTER:int:cannot_fetch_register:int regnum:regnum:::cannot_register_not::0 f:2:CANNOT_STORE_REGISTER:int:cannot_store_register:int regnum:regnum:::cannot_register_not::0 @@ -759,6 +759,7 @@ cat <<EOF /* Pull in function declarations refered to, indirectly, via macros. */ #include "value.h" /* For default_coerce_float_to_double which is referenced by a macro. */ #include "inferior.h" /* For unsigned_address_to_pointer(). */ +#include "sim-regno.h" /* For legacy_register_sim_regno(). */ #endif struct frame_info; @@ -1220,6 +1221,7 @@ cat <<EOF #if GDB_MULTI_ARCH #include "gdbcmd.h" #include "inferior.h" /* enum CALL_DUMMY_LOCATION et.al. */ +#include "sim-regno.h" /* For legacy_register_sim_regno(). */ #else /* Just include everything in sight so that the every old definition of macro is visible. */ diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 1d037c8..2c2790b 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -40,6 +40,8 @@ #include "remote-utils.h" #include "command.h" #include "regcache.h" +#include "gdb_assert.h" +#include "sim-regno.h" /* Prototypes */ @@ -276,46 +278,88 @@ gdb_os_error (host_callback * p, const char *format,...) } } +int +legacy_register_sim_regno (int regnum) +{ + /* Only makes sense to supply raw registers. */ + gdb_assert (regnum >= 0 && regnum < NUM_REGS); + /* NOTE: cagney/2002-05-13: The old code did it this way and it is + suspected that some GDB/SIM combinations may rely on this + behavour. The default should be one2one_register_sim_regno + (below). */ + if (REGISTER_NAME (regnum) != NULL + && REGISTER_NAME (regnum)[0] != '\0') + return regnum; + else + return LEGACY_SIM_REGNO_IGNORE; +} + +int +one2one_register_sim_regno (int regnum) +{ + /* Only makes sense to supply raw registers. */ + gdb_assert (regnum >= 0 && regnum < NUM_REGS); + return regnum; +} + static void gdbsim_fetch_register (int regno) { - static int warn_user = 1; if (regno == -1) { for (regno = 0; regno < NUM_REGS; regno++) gdbsim_fetch_register (regno); + return; } - else if (REGISTER_NAME (regno) != NULL - && *REGISTER_NAME (regno) != '\0') + + switch (REGISTER_SIM_REGNO (regno)) { - char buf[MAX_REGISTER_RAW_SIZE]; - int nr_bytes; - if (REGISTER_SIM_REGNO (regno) >= 0) + case LEGACY_SIM_REGNO_IGNORE: + break; + case SIM_REGNO_DOES_NOT_EXIST: + { + /* For moment treat a `does not exist' register the same way + as an ``unavailable'' register. */ + char *buf = alloca (MAX_REGISTER_RAW_SIZE); + int nr_bytes; + memset (buf, 0, MAX_REGISTER_RAW_SIZE); + supply_register (regno, buf); + set_register_cached (regno, -1); + break; + } + default: + { + static int warn_user = 1; + char *buf = alloca (MAX_REGISTER_RAW_SIZE); + int nr_bytes; + gdb_assert (regno >= 0 && regno < NUM_REGS); + memset (buf, 0, MAX_REGISTER_RAW_SIZE); nr_bytes = sim_fetch_register (gdbsim_desc, REGISTER_SIM_REGNO (regno), buf, REGISTER_RAW_SIZE (regno)); - else - nr_bytes = 0; - if (nr_bytes == 0) - /* register not applicable, supply zero's */ - memset (buf, 0, MAX_REGISTER_RAW_SIZE); - else if (nr_bytes > 0 && nr_bytes != REGISTER_RAW_SIZE (regno) - && warn_user) - { - fprintf_unfiltered (gdb_stderr, - "Size of register %s (%d/%d) incorrect (%d instead of %d))", - REGISTER_NAME (regno), - regno, REGISTER_SIM_REGNO (regno), - nr_bytes, REGISTER_RAW_SIZE (regno)); - warn_user = 0; - } - supply_register (regno, buf); - if (sr_get_debug ()) - { - printf_filtered ("gdbsim_fetch_register: %d", regno); - /* FIXME: We could print something more intelligible. */ - dump_mem (buf, REGISTER_RAW_SIZE (regno)); - } + if (nr_bytes > 0 && nr_bytes != REGISTER_RAW_SIZE (regno) && warn_user) + { + fprintf_unfiltered (gdb_stderr, + "Size of register %s (%d/%d) incorrect (%d instead of %d))", + REGISTER_NAME (regno), + regno, REGISTER_SIM_REGNO (regno), + nr_bytes, REGISTER_RAW_SIZE (regno)); + warn_user = 0; + } + /* FIXME: cagney/2002-05-27: Should check `nr_bytes == 0' + indicatingthat GDB and the SIM have different ideas about + which registers are fetchable. */ + /* Else if (nr_bytes < 0): an old simulator, that doesn't + think to return the register size. Just assume all is ok. */ + supply_register (regno, buf); + if (sr_get_debug ()) + { + printf_filtered ("gdbsim_fetch_register: %d", regno); + /* FIXME: We could print something more intelligible. */ + dump_mem (buf, REGISTER_RAW_SIZE (regno)); + } + break; + } } } @@ -327,10 +371,9 @@ gdbsim_store_register (int regno) { for (regno = 0; regno < NUM_REGS; regno++) gdbsim_store_register (regno); + return; } - else if (REGISTER_NAME (regno) != NULL - && *REGISTER_NAME (regno) != '\0' - && REGISTER_SIM_REGNO (regno) >= 0) + else if (REGISTER_SIM_REGNO (regno) >= 0) { char tmp[MAX_REGISTER_RAW_SIZE]; int nr_bytes; @@ -341,6 +384,9 @@ gdbsim_store_register (int regno) if (nr_bytes > 0 && nr_bytes != REGISTER_RAW_SIZE (regno)) internal_error (__FILE__, __LINE__, "Register size different to expected"); + /* FIXME: cagney/2002-05-27: Should check `nr_bytes == 0' + indicatingthat GDB and the SIM have different ideas about + which registers are fetchable. */ if (sr_get_debug ()) { printf_filtered ("gdbsim_store_register: %d", regno); diff --git a/gdb/sim-regno.h b/gdb/sim-regno.h new file mode 100644 index 0000000..7791ac4 --- /dev/null +++ b/gdb/sim-regno.h @@ -0,0 +1,50 @@ +/* Generic remote debugging interface for simulators. + + Copyright 2002 Free Software Foundation, Inc. + + Contributed by Red Hat, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef SIM_REGNO_H +#define SIM_REGNO_H + +/* The REGISTER_SIM_REGNO(REGNUM) method, when there is a + corresponding simulator register, returns that register number as a + cardinal. When there is no corresponding register, it returns a + negative value. */ + +enum sim_regno { + /* Normal sane architecture. The simulator is known to not model + this register. */ + SIM_REGNO_DOES_NOT_EXIST = -1, + /* For possible backward compatibility. The register cache doesn't + have a corresponding name. Skip the register entirely. */ + LEGACY_SIM_REGNO_IGNORE = -2 +}; + +/* For compatibility with older architectures, returns + (LEGACY_SIM_REGNO_IGNORE) when a register doesn't have. */ + +extern int legacy_register_sim_regno (int regnum); + +/* Treat all raw registers as valid. */ + +extern int one2one_register_sim_regno (int regnum); + +#endif |