Using the command line

Start a command shell (such as a Cygwin shell window in Windows) with the environment variables set as described in the toolchain 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:

$ TARGET-gdb -nw install/tests/kernel/<version>/tests/bin_sem0

You should see output similar to the following in the command window:

Copyright 2001 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.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=THIS-HOST --target=THIS-TARGET".

If you are trying to run a synthetic target test on Linux, skip the following connection and download steps. Otherwise, connect to the target by typing:

(gdb) set remotebaud 38400
(gdb) target remote /dev/ttyS0

on Linux or

(gdb) set remotebaud 38400
(gdb) target remote com1

on Windows or

(gdb) target sim

to use a simulator in either host O/S.

Check the documentation for the target board for the actual baud rate to use when connecting to real targets.

You will see output similar to the following:

Remote debugging using /dev/ttyS1
0x0000d50c in ?? ()
    at BASE_DIR/kernel/<version>/src/common/kapi.cxx:345

Current language:  auto; currently c++

Or if you are using the simulator:

Connected to the simulator.

Now download the program to the target with

(gdb) load

You should see output similar to the following on your screen:

Loading section .text, size 0x4b04 lma 0x108000
Loading section .rodata, size 0x738 lma 0x10cb08
Loading section .data, size 0x1c0 lma 0x10d240
Start address 0x108000, load size 21500
Transfer rate: 24571 bits/sec, 311 bytes/write.

You are now ready to run your program. If you type:

(gdb) continue

you will see output similar to the following:

PASS:<Binary Semaphore 0 OK>

Note: If you are using a simulator or the synthetic target rather than real hardware, you must use the GDB command “run” rather than “continue” to start your program.

You can terminate your GDB session with Control+C, otherwise it will sit in the “idle” thread and use up CPU time. This is not a problem with real targets, but may have undesirable effects in simulated or synthetic targets. Type quit and you are done.