在golang exe的GDB中展开goroutine的堆栈';s堆芯转储

在golang exe的GDB中展开goroutine的堆栈';s堆芯转储,go,gdb,core,Go,Gdb,Core,我需要分析一些用Golang编写的服务器的核心转储文件。但是我不能使用GDB来释放堆栈信息(甚至一点有用的信息) 例如,我有一个main.go,它的代码是: package main func main(){ panic("stupid") } 我使用以下方法获取核心文件: ulimit -c unlimited GOTRACEBACK=crash ./main 然后我运行gdb主核。在gdb中,如下所示 xxx@ubuntu:/tmp/crash$ gdb main core G

我需要分析一些用Golang编写的服务器的核心转储文件。但是我不能使用GDB来释放堆栈信息(甚至一点有用的信息)

例如,我有一个main.go,它的代码是:

package main

func main(){
    panic("stupid")
}
我使用以下方法获取核心文件:

ulimit -c unlimited
GOTRACEBACK=crash ./main
然后我运行
gdb主核
。在gdb中,如下所示

xxx@ubuntu:/tmp/crash$ gdb main core
GNU gdb (Ubuntu 7.12.50.20170314-0ubuntu1.1) 7.12.50.20170314-git
Copyright (C) 2017 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-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from main...done.
[New LWP 5735]
[New LWP 5736]
[New LWP 5738]
[New LWP 5739]
[New LWP 5737]
Core was generated by `./main'.
Program terminated with signal SIGABRT, Aborted.
#0  runtime.raise () at /usr/lib/go-1.7/src/runtime/sys_linux_amd64.s:110
110        RET
[Current thread is 1 (LWP 5735)]
(gdb) source /usr/share/go-1.7/src/runtime/runtime-gdb.py
Loading Go Runtime support.
(gdb) info goroutines
* 1 running  runtime.systemstack_switch
  2 waiting  runtime.gopark
  3 waiting  runtime.gopark
(gdb) goroutine 1 bt
Python Exception <class 'gdb.error'> You can't do that without a process to debug.: 
Error occurred in Python command: You can't do that without a process to debug.
(gdb) goroutine 1 info r
Python Exception <class 'gdb.error'> You can't do that without a process to debug.: 
Error occurred in Python command: You can't do that without a process to debug.
xxx@ubuntu:/tmp/crash$gdb主核心
GNU gdb(Ubuntu 7.12.50.20170314-0ubuntu1.1)7.12.50.20170314-git
版权所有(C)2017免费软件基金会。
许可证GPLv3+:GNU GPL版本3或更高版本
这是自由软件:您可以自由更改和重新发布它。
在法律允许的范围内,不存在任何担保。键入“显示复制”
和“显示保修”了解详细信息。
此GDB配置为“x86_64-linux-gnu”。
键入“显示配置”以获取配置详细信息。
有关错误报告说明,请参阅:
.
在线查找GDB手册和其他文档资源,网址为:
.
要获得帮助,请键入“帮助”。
键入“apropos word”以搜索与“word”相关的命令。。。
从主菜单中读取符号…完成。
[新LWP 5735]
[新LWP 5736]
[新LWP 5738]
[新LWP 5739]
[新LWP 5737]
核心由“./main”生成。
程序以信号SIGABRT终止,中止。
#0 runtime.raise()位于/usr/lib/go-1.7/src/runtime/sys_linux_amd64.s:110
110 RET
[当前线程为1(LWP 5735)]
(gdb)source/usr/share/go-1.7/src/runtime/runtime-gdb.py
加载Go运行时支持。
(gdb)信息goroutines
*1正在运行runtime.systemstack\u开关
2.gopark
3.gopark
(gdb)goroutine 1 bt
Python异常如果没有要调试的进程,则无法执行此操作:
Python命令中出现错误:如果没有要调试的进程,则无法执行此操作。
(gdb)goroutine 1信息r
Python异常如果没有要调试的进程,则无法执行此操作:
Python命令中出现错误:如果没有要调试的进程,则无法执行此操作。

我在这里找到了,但它没有给我一个解决方案,所以任何人都可以告诉我如何查看goroutine信息,比如核心转储中的堆栈跟踪?任何解决方案都将不胜感激,谢谢

不幸的是,gdb对golang的支持非常弱。通常,最好使用delve调试器

dlv core ./hello core.546
> bt
> ls
delve调试器的命令名为dlv。使用bt,您可以获得回溯,并列出代码/程序集的相应部分

有关调试器的信息,请访问