Tux
Communication
Mailing lists
Documentation
User Manual
Target board info.
Target chip info.
Support
Linux support
Bugzilla
Downloads
STLinux
Updates
Search
Google


The web
stlinux.com
Getting Started
Using gdb
ST Logo
Previous   Contents   Next

Using remote gdb

The easiest way to use gdb for debugging user applications, is to run it directly on the target. However this requires that the gdb on the target has access to the host file system for source code, and requires quite a large amount of memory on the target.

To avoid these problems, it is possible to run gdb on the host, controlling a program running on the target. To do this a small server process is run on the target, specifying a socket which it should wait on for commands:

target% gdbserver localhost:6789 application

On the host, simply run gdb, and the connect to the target:

host% sh4-linux-gdb application
GNU gdb 5.1
Copyright 2001 Free Software Foundation, Inc.
This GDB was configured as "--host=i686-pc-linux-gnu --target=sh4-linux"...
(gdb) target remote targetip:6789
Remote debugging using targetip:6789
0x29558080 in ??()

In the target remote command, targetip specifies the target name or IP address, and 6789 is the port number used when gdbserver was started.

Initial the program will be stopped at its entry point, in the C runtime. So the first thing to do is advance to main:

(gdb) break main
Breakpoint 1 at 0x400656: file main.c, line 20.
(gdb) continue
Continuing.

Breakpoint 1, main() at main.c:20
20   printf("Welcome to the application\n");
(gdb)

From here onwards you can debug the target in the same way as you would debug a program on the host.

To avoid typing all these command every time, it may be useful to create a gdb script file. gdb will always run .gdbinit from the users home directory, and the current directory, alternatively it can be started with the command line option -command=script.

Using DDD

If you want to use gdb with DDD (the Data Display Debugger), simply specify sh4-linux-gdb as the debugger to start:

host% ddd --debugger sh4-linux-gdb

Then connect to the target in the way described above.

Previous   Contents   Next
Valid HTML 4.01! Last updated: 2004/04/08 18:09:38
© Copyright STMicroelectronics Limited, 2005
Printer