aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-06-20 12:32:27 -0400
committerMike Frysinger <vapier@gentoo.org>2021-06-20 23:45:24 -0400
commit1b40d569a861eb8b290faaad05ae8a6152e0b2ee (patch)
tree3747a4952c1ce3455fa9d6dd7ee5894b0d84cde5 /sim
parente27c0d7ae3b154b9e753646c6d1400b7c329d0ce (diff)
downloadfsf-binutils-gdb-1b40d569a861eb8b290faaad05ae8a6152e0b2ee.zip
fsf-binutils-gdb-1b40d569a861eb8b290faaad05ae8a6152e0b2ee.tar.gz
fsf-binutils-gdb-1b40d569a861eb8b290faaad05ae8a6152e0b2ee.tar.bz2
sim: cris: clean up printf & abort usage a bit
Inline the stats printf calls to avoid compiler warnings about non-literal format strings. This in turn highlights bad type sizes being passed in, so fix the strings to use the right size type. This in turn highlights the rest of the func using casts rather than the right type directly, so adjust all of those. Finally, replace a few abort+sim_engine_halt calls with the common sim_engine_abort. This provides good output while still aborting as we want.
Diffstat (limited to 'sim')
-rw-r--r--sim/cris/ChangeLog6
-rw-r--r--sim/cris/traps.c77
2 files changed, 43 insertions, 40 deletions
diff --git a/sim/cris/ChangeLog b/sim/cris/ChangeLog
index ad25fc4..7f2b465 100644
--- a/sim/cris/ChangeLog
+++ b/sim/cris/ChangeLog
@@ -1,5 +1,11 @@
2021-06-20 Mike Frysinger <vapier@gentoo.org>
+ * traps.c (dump_statistics): Clean up sim_io_eprintf calls, and
+ replace raw abort with sim engine abort.
+ (cris_break_13_handler): Likewise.
+
+2021-06-20 Mike Frysinger <vapier@gentoo.org>
+
* configure.ac (SIM_AC_COMMON): Delete.
* aclocal.m4, configure: Regenerate.
diff --git a/sim/cris/traps.c b/sim/cris/traps.c
index 130a380..f92bb7c 100644
--- a/sim/cris/traps.c
+++ b/sim/cris/traps.c
@@ -804,7 +804,10 @@ dump_statistics (SIM_CPU *current_cpu)
CRIS_MISC_PROFILE *profp
= CPU_CRIS_MISC_PROFILE (current_cpu);
unsigned64 total = profp->basic_cycle_count;
- const char *textmsg = "Basic clock cycles, total @: %llu\n";
+
+ /* Historically, these messages have gone to stderr, so we'll keep it
+ that way. It's also easier to then tell it from normal program
+ output. FIXME: Add redirect option like "run -e file". */
/* The --cris-stats={basic|unaligned|schedulable|all} counts affect
what's included in the "total" count only. */
@@ -812,16 +815,18 @@ dump_statistics (SIM_CPU *current_cpu)
& FLAG_CRIS_MISC_PROFILE_ALL)
{
case FLAG_CRIS_MISC_PROFILE_SIMPLE:
+ sim_io_eprintf (sd, "Basic clock cycles, total @: %" PRIu64 "\n", total);
break;
case (FLAG_CRIS_MISC_PROFILE_UNALIGNED | FLAG_CRIS_MISC_PROFILE_SIMPLE):
- textmsg
- = "Clock cycles including stall cycles for unaligned accesses @: %llu\n";
total += profp->unaligned_mem_dword_count;
+ sim_io_eprintf (sd,
+ "Clock cycles including stall cycles for unaligned "
+ "accesses @: %" PRIu64 "\n",
+ total);
break;
case (FLAG_CRIS_MISC_PROFILE_SCHEDULABLE | FLAG_CRIS_MISC_PROFILE_SIMPLE):
- textmsg = "Schedulable clock cycles, total @: %llu\n";
total
+= (profp->memsrc_stall_count
+ profp->memraw_stall_count
@@ -830,10 +835,11 @@ dump_statistics (SIM_CPU *current_cpu)
+ profp->mulsrc_stall_count
+ profp->jumpsrc_stall_count
+ profp->unaligned_mem_dword_count);
+ sim_io_eprintf (sd, "Schedulable clock cycles, total @: %" PRIu64 "\n",
+ total);
break;
case FLAG_CRIS_MISC_PROFILE_ALL:
- textmsg = "All accounted clock cycles, total @: %llu\n";
total
+= (profp->memsrc_stall_count
+ profp->memraw_stall_count
@@ -845,44 +851,36 @@ dump_statistics (SIM_CPU *current_cpu)
+ profp->branch_stall_count
+ profp->jumptarget_stall_count
+ profp->unaligned_mem_dword_count);
+ sim_io_eprintf (sd, "All accounted clock cycles, total @: %" PRIu64 "\n",
+ total);
break;
default:
- abort ();
-
- sim_io_eprintf (sd,
- "Internal inconsistency at %s:%d",
- __FILE__, __LINE__);
- sim_engine_halt (sd, current_cpu, NULL, 0,
- sim_stopped, SIM_SIGILL);
+ sim_engine_abort (sd, current_cpu, 0,
+ "Internal inconsistency at %s:%d",
+ __FILE__, __LINE__);
}
- /* Historically, these messages have gone to stderr, so we'll keep it
- that way. It's also easier to then tell it from normal program
- output. FIXME: Add redirect option like "run -e file". */
- sim_io_eprintf (sd, textmsg, total);
-
/* For v32, unaligned_mem_dword_count should always be 0. For
v10, memsrc_stall_count should always be 0. */
- sim_io_eprintf (sd, "Memory source stall cycles: %llu\n",
- (unsigned long long) (profp->memsrc_stall_count
- + profp->unaligned_mem_dword_count));
- sim_io_eprintf (sd, "Memory read-after-write stall cycles: %llu\n",
- (unsigned long long) profp->memraw_stall_count);
- sim_io_eprintf (sd, "Movem source stall cycles: %llu\n",
- (unsigned long long) profp->movemsrc_stall_count);
- sim_io_eprintf (sd, "Movem destination stall cycles: %llu\n",
- (unsigned long long) profp->movemdst_stall_count);
- sim_io_eprintf (sd, "Movem address stall cycles: %llu\n",
- (unsigned long long) profp->movemaddr_stall_count);
- sim_io_eprintf (sd, "Multiplication source stall cycles: %llu\n",
- (unsigned long long) profp->mulsrc_stall_count);
- sim_io_eprintf (sd, "Jump source stall cycles: %llu\n",
- (unsigned long long) profp->jumpsrc_stall_count);
- sim_io_eprintf (sd, "Branch misprediction stall cycles: %llu\n",
- (unsigned long long) profp->branch_stall_count);
- sim_io_eprintf (sd, "Jump target stall cycles: %llu\n",
- (unsigned long long) profp->jumptarget_stall_count);
+ sim_io_eprintf (sd, "Memory source stall cycles: %" PRIu64 "\n",
+ profp->memsrc_stall_count + profp->unaligned_mem_dword_count);
+ sim_io_eprintf (sd, "Memory read-after-write stall cycles: %" PRIu64 "\n",
+ profp->memraw_stall_count);
+ sim_io_eprintf (sd, "Movem source stall cycles: %" PRIu64 "\n",
+ profp->movemsrc_stall_count);
+ sim_io_eprintf (sd, "Movem destination stall cycles: %" PRIu64 "\n",
+ profp->movemdst_stall_count);
+ sim_io_eprintf (sd, "Movem address stall cycles: %" PRIu64 "\n",
+ profp->movemaddr_stall_count);
+ sim_io_eprintf (sd, "Multiplication source stall cycles: %" PRIu64 "\n",
+ profp->mulsrc_stall_count);
+ sim_io_eprintf (sd, "Jump source stall cycles: %" PRIu64 "\n",
+ profp->jumpsrc_stall_count);
+ sim_io_eprintf (sd, "Branch misprediction stall cycles: %" PRIu64 "\n",
+ profp->branch_stall_count);
+ sim_io_eprintf (sd, "Jump target stall cycles: %" PRIu64 "\n",
+ profp->jumptarget_stall_count);
}
/* Check whether any part of [addr .. addr + len - 1] is already mapped.
@@ -1481,10 +1479,9 @@ cris_break_13_handler (SIM_CPU *current_cpu, USI callnum, USI arg1,
if (cb_syscall (cb, &s) != CB_RC_OK)
{
- abort ();
- sim_io_eprintf (sd, "Break 13: invalid %d? Returned %ld\n", callnum,
- s.result);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped, SIM_SIGILL);
+ sim_engine_abort (sd, current_cpu, pc,
+ "Break 13: invalid %d? Returned %ld\n", callnum,
+ s.result);
}
retval = s.result == -1 ? -s.errcode : s.result;