EBC Exercise 28 Remote gdb and more
There are many handy tools to know how to use.
gdb, the GNU Project debugger, allows you to see what is going on inside another program while it executes -- or what another program was doing at the moment it crashed.
gdb can do four main kinds of things to help you catch bugs in the act:
- Start your program, specifying anything that might affect its behavior.
- Make your program stop on specified conditions.
- Examine what has happened, when your program has stopped.
- Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.
The program being debugged can be written in Ada, C, C++, Objective-C, Pascal (and many other languages). Those programs might be executing on the same machine as GDB (native) or on another machine (remote). GDB can run on most popular UNIX and Microsoft Windows variants.
For our lab we'll be using a C program and do both local execution on the BeagleBoard and remote execution with gdb running on your host and debugging code on your Beagle.
The Sample Program
You can get the sample program from dfs.
$ sftp dfs.rose-hulman.edu Connecting to dfs.rose-hulman.edu... firstname.lastname@example.org's password: sftp> cd users/y/yoder/shared/beagleboard sftp> get gdbExample.tar.gz sftp> exit $ tar xvf gdbExample.tar.gz gdbExample/ gdbExample/cfft.c gdbExample/main_bench.c gdbExample/changelog gdbExample/distance.c gdbExample/cfft.h gdbExample/README gdbExample/distance.h gdbExample/common.h gdbExample/Makefile gdbExample/main_cfft.c $ cd gdbExample $ gedit Makefile
Edit the Makefile and correct ARM_TOOLCHAIN_PATH for your machine. Also search for install: and fix it for your beagle.
$ make all install
This will compile the code and scp to your Beagle. You've just compiled a program that performs a complex fft on random data. It's main purpose is to see how fast it runs on the Beagle. (In case you are interested, I added to rule so you can compile it for your host computer. Try make x86 and compare the times on your host to those on the Beagle.)