Fix 5-line offset of edit command

Message ID 20230212091534.GA27308@phoenix
State New
Headers
Series Fix 5-line offset of edit command |

Commit Message

Gary Johnson Feb. 12, 2023, 9:15 a.m. UTC
  [I originally sent this to the gdb list by mistake.]

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.

Regards,
Gary

--------------------------------------------------------------------
  

Patch

--- cli-cmds.c.orig     2022-05-01 11:46:31.000000000 -0700
+++ cli-cmds.c  2023-02-11 00:54:01.695108617 -0800
@@ -963,7 +963,6 @@ 
     {
       if (sal.symtab == 0)
        error (_("No default source file yet."));
-      sal.line += get_lines_to_list () / 2;
     }
   else
     {