The semihosting mechanism
C-SPY emulated I/O is compatible with the semihosting interface provided by Arm Limited. When an application invokes a semihosting call, the execution stops at a debugger breakpoint. The debugger then handles the call, performs any necessary actions on the host computer and then resumes the execution.
There are three variants of semihosting mechanisms available:
For Cortex-M, the interface uses
BKPTinstructions to perform semihosting callsFor other Arm cores,
SVCinstructions are used for the semihosting calls in 32-bit modeIn 64-bit mode,
HLTinstructions are used for the semihosting callsUsing IAR breakpoint, which is an IAR-specific alternative to semihosting that uses SVC.
To support semihosting via SVC, the debugger must set its semihosting breakpoint on the Supervisor Call vector to catch SVC calls. If your application uses SVC calls for other purposes than semihosting, the handling of this breakpoint will cause a severe performance penalty for each such call. IAR breakpoint is a way to get around this. By using a special function call instead of an SVC instruction to perform semihosting, the semihosting breakpoint can be set on that special function instead. This means that semihosting will not interfere with other uses of the Supervisor Call vector.
Unsafe semihosting commands that might alter or leak information about the host system are by default disabled. The debugger will block calls to such functions, and print a message in the debug log. Some calls are considered safe, and are enabled by default. These include reading from and writing to stdin, stdout, and stderr. Reading from or writing to the host file system is considered unsafe, and is disabled by default. This includes the IAR proprietary variant of semihosting (IAR breakpoint).
To enable the unsafe calls, choose Project>Options>General>Library Configuration and select the Enable unsafe semihosting commands option, or specify the cspybat command line option ‑‑unsafe_semihosting to the debugger backend.
Note
IAR breakpoint is an IAR-specific extension of the semihosting standard. If you link your application with libraries built with tool chains from other vendors than IAR and use IAR breakpoint, semihosting calls made from code in those libraries will not work.