You copied the Doc URL to your clipboard.

Enabling automatic semihosting support in the debugger

Describes how create an ELF symbol to enable semihosting support in the debugger.

By default, semihosting support is disabled in the debugger. However, the debugger can automatically enable semihosting on supported targets when you load debug information that contains the ELF symbol __auto_semihosting.

In C code you can easily 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.


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

Create a special semihosting ELF symbol with an alias to main()

#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;

Related information