You copied the Doc URL to your clipboard.

Working with semihosting

Semihosting is supported by the debugger in both the command-line console and from the user interface.

Enabling semihosting support

By default, semihosting support is disabled in the debugger. However, Arm® Debugger enables semihosting automatically if either __auto_semihosting or __semihosting_library_function ELF symbols are present in an image. Also, if the image is compiled with Arm Compiler 5.0 and later, the linker automatically adds __semihosting_library_function to an image if it uses functions that require semihosting.

In C code, you can create the ELF symbol by defining a function with the name __auto_semihosting. To prevent this function generating any additional code or data in your image, you can define it as an alias of another function. This places the required ELF symbol in the debug information, but does not affect the code and data in the application image.


#include <stdio.h>
void __auto_semihosting(void) __attribute__((alias("main")));
//mark as alias for main() to declare
//semihosting ELF symbol in debug information only
int main(void){
  printf("Hello world\n");
  return 0;

Using semihosting from the command-line console

The input/output requests from application code to a host workstation running the debugger are called semihosting messages. By default, all semihosting messages (stdout and stderr) are output to the console. When using this console interactively with debugger commands , you must use the stdin option to send input messages to the application.

By default, all messages are output to the command-line console, but you can choose to redirect them when launching the debugger by using one or more of the following options:


Disables all semihosting operations.


Disables all semihosting operations to the debugger console.


Specifies a file to write stderr for semihosting operations.


Specifies a file to read stdin for semihosting operations.


Specifies a file to write stdout for semihosting operations.


Alternatively, you can disable semihosting in the console and use a separate telnet session to interact directly with the application. During start up, the debugger creates a semihosting server socket and displays the port number to use for the telnet session.

See Command-line debugger options for more information.

Using semihosting from the user interface

The App Console view in the DS Debug perspective controls all the semihosting input/output requests (stdin, stdout, and stderr ) between the application code and the debugger.