There are two debugging methods you can use to debug your shared library. Both assume that you have built the shared library that is going to be deployed using the practices described in the document
Getting Started with C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition . The document is packaged with your install of the C & C++ Development Tools for NI Linux Real-Time (LinuxRT), Eclipse Edition.
You may also import your existing code into C & C++ Development Tools for NI Linux Real-Time (LinuxRT), Eclipse Edition and build using the specified cross compiler path and specific prefix,
arm-none-linux-gnueabi-
, to allow compatibility with the Linux Real-Time operating system running on the target.
To allow the GDB in Eclipse to work correctly, you must copy /usr and /usrlib from the target root file system to a directory on the local host, <RootFileSystemDir>. Before you begin, make sure that your project has a Debug configuration that is deployable.
Before engaging in the following debugging methods, complete the following steps to transfer the shared library
.so
file to the target:
- Go to the file menu bar and click Window»Open Perspective»Other»Remote System Explorer.
- Click OK.
- Click Define a connection to remote system button to open the New Connection Wizard.
- Select SSH Only under the
General
folder. - Click Next.
- Select a profile to contain the remote system connection from the Parent profile pull-down menu.
- Enter the hostname or IP Address of your Linux Real-Time target in the Host name text box.
- Click Finish.
- In the Remote System Explorer window, navigate to the workspace directory and find the .sofile in the Debug folder of the appropriate project.
- Copy the .so file over to the /usr/lib directory of the target by expanding Sftp Files under the target and navigate to /usr/lib
Note: The shared library does not have to placed in this directory. If placed in another directory, the Call Library Node will then have to be supplied the entire path to the shared library.
Debugging Method Using GDB in Eclipse: Please note that you will need a .gbdinit file to run the debugging capabilities. This will set your breakpoints in the code. Complete the following steps to create the .gbdinit file:
- Navigate to your project path in the Windows explorer.
- Right-click the window.
- Select New»Text Document»File»Save As.
- Select All Files as the Save as type and name it
.gdbinit
. - Select Save.
- In the file, enter on separate lines:
set breakpoint pending on
set sysroot <RootFileSystemDir>
Then, follow the instructions in the document,
Getting Started with C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition , under
Debugging a C/C++ Project. This will set you up to debug your shared library. The new project should be added under the
C/C++ Remote Application in the Debug Configurations menu. Complete the following steps to further debug your shared library:
- Navigate to Run»Debug Configurations.
- In the Debug Configurations window, make sure your project is selected in the Main tab.
- In the same tab, go to the Connection option and select your target.
- In the same tab, change the Remote Absolute File Path for C/C++ Application to point to the shared library on the target.
- In the same tab, next to the Apply button, click Select other.
- From the Select Preferred Launcher window, select Standard Remote Create Process Launcher if not already selected.
- Click OK.
- Navigate to the Debugger tab.
- Select Gdbserver Settings.
- Take note of the port number that will be in the form xxxx. Normally, this will have a default value of 2345.
- Open your operating system command prompt.
- Execute the command gdbserver :xxxx ---attach 'pidof lvrt' where
xxxx
is your port number. - Go back to the Debug Configurations window.
- In the Debugger tab, click the Main tab.
- Select Browse for the GDB Debugger option.
- Navigate to <National Instruments>\Eclipse\toolchain\gcc-4.4-arm\i386\bin\arm-none-linux-gnueabi-gdb.exe.
- Click Open.
- Select Browse for the GDB command file.
- Navigate to your current project's .gdbinit file.
- Click Open.
- Uncheck Stop on startup.
- Select Apply»Debug.
The
Debug View should now open up, and, in the bottom portion of Eclipse, in the
Console Tab, you should be able to debug your application. Once execution is suspended at a breakpoint in the shared library source code, you will have control of this
GDB Console tab.
To stop debugging, you need to have control of the Console. You can stop the program by clicking the pause icon, labelled
Suspend. Then, enter the command detach to disassociate the project.
Note: When the shared library is called from the VI running on the target and the execution arrives at a breakpoint, the
lvrt
process on the target will be suspended. This causes the host to lose connection to the target. Once the debugger is no longer on a breakpoint, the connection to the target will be repaired.
Debugging using the GDB Command Prompt and SSH Client: To use this method, you will need an SSH Client. Complete the following steps to debug using the GDB command prompt and SSH client:
- Open the command prompt on the local host.
- Navigate to the location of the GDB debugger by typing cd C:\Program Files\National Instruments\Eclipse\toolchain\gcc-4.4-arm\i386\bin\.
- Type arm-none-linux-gnueabi-gdb.exe to execute the debugger.
- Type the following commands:
set breakpoint pending on
file C:/<path to the shared object>/ExampleLibrary.so
set sysroot <RootFileSystemDir>
- Enter in any breakpoints in the command prompt here.
- Find an open TCP port on the cRIO in the format of xxxx, where xxxx is an open port number on your target. The default value is usually 2345.
- Open the SSH client, and enter:
gdbserver :xxxx --attach 'pidof lvrt'. - Go back to the command prompt and enter:
target remote <Target Name>:xxxx.
To exit the debugging process, ensure that the GDB is no longer in continue mode, and type detach.