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

Unreadable arguments and "debugging optimized function" warning #1368

Closed
antoineco opened this issue Oct 11, 2018 · 6 comments
Closed

Unreadable arguments and "debugging optimized function" warning #1368

antoineco opened this issue Oct 11, 2018 · 6 comments

Comments

@antoineco
Copy link

antoineco commented Oct 11, 2018

Environment

dlv 1.1.0 (master @ 4e4ed02)
go 1.11.1
os darwin/amd64

What did you do?

With the following test code:

https://gist.github.com/antoineco/262c7dc7860ddd25ef5cd124d2a8ceb3

I ran:

$ dlv test ./
Type 'help' for list of commands.
(dlv) b k8s.io/client-go/testing.(*tracker).add
Breakpoint 1 set at 0x19ec06b for issue/vendor/k8s.io/client-go/testing.(*tracker).add() ./vendor/k8s.io/client-go/testing/fixture.go:309
(dlv) c
> issue/vendor/k8s.io/client-go/testing.(*tracker).add() ./vendor/k8s.io/client-go/testing/fixture.go:309 (PC: 0x19ec06b)
Warning: debugging optimized function
   304:                 }
   305:         }
   306:         return watches
   307: }
   308:
=> 309: func (t *tracker) add(gvr schema.GroupVersionResource, obj runtime.Object, ns string, replaceExisting bool) error {
   310:         t.lock.Lock()
   311:         defer t.lock.Unlock()
   312:
   313:         gr := gvr.GroupResource()
   314:
(dlv) args

What did you expect to see?

The args command prints the value of the function arguments.

What did you see instead?

Warning: debugging optimized function is printed and function arguments are unreadable.

(dlv) args
gvr = (unreadable empty OP stack)
ns = (unreadable could not find loclist entry at 0x4bed3 for address 0x1e3050b)
obj = (unreadable could not find loclist entry at 0x4bf0f for address 0x1e3050b)
replaceExisting = (unreadable could not find loclist entry at 0x4bf4a for address 0x1e3050b)
t = (unreadable could not find loclist entry at 0x4bf7f for address 0x1e3050b)
~r4 = (unreadable empty OP stack)

Important note

⚠️ Here comes the interesting part.

If one un-comments the commented out lines inside issue.go, the warning will not appear, and Delve will consistently print function arguments:

(dlv) args
gvr = issue/vendor/k8s.io/apimachinery/pkg/runtime/schema.GroupVersionResource {Group: "", Version: "v1", Resource: "events"}
ns = ""
obj = issue/vendor/k8s.io/apimachinery/pkg/runtime.Object(*issue/vendor/k8s.io/api/core/v1.Event) 0xc0000f8dd8
replaceExisting = false
t = (*issue/vendor/k8s.io/client-go/testing.tracker)(0xc0002c5400)
~r4 = (unreadable invalid interface type: could not find str field)
@aarzilli
Copy link
Member

Duplicate of golang/go#27681

@barbu110
Copy link

barbu110 commented Mar 6, 2019

it still happens to me after golang/go#27681 has been closed

@john8329
Copy link

Same, using the integrated debugger of Goland. The binary is built without optimization, and not all variables are readable.

Using the build flags (go 1.12):
go build -o=/... -gcflags="all=-N -l" ...

Error:
unreadable: could not find loclist entry at 0x... for address 0x...

@zhangguanzhang
Copy link

 -gcflags="all=-N -l" 

@asg0451
Copy link

asg0451 commented Mar 28, 2022

 -gcflags="all=-N -l" 

this is amazing. it should be prominently displayed in the docs, as delve can be borderline unusable without it.

@KMankowski
Copy link

This still happens to me on macOS

macOS:reflection owner$ l
total 32
-rw-r--r--  1 owner  staff    52 Nov 10 00:40 go.mod
-rw-r--r--  1 owner  staff   569 Nov 13 14:14 walk.go
-rw-r--r--  1 owner  staff  1781 Nov 13 14:14 walk_test.go
-rw-r--r--  1 owner  staff   120 Nov 13 14:14 main.go
macOS:reflection owner$ go build -gcflags="all=-N -l"
macOS:reflection owner$ l
total 4384
-rw-r--r--  1 owner  staff       52 Nov 10 00:40 go.mod
-rw-r--r--  1 owner  staff      569 Nov 13 14:14 walk.go
-rw-r--r--  1 owner  staff     1781 Nov 13 14:14 walk_test.go
-rw-r--r--  1 owner  staff      120 Nov 13 14:14 main.go
-rwxr-xr-x  1 owner  staff  2227472 Nov 13 14:22 reflection
macOS:reflection owner$ dlv debug
Type 'help' for list of commands.
(dlv) break main.go:6
Breakpoint 1 set at 0x813114e,0x81314ce for (multiple functions)() ./main.go:6
(dlv) continue
> [Breakpoint 1] main.main() ./main.go:6 (hits goroutine(1):1 total:1) (PC: 0x813114e)
     1: package main
     2:
     3: import "fmt"
     4:
     5: func main() {
=>   6:         walk(struct{ Name string }{"Billy"}, func(s string) {
     7:                 fmt.Println(s)
     8:         })
     9: }
(dlv) args
(no args)
(dlv) s
> main.walk() ./walk.go:5 (PC: 0x81311d3)
     1: package main
     2:
     3: import "reflect"
     4:
=>   5: func walk(structToWalk interface{}, funcToCall func(string)) {
     6:         val := getVal(structToWalk)
     7:
     8:         switch val.Kind() {
     9:         case reflect.String:
    10:                 funcToCall(val.String())
(dlv) args
structToWalk = (unreadable error loading module data: read out of bounds)
funcToCall = (unreadable read out of bounds)
(dlv) exit
macOS:reflection owner$ go version
go version go1.23.3 darwin/amd64`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants