2014-01-24 65 views
2

我正在学习使用gdb来调试Go程序。 Go版本是1.2,并且在linux/amd64上运行。为什么gdb输出致命错误?

的围棋程序是非常简单的:

package main 
import "fmt" 
func main(){ 
    fmt.Printf("hello, world\n"); 
} 

当用gdb调试它,gdb的输出

$ gdb hello 
GNU gdb (GDB) 7.6 
Copyright (C) 2013 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. 
This GDB was configured as "x86_64-unknown-linux-gnu". 
For bug reporting instructions, please see: 
<http://www.gnu.org/software/gdb/bugs/>... 
Reading symbols from /data2/home/nanxiao/hello...done. 
Loading Go Runtime support. 
(gdb) start 
Temporary breakpoint 1 at 0x400c00: file /data2/home/nanxiao/hello.go, line 3. 
Starting program: /data2/home/nanxiao/hello 

Temporary breakpoint 1, main.main() at /data2/home/nanxiao/hello.go:3 
3  func main(){ 
(gdb) n 
runtime: pc=0x400c13 0xcc 0xeb 0x48 0x83 0xec 
fatal error: runtime: misuse of rewindmorestack 

runtime stack: 
runtime.throw(0x56325f) 
    /data2/soft/go/src/pkg/runtime/panic.c:464 +0x69 
runtime.rewindmorestack(0xc210001148) 
    /data2/soft/go/src/pkg/runtime/sys_x86.c:41 +0xb4 
runtime.newstack() 
    /data2/soft/go/src/pkg/runtime/stack.c:230 +0x153 
runtime.morestack() 
    /data2/soft/go/src/pkg/runtime/asm_amd64.s:225 +0x61 

按我的理解,运行 “n” 命令之后,GDB应该去下一条语句,输出是:

fmt.Printf("hello, world\n"); 

为什么它输出以下“致命错误”?

runtime: pc=0x400c13 0xcc 0xeb 0x48 0x83 0xec 
fatal error: runtime: misuse of rewindmorestack 

非常感谢!

+0

我不认为它会有所作为,但是如果你使用gdb命令'run'而不是'start',会发生什么? –

+0

@NathanErnst:使用“运行”命令后,程序成功退出。 –

+0

不熟悉'start'命令,我会建议看看'start'和'run'之间的gdb环境差异。 –

回答

相关问题