Semihosting

Some debuggers that can be used with Armv8-A will provide a mechanism called semihosting. Semihosting enables code that is running on a target to communicate with and use the Input/Output (I/O) facilities on a host computer. A good example is a program running on a target that uses the printf() function to output a message, and the message appears in a debugger console instead of in a target output device or console.

Semihosting works by building a program against a set of semihosting-enabled libraries which contain special SVC or HLT instructions in the I/O functions. When a debugger encounters these special SVC or HLT instructions, the debugger will take control and perform the I/O operation that the program needs.

The following diagram illustrates how semihosting works if the target program outputs “Hello!” using a printf() function:

This image shows how semihosting works when debugging. 

Semihosting is useful when you are working with a target that does not have all the I/O functionality, or has only part of the I/O functionality, that is needed to run or validate software.

Because the debugger is performing the I/O operation, using semihosting can cause some differences when compared to executing a program without semihosting. For example, semihosting will effectively halt execution while the semihosting operation is performed. This could cause unwanted timing changes to time-critical systems.

In most cases, using semihosting will not have any noticeable effect on target execution. However, you should consider the possible effects of semihosting if you encounter unexplainable behavior around I/O operations.

Previous Next