Open
Description
What version of Go are you using (go version
)?
go version devel +66bb8ddb95 Thu Oct 25 13:37:38 2018 +0000 darwin/amd64
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/yagami/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/yagami/go"
GOPROXY=""
GORACE=""
GOROOT="/Users/yagami/src/go"
GOTMPDIR=""
GOTOOLDIR="/Users/yagami/src/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/5t/5crzwsxs305_ngrhgx90phzh0000gn/T/go-build561220144=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
In the sample program below, the DW_AT_location of the return value ~r1
is empty. It's nice to provide the information about the location here because the value is present on the stack and is used later.
% cat loc_attr.go
package main
import "fmt"
func fib(n int) int {
if n == 0 || n == 1 {
return n
}
return fib(n-1) + fib(n-2)
}
func main() {
fmt.Println(fib(10))
}
% go build -ldflags=-compressdwarf=false loc_attr.go
% gobjdump --dwarf=info ./loc_attr | grep -B 1 -A 18 'main.fib'
<1><75c36>: Abbrev Number: 3 (DW_TAG_subprogram)
<75c37> DW_AT_name : main.fib
<75c40> DW_AT_low_pc : 0x1091960
<75c48> DW_AT_high_pc : 0x10919e8
<75c50> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<75c52> DW_AT_decl_file : 0x1
<75c56> DW_AT_external : 1
<2><75c57>: Abbrev Number: 16 (DW_TAG_formal_parameter)
<75c58> DW_AT_name : n
<75c5a> DW_AT_variable_parameter: 0
<75c5b> DW_AT_decl_line : 5
<75c5c> DW_AT_type : <0x339f7>
<75c60> DW_AT_location : 0x71216 (location list)
<2><75c64>: Abbrev Number: 15 (DW_TAG_formal_parameter)
<75c65> DW_AT_name : ~r1
<75c69> DW_AT_variable_parameter: 1
<75c6a> DW_AT_decl_line : 5
<75c6b> DW_AT_type : <0x339f7>
<75c6f> DW_AT_location : 0 byte block: ()
<2><75c70>: Abbrev Number: 0
I'm not sure it's helpful, but I noticed the DW_AT_location is not empty if the name of the return value is specified in the source:
% cat loc_attr.go
package main
import "fmt"
func fib(n int) (r int) { // now the return value is named.
if n == 0 || n == 1 {
return n
}
return fib(n-1) + fib(n-2)
}
func main() {
fmt.Println(fib(10))
}
% go build -ldflags=-compressdwarf=false loc_attr.go
% gobjdump --dwarf=info ./loc_attr | grep -B 1 -A 18 'main.fib'
<1><75c36>: Abbrev Number: 3 (DW_TAG_subprogram)
<75c37> DW_AT_name : main.fib
<75c40> DW_AT_low_pc : 0x1091960
<75c48> DW_AT_high_pc : 0x10919e8
<75c50> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<75c52> DW_AT_decl_file : 0x1
<75c56> DW_AT_external : 1
<2><75c57>: Abbrev Number: 16 (DW_TAG_formal_parameter)
<75c58> DW_AT_name : n
<75c5a> DW_AT_variable_parameter: 0
<75c5b> DW_AT_decl_line : 5
<75c5c> DW_AT_type : <0x339f7>
<75c60> DW_AT_location : 0x71216 (location list)
<2><75c64>: Abbrev Number: 16 (DW_TAG_formal_parameter)
<75c65> DW_AT_name : r
<75c67> DW_AT_variable_parameter: 1
<75c68> DW_AT_decl_line : 5
<75c69> DW_AT_type : <0x339f7>
<75c6d> DW_AT_location : 0x71249 (location list)
<2><75c71>: Abbrev Number: 0
What did you expect to see?
The DW_AT_location of the return value ~r1
provides the information about the location.
What did you see instead?
The DW_AT_location of the return value ~r1
is empty.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Triage Backlog