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:
You should see output similar to the following in the command
window:
GNU gdb THIS-GDB-VERSION
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".
(gdb)
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++
(gdb)
Or if you are using the simulator:
Connected to the simulator.
(gdb)
Now download the program to the target with
(gdb) load
You should see output similar to the following on your screen:
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.