gdb and "No symbol xxx in current context"

366 views
Skip to first unread message

Michael Monashev

unread,
Dec 20, 2015, 12:56:46 AM12/20/15
to golan...@googlegroups.com
Hi.

I used gbd 7.10 with "Go Runtime support" to print value of "port"
variable after flag.Parse(), and always saw
"No symbol "port" in current context."

But fmt.Println(port) works fine:

(gdb)n
20 flag.Parse()
(gdb)
22 fmt.Println(port)
(gdb) p port
No symbol "port" in current context.
(gdb)n
12345

Code:

func main() {
var port int
...
flag.IntVar(&port, "port", 12345, "Port")
...
flag.Parse()

fmt.Println(port)
...
}

How to print value of "port"?

--
Michael

Florin Patan

unread,
Dec 21, 2015, 4:23:21 AM12/21/15
to golang-nuts, softs...@gmail.com
Hi, 

According to the documentation, https://golang.org/doc/gdb, gdb is not useful unless you are compiling with gccgo.
Please try and use delve, https://github.com/derekparker/delve, which is still in pre-1.0 but works better than gdb in my exprience.

Cheers
Reply all
Reply to author
Forward
0 new messages