Skip to main content.
Navigation:
DENX
>
DULG
>
DebuggingApplication
Translations:
Edit
|
Attach
|
Raw
|
Ref-By
|
Printable
|
More
DULG
Sections of this site:
DENX Home
|
DULG
|
ELDK-5
|
Know
|
Training
|
U-Boot
|
U-Bootdoc
Topics
DULG Home
BoardSelect
Manual
FAQ
Application Notes
Changes
Index
List of pages in DULG
Search
%SECTION0{name=DebuggingApplication}% Application Debugging %SECTION1{name=DebuggingApplicationLocal}% Local Debugging In case there is a native GDB available for your target you can use it for application debugging as usual: <verbatim> bash$ gcc -Wall -g -o hello hello.c bash$ gdb hello ... (gdb) l 1 #include <stdio.h> 2 3 int main(int argc, char* argv[]) 4 { 5 printf ("Hello world\n"); 6 return 0; 7 } (gdb) break 5 Breakpoint 1 at 0x8048466: file hello.c, line 5. (gdb) run Starting program: /opt/eldk/ppc_8xx/tmp/hello Breakpoint 1, main (argc=0x1, argv=0xbffff9f4) at hello.c:5 5 printf ("Hello world\n"); (gdb) c Continuing. Hello world Program exited normally. </verbatim> %SECTION1{name=DebuggingApplicationRemote}% Remote Debugging =gdbserver= allows you to connect your program with a remote GDB using the "target remote" command. On the target machine, you need to have a copy of the program you want to debug. =gdbserver= does not need your program's symbol table, so you can strip the program if necessary to save space. =GDB= on the host system does all the symbol handling. Here is an example: <verbatim> bash$ ${CROSS_COMPILE}gcc -Wall -g -o hello hello.c bash$ cp -p hello <directory-shared-with-target>/hello-stripped bash$ ${CROSS_COMPILE}strip <directory-shared-with-target>/hello-stripped </verbatim> To use the server, you must tell it how to communicate with =GDB=, the name of your program, and the arguments for your program. To start a debugging session via network type on the target: <verbatim> bash$ cd <directory-shared-with-host> bash$ gdbserver 192.168.1.1:12345 hello-stripped Process hello-stripped created; pid = 353 </verbatim> And then on the host: <verbatim> bash$ ${CROSS_COMPILE}gdb hello ... (gdb) set solib-absolute-prefix /opt/eldk/$CROSS_COMPILE (gdb) dir /opt/eldk/$CROSS_COMPILE Source directories searched: /opt/eldk/$CROSS_COMPILE:$cdir:$cwd (gdb) target remote 192.168.1.99:12345 Remote debugging using 192.168.1.99:12345 0x30012748 in ?? () ... (gdb) l 1 #include <stdio.h> 2 3 int main(int argc, char* argv[]) 4 { 5 printf ("Hello world\n"); 6 return 0; 7 } (gdb) break 5 Breakpoint 1 at 0x10000498: file hello.c, line 5. (gdb) continue Continuing. Breakpoint 1, main (argc=1, argv=0x7ffffbe4) at hello.c:5 5 printf ("Hello world\n"); (gdb) p argc $1 = 1 (gdb) continue Continuing. Program exited normally. </verbatim> %X% If the target program you want to debug is linked against shared libraries, you _must_ tell GDB where the proper target libraries are located. This is done using the =set solib-absolute-prefix= GDB command. If this command is omitted, then, apparently, GDB loads the host versions of the libraries and gets crazy because of that.
10.4. Tips and Tricks
1. Abstract
10.6. Debugging with Graphical User Interfaces
Prev
Home
Next