gdb
Introduction and openocd
2022/12
gdb
(2022/12/29) Following QEMU simulation for hardware boards, created another article to collect everything related to gdb
. Can refer to another article, QEMU simulation with hardware boards, which provides examples related to qemu
, gdb
, and openocd
.
latest update on 2022/12/29
Table of Contents
gdb
related documents
gdb
official documents
gdb
popluar commands and usages
(gdb) target extended-remote localhost:3333
: connect to gdbserver. From previous example, when we launch openocd
, the system output Info : starting gdb server for stm32f1x.cpu on 3333
Info : Listening on port 3333 for gdb connections
, showing it starts a gdb server on port 3333. (since we use the same PC, so localhost
is used, instead of specific ip address. And localhost
can be omitted.)(gdb) disconnect
: to disconntect from gdb server.(gdb) monitor reset init
: Reset and intialize the target hardware.(gdb) run or r
: Run
the program continueously from the beginning. To stop, press CTRL-c
.(gdb) Continue or c
: Continue
the program continueously from where it stopped. To stop, press CTRL-c
.(gdb) Next or n
: Next
step by sept to execute the program per line instruction. Complete the subroutine if next instruction is a subroutine.(gdb) Step or s
: Step
by step to execute the program per line instruction. Step into the subroutine if if next instruction is a subroutine.gdb
is a magic command. You can use the monitor command to send special requests to gdbserver.
(gdb) monitor help
: This is a gdb
command to list the openocd
commands supported. More details in next section of openocd
.gdb
examples
openocd
Related Documents
openocd
official documents
gdb
for openocd
.openocd
popular commands and usage
gdb
is a magic command, which was introduced at previous gdb
section. Can use monitor + openocd
commands to control openocd
and target hardware in gdb
.
(gdb) monitor help
: This is a gdb
command to list the openocd
commands supported.(gdb) monitor reset {run, halt, init}
: Reset the hardware target, then take next action of run
(run the program), halt
(halt the CPU), init
(Initialize the target hardware system).(gdb) monitor soft_reset_halt
: Requesting target halt and executing a soft reset. This is often used when a target cannot be reset and halted. The target, after reset is released begins to execute code. OpenOCD attempts to stop the CPU and then sets the program counter back to the reset vector. Unfortunately the code that was executed may have left the hardware in an unknown state.(gdb) monitor flash help
to know more flash
command provided by target hardware about OpenOCD flash commands.
openocd
+ gdb
examples
A : Debugging multithreaded programs in GDB
gdb
for openocd
.gdb
for openocd
gdb
and openocd
examples
gdb
examples
gdb -tui
or cgdb
for Text UI or GUI operation.
Learn More →
Learn More →
Learn More →