GDB break commands don't get executed in command files

£可爱£侵袭症+ 提交于 2019-12-11 16:48:04

问题


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 fount that the issue is somehow 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.

来源:https://stackoverflow.com/questions/57988776/gdb-break-commands-dont-get-executed-in-command-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!