diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c index ae974982f4..f72bf4c094 100644 --- a/cpukit/sapi/src/exinit.c +++ b/cpukit/sapi/src/exinit.c @@ -61,6 +61,26 @@ RTEMS_SECTION(".rtemsroset.copyright") const char _Copyright_Notice[] = "Copyright (C) 1989, 2021 RTEMS Project and contributors"; +/* + * Additional Macro to add custom section (.debug_gdb_scripts) to + * every ELF being built on RTEMS, in order to add auto-loading + * support for Python scripts (specifically, GCC's pretty-printing + * scripts), by in-lining the Python script in the section. + */ +#define DEFINE_GDB_PY() \ + asm( \ + ".pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n" \ + ".byte 4\n" \ + ".ascii \"gdb.inlined-script\\n\"\n" \ + ".ascii \"import sys\\n\"\n" \ + ".ascii \"import os.path\\n\"\n" \ + ".ascii \"sys.path.append(os.path.join(gdb.PYTHONDIR, 'rtems'))\\n\"\n" \ + ".ascii \"import rtems.stdcxx as stdcxx\\n\"\n" \ + ".byte 0\n" \ + ".popsection\n" \ + ) + + static Objects_Information * _Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ]; @@ -101,6 +121,9 @@ static void rtems_initialize_data_structures(void) _Scheduler_Handler_initialization(); _SMP_Handler_initialize(); + + /* Macro call to embed section in script for pretty-printing */ + DEFINE_GDB_PY(); } RTEMS_LINKER_ROSET( _Sysinit, rtems_sysinit_item );