When asking GPT, it’s anwser is very obscure, like how print a variable without switch to the stack frame, really frustrating. When we examine a core file, there is no way to switch to none-stack variables. So after some study, I found the right ways, recording them as such.
The first tip, I learn that from dlv github repository document. It should be like this:
p “github.com/xx/my/pkg”.localVar”
Do remember the quote should be “, not ‘;
The second is how to use gdb Python extention. I use that to examine the Go’s mspan status.
You can add it to the $GOROOT/src/runtime/runtime-gdb.py, then using following command to invoke it in gdb.
1 2
source $GOROOT/src/runtime/runtime-gdb.py info spans