aboutsummaryrefslogtreecommitdiff
path: root/c_emulator
diff options
context:
space:
mode:
authorPrashanth Mundkur <prashanth.mundkur@gmail.com>2020-01-07 17:09:57 -0800
committerPrashanth Mundkur <prashanth.mundkur@gmail.com>2020-01-07 17:09:57 -0800
commit778301c9a2f483523e83581d7cffb93effb75134 (patch)
tree3691b22682552587b8c50b3b63a32a366d6b3274 /c_emulator
parente15f302b12df29014c5dd6d19bbacf12be19ff4d (diff)
parentdfebc748f8a762718cfda1f1a1201debe754a9c6 (diff)
downloadsail-riscv-778301c9a2f483523e83581d7cffb93effb75134.zip
sail-riscv-778301c9a2f483523e83581d7cffb93effb75134.tar.gz
sail-riscv-778301c9a2f483523e83581d7cffb93effb75134.tar.bz2
Merge branch 'master' into rsnikhil.
Diffstat (limited to 'c_emulator')
-rw-r--r--c_emulator/riscv_sim.c72
1 files changed, 33 insertions, 39 deletions
diff --git a/c_emulator/riscv_sim.c b/c_emulator/riscv_sim.c
index 4e92b7a..841b249 100644
--- a/c_emulator/riscv_sim.c
+++ b/c_emulator/riscv_sim.c
@@ -194,7 +194,7 @@ static void read_dtb(const char *path)
char *process_args(int argc, char **argv)
{
- int c, idx = 1;
+ int c;
uint64_t ram_size = 0;
while(true) {
c = getopt_long(argc, argv,
@@ -216,7 +216,7 @@ char *process_args(int argc, char **argv)
"v::"
"l:"
"F:"
- , options, &idx);
+ , options, NULL);
if (c == -1) break;
switch (c) {
case 'a':
@@ -305,7 +305,7 @@ char *process_args(int argc, char **argv)
}
if (do_dump_dts) dump_dts();
#ifdef RVFI_DII
- if (idx > argc || (idx == argc && !rvfi_dii)) print_usage(argv[0], 0);
+ if (optind > argc || (optind == argc && !rvfi_dii)) print_usage(argv[0], 0);
#else
if (optind >= argc) {
fprintf(stderr, "No elf file provided.\n");
@@ -689,39 +689,37 @@ void run_sail(void)
fprintf(stderr, "Cannot gettimeofday: %s\n", strerror(errno));
exit(1);
}
-
+
while (!zhtif_done && (insn_limit == 0 || total_insns < insn_limit)) {
#ifdef RVFI_DII
if (rvfi_dii) {
- if (need_instr) {
- mach_bits instr_bits;
- int res = read(rvfi_dii_sock, &instr_bits, sizeof(instr_bits));
- if (res == 0) {
- rvfi_dii = false;
- return;
- }
- if (res < sizeof(instr_bits)) {
- fprintf(stderr, "Reading RVFI DII command failed: insufficient input");
- exit(1);
- }
- if (res == -1) {
- fprintf(stderr, "Reading RVFI DII command failed: %s", strerror(errno));
- exit(1);
- }
- zrvfi_set_instr_packet(instr_bits);
- zrvfi_zzero_exec_packet(UNIT);
- mach_bits cmd = zrvfi_get_cmd(UNIT);
- switch (cmd) {
- case 0: /* EndOfTrace */
- zrvfi_halt_exec_packet(UNIT);
- rvfi_send_trace();
- return;
- case 1: /* Instruction */
- break;
- default:
- fprintf(stderr, "Unknown RVFI-DII command: %d\n", (int)cmd);
- exit(1);
- }
+ mach_bits instr_bits;
+ int res = read(rvfi_dii_sock, &instr_bits, sizeof(instr_bits));
+ if (res == 0) {
+ rvfi_dii = false;
+ return;
+ }
+ if (res < sizeof(instr_bits)) {
+ fprintf(stderr, "Reading RVFI DII command failed: insufficient input");
+ exit(1);
+ }
+ if (res == -1) {
+ fprintf(stderr, "Reading RVFI DII command failed: %s", strerror(errno));
+ exit(1);
+ }
+ zrvfi_set_instr_packet(instr_bits);
+ zrvfi_zzero_exec_packet(UNIT);
+ mach_bits cmd = zrvfi_get_cmd(UNIT);
+ switch (cmd) {
+ case 0: /* EndOfTrace */
+ zrvfi_halt_exec_packet(UNIT);
+ rvfi_send_trace();
+ return;
+ case 1: /* Instruction */
+ break;
+ default:
+ fprintf(stderr, "Unknown RVFI-DII command: %d\n", (int)cmd);
+ exit(1);
}
sail_int sail_step;
CREATE(sail_int)(&sail_step);
@@ -730,12 +728,8 @@ void run_sail(void)
if (have_exception) goto step_exception;
flush_logs();
KILL(sail_int)(&sail_step);
- if (stepped) {
- need_instr = true;
- rvfi_send_trace();
- } else
- need_instr = false;
- } else
+ rvfi_send_trace();
+ } else /* if (!rvfi_dii) */
#endif
{ /* run a Sail step */
sail_int sail_step;