问题
I have a debugging script that does the following:
- sets two breakpoints. let's call them start and end breakpoints.
- after starting, the script continues until start breakpoint is hit.
- 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