Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dealing with EXIT code of target #136

Open
PhilippvK opened this issue Jun 19, 2023 · 2 comments
Open

Dealing with EXIT code of target #136

PhilippvK opened this issue Jun 19, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@PhilippvK
Copy link
Member

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):

  • Custom _exit hook implemented in syscalls.c:
    void _exit_(int exit_status)
    {
    #ifdef DEBUG_SYSTEM
    printf_fromisr("exit called with code: %i\n", exit_status);
    #endif
    asm("ebreak");
    while (1)
    ;
    }
  • Based on printf -> ROM size overhead -> Only enabled in DEBUG mode

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

Proposed Improvements:

  • Print exit code in handler for SYS_EXIT using etiss logger
  • Log level Warn/Error for non zero (FAIL) values
  • Log level Verbose/Info elsewhere (OK)
  • Optionally pass through exit code to bare_etiss_simulator to fails as well (if configured by the user)
@PhilippvK PhilippvK added the enhancement New feature or request label Jun 19, 2023
@wysiwyng
Copy link
Contributor

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
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants