上卷 程序设计
中卷 标准库
- bufio 1.18
- bytes 1.18
- io 1.18
- container 1.18
- encoding 1.18
- crypto 1.18
- hash 1.18
- index 1.18
- sort 1.18
- context 1.18
- database 1.18
- connection
- query
- queryrow
- exec
- prepare
- transaction
- scan & null
- context
- tcp
- udp
- http
- server
- handler
- client
- h2、tls
- url
- rpc
- exec
- signal
- embed 1.18
- plugin 1.18
- reflect 1.18
- runtime 1.18
- KeepAlived
- ReadMemStats
- SetFinalizer
- Stack
- sync 1.18
- atomic
- mutex
- rwmutex
- waitgroup
- cond
- once
- map
- pool
- copycheck
- nocopy
- unsafe 1.18
- fmt 1.18
- log 1.18
- math 1.18
- time 1.18
- timer
下卷 运行时
源码剖析
附录
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
GOTRACEBACK
控制进程崩溃(panic, runtime)时输出的调用堆栈跟踪信息。
默认仅输出当前 goroutine 堆栈信息,返回错误码(exit code) 2
,忽略运行时内部函数调用。
none
: 忽略堆栈跟踪信息。single
: 默认。all
: 所有 goroutine 堆栈信息。system
: 类似 all,但堆栈信息包含运行时函数。crash
: 类似 system,但以操作系统规范退出。
提示:crash 方式在 UNIX 系统中,会引发 SIGABRT,生成 core dump 文件。
也可在 crash 方式时,通过
ctrl + \
主动引发崩溃,生成 core dump 文件。
package main import ( "fmt" "time" ) func test(id int) { panic(fmt.Sprintf("%d err", id)) } func main() { for i := 0; i < 3; i++ { go test(i) } time.Sleep(time.Second) }
$ go build -o test $ ulimit -c unlimited $ GOTRACEBACK=crash ./test Aborted (core dumped)
$ dlv core ./test core (dlv) bt 0 0x000000000045c041 in runtime.raise at /usr/local/go/src/runtime/sys_linux_amd64.s:168 1 0x0000000000443865 in runtime.dieFromSignal at /usr/local/go/src/runtime/signal_unix.go:852 2 0x0000000000443e36 in runtime.sigfwdgo at /usr/local/go/src/runtime/signal_unix.go:1066 3 0x0000000000442587 in runtime.sigtrampgo at /usr/local/go/src/runtime/signal_unix.go:430 4 0x000000000045cd8e in runtime.sigtrampgo at <autogenerated>:1 5 0x000000000045c31d in runtime.sigtramp at /usr/local/go/src/runtime/sys_linux_amd64.s:361 6 0x000000000045c420 in runtime.sigreturn at /usr/local/go/src/runtime/sys_linux_amd64.s:466 7 0x000000000042ffc9 in runtime.crash at /usr/local/go/src/runtime/signal_unix.go:944 8 0x000000000042ffc9 in runtime.fatalpanic at /usr/local/go/src/runtime/panic.go:1092 9 0x000000000042f797 in runtime.gopanic at /usr/local/go/src/runtime/panic.go:941 10 0x000000000047e3a5 in main.test at ./main.go:9 11 0x000000000047e466 in main.main.func1 at ./main.go:14 12 0x000000000045a741 in runtime.goexit at /usr/local/go/src/runtime/asm_amd64.s:1571 (dlv) frame 10 > runtime.raise() /usr/local/go/src/runtime/sys_linux_amd64.s:168 (PC: 0x45c041) Warning: debugging optimized function Frame 10: ./main.go:9 (PC: 47e3a5) 4: "fmt" 5: "time" 6: ) 7: 8: func test(id int) { => 9: panic(fmt.Sprintf("%d err", id)) 10: } 11: 12: func main() { 13: for i := 0; i < 3; i++ { 14: go test(i)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论