Jump to content

Preparing Yocto Development Environment for Debugging: Difference between revisions

Line 57: Line 57:


Strace is mostly used for problems outside of the binary itself; for example configuration files, input data, and kernel interfaces. This recipe will explain how to use it. For setting up the environment to use it, remember that the package "tools-debug" already includes it, so you should add to your local.conf file:
Strace is mostly used for problems outside of the binary itself; for example configuration files, input data, and kernel interfaces. This recipe will explain how to use it. For setting up the environment to use it, remember that the package "tools-debug" already includes it, so you should add to your local.conf file:
'''build/conf/local.conf:'''
<syntaxhighlight lang=make>
<syntaxhighlight lang=make>
EXTRA_IMAGE_FEATURES += "tools-debug"  
EXTRA_IMAGE_FEATURES += "tools-debug"  
Line 62: Line 63:


If you want to only add strace, make sure the following are added to your image recipe file:
If you want to only add strace, make sure the following are added to your image recipe file:
On image recipe:
<syntaxhighlight lang=make>
<syntaxhighlight lang=make>
IMAGE_INSTALL += "strace procps"
IMAGE_INSTALL += "strace procps"
Line 71: Line 73:


Profiling and tracing can be achieved using Perf. The basic setup can be done manually, or you can also use the available at the git repository from the Yocto Project. The following options are the minimum needed for running perf.  
Profiling and tracing can be achieved using Perf. The basic setup can be done manually, or you can also use the available at the git repository from the Yocto Project. The following options are the minimum needed for running perf.  
'''build/conf/local.conf:'''
<syntaxhighlight lang=make>
<syntaxhighlight lang=make>
EXTRA_IMAGE_FEATURES = "debug-tweaks tools-profile dbg-pkgs"
EXTRA_IMAGE_FEATURES = "debug-tweaks tools-profile dbg-pkgs"
Line 76: Line 79:
PACKAGE_DEBUG_SPLIT_STYLE = 'debug-file-directory'
PACKAGE_DEBUG_SPLIT_STYLE = 'debug-file-directory'
</syntaxhighlight>
</syntaxhighlight>
 
'''On local image:'''
<syntaxhighlight lang=make>
IMAGE_INSTALL += "perf"
</syntaxhighlight>
=== Valgrind ===
=== Valgrind ===
As you would do for any other package that you want to include in your image and is not part of the default configuration, you need to add the recipe to build it. The source will depend on what board you a using, and you must add the recipe to your meta-layer. Valgrind also needs some of the previously defined features on your '''local.conf''', specifically:   
As you would do for any other package that you want to include in your image and is not part of the default configuration, you need to add the recipe to build it. The source will depend on what board you a using, and you must add the recipe to your meta-layer. Valgrind also needs some of the previously defined features on your '''local.conf''', specifically:   
'''build/conf/local.conf:'''
<syntaxhighlight lang=make>
<syntaxhighlight lang=make>
EXTRA_IMAGE_FEATURES += " dbg-pkgs tools-debug "
EXTRA_IMAGE_FEATURES += " dbg-pkgs tools-debug "
</syntaxhighlight>
</syntaxhighlight>
Also, remember to add it to your image recipe, as follows:
Also, remember to add it to your image recipe, as follows:
'''On your image recipe:'''
<syntaxhighlight lang=make>
<syntaxhighlight lang=make>
IMAGE_INSTALL += "valgrind"
IMAGE_INSTALL += "valgrind"
Line 89: Line 97:
=== Tcpdump ===
=== Tcpdump ===
Tcpdump is a powerful command-line packet analyzer; and libpcap, a portable C/C++ library for network traffic capture. You can add it to your target image by including the corresponding recipe on your meta-layer. To add it to your image, you need to add to your image recipe:
Tcpdump is a powerful command-line packet analyzer; and libpcap, a portable C/C++ library for network traffic capture. You can add it to your target image by including the corresponding recipe on your meta-layer. To add it to your image, you need to add to your image recipe:
'''On your image recipe:'''
<syntaxhighlight lang=make>
<syntaxhighlight lang=make>
IMAGE_INSTALL += "tcpdump"
IMAGE_INSTALL += "tcpdump"
Line 95: Line 104:
=== Kdump ===
=== Kdump ===
Kdump uses kexec to quickly boot to a dump-capture kernel whenever a dump of the system kernel's memory needs to be taken (for example, when the system panics). The system kernel's memory image is preserved across the reboot and is accessible to the dump-capture kernel. You can find more information on how to use it in the [[https://devtalk.nvidia.com/default/topic/1020708/jetson-tx2/method-to-modify-use-different-device-tree-in-r28-1/ Yocto Project repository]] For Yocto, it is available in the kexec-tools package, and it can be included in your image by adding the recipe to your meta-layer, and modifying your recipe by adding the line:   
Kdump uses kexec to quickly boot to a dump-capture kernel whenever a dump of the system kernel's memory needs to be taken (for example, when the system panics). The system kernel's memory image is preserved across the reboot and is accessible to the dump-capture kernel. You can find more information on how to use it in the [[https://devtalk.nvidia.com/default/topic/1020708/jetson-tx2/method-to-modify-use-different-device-tree-in-r28-1/ Yocto Project repository]] For Yocto, it is available in the kexec-tools package, and it can be included in your image by adding the recipe to your meta-layer, and modifying your recipe by adding the line:   
'''On your image recipe:'''
<syntaxhighlight lang=make>
<syntaxhighlight lang=make>
IMAGE_INSTALL += "kexec-tools"
IMAGE_INSTALL += "kexec-tools"
Line 105: Line 115:


As previously mentioned, GDB is included in the package "tools-debug", so commonly the EXTRA_IMAGE_FEATURES would be set as follows:
As previously mentioned, GDB is included in the package "tools-debug", so commonly the EXTRA_IMAGE_FEATURES would be set as follows:
'''build/conf/local.conf:'''
<syntaxhighlight lang=make>
<syntaxhighlight lang=make>
EXTRA_IMAGE_FEATURES = "tools-debug debug-tweaks dbg-pkgs"
EXTRA_IMAGE_FEATURES = "tools-debug debug-tweaks dbg-pkgs"
Line 110: Line 121:


Notice also that the package "dbg-pkgs" will help us include the debug symbols for all the packages. To enable debugging symbols for a specific package, the -dbg package must be included. This can be done by modifying the recipe, or the local.conf file, by adding the following line:
Notice also that the package "dbg-pkgs" will help us include the debug symbols for all the packages. To enable debugging symbols for a specific package, the -dbg package must be included. This can be done by modifying the recipe, or the local.conf file, by adding the following line:
'''On your image recipe:'''
<syntaxhighlight lang=make>
<syntaxhighlight lang=make>
IMAGE_INSTALL += " $PACKAGE_NAME $PACKAGE_NAME-dbg"
IMAGE_INSTALL += " $PACKAGE_NAME $PACKAGE_NAME-dbg"
Line 119: Line 131:
==== Setting up environment for remote debugging (GDBServer) ====
==== Setting up environment for remote debugging (GDBServer) ====
The host GDB must have access to all debugging information and unstripped binaries, libraries and target must be compiled with no optimizations, all of which were mentioned on the general environment setup. For more information, refer to the official documentation. The steps are listed here for convenience:
The host GDB must have access to all debugging information and unstripped binaries, libraries and target must be compiled with no optimizations, all of which were mentioned on the general environment setup. For more information, refer to the official documentation. The steps are listed here for convenience:
* Configure your build system to construct the companion debug filesystem by editing the local.conf file
* Configure your build system to construct the companion debug filesystem by editing the local.conf file:
'''build/conf/local.conf:'''
<syntaxhighlight lang=make>
<syntaxhighlight lang=make>
IMAGE_GEN_DEBUGFS = "1"
IMAGE_GEN_DEBUGFS = "1"
Line 130: Line 143:


* Configure the system to include gdbserver in the target filesystem by adding gdbserver to either the local.conf or the recipe:
* Configure the system to include gdbserver in the target filesystem by adding gdbserver to either the local.conf or the recipe:
'''On your image recipe:'''
<syntaxhighlight lang=make>
<syntaxhighlight lang=make>
IMAGE_INSTALL += “gdbserver"
IMAGE_INSTALL += “gdbserver"
Line 137: Line 151:
* Construct the image and companion filesystem
* Construct the image and companion filesystem
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
bitbake <image_name>
bitbake $IMAGE_NAME
</syntaxhighlight>
</syntaxhighlight>
                        
                        
* Build the cross GDB component and make it available for debugging. Build the SDK that matches the image. Building the SDK is best for a production build that can be used later for debugging, especially during long term maintenance:
* Build the cross GDB component and make it available for debugging. Build the SDK that matches the image. Building the SDK is best for a production build that can be used later for debugging, especially during long term maintenance:
<syntaxhighlight lang=make>
<syntaxhighlight lang=make>
bitbake -c populate_sdk <image_name>         
bitbake -c populate_sdk $IMAGE_NAME       
</syntaxhighlight>
</syntaxhighlight>


352

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.