open-isa-rv32m1 / rv32m1-openocd

Base on official openocd, add RV32M1 support
GNU General Public License v2.0
4 stars 4 forks source link

GDB break commands don't get executed in command files #2

Open el-mamado opened 5 years ago

el-mamado commented 5 years ago

I have a debugging script that does the following:

  1. sets two breakpoints. let's call them start and end breakpoints.
  2. after starting, the script continues until start breakpoint is hit.
  3. once start breakpoint is hit, I perform single-stepping until end breakpoint is hit.

This is my command file:

# end breakpoint
break 38
commands
    stop 1
    quit
end

# start breakpoint
break 50
commands
    set logging off
    set logging file log.txt
    set logging overwrite on
    set logging on
    printf "program counter: $pc"
end

continue

set $count = 0
set $steps = 15
while $count < $steps
    set $count = $count + 1
    next
end

To clarify, once I start my debugging session the program stops at the beginning of main; that's why I have continue in the script to jump to the start breakpoint.

The problem is that the break command does not get executed whenever the breakpoint is hit. This is what I get in the console:

++next

Breakpoint 23, main () at ..\..\hello_world.c:50
50      test_byte++;
++set $count = $count + 1
++next
51      test_byte++;
++set $count = $count + 1
++next

Nothing is printed to the console or to the logging file. However, when I write the same break command directly to the console and step manually it works.

I am debugging a VEGAboard with RISC-V using a JLink debugger and openOCD.

Update:

I found that the issue is somehow is with having next in the loop. So whenever I get rid of the loop and simply hardcode the number of next commands, the break command gets executed successfully.

This behavior is still odd and I hope somebody has an explanation.

zejiang0jason commented 5 years ago

Hi el-mamado,

Are you using the latest OpenOCD? There are some bugfixes. Anyway, we will try to reproduce the issue and find the root cause.