Using the GNU Project Debugger for debugging

While developing any project, from time to time we end up struggling to understand subtle bugs. The GNU Project Debugger (GDB) is available as a package within Poky and is installed in SDK images by default, as was detailed in Chapter 8Developing with the Yocto Project.

In order to install debugging packages that contain the debug symbols and debugging tools in an image, add IMAGE_FEATURES += "dbg-pkgs tools-debug" in build/conf/local.conf.

The use of the SDK, or an image with the debugging packages and tools installed, allows us to debug applications directly in the target, as we usually do on our development machine.

The GDB may not be usable on some targets because of memory or disk space constraints. The main reason for this limitation is the GDB needs to load the debugging information, along with the binaries of the process being debugged, before starting the debugging process.

To overcome these constraints, we can use gdbserver, included by default when using tools-debug in IMAGE_FEATURES. It runs on the target and doesn't load any debugging information from the debugged process. Instead, a GDB instance processes the debugging information on the host. The host GDB then sends control commands to gdbserver to control the debugged application.

As the host GDB is responsible for loading the debugging information and performing the necessary processing to make the debugging process take place, the target does not need to have the debugging symbols installed and we need to make sure the host can access the binaries with their debugging information. It is advisable that the target binaries are compiled with no optimizations to facilitate the debugging process.

The process to use gdbserver and configure the host and target in the appropriate way is detailed on the following site: http://www.yoctoproject.org/docs/2.4/dev-manual/dev-manual.html.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.151.158