Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: bad DWARF location for variable #58813

Open
aarzilli opened this issue Mar 1, 2023 · 2 comments
Open

cmd/compile: bad DWARF location for variable #58813

aarzilli opened this issue Mar 1, 2023 · 2 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@aarzilli
Copy link
Contributor

aarzilli commented Mar 1, 2023

$ go version
go version go1.20.1 linux/amd64

Given the following code:

package main

import "fmt"

func cul(row int64) bool {
	id := int((row >> 32) & 0x3fffffff)
	
	return id != 0
}

func main() {
	fmt.Println(cul(0))
}

Compiled with `-gcflags='all=-N -l', main.cul function compiles into:

  test.go:5		0x49c8c0		4883ec18		SUBQ $0x18, SP		
  test.go:5		0x49c8c4		48896c2410		MOVQ BP, 0x10(SP)	
  test.go:5		0x49c8c9		488d6c2410		LEAQ 0x10(SP), BP	
  test.go:5		0x49c8ce		4889442420		MOVQ AX, 0x20(SP)	
  test.go:5		0x49c8d3		c644240700		MOVB $0x0, 0x7(SP)	
  test.go:6		0x49c8d8		488b4c2420		MOVQ 0x20(SP), CX	
  test.go:6		0x49c8dd		48c1f920		SARQ $0x20, CX		
  test.go:6		0x49c8e1		81e1ffffff3f		ANDL $0x3fffffff, CX	
  test.go:8		0x49c8e7		4885c9			TESTQ CX, CX		
  test.go:8		0x49c8ea		0f95c0			SETNE AL		
  test.go:6		0x49c8ed		48894c2408		MOVQ CX, 0x8(SP)	
  test.go:8		0x49c8f2		88442407		MOVB AL, 0x7(SP)	
  test.go:8		0x49c8f6		488b6c2410		MOVQ 0x10(SP), BP	
  test.go:8		0x49c8fb		4883c418		ADDQ $0x18, SP		
  test.go:8		0x49c8ff		90			NOPL			
  test.go:8		0x49c900		c3			RET			

and the variable id has DW_OP_fbreg -0x18 has its location, however at instruction 0x49c8ea, which is the instruction picked for a breakpoint on line :8, the variable is stored on register rcx, not in its stack location (where it gets moved only later at instruction 0x49c8ed).
Originally reported as go-delve/delve#3290.

cc @dr2chase.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Mar 1, 2023
@dmitshur
Copy link
Contributor

dmitshur commented Mar 1, 2023

CC @golang/compiler.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 1, 2023
@dmitshur dmitshur added this to the Backlog milestone Mar 1, 2023
@mknyszek
Copy link
Contributor

mknyszek commented Mar 8, 2023

@dr2chase assigned to you in triage since we want your input but feel free to unassign.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Status: Todo
Development

No branches or pull requests

5 participants