The source line passed to the editor for the 'edit' command appears to consistently be off by five. The script below will produce this output: Breakpoint 1, main () at test.c:3 3 int i = 5; edit +8 /tmp/test.c Note that source line is 3. Line number passed to editor is 8. #!/bin/sh GDB=${HOME}/opt/gdb-7.8.1/bin/gdb cat >test.c <<end_of_source int main() { int i = 5; int j = 6; int k = 1; return i - j + k; } end_of_source gcc test.c -g -o test cat <<end_of_gdb | EDITOR=echo $GDB test b 2 r edit q end_of_gdb
Script and output don't quite match up. Corrected script (cosmetic change). #!/bin/sh GDB=${HOME}/opt/gdb-7.8.1/bin/gdb cat >test.c <<end_of_source int main() { int i = 5; int j = 6; int k = 1; return i - j + k; } end_of_source gcc test.c -g -o test cat <<end_of_gdb | EDITOR="echo edit" $GDB test b 2 r edit q end_of_gdb
I wonder if this is related to the list window size. Yeah, simple experiments suggest it is. E.g., do "set listsize 1", and I get the cursor on the right line.
*** Bug 23337 has been marked as a duplicate of this bug. ***
The bug is in edit_command since 2002 very annoying also to me, where it adds listsize/2 to the src line. Can someone maintainer quickly remove this line? https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/cli/cli-cmds.c;h=4694553b7ddf8e37dc1834e9bbcd6f7a14549bbd;hb=15146ff7370d5abad01dbecfacb0bf0e66a93cd6#l787 Line to be deleted: sal.line += get_lines_to_list () / 2;