Remote debugging of C++ code

Suitable with AXC F x152 with inactive Security Profile only

PLCnext Technology has an integrated GDB server, so you can set up a remote debugging session. Read more about the GDB server if you're new to this tool or interested in the complete functionality of this tool.

Setting up the station for a remote debugging session takes some time, but remote debugging your C++ code on your PLCnext Control will be a very useful feature that's worth the effort. Most effort goes into setting up the debug configuration. Once you finished that for your station, the rest is quite as simple as you perhaps already know it as an experienced developer. 

Restrictions

  • For the time being, a remote debugging procedure cannot be performed on a safety-related controller due to untouchable safety tasks.
  • Remote debugging can be done on AXC F x152 with inactive Security Profile only.

Step-by-step instructions

Using the Visual Studio® IDE

See the regarding Maker's Blog article in the PLCnext Community.

Using the Eclipse® IDE

Used in the following description:

  • Firmware 2019.x of the AXC F 2152.
  • Phoenix Contact Eclipse® Add-in 2020.0 LTS
  • Eclipse® 2019-9

Newer versions might differ visually but the procedure is still the same.

Prerequisites

  • The task watchdogs must be deactivated (0 ms) during the debug session.
  • The shared library must be created in Debug build mode.
  • The shared library (.so file) on the host system (Eclipse workspace) and on the PLCnext Control target must be the same.
  • The overall performance between steps can take a few seconds.
  • For some steps you'll need root or admin user privileges (as admin user, use the sudo precommand).

Debug configuration

  1. Make sure to meet the prerequisites regarding the Eclipse versions that these instruction are based on.
  2. Open your C++ program in the Eclipse IDE and start the build configuration by the Set Active → Debug all targets menu:
  3. Start the debug configuration by the Run → Debug Configurations... menu:
    Debug Configuration
  4. Create a C/C++ Remote Application by double-clicking the list item:
    Debug remote application
  5. On the Main tab that shows up in the right section of the dialog box,
    1. insert the path to the C/C++ application executable, e.g.:
      FW_SVN_XXXX\SDK\sysroots\cortexa9t2hf-neon-pxc-linux-gnueabi\usr\bin\Arp.System.Application
    2. Set the "Build Configuration" drop-down menu
      to Debug (in Eclipse Neon):
      Debug Settings
      to Use Active (in Eclipse Photon):
      EclipsePhoton MainConfig
    3. Click the Select other link (same in both Eclipse Neon and Photon).
  6. In the Select Preferred Launcher dialog box,
    choose GDB (DSF) Manual Remote Debugging Launcher and close with the OK button:
    Manual remote debug launcher
  7. Back in the Debug Configuration dialog, switch to the Debugger tab, Main subtab, then proceed:
    1. Make sure to have enabled the checkboxes shown here:
      Attach to process with 2022.0 LTS or newer
    2. As the  GDB debugger, insert the command to execute a specific .bat file and just the file name of the gdb executable, e.g.:
      cmd /c C:\PLCnext\SDKs\AXCF2152\2021.0_Release\environment-setup-cortexa9t2hf-neon-pxc-linux-gnueabi.bat && arm-pxc-linux-gnueabi-gdb.exe
    3. As the GDB command file, create a gdbinit.txt file containing the following handles and add it:
      handle SIGUSR2 nostop noprint 
      handle SIGILL nostop noprint 
      handle SIGSTOP nostop noprint
  8. On the Shared Libraries subtab of the Debugger tab, proceed:
    1. Insert the directory of the shared library to debug; usually, the library of an Eclipse® project is saved in the Debug or Debug\lib subdirectory to a program.
      Shared libraries
  9. On the Connection subtab of the Debugger tab, proceed:
    1. Insert a host name or IP address of the remote target.
    2. Insert the port on which the GDB server instance is listening.
      Debugger connection
  10. Click the Close button. The next step is attaching to the remote GDB server.

Attaching to the remote GDB server

Risk of personal injury or damage to equipment

Using the debugging function can result in an unsafe process interruption.

Ensure that there is no risk of personal injury or damage to the equipment.

  1. Log into a shell session on the remote system.
  2. Determine the process ID of PLCnext Technology process:
    1. With firmware 2019.0 LTS to 2019.9, issue this command:
      ps | grep Arp.System
    2. From 2020.0 LTS, issue this command:
      ps aux | grep Arp.System
  3. Start the gdbserver and attach it to the desired port, e.g. for port 2345:
    sudo gdbserver :2345 --attach <your process ID here>

↪ If the process is successfully attached, you should get the blue highlighted answer:
Grep Arp System answer

↪ The plcnext task will go into Stop mode, so the OUT ports will stand still and the remote connection to PLCnext Engineer will be interrupted.

Note:

  • After debugging, the plcnext task will remain stopped (i.e. detached or disconnected in Eclipse®) and has to be restarted manually:
    • Issue the restart command from the shell (see firmware commands), 
      or
    • restart the controller by pressing the Reset button on its housing, or switch the current off and on again.
  • A breakpoint in GDB will stop the cyclic task only, so all other programs will keep running.
  • A breakpoint in PLCnext Engineer prohibits the call of C++ programs, so all tasks controlled by the ESM will stop.

 

Setting the breakpoints and starting a debug session

  1. Select the newly created debug configuration by means of the "bug" menu:
    Start Debug
  2. It might happen that warnings or errors are displayed after starting the debug session.
    1. Warnings in Eclipse® Neon:
      Prevent that by checking Always launch without asking  in the dialog box:
      Failure Debug 1
    2. Warning in Eclipse® Photon:
      Prevent that by checking Remember my decision in the dialog box:
      Eclipse Photon Confirm Switch
    3. Wait for the the Eclipse® debug view to appear.
  3. Add breakpoints and step through your code:
    Debug window

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

cookie

Note: Tutorial videos are embedded from the Phoenix Contact Technical Support YouTube channel. With playing an embedded YouTube video in this platform, you accept the YouTube Terms & Conditions. Even showing the video previews on this page depends on your personal settings. To watch YouTube videos, you have to allow cookies for marketing purposes which will remain on your device. The data gained through these cookies will be used by YouTube to provide video suggestions and advertisements based on your browsing habits, and that data may be made available to other parties.

How to set up a remote debugging session for C++ programming with Eclipse® version 2019-03 (Neon)

Note: This tutorial video and the above step-by-step instructions differ in some regards:

  • In the video, the Eclipse IDE version is 2019-03. The screenshots in the instructions below are taken from an older Eclipse® version, but the options are still the same.
  • In the video, the presenter chose a slightly different route to start debugging after setting up the debug configuration; both ways are similarly successful.

 

 

 

 


• Published/reviewed: 2026-06-11  ✿  Revision 095 •