Skip to content

cmd/compile: DWARF IsStmt flag not set for line although it is executed #45680

Open
@mahdi-hm

Description

@mahdi-hm

What version of Go are you using (go version)?

$ go version
go version go1.16.3 linux/amd64

Does this issue reproduce with the latest release?

It was working on 1.14.9 but not after that

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mahdi/.cache/go-build"
GOENV="/home/mahdi/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/mahdi/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/mahdi/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1744891559=/tmp/go-build -gno-record-gcc-switches"

What did you do?

for some sample code I tried to read the dwarf information however in below specific code the line number information is wrong

package main

import "fmt"

type t2 struct {
	i int
	j [2]int
}

func printType(tt t2) {
	fmt.Println(tt.i)
	fmt.Println(tt.i)
}

func main() {
	tt := t2{
		i: 2,
	}
	printType(tt) // <-- Line 19 with the problem
}

I get dwarf line info using objdump --dwarf=decodedline hello2

What did you expect to see?

Line 19 is desirable

File name                            Line number    Starting address    View    Stmt
hello2.go                                     15            0x497660               x
hello2.go                                     15            0x497673               x
hello2.go                                     19            0x497681               x
hello2.go                                     19            0x49768a
hello2.go                                     11            0x49769b               x
hello2.go                                     11            0x4976a8

What did you see instead?

Line 19 is desirable

File name                            Line number    Starting address    View    Stmt
hello2.go                                     15            0x497760               x
hello2.go                                     15            0x49776f               x
hello2.go                                     19            0x49777d
hello2.go                                     20            0x49779a               x
hello2.go                                     15            0x4977a4               x
hello2.go                                     15            0x4977ab               x

So it is not possible to put a breakpoint on line 19 for instance on debuggers

Speculation

The strange thing about this bug is that if you change the source code to be like this:

package main

import "fmt"

type t2 struct {
	i int
	j [2]int
}

func printType(tt t2) {
	fmt.Println(tt.i)
	println(tt.i)
}

func main() {
	tt := t2{
		i: 2,
	}
	printType(tt)
}

or this

package main

import "fmt"

type t2 struct {
	i int
	j []int
}

func printType(tt t2) {
	fmt.Println(tt.i)
	fmt.Println(tt.i)
}

func main() {
	tt := t2{
		i: 2,
	}
	printType(tt)
}

the line number information is right.
So passing struct which has array elements or complex64 to a function which does two fmt.Println call make the line number information for the calling line, wrong

Metadata

Metadata

Assignees

No one assigned

    Labels

    DebuggingNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Triage Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions