This problem has always existed with the SSA backend and my impression is that it got better during go1.9 development windows, however a recent commit, 00263a8, while trying to improve the situation actually made some things worse (although I'm sure it did actually improve numbering in other circumstances). For example in this program the function main.helloworld went from compiling (with -gcflags='-N -l') to:
TEXT main.helloworld(SB) /home/a/n/go/src/github.com/derekparker/delve/_fixtures/testnextprog.go
testnextprog.go:13 0x481b20 64488b0c25f8ffffff MOVQ FS:0xfffffff8, CX
testnextprog.go:13 0x481b29 483b6110 CMPQ 0x10(CX), SP
testnextprog.go:13 0x481b2d 0f8689000000 JBE 0x481bbc
testnextprog.go:13 0x481b33 4883ec68 SUBQ $0x68, SP
testnextprog.go:13 0x481b37 48896c2460 MOVQ BP, 0x60(SP)
testnextprog.go:13 0x481b3c 488d6c2460 LEAQ 0x60(SP), BP
testnextprog.go:14 0x481b41 48c744243800000000 MOVQ $0x0, 0x38(SP)
testnextprog.go:14 0x481b4a 48c744244000000000 MOVQ $0x0, 0x40(SP)
testnextprog.go:14 0x481b53 488d442438 LEAQ 0x38(SP), AX
testnextprog.go:14 0x481b58 4889442430 MOVQ AX, 0x30(SP)
testnextprog.go:14 0x481b5d 8400 TESTB AL, 0(AX)
testnextprog.go:14 0x481b5f 488d057aed0000 LEAQ 0xed7a(IP), AX
testnextprog.go:14 0x481b66 4889442438 MOVQ AX, 0x38(SP)
testnextprog.go:14 0x481b6b 488d05bec30300 LEAQ 0x3c3be(IP), AX
testnextprog.go:14 0x481b72 4889442440 MOVQ AX, 0x40(SP)
testnextprog.go:14 0x481b77 488b442430 MOVQ 0x30(SP), AX
testnextprog.go:14 0x481b7c 8400 TESTB AL, 0(AX)
testnextprog.go:14 0x481b7e eb00 JMP 0x481b80
testnextprog.go:14 0x481b80 4889442448 MOVQ AX, 0x48(SP)
testnextprog.go:14 0x481b85 48c744245001000000 MOVQ $0x1, 0x50(SP)
testnextprog.go:14 0x481b8e 48c744245801000000 MOVQ $0x1, 0x58(SP)
testnextprog.go:14 0x481b97 48890424 MOVQ AX, 0(SP)
testnextprog.go:14 0x481b9b 48c744240801000000 MOVQ $0x1, 0x8(SP)
testnextprog.go:14 0x481ba4 48c744241001000000 MOVQ $0x1, 0x10(SP)
testnextprog.go:14 0x481bad e8fe8dffff CALL fmt.Println(SB)
testnextprog.go:15 0x481bb2 488b6c2460 MOVQ 0x60(SP), BP
testnextprog.go:15 0x481bb7 4883c468 ADDQ $0x68, SP
testnextprog.go:15 0x481bbb c3 RET
testnextprog.go:13 0x481bbc e86fd2fcff CALL runtime.morestack_noctxt(SB)
testnextprog.go:13 0x481bc1 e95affffff JMP main.helloworld(SB)
To compiling to:
TEXT main.helloworld(SB) /home/a/n/go/src/github.com/derekparker/delve/_fixtures/testnextprog.go
testnextprog.go:13 0x481b20 64488b0c25f8ffffff MOVQ FS:0xfffffff8, CX
testnextprog.go:13 0x481b29 483b6110 CMPQ 0x10(CX), SP
testnextprog.go:13 0x481b2d 0f8689000000 JBE 0x481bbc
testnextprog.go:13 0x481b33 4883ec68 SUBQ $0x68, SP
testnextprog.go:13 0x481b37 48896c2460 MOVQ BP, 0x60(SP)
testnextprog.go:13 0x481b3c 488d6c2460 LEAQ 0x60(SP), BP
testnextprog.go:14 0x481b41 48c744243800000000 MOVQ $0x0, 0x38(SP)
testnextprog.go:14 0x481b4a 48c744244000000000 MOVQ $0x0, 0x40(SP)
testnextprog.go:14 0x481b53 488d442438 LEAQ 0x38(SP), AX
testnextprog.go:14 0x481b58 4889442430 MOVQ AX, 0x30(SP)
testnextprog.go:14 0x481b5d 8400 TESTB AL, 0(AX)
testnextprog.go:13 0x481b5f 488d057aed0000 LEAQ 0xed7a(IP), AX
testnextprog.go:14 0x481b66 4889442438 MOVQ AX, 0x38(SP)
testnextprog.go:14 0x481b6b 488d059ec00300 LEAQ 0x3c09e(IP), AX
testnextprog.go:14 0x481b72 4889442440 MOVQ AX, 0x40(SP)
testnextprog.go:14 0x481b77 488b442430 MOVQ 0x30(SP), AX
testnextprog.go:14 0x481b7c 8400 TESTB AL, 0(AX)
testnextprog.go:14 0x481b7e eb00 JMP 0x481b80
testnextprog.go:14 0x481b80 4889442448 MOVQ AX, 0x48(SP)
testnextprog.go:14 0x481b85 48c744245001000000 MOVQ $0x1, 0x50(SP)
testnextprog.go:14 0x481b8e 48c744245801000000 MOVQ $0x1, 0x58(SP)
testnextprog.go:14 0x481b97 48890424 MOVQ AX, 0(SP)
testnextprog.go:14 0x481b9b 48c744240801000000 MOVQ $0x1, 0x8(SP)
testnextprog.go:14 0x481ba4 48c744241001000000 MOVQ $0x1, 0x10(SP)
testnextprog.go:14 0x481bad e8fe8dffff CALL fmt.Println(SB)
testnextprog.go:15 0x481bb2 488b6c2460 MOVQ 0x60(SP), BP
testnextprog.go:15 0x481bb7 4883c468 ADDQ $0x68, SP
testnextprog.go:15 0x481bbb c3 RET
testnextprog.go:13 0x481bbc e86fd2fcff CALL runtime.morestack_noctxt(SB)
testnextprog.go:13 0x481bc1 e95affffff JMP main.helloworld(SB)
Note the line number of the LEA at 0x481b5f, there multiple examples of this happening in delve's test set.
cc @dr2chase
This problem has always existed with the SSA backend and my impression is that it got better during go1.9 development windows, however a recent commit, 00263a8, while trying to improve the situation actually made some things worse (although I'm sure it did actually improve numbering in other circumstances). For example in this program the function main.helloworld went from compiling (with -gcflags='-N -l') to:
To compiling to:
Note the line number of the LEA at 0x481b5f, there multiple examples of this happening in delve's test set.
cc @dr2chase