DarkSharpness / REIMU

A user-mode RISC-V simulator for education purpose.
9 stars 3 forks source link

Bug: program output after Exit code #5

Closed jason-fxz closed 2 months ago

jason-fxz commented 2 months ago

It looks like this:

❯ reimu -f output.s -i test.in
Warning: attribute ignored: .attribute
Warning: attribute ignored: .file
Warning: attribute ignored: .type
Warning: attribute ignored: .size
Warning: attribute ignored: .ident
Warning: attribute ignored: .unknown

=============================== Build time: 0ms ================================

Exit code: 0
Total cycles: 103129
Instruction parsed: 282
Instruction counts:
# arith  = 1084
# mul    = 0
# div    = 0
# bits   = 101
# mem    = 1564
# branch = 128
# jump   = 244
# jalr   = 162
23 24 25 26 27 28 29 30 31 32 33 34 (35) 36 37 38 39 40 41 42 43 44 45 46 47   // <<< here is output
============================= Interpret time: 0ms ==============================

It seems like you should flush stdout before print the debug info.

DarkSharpness commented 2 months ago

Hi!

This is a known issue, resulting from the fact that the profiling output (Exit code, Total cycles, etc.) is default to stderr, while the default program output is default to stdout. These 2 streams are not synchronized. As a consequence, this may lead to a confusing output sequence.