When debugging with gdb, sometimes the displayed running position is strange. When I use n
to execute the next line, the instruction I want to focus on has already been executed. Below is an example. The cursor showing the execution position is not currently placed on any command
When I use the n command, the result is as shown in the figure below.
You can see that the cursor does not stay on line 911. Sometimes skip several lines.
And the cursor often stays on the comment.
When you are stepping with
n
in GDB tui mode, source code window can get broken. This can happen when the program is printing something to stdout, breaking layout of tui windows. Looks like this is what happening in 911 line inDPRINTF()
call. To fix the layout you can press Ctrl+L and tui window will be refreshed.