Page tree
Skip to end of metadata
Go to start of metadata

Applications compiled with the g++ compiler using the –g option include the necessary debugging information in the executable and can thus be debugged using the GNU Project Debugger (gdb).  Although the SmartServer IoT includes a pre-installed copy of the compiler (g++), gdb isn’t preinstalled on the SmartServer IoT.  If you want to use gdb to debug a custom IDL driver, it first needs to be installed onto the SmartServer IoT.

To install gdb on the SmartServer IoT, the unit needs to have internet access in order to download the necessary packages.  Using a console application like PuTTY, navigate to the /usr/bin/ directory and type sudo apt update.  The Advanced Package Tool will download package information from configured sources so it knows which packages are available for upgrade and where to retrieve them.

After running sudo apt update, install the GNU Project Debugger by running sudo apt install –y gdb from the console.

Once this completes, you can verify the installation of gdb by checking the version information from the console by typing gdb --version.  You should get version information in response, similar to what is shown below.

Note that installing the GNU Project Debugger also installs the associated gdbserver application, which provides options for debugging applications remotely as well.

With gdb installed on the SmartServer IoT, you can debug an application like the example driver by starting it up under gdb control using sudo gdb ./example as shown below.



Note that the error referencing ‘libcrypto’, which is highlighted above, is benign and can be ignored.  You can also prevent this reported error (and others such as designed interruptions) by using the command ‘handle SIGILL nostop noprint’ within gdb just before you run (r) or continue (c) a managed driver application like ‘./example’.  Although gdb is a command line debugger, it is a full-featured debugging tool.  You can set breakpoints, inspect variables, start and stop program execution, single step, and so on.  There is an extensive list of available commands you can use within gdb to manage the debugging of your application.  Since these commands are readily documented online from many sources, including from GNU.org itself, these are not documented here, however you can easily find this information online from sources like https://sourceware.org/gdb/download/onlinedocs/gdb.pdf

As mentioned above, installing the GNU Project Debugger installs not only the command line debugger (gdb), it also installs the gdbserver application on the SmartServer IoT.  gdbserver makes it possible to remotely connect to and debug an application running on the SmartServer IoT from another development system such as a PC.  The setup for remote debugging is dependent on whether this development PC is Linux or Windows based, and may differ depending on the OS version.  For example, on a Windows-based PC this generally requires installing and configuring several tools in addition to the Microsoft C/C++ extension in Visual Studio Code as well as Mingw-w64 described in Compiling a Custom IDL Driver.  Some of the additional required tools may include the Native Debug Extension in Visual Studio Code as well as OpenSSH (installed with GIT), which is used to create an SSH key pair from the PC to be installed onto the SmartServer IoT.  Since there are various techniques for remote debugging, they are not covered in detail in this documentation. You can reach out to the support organization for more details.



  • No labels