forked from ARMmbed/mbed-os
-
Notifications
You must be signed in to change notification settings - Fork 19
Debugger Commands and State in Upload Methods
Jamie Smith edited this page Jan 22, 2023
·
2 revisions
In order for debugging to work correctly (e.g. in VS Code, on the command line, etc), upload methods need to follow a couple of rules about the state of the debugger.
- This command shall start a GDB server
- It's preferable for the GDB server to exit after GDB disconnects from it, though this is not always possible to configure (e.g. STLINK).
- Iff an extended remote mode GDB server is started,
UPLOAD_WANTS_EXTENDED_REMOTE
shall be set to true.
- These commands shall perform the following jobs:
- Load code onto the target
- Set a breakpoint on main()
- Reset the target
- When the debug session starts, the user should start at the main() function.
An easy way to check if the setup is correct is to build for command-line, then run, in one terminal:
ninja gdbserver
and in another terminal:
ninja debug-mbed-drivers-ticker
The second terminal should show something like:
[0/1] Starting GDB to debug mbed-drivers-ticker...
GNU gdb (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 8.3.0.20190709-git
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from I:/RPL/mbed-os/cmake-build-nucleo-l452re-p-greentea/drivers/tests/TESTS/mbed_drivers/ticker/mbed-drivers-ticker.elf...
Reset_Handler () at ../targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L452xE/TOOLCHAIN_GCC_ARM/startup_stm32l452xx.S:63
63 ldr sp, =_estack /* Set stack pointer */
Loading section .text, size 0xbe64 lma 0x8000000
Loading section .ARM.exidx, size 0x8 lma 0x800be64
Loading section .data, size 0xa58 lma 0x800be6c
Start address 0x80002dc, load size 51396
Transfer rate: 18 KB/sec, 8566 bytes/write.
Breakpoint 1 at 0x8006b50: file ../drivers/tests/TESTS/mbed_drivers/ticker/main.cpp, line 311.
Note: automatically using hardware breakpoints for read-only addresses.
Breakpoint 1, main () at ../drivers/tests/TESTS/mbed_drivers/ticker/main.cpp:311
311 utest::v1::Harness::run(specification);
(gdb)
If it's running, or not stopped at main, or having some other issue, then the commands are not correct!