0

I'm debugging a Cortex-M4 embedded device using GDB and OpenOCD.

Here's what I do:

  1. Connect GDB to OpenOCD: target remote :3333
  2. Set a breakpoint at main: break main
  3. Then reset and start the program: monitor reset run

However, the breakpoint at main is never hit, and the program just runs.

I expected execution to stop at main, but it doesn't. Is reset run skipping the breakpoint or starting execution before the breakpoint is active? (I'm debugging from Flash, and use hardware breakpoints if this makes any sense)

In parallel, if I execute reset init, which halts the CPU at the beginning, and then execute continue command, then it hits the breakpoint.

3
  • 1
    In your 1/2/3 steps, you say that you reset, and start the program with "monitor reset run". Do you mean that you are using this command to set the inferior running? Because if you are, then this is not going to work. First, GDB doesn't know what "monitor reset run" does, it just passes the string "reset run" to the remote, so GDB will not know th inferior is running. Second, GDB only inserts breakpoints at the point when it sets the inferior running, which explains the "not hitting breakpoints" problem. And third, if the inferior did hit a breakpoint, GDB wouldn't know.... Commented Jul 18 at 22:26
  • 1
    ... what to do about it, as it doesn't know the inferior is running, and so doesn't know to look for the inferior stopping. You need to find a better set of monitor commands to use, though it looks like "reset init" (I assume this is actually a monitor command) seems to be doing what you want. Once the CPU is in the right state, you can then use the normal GDB commands to set the CPU running (e.g. continue). Commented Jul 18 at 22:29
  • Great, this answers my question. Commented Jul 19 at 12:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.