C++ remote debugging with GDB server


Because the PLCnext Technology does have a GDB server (GNU debug server) directly implemented it is possible to create in an easy and performant way a C++ remote session.

This short manual introduced all necessary steps to establish a remote debug session and connect directly to a running process by using the Eclipse® Neon or Eclipse® Photon IDE.


Software used in the following description:


Debug Configuration

  1. Open your program in Eclipse.
  2. Configure the Debugging by "Run" -> "Debug Configurations...":
    Debug Configuration
  3. Create a C/C++ remote application by double-clicking the list item:
    Debug remote application
  4. On the "Main" tab,
    1. Insert the path to the C/C++ application executable, e.g.:
    2. Set the "Build Configuration" drop-down menu to "Debug" (in Eclipse Neon):

    3. Debug Settings
    4. ...or to "Use Active" (in Eclipse Photon):
      EclipsePhoton MainConfig
    5. Click the "Select other" button (same in both Eclipse Neon and Photon).
  5. In the "Select Preferred Launcher" dialog box, choose "GDB (DSF) Manual Remote Debugging Launcher" and close with the "OK" button:
    Manual remote debug launcher
  6. Back in the "Debug Configuration" dialog, switch to the "Debugger" tab.
  7. As the "GDB debugger", choose the "gdb" executable from the PLCnext toolchain, e.g.:
  8. Create a "gdbinit.txt" file containing the following handles and add it as the "GDB command file":
                handle SIGUSR2 nostop noprint 
                handle SIGILL nostop noprint 
                handle SIGSTOP nostop noprint

    Attach to process
  9. On the "Shared Libraries" tab, insert the directory of the shared library to debug.
    Usually, the library of a Eclipse project is saved in the "Debug" or "Debug\lib" subdirectory to a program.
    Shared libraries
  10. On the "Connection" tab, insert a host name or IP address of the remote target; insert the port on which the gdbserver instance is listening:
    Debugger connection
  11. Click the "Debug" button.

Attach to remote gdbserver


  1. Log into a shell on the remote system.
  2. Determine the process ID of PLCnext Technology process:
    ps | grep Arp.System - but NOTE: as of firmware 2020.0 LTS, this has to be ps aux | grep Arp.System
  3. Start the gdbserver and attach it to the desired port:
    sudo gdbserver :2345 --attach <your process ID here>
    resulting in this answer if successfully attached:
    Grep Arp System answer

Set the breakpoints and start a debug session

  1. Select the newly created debug configuration by means of the "Debug" menu icon:
    Start Debug
    Note: It might happen that warnings or errors are displayed after starting the debug session. Prevent that by checking "Always launch without asking" or "Remember my decision" in the respective dialog boxes:
    Warnings in Eclipse Neon:
    Failure Debug 1
    Failure Debug 2
    Warning in Eclipse Photon:
    Eclipse Photon Confirm Switch
  2. After the warnings have been acknowledged, the Eclipse debug view appears where you can add breakpoints and step through the code:
    Debug window

For actions in this environment, please refer to the Eclipse Neon Online Help or the Eclipse Photon Online Help.