From 6e61ecfc92456bd557cd2276a92e34a13fd1ca4e Mon Sep 17 00:00:00 2001 From: Gavin Romig-Koch Date: Thu, 22 May 1997 13:16:03 +0000 Subject: [PATCH] Change longjmp param/setjmp return value used for simulator restart from 0 to 2. --- sim/common/ChangeLog | 6 ++++++ sim/common/sim-engine.c | 10 +++++++--- sim/common/sim-resume.c | 17 ++++++++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 6dfbdcd..89a6759 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,9 @@ +Thu May 22 09:12:16 1997 Gavin Koch + + * sim-engine.c (sim_engine_restart): + * sim-resume.c (sim_resume): Change longjmp param/setjmp + return value used for simulator restart from 0 to 2. + Wed May 21 08:47:30 1997 Andrew Cagney * cgen-scache.c (scache_option_handler): Add is_command arg. diff --git a/sim/common/sim-engine.c b/sim/common/sim-engine.c index 46f69e5..6d6343e 100644 --- a/sim/common/sim-engine.c +++ b/sim/common/sim-engine.c @@ -18,11 +18,12 @@ 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. */ -#include "sim-main.h" - #include #include +#include "sim-main.h" +#include "sim-assert.h" + /* Generic halt */ @@ -35,6 +36,7 @@ sim_engine_halt (SIM_DESC sd, int sigrc) { sim_engine *engine = STATE_ENGINE (sd); + ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); if (engine->jmpbuf != NULL) { jmp_buf *halt_buf = engine->jmpbuf; @@ -59,13 +61,14 @@ sim_engine_restart (SIM_DESC sd, sim_cia cia) { sim_engine *engine = STATE_ENGINE (sd); + ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); if (engine->jmpbuf != NULL) { jmp_buf *halt_buf = engine->jmpbuf; engine->last_cpu = last_cpu; engine->next_cpu = next_cpu; SIM_ENGINE_RESTART_HOOK (sd, last_cpu, cia); - longjmp(*halt_buf, 0); + longjmp(*halt_buf, 2); } else sim_io_error (sd, "sim_restart - bad long jump"); @@ -81,6 +84,7 @@ sim_engine_abort (SIM_DESC sd, const char *fmt, ...) { + ASSERT (sd == NULL || STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); if (sd == NULL) { va_list ap; diff --git a/sim/common/sim-resume.c b/sim/common/sim-resume.c index e1004b7..ebc9ce6 100644 --- a/sim/common/sim-resume.c +++ b/sim/common/sim-resume.c @@ -18,16 +18,18 @@ 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. */ -#include "sim-main.h" - #include +#include "sim-main.h" +#include "sim-assert.h" + /* Halt the simulator after just one instruction */ static void has_stepped (SIM_DESC sd, void *data) { + ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); sim_engine_halt (sd, NULL, NULL, NULL_CIA, sim_stopped, SIGTRAP); } @@ -41,6 +43,9 @@ sim_resume (SIM_DESC sd, { sim_engine *engine = STATE_ENGINE (sd); jmp_buf buf; + int jmpval; + + ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); /* we only want to be single stepping the simulator once */ if (engine->stepper != NULL) @@ -52,8 +57,14 @@ sim_resume (SIM_DESC sd, engine->stepper = sim_events_schedule (sd, 1, has_stepped, sd); /* run/resume the simulator */ + /* jmpval: 0 (initial use) start simulator + 1 halt simulator + 2 restart simulator + */ + engine->jmpbuf = &buf; - if (! setjmp (buf)) + jmpval = setjmp (buf); + if (jmpval == 0 || jmpval == 2) { int last_cpu_nr = sim_engine_last_cpu_nr (sd); int next_cpu_nr = sim_engine_next_cpu_nr (sd); -- 2.7.4