Hello all,

I'd like to propose improvements to OpenOCD's semihosting behavior for the SYS_EXIT and SYS_EXIT_EXTENDED syscalls.

Currently, if GDB is not connected and the target calls `SYS_EXIT` or `SYS_EXIT_EXTENDED` (with the appropriate parameter):

 * If GDB is not connected - OpenOCD calls `exit(code)` immediately,
   without any cleanup. I believe this should be fixed - OpenOCD should
   go trough the standard shutdown sequence.
 * If GDB is connected - message is printed and target is either halted
   or resumed depending on `arm semihosting_resexit`.

I would like to make these improvements:

1. Avoid the direct call to `exit()`

2. Introduce a new command: `arm semihosting_exit_behavior`

The options would be:

 * `always_halt`
 * `always_exit`
 * `exit_if_no_gdb`

3. Introduce commands to get the program exit code in Tcl scripts:

 * `arm semihosting_has_program_exited` - would return true if the
   semihosting exit already happened
 * `arm semihosting_exit_code` - returns exit code (from
   `SYS_EXIT_EXTENDED`)

Would you be in favor of this proposal? I welcome any comments.

Thank you,

Marek Vrbka


Reply via email to