You copied the Doc URL to your clipboard.

Enabling automatic semihosting support in the debugger

By default, semihosting support is not enabled in the debugger. However, you can create a special semihosting function, __auto_semihosting(void) in your C code with an alias to another function. This places the required symbol in the debug information but not in the main application image. When the debugger detects that symbol then it automatically enables semihosting operations if the target supports it.

Note

Creating a special semihosting function is not required if you build your application image using ARM Compiler 5.0 and later. The linker automatically adds a semihosting symbol if required.

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