首页 > 解决方案 > OpenOCD - 卡在断点上,跳过并继续不起作用

问题描述

我正在使用带有 STLinkV3 的 STM32H745ZI Nucleo 板。我已经成功编译并运行了在 Cortex M7 内核上闪烁 LED 的简单程序。当程序在没有调试器的情况下运行时,一切都很好。

调试时出现问题。当我在打开 LED 的线路上设置断点时,调试器会在此位置停止。问题是一旦停止,continue 和 step over 在断点未设置之前都不起作用

代码并不复杂:

while (1) {
  LD1_SET(1);
  HAL_Delay(100);
  LD2_SET(1);
  HAL_Delay(100);
  LD3_SET(1);
  HAL_Delay(100);

  LD1_SET(0);
  HAL_Delay(100);
  LD2_SET(0);
  HAL_Delay(100);
  LD3_SET(0);
  HAL_Delay(100);
}

这是它在 gdb 控制台中的样子:

# Setting breakpoint on LED ON
(gdb) b main.c:166
Breakpoint 1 at 0x8001788: file Src/main.c, line 166.
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

# Hit! Debugger seems working, LED is still OFF   
Breakpoint 1, main () at Src/main.c:166
166     LD1_SET(1);
(gdb) c
Continuing.

# Hit the same breakpoint with no blinking between
Breakpoint 1, main () at Src/main.c:166
166     LD1_SET(1);

# Setting breakpoint on LED OFF
(gdb) b main.c:174
Breakpoint 2 at 0x80017c6: file Src/main.c, line 174.
(gdb) c
Continuing.

# Still hits LED ON, LED is still OFF
Breakpoint 1, main () at Src/main.c:166
166     LD1_SET(1);
(gdb) info b
Num     Type           Disp Enb Address    What
1       breakpoint     keep y   0x08001788 in main at Src/main.c:166
    breakpoint already hit 3 times
2       breakpoint     keep y   0x080017c6 in main at Src/main.c:174

# Removing breakpoint on LED ON
(gdb) del 1
(gdb) c
Continuing.

# LED is ON, prorgram finally hit next breakpoint
Breakpoint 2, main () at Src/main.c:174
174     LD1_SET(0);

如何让它发挥作用?你以前有没有遇到过类似的问题?

标签: gdbstm32cortex-mgdbserveropenocd

解决方案


推荐阅读