English 中文(简体)
go: 带有 gdb 的打印变量
原标题:Go: print variables with gdb
  • 时间:2012-05-21 23:15:28
  •  标签:
  • gdb
  • go

在此程序下, 如何与调试器断开执行并打印 i 值?

package main

import "fmt"

func main() {
        x := "abc"
        i := 3
        fmt.Println(i)
        fmt.Println(x)
}

我无法打印i。然而,我可以打印x:

go build test.go
gdb test  
[...]Reading symbols from /home/ned/test...done.
(gdb) br 9
(gdb) run
(gdb) p i
No symbol "i" in current context.
(gdb) p x
$1 = "abc"
最佳回答

听起来像是我可能从编译器的存在中得到优化的变量。 您尝试过调试结构吗?

您可以使用 go building - gclags - N

问题回答

暂无回答




相关问题
tell gdb to disassemble "unknown" code

is it possible to configure gdb in order to debug assembly code when there are no debug symbols or no sources available ? I mean showing assembly instruction by assembly instruction when performing a ...

C++ Netbeans debugging issues

I installed netbeans6.7.1 ide for c/c++ also i have mingw/msys cygwin installed and i have given C:Msysin as environment variable path.It has gdb7 version.However wheni run dbugging thru netbeans ...

setting strings in gdb

c++: int main() { string a = "a"; ... ... } when i debug in gdb: (gdb) set var a = "ok" Invalid cast I run the program and pause at a break point after string a has been ...

How to debug programms written in fasm under linux using gdb?

I wrote simple "hello, world" in fasm, and its works, but how i can generate debug info for gdb and edb (Evan s Debugger)? Fasm compiler could only produce debugging symbols in its specific format - "...

How can I display Unicode strings while debugging on linux?

I have been working for some years now as C++ Developer using MS Visual Studio as working platform. Since I privately prefer to use linux, I recently took the chance to move my working environment to ...

Continue to debug after failed assertion on Linux?

When an assertion fails with Visual C++ on Windows, the debugger stops, displays the message, and then lets you continue (or, if no debugging session is running, offers to launch visual studio for you)...

热门标签