[PATCH] Fix 5-line offset of edit command

Eli Zaretskii eliz@gnu.org
Sat Feb 11 10:58:03 GMT 2023


> Date: Sat, 11 Feb 2023 02:08:14 -0800
> From: Gary Johnson <garyjohn@spocom.com>
> 
> When gdb is paused at a line and I open the current file with the
> edit command, gdb uses vim to open the file at the current line, but
> the line number given to vim is always too high by 5.
> 
> For example, using gdb-12.1 and the gdb-12.1 source, cd to
> gdb-12.1/gdb and run gdb on itself.
> 
>     $ gdb gdb
>     (gdb) b main
>     (gdb) run
> 
> Gdb will stop at line 25.
> 
>     (gdb) edit
> 
> will open vim at line 30.  Executing
> 
>     :ps -fH
> 
> confirms that vim was started with the argument "+30".
> 
> The problem appears to be in the edit_command() function in
> cli-cmds.c, at line 966 in version 12.1.  The solution is to
> delete that line.  The patch is below.

This is probably editor-specific?

But I admit I cannot understand that addition, either.  I could
understand if we were _subtracting_ half the number of lines to list,
for those editors which place the line at the top of the display.


More information about the Gdb mailing list