/* main.c --- main function for stand-alone RX simulator.
-Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+Copyright (C) 2005-2021 Free Software Foundation, Inc.
Contributed by Red Hat, Inc.
This file is part of the GNU simulators.
#include "config.h"
#include <stdio.h>
#include <string.h>
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <assert.h>
#include <setjmp.h>
#include <signal.h>
-#ifdef HAVE_GETOPT_H
#include <getopt.h>
-#endif
#include "bfd.h"
int o;
int save_trace;
bfd *prog;
+ int rc;
/* By default, we exit when an execution error occurs. */
execution_error_init_standalone ();
rx_in_gdb = 0;
save_trace = trace;
trace = 0;
- rx_load (prog);
+ rx_load (prog, NULL);
trace = save_trace;
sim_disasm_init (prog);
- while (1)
- {
- int rc;
-
- if (trace)
- printf ("\n");
+ enable_counting = verbose;
- if (disassemble)
- sim_disasm_one ();
+ rc = setjmp (decode_jmp_buf);
- enable_counting = verbose;
- rc = decode_opcode ();
- enable_counting = 0;
-
- if (RX_HIT_BREAK (rc))
- done (1);
- else if (RX_EXITED (rc))
- done (RX_EXIT_STATUS (rc));
- else if (RX_STOPPED (rc))
+ if (rc == 0)
+ {
+ if (!trace && !disassemble)
{
- if (verbose)
- printf("Stopped on signal %d\n", RX_STOP_SIG (rc));
- exit(1);
+ /* This will longjmp to the above if an exception
+ happens. */
+ for (;;)
+ decode_opcode ();
}
else
- assert (RX_STEPPED (rc));
+ while (1)
+ {
- trace_register_changes ();
+ if (trace)
+ printf ("\n");
+
+ if (disassemble)
+ {
+ enable_counting = 0;
+ sim_disasm_one ();
+ enable_counting = verbose;
+ }
+
+ rc = decode_opcode ();
+
+ if (trace)
+ trace_register_changes ();
+ }
+ }
+
+ if (RX_HIT_BREAK (rc))
+ done (1);
+ else if (RX_EXITED (rc))
+ done (RX_EXIT_STATUS (rc));
+ else if (RX_STOPPED (rc))
+ {
+ if (verbose)
+ printf("Stopped on signal %d\n", RX_STOP_SIG (rc));
+ exit(1);
}
+ done (0);
+ exit (0);
}