From e36bacd9bce9ebf570d5e8bc5883b9a5190dcb9e Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 17 Feb 2017 18:50:44 -0800 Subject: [PATCH] Compress log output of jump-to-self loops. This helps hugely when reading "spike -l" output when debugging is going on. --- riscv/processor.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/riscv/processor.cc b/riscv/processor.cc index 064c452..13aeaa4 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -270,9 +270,23 @@ void processor_t::take_trap(trap_t& t, reg_t epc) void processor_t::disasm(insn_t insn) { + static uint64_t last_pc = 1, last_bits; + static uint64_t executions = 1; + uint64_t bits = insn.bits() & ((1ULL << (8 * insn_length(insn.bits()))) - 1); - fprintf(stderr, "core %3d: 0x%016" PRIx64 " (0x%08" PRIx64 ") %s\n", - id, state.pc, bits, disassembler->disassemble(insn).c_str()); + if (last_pc != state.pc || last_bits != bits) { + if (executions != 1) { + fprintf(stderr, "core %3d: Executed %" PRIx64 " times\n", id, executions); + } + + fprintf(stderr, "core %3d: 0x%016" PRIx64 " (0x%08" PRIx64 ") %s\n", + id, state.pc, bits, disassembler->disassemble(insn).c_str()); + last_pc = state.pc; + last_bits = bits; + executions = 1; + } else { + executions++; + } } static bool validate_vm(int max_xlen, reg_t vm) -- 2.30.2