This topic only applies to Intel® MIC Architecture.
void attach_idb() {
volatile int loop = 1;
do {
volatile int a = 1;
} while (loop);
}
Call attach_idb() before the portion of code you want to debug is executed. After attaching to the process on the card, set a breakpoint inside the while-loop and continue execution. Once stopped there, set loop to 0, set breakpoints as required by your debugging session and continue execution.
To debug a native application on the coprocessor only, you can either start the application with the target debugger or start the application on the coprocessor and attach the debugger to it:
The debugger starts the application, or attaches to the application's process, and stops it.
If the target-side application is dynamically linked against shared objects that are not part of the compiler or driver, and that need LD_LIBRARY_PATH to be set in order to find them, set a breakpoint before the libraries are loaded. When the debugger stops at that location, you can use the command set environment LD_LIBRARY_PATH to set that variable. Do the same for other environment variables that the application might need.