From d47f5b30d8481272e9480118bdcb283690070349 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 2 Jan 2016 09:23:06 -0500 Subject: [PATCH] sim: delete dead current_state globals The global current_state handle to the current simulator state is a design idea that was half implemented, but never really cleaned up. The point was to have a global variable pointing to the state so that funcs could more quickly & easily access the state anywhere. We've instead moved in the direction of passing state around everywhere and don't have any intention of moving back. I also can't find any references to gdb using this variable, or to cgen related "dump_regs" functions, both of which were used in the comments related to this code. --- sim/common/ChangeLog | 6 ++++++ sim/common/cgen-defs.h | 6 ------ sim/common/sim-base.h | 22 ---------------------- sim/common/sim-utils.c | 4 ---- sim/cris/ChangeLog | 5 +++++ sim/cris/sim-if.c | 8 -------- sim/frv/ChangeLog | 6 ++++++ sim/frv/reset.c | 2 +- sim/frv/sim-if.c | 8 -------- sim/iq2000/ChangeLog | 5 +++++ sim/iq2000/sim-if.c | 8 -------- sim/lm32/ChangeLog | 5 +++++ sim/lm32/sim-if.c | 8 -------- sim/m32r/ChangeLog | 5 +++++ sim/m32r/sim-if.c | 8 -------- sim/mips/ChangeLog | 4 ++++ sim/mips/dv-tx3904cpu.c | 5 ----- sim/sh64/ChangeLog | 5 +++++ sim/sh64/sim-if.c | 8 -------- 19 files changed, 42 insertions(+), 86 deletions(-) diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 58ffa6c5e5b..65a0abfd1bc 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,9 @@ +2016-01-02 Mike Frysinger + + * cgen-defs.h (current_state): Delete. + * sim-base.h (CURRENT_STATE_REG, CURRENT_STATE): Delete. + * sim-utils.c (current_state): Delete. + 2015-12-30 Mike Frysinger * sim-module.c (sim_pre_argv_init): Change STATE_MY_NAME assignment diff --git a/sim/common/cgen-defs.h b/sim/common/cgen-defs.h index be717f85b4f..c42db9b4693 100644 --- a/sim/common/cgen-defs.h +++ b/sim/common/cgen-defs.h @@ -140,12 +140,6 @@ typedef enum { /* Simulator state. */ -/* Records simulator descriptor so utilities like @cpu@_dump_regs can be - called from gdb. */ -extern SIM_DESC current_state; - -/* Simulator state. */ - /* CGEN_STATE contains additional state information not present in sim_state_base. */ diff --git a/sim/common/sim-base.h b/sim/common/sim-base.h index a0e70908ac0..350b352cc4c 100644 --- a/sim/common/sim-base.h +++ b/sim/common/sim-base.h @@ -89,28 +89,6 @@ typedef struct _sim_cpu sim_cpu; #include "sim-memopt.h" #include "sim-cpu.h" -/* Global pointer to current state while sim_resume is running. - On a machine with lots of registers, it might be possible to reserve - one of them for current_state. However on a machine with few registers - current_state can't permanently live in one and indirecting through it - will be slower [in which case one can have sim_resume set globals from - current_state for faster access]. - If CURRENT_STATE_REG is defined, it means current_state is living in - a global register. */ - - -#ifdef CURRENT_STATE_REG -/* FIXME: wip */ -#else -extern struct sim_state *current_state; -#endif - - -/* The simulator may provide different (and faster) definition. */ -#ifndef CURRENT_STATE -#define CURRENT_STATE current_state -#endif - /* We require all sims to dynamically allocate cpus. See comment up top about struct sim_state. */ diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c index 5439b8bada3..d2b5f7c0d03 100644 --- a/sim/common/sim-utils.c +++ b/sim/common/sim-utils.c @@ -48,10 +48,6 @@ along with this program. If not, see . */ #include "bfd.h" #include "sim-utils.h" -/* Global pointer to all state data. - Set by sim_resume. */ -struct sim_state *current_state; - /* Allocate zero filled memory with xcalloc - xcalloc aborts if the allocation fails. */ diff --git a/sim/cris/ChangeLog b/sim/cris/ChangeLog index 9bf94f9709f..df428e7f774 100644 --- a/sim/cris/ChangeLog +++ b/sim/cris/ChangeLog @@ -1,3 +1,8 @@ +2016-01-02 Mike Frysinger + + * sim-if.c (current_state): Delete. + (sim_open): Delete current_state assignment. + 2015-12-30 Mike Frysinger * sim-if.c (sim_open): Delete current_target_byte_order assignment. diff --git a/sim/cris/sim-if.c b/sim/cris/sim-if.c index eba9dc90a78..cf680cf5136 100644 --- a/sim/cris/sim-if.c +++ b/sim/cris/sim-if.c @@ -81,10 +81,6 @@ static int cris_program_offset = 0; enum cris_unknown_syscall_action_type cris_unknown_syscall_action = CRIS_USYSC_MSG_STOP; -/* Records simulator descriptor so utilities like cris_dump_regs can be - called from gdb. */ -SIM_DESC current_state; - /* CRIS-specific options. */ typedef enum { OPTION_CRIS_STATS = OPTION_START, @@ -985,10 +981,6 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, Must be done after cris_cgen_cpu_open. */ cgen_init (sd); - /* Store in a global so things like cris_dump_regs can be invoked - from the gdb command line. */ - current_state = sd; - cris_set_callbacks (callback); return sd; diff --git a/sim/frv/ChangeLog b/sim/frv/ChangeLog index c716e6aeae5..a566ba05b1b 100644 --- a/sim/frv/ChangeLog +++ b/sim/frv/ChangeLog @@ -1,3 +1,9 @@ +2016-01-02 Mike Frysinger + + * reset.c (frv_term): Change current_state to sd. + * sim-if.c (current_state): Delete. + (sim_open): Delete current_state assignment. + 2015-12-27 Mike Frysinger * Makefile.in (SIM_OBJS): Delete sim-hload.o. diff --git a/sim/frv/reset.c b/sim/frv/reset.c index 0bc9dd98063..6f973b5a228 100644 --- a/sim/frv/reset.c +++ b/sim/frv/reset.c @@ -105,7 +105,7 @@ frv_term (SIM_DESC sd) then turn it off again. This is the only place we can currently gain control to do this. */ if (frv_interrupt_state.timer.enabled && ! frv_save_profile_model_p) - sim_profile_set_option (current_state, "-model", PROFILE_MODEL_IDX, "0"); + sim_profile_set_option (sd, "-model", PROFILE_MODEL_IDX, "0"); } /* Perform a power on reset. */ diff --git a/sim/frv/sim-if.c b/sim/frv/sim-if.c index aab8ff794cf..6bf77fde0ae 100644 --- a/sim/frv/sim-if.c +++ b/sim/frv/sim-if.c @@ -30,10 +30,6 @@ along with this program. If not, see . */ static void free_state (SIM_DESC); static void print_frv_misc_cpu (SIM_CPU *cpu, int verbose); - -/* Records simulator descriptor so utilities like frv_dump_regs can be - called from gdb. */ -SIM_DESC current_state; /* Cover function of sim_state_free to free the cpu buffers as well. */ @@ -175,10 +171,6 @@ sim_open (kind, callback, abfd, argv) frv_initialize (cpu, sd); } - /* Store in a global so things like sparc32_dump_regs can be invoked - from the gdb command line. */ - current_state = sd; - return sd; } diff --git a/sim/iq2000/ChangeLog b/sim/iq2000/ChangeLog index 8f760bbfabe..d2584e905da 100644 --- a/sim/iq2000/ChangeLog +++ b/sim/iq2000/ChangeLog @@ -1,3 +1,8 @@ +2016-01-02 Mike Frysinger + + * sim-if.c (current_state): Delete. + (sim_open): Delete current_state assignment. + 2015-12-27 Mike Frysinger * Makefile.in (SIM_OBJS): Delete sim-hload.o. diff --git a/sim/iq2000/sim-if.c b/sim/iq2000/sim-if.c index b5240f089b7..d21ec1b9abe 100644 --- a/sim/iq2000/sim-if.c +++ b/sim/iq2000/sim-if.c @@ -26,10 +26,6 @@ along with this program. If not, see . */ #include "bfd.h" static void free_state (SIM_DESC); - -/* Records simulator descriptor so utilities like iq2000_dump_regs can be - called from gdb. */ -SIM_DESC current_state; /* Cover function for sim_cgen_disassemble_insn. */ @@ -149,10 +145,6 @@ sim_open (kind, callback, abfd, argv) Must be done after iq2000_cgen_cpu_open. */ cgen_init (sd); - /* Store in a global so things like sparc32_dump_regs can be invoked - from the gdb command line. */ - current_state = sd; - return sd; } diff --git a/sim/lm32/ChangeLog b/sim/lm32/ChangeLog index a7596a6f178..eda8a23df1f 100644 --- a/sim/lm32/ChangeLog +++ b/sim/lm32/ChangeLog @@ -1,3 +1,8 @@ +2016-01-02 Mike Frysinger + + * sim-if.c (current_state): Delete. + (sim_open): Delete current_state assignment. + 2015-12-27 Mike Frysinger * Makefile.in (SIM_OBJS): Delete sim-hload.o. diff --git a/sim/lm32/sim-if.c b/sim/lm32/sim-if.c index 364fc7d8982..3f65c93334f 100644 --- a/sim/lm32/sim-if.c +++ b/sim/lm32/sim-if.c @@ -43,10 +43,6 @@ static const OPTION lm32_options[] = { lm32_option_handler}, {{NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL} }; - -/* Records simulator descriptor so utilities like lm32_dump_regs can be - called from gdb. */ -SIM_DESC current_state; /* Cover function of sim_state_free to free the cpu buffers as well. */ @@ -240,10 +236,6 @@ sim_open (kind, callback, abfd, argv) Must be done after lm32_cgen_cpu_open. */ cgen_init (sd); - /* Store in a global so things like lm32_dump_regs can be invoked - from the gdb command line. */ - current_state = sd; - return sd; } diff --git a/sim/m32r/ChangeLog b/sim/m32r/ChangeLog index 6bedd999bba..5b3d70e6fe0 100644 --- a/sim/m32r/ChangeLog +++ b/sim/m32r/ChangeLog @@ -1,3 +1,8 @@ +2016-01-02 Mike Frysinger + + * sim-if.c (current_state): Delete. + (sim_open): Delete current_state assignment. + 2015-12-27 Mike Frysinger * Makefile.in (SIM_OBJS): Delete sim-hload.o. diff --git a/sim/m32r/sim-if.c b/sim/m32r/sim-if.c index f6a44e8f090..2ed6934cf5d 100644 --- a/sim/m32r/sim-if.c +++ b/sim/m32r/sim-if.c @@ -37,10 +37,6 @@ static void free_state (SIM_DESC); static void print_m32r_misc_cpu (SIM_CPU *cpu, int verbose); - -/* Records simulator descriptor so utilities like m32r_dump_regs can be - called from gdb. */ -SIM_DESC current_state; /* Cover function of sim_state_free to free the cpu buffers as well. */ @@ -169,10 +165,6 @@ sim_open (kind, callback, abfd, argv) = print_m32r_misc_cpu; } - /* Store in a global so things like sparc32_dump_regs can be invoked - from the gdb command line. */ - current_state = sd; - return sd; } diff --git a/sim/mips/ChangeLog b/sim/mips/ChangeLog index 8b2e23f396e..a77058e0847 100644 --- a/sim/mips/ChangeLog +++ b/sim/mips/ChangeLog @@ -1,3 +1,7 @@ +2016-01-02 Mike Frysinger + + * dv-tx3904cpu.c (CPU, SD): Delete. + 2015-12-30 Mike Frysinger * wrapper.c (mips_reg_store, mips_reg_fetch): Define. diff --git a/sim/mips/dv-tx3904cpu.c b/sim/mips/dv-tx3904cpu.c index 1c5b70d770f..da28a49a60c 100644 --- a/sim/mips/dv-tx3904cpu.c +++ b/sim/mips/dv-tx3904cpu.c @@ -143,9 +143,6 @@ deliver_tx3904cpu_interrupt (struct hw *me, sim_cpu *cpu = STATE_CPU (sd, 0); /* NB: fix CPU 0. */ address_word cia = CPU_PC_GET (cpu); -#define CPU cpu -#define SD current_state - if (controller->pending_reset) { controller->pending_reset = 0; @@ -190,8 +187,6 @@ deliver_tx3904cpu_interrupt (struct hw *me, } } /* interrupt set */ } -#undef CPU cpu -#undef SD current_state } diff --git a/sim/sh64/ChangeLog b/sim/sh64/ChangeLog index 945ec35c4fb..06ce139842f 100644 --- a/sim/sh64/ChangeLog +++ b/sim/sh64/ChangeLog @@ -1,3 +1,8 @@ +2016-01-02 Mike Frysinger + + * sim-if.c (current_state): Delete. + (sim_open): Delete current_state assignment. + 2015-12-27 Mike Frysinger * Makefile.in (SIM_OBJS): Delete sim-hload.o. diff --git a/sim/sh64/sim-if.c b/sim/sh64/sim-if.c index bbc57cd70e0..a74f1e58b4e 100644 --- a/sim/sh64/sim-if.c +++ b/sim/sh64/sim-if.c @@ -32,10 +32,6 @@ static void free_state (SIM_DESC); /* Since we don't build the cgen-opcode table, we use a wrapper around the existing disassembler from libopcodes. */ static CGEN_DISASSEMBLER sh64_disassemble_insn; - -/* Records simulator descriptor so utilities like sh5_dump_regs can be - called from gdb. */ -SIM_DESC current_state; /* Cover function of sim_state_free to free the cpu buffers as well. */ @@ -155,10 +151,6 @@ sim_open (kind, callback, abfd, argv) Must be done after sh_cgen_cpu_open. */ cgen_init (sd); - /* Store in a global so things like sparc32_dump_regs can be invoked - from the gdb command line. */ - current_state = sd; - return sd; } -- 2.30.2