/* 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.
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <assert.h>
#include <setjmp.h>
#include <signal.h>
+#include <getopt.h>
#include "bfd.h"
printf ("insns: %14s\n", comma (rx_cycles));
else
printf ("insns: %u\n", rx_cycles);
+
+ pipeline_stats ();
}
exit (exit_code);
}
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");
-
- if (disassemble)
- sim_disasm_one ();
+ enable_counting = verbose;
- enable_counting = verbose;
- rc = decode_opcode ();
- enable_counting = 0;
+ rc = setjmp (decode_jmp_buf);
- 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)
+ {
+
+ if (trace)
+ printf ("\n");
- trace_register_changes ();
+ 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);
}