PS C:\> arm-none-eabi-gdb GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs Copyright (C) 2014 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". (gdb) file Demo.elf Reading symbols from Demo.elf...done. (gdb) target remote localhost:2331 Remote debugging using localhost:2331 0x00000000 in ?? () (gdb) monitor reset Resetting target (gdb) load Loading section .text, size 0x434 lma 0x8000000 Loading section .data, size 0x14 lma 0x8000434 Start address 0x80003ec, load size 1096 Transfer rate: 59 KB/sec, 548 bytes/write. (gdb) break main Breakpoint 1 at 0x8000112: file src\App\main.c, line 27. (gdb) c Continuing.
Breakpoint 1, main () at src\App\main.c:27 27 int i = 0; (gdb) l 22 /* Includes ------------------------------------------------------------------*/ 23#include "stm32f10x.h" 24#include <stdio.h> 25 int main(void) 26 { 27 int i = 0; 28 29 30for(int m = 0; m < 100; m++) 31 { (gdb) l 32 i = m + i; 33 } 34 35return0; 36 } (gdb) s 30for(int m = 0; m < 100; m++) (gdb) s 32 i = m + i; (gdb) s 30for(int m = 0; m < 100; m++) (gdb) s 32 i = m + i; (gdb) p m $1 = 1 (gdb) break35 Breakpoint 2 at 0x8000130: file src\App\main.c, line 35. (gdb) c Continuing.
Breakpoint 2, main () at src\App\main.c:35 35return0; (gdb) p i $2 = 4950 (gdb) q A debugging session is active.
Inferior 1 [Remote target] will be killed.
Quit anyway? (y or n) y
参考资料:
gcc manual
gdb manual
jlink user manual, charapter 3.3 J-link GDB Server