Enabling automatic 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.

Example 7. 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;
}

Note

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.

Show/hideSee also

Copyright © 2010-2012 ARM. All rights reserved.ARM DUI 0446K
Non-ConfidentialID071912