Skip to content

Instantly share code, notes, and snippets.

@ear7h
Created February 18, 2020 20:04
Show Gist options
  • Save ear7h/f07da14eb6bd25bbe18b7788e7505864 to your computer and use it in GitHub Desktop.
Save ear7h/f07da14eb6bd25bbe18b7788e7505864 to your computer and use it in GitHub Desktop.
dlv debug $GOPATH/src/github.com/go-delve/delve/cmd/dlv -- debug main.go --init dlvscript.txt
Type 'help' for list of commands.
(dlv) b proc/variables.go:840
Breakpoint 1 set at 0x145e9e7 for github.com/go-delve/delve/pkg/proc.(*Variable).structMember() ./lib/go/src/github.com/go-delve/delve/pkg/proc/variables.go:840
(dlv) c
WARN[0000] CGO_CFLAGS already set, Cgo code could be optimized. layer=dlv
Type 'help' for list of commands.
Breakpoint 1 set at 0x1057f66 for main.main() ./main.go:13
> main.main() ./main.go:13 (hits goroutine(1):1 total:1) (PC: 0x1057f66)
8: }
9:
10: func main() {
11: var x X
12:
=> 13: x.M()
14: }
> github.com/go-delve/delve/pkg/proc.(*Variable).structMember() ./lib/go/src/github.com/go-delve/delve/pkg/proc/variables.go:840 (hits goroutine(30):1 total:1) (PC: 0x145e9e7)
835: return nil, fmt.Errorf("%s has no member %s", vname, memberName)
836: default:
837: if v.Name == "" {
838: return nil, fmt.Errorf("type %s is not a struct", structVar.TypeString())
839: }
=> 840: return nil, fmt.Errorf("%s (type %s) is not a struct", vname, structVar.TypeString())
841: }
842: }
843:
844: func readVarEntry(varEntry *dwarf.Entry, image *Image) (entry reader.Entry, name string, typ godwarf.Type, err error) {
845: entry, _ = reader.LoadAbstractOrigin(varEntry, image.dwarfReader)
(dlv) stack
0 0x000000000145e9e7 in github.com/go-delve/delve/pkg/proc.(*Variable).structMember
at ./lib/go/src/github.com/go-delve/delve/pkg/proc/variables.go:840
1 0x000000000141f85a in github.com/go-delve/delve/pkg/proc.(*EvalScope).evalStructSelector
at ./lib/go/src/github.com/go-delve/delve/pkg/proc/eval.go:1051
2 0x0000000001419a0e in github.com/go-delve/delve/pkg/proc.(*EvalScope).evalAST
at ./lib/go/src/github.com/go-delve/delve/pkg/proc/eval.go:639
3 0x000000000142e390 in github.com/go-delve/delve/pkg/proc.funcCallEvalFuncExpr
at ./lib/go/src/github.com/go-delve/delve/pkg/proc/fncall.go:404
4 0x000000000142d017 in github.com/go-delve/delve/pkg/proc.evalFunctionCall
at ./lib/go/src/github.com/go-delve/delve/pkg/proc/fncall.go:273
5 0x0000000001418cf2 in github.com/go-delve/delve/pkg/proc.(*EvalScope).evalAST
at ./lib/go/src/github.com/go-delve/delve/pkg/proc/eval.go:606
6 0x0000000001410175 in github.com/go-delve/delve/pkg/proc.(*EvalScope).EvalExpression
at ./lib/go/src/github.com/go-delve/delve/pkg/proc/eval.go:77
7 0x0000000001065581 in runtime.goexit
at /usr/local/go/src/runtime/asm_amd64.s:1357
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment