From 4045c3bd53e845d0332981424b7e5404be6ae4f1 Mon Sep 17 00:00:00 2001 From: Scott Rifenbark Date: Wed, 10 Apr 2013 09:59:23 -0700 Subject: dev-manual: Updates to the debugging using GDB section. Fixes YOCTO #3540 Applied changes per Jessica Zhang's feedback from the bug entry in Bugzilla. I added some missing steps and also tried to make the section stick with one example throughout. (From yocto-docs rev: f995006a90a3646c92d54dc96a8fceae4de758eb) Signed-off-by: Scott Rifenbark Signed-off-by: Richard Purdie --- .../dev-manual/dev-manual-common-tasks.xml | 196 ++++++++------------- 1 file changed, 74 insertions(+), 122 deletions(-) (limited to 'documentation') diff --git a/documentation/dev-manual/dev-manual-common-tasks.xml b/documentation/dev-manual/dev-manual-common-tasks.xml index 51d65016fc..8684851dcc 100644 --- a/documentation/dev-manual/dev-manual-common-tasks.xml +++ b/documentation/dev-manual/dev-manual-common-tasks.xml @@ -3868,25 +3868,51 @@ GDB site. + + The remainder of this section describes the steps you need to take + to debug using the GNU project debugger. + + +
+ Set Up the Cross-Development Debugging Environment + + + Before you can initiate a remote debugging session, you need + to be sure you have set up the cross-development environment, + toolchain, and sysroot. + The "Preparing for Application Development" + chapter of the Yocto Project Application Developer's Guide + describes this process. + Be sure you have read that chapter and have your environment + set up. + +
+
Launching Gdbserver on the Target - First, make sure Gdbserver is installed on the target. - If it is not, install the package gdbserver, which needs the + Make sure Gdbserver is installed on the target. + If it is not, install the package + gdbserver, which needs the libthread-db1 package. - As an example, to launch Gdbserver on the target and make it ready to "debug" a - program located at /path/to/inferior, connect - to the target and launch: + As an example, to launch Gdbserver on the target and make it + ready to "debug" a program located in the + /usr/bin/hello directory, from the host + you need to enter a command like the following. + This command connects to the target and launches Gdbserver + on the target: - $ gdbserver localhost:2345 /path/to/inferior + $ gdbserver localhost:2345 /usr/bin/hello Gdbserver should now be listening on port 2345 for debugging - commands coming from a remote GDB process that is running on the host computer. - Communication between Gdbserver and the host GDB are done using TCP. + commands coming from a remote GDB process that is running on + the host computer. + Communication between Gdbserver and the host GDB are done + using TCP. To use other communication protocols, please refer to the Gdbserver documentation. @@ -3903,20 +3929,24 @@
Build the Cross-GDB Package - A suitable GDB cross-binary is required that runs on your host computer but - also knows about the the ABI of the remote target. - You can get this binary from the meta-toolchain. + A suitable GDB cross-binary is required that runs on your + host computer but also knows about the the ABI of the + remote target. + You can get this binary from the + Cross-Development Toolchain. Here is an example where the toolchain has been installed - in the default directory /opt/poky/&DISTRO;: + in the default directory + /opt/poky/&DISTRO;: /opt/poky/1.4/sysroots/i686-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb - where arm is the target architecture and - linux-gnueabi the target ABI. + where arm is the target architecture + and linux-gnueabi the target ABI. - Alternatively, you can use BitBake to build the gdb-cross binary. + Alternatively, you can use BitBake to build the + gdb-cross binary. Here is an example: $ bitbake gdb-cross @@ -3929,7 +3959,7 @@
- Create the GDB Initialization File + Create the GDB Initialization File and Point to Your Root Filesystem Aside from the GDB cross-binary, you also need a GDB @@ -3943,17 +3973,15 @@ by maintained by sourceware.org. -
- -
- Point to Your Root Filesystem - Before starting your debugging session, you need to enter - the following to set your root filesystem location - by using a command with this form: + You need to add a statement in the + .gdbinit file that points to your + root filesystem. + Here is an example that points to the root filesystem for + an ARM-based target device: - set sysroot <your-sysroot-path> + set sysroot /home/jzhang/sysroot_arm
@@ -3962,122 +3990,46 @@ Launch the Host GDB - To launch the host GDB, you need to source the - cross-debugging environment script, which if you installed - the root filesystem in the default location is at - /opt/poky/&DISTRO; and begins with the - string "environment-setup". + Before launching the host GDB, you need to be sure + you have sourced the cross-debugging environment script, + which if you installed the root filesystem in the default + location is at /opt/poky/&DISTRO; + and begins with the string "environment-setup". + For more information, see the + "Setting Up the Cross-Development Environment" + section in the Yocto Project Application Developer's + Guide. - Finally, run the cross-gdb binary - and provide the inferior binary as part of the command line. + Finally, switch to the directory where the binary resides + and run the cross-gdb binary. + Provide the binary file you are going to debug. For example, the following command form continues with the example used in the previous section. - This command form loads the foo binary - as well as the debugging information: + This command form loads the helloworld + binary as well as the debugging information: - $ <target-abi>-gdb rootfs/usr/bin/foo + $ i586-poky-linux-gdb helloworld The commands in your .gdbinit execute and the GDB prompt appears.
-
Use the Debugger -- cgit v1.2.3-54-g00ecf