Debugging Native Applications Only on the Coprocessor Side

Note

This topic only applies to Intel® MIC Architecture.

If you want to start the application manually on the coprocessor only and attach to it, the process must contain an endless worker loop:

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:

  1. Upload the debug build of the application to the coprocessor.
  2. Launch the target debugger by using the following command:

    idbc_mic -tco -rconnect=tcpip:coprocessor-ip-address:port

    Please refer to the MPSS documentation for information on which IP addresses are assigned to the coprocessor. The default port number is 2000.

    For example, enter idbc_mic -tco -rconnect=tcpip:192.168.1.100:2000 for the first Intel® MIC Architecture device using the default port.
  3. You may need to tell the debugger where to search for the debug information specific to your application if the application was not built on the same system, or if the shared object containing the debug information has been moved from its original location. Use the following command: set solib-search-path path[:path].
  4. Start the application with the debugger:
    1. Specify the remote executable file: idb file-remote target-bin-path
    2. Specify the file containing debug info: file host-bin-path
    3. Set breakpoints and perform anything else required before starting the application.
    4. Enter run to start the application.
  5. Alternatively, you can start the application's process on the coprocessor and attach the debugger to it.

    Note

    See above how to use an endless worker loop to have the application wait for attach.

    Enter attach pid host-side-symbol-info-file-path/file-name

The debugger starts the application, or attaches to the application's process, and stops it.

Note

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.


Submit feedback on this help topic