In the section called Verification in Chapter 12 you ran the prebuilt test case on real hardware; now you are ready to run one of the test programs in the simulated environment.
Start a command window, for example a bash shell or an MS-DOS command prompt with the environment variables set up as described in the GNUPro documentation. Change to the directory in which you set up your build tree, and invoke GDB on the test program. To run the bin_sem0 test (which will test the kernel for the correct creation and destruction of binary semaphores) type:
$ gdb -nw install/tests/kernel/bin_sem0
You should see the following in the command window:
Example 15-1. Starting up GDB
GNU gdb 4.17-ecos-98r1p3 Copyright 1998 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. This version of GDB is supported for customers of Cygnus Solutions. Type "show warranty" for details. This GDB was configured as "--host=THIS-HOST --target=THIS-TARGET". (gdb) |
To specify that you are using the simulator target (rather than real hardware) you can type:
(gdb) target sim --board=stdeval1
on the MN10300, or
(gdb) target sim --board=jmr3904
on the TX39, or
(gdb) target sim -f BASE_DIR/hal/powerpc/sim/v1_1/runtime/tree
on the PowerPC.
You will see the following lines on your screen:
Connected to the simulator. (gdb) |
Tip: The PowerPC instruction for GDB involves typing a lengthy line to set up some parameters for the simulator. One way to reduce the amount of typing is to put the following code in your personal GDB startup file (gdb.init on Windows and .gdbinit on UNIX):
define psim target sim -f BASE_DIR/hal/powerpc/sim/v1_1/runtime/tree load break cyg_test_exit break cyg_assert_fail end
Now download the program to the (simulator) target with
(gdb) load
You should see the following output on your screen:
On the MN10300:
Loading section .rom_vectors, size 0xc0 lma 0x40000000 Loading section .text, size 0x1b3b lma 0x400000c0 Loading section .rodata, size 0x2f4 lma 0x40001bfc Loading section .data, size 0x7c lma 0x40001ef0 Start address 0x40000000 Transfer rate: 64344 bits in <1 sec. (gdb) |
On the TX39:
Loading section .rom_vectors, size 0x218 lma 0xbfc00000 Loading section .text, size 0x56a8 lma 0xbfc00218 Loading section .rodata, size 0x41c lma 0xbfc058c0 Loading section .data, size 0x578 lma 0xbfc05ce0 Start address 0xbfc00000 Transfer rate: 201376 bits in <1 sec. (gdb) |
On the PowerPC:
Loading section .rom_vectors, size 0xa8 vma 0x40000000 Loading section .text, size 0x19ef vma 0x400000a8 Loading section .rodata, size 0x318 vma 0x40001a98 Loading section .data, size 0x68 vma 0x40001db0 Start address 0x40000000 Transfer rate: 61624 bits in <1 sec. (gdb) |
You are now ready to run your program as if this were an ordinary debugging session with GDB. If you type
(gdb) run
you will see the something like following output:
Starting program: /ecos-work/./install/tests/kernel/bin_sem0.exe PASS:<Binary Semaphore 0 OK> EXIT:<done> |
You must kill your GDB session with Control-C, or it will sit in the "idle" thread and use up CPU time. Type quit and you are done.
Note: If you are using a CD distribution of the eCos Developer's Kit, the GNUPro tool chain which accompanies it comes with the graphical front end to GDB, GDB/Tk, which will be invoked if you do not specify the -nw option to gdb. We have used the command line version in this tutorial.