tum-ei-eda / etiss

Extendable Translating Instruction Set Simulator
https://tum-ei-eda.github.io/etiss/
Other
28 stars 36 forks source link

Dealing with EXIT code of target #136

Open PhilippvK opened 1 year ago

PhilippvK commented 1 year ago

The exit code of the simulated program is either the return value of the main() function or the argument to the exit(-1) function. For unit testing and benchmarks, we should make sure to not ignore if the program reports a non-zero exit code.

Previous approach (without Semihosting):

Current approach (with Semihosting based on https://github.com/wysiwyng/etiss/tree/coredsl_exceptions)

Proposed Improvements:

wysiwyng commented 11 months ago

bare_etiss_processor currently also uses exit codes to signal when ETISS encountered some internal error. Distinguishing these from the application's exit code would not be possible, this would at least have to be noted somewhere. How do other simulators handle this?

PhilippvK commented 11 months ago

RISC-V OVPSim has a command line flag to choose whether a non-zero _exit() call will lead to a failed simulation: --override riscvOVPsim/cpu/pk/reportExitErrors=F (Boolean) (default=F) (default) Report non-zero exit() return codes as simulator errors

At least to my knowledge, when using Spike & riscv-pk the exit code of spike should always be the exit code of the program (wihich of course, has disadvantages, as you just mentioned.)

If this flag is enabled, it will also print the exit code to stdout, which at least allows extracting the actual value by parsing the output. I prefer this approach over handing the printing of the Exit code in the target SW (using custom syscalls) which is not even feasible when using semihosting.