Skip to content

Instantly share code, notes, and snippets.

@stapelberg
Created January 16, 2024 13:00
Show Gist options
  • Save stapelberg/8a752b5363bf5329aff446779e267636 to your computer and use it in GitHub Desktop.
Save stapelberg/8a752b5363bf5329aff446779e267636 to your computer and use it in GitHub Desktop.
(dlv) b main.main
Breakpoint 1 set at 0x48004e for main.main() ./debugme.go:5
(dlv) c
> main.main() ./debugme.go:5 (hits goroutine(1):1 total:1) (PC: 0x48004e)
1: package main
2:
3: import "os"
4:
=> 5: func main() {
6: fi, _ := os.Lstat("/this/path/does/not/exist")
7: fi.Size()
8: }
(dlv) next
> main.main() ./debugme.go:6 (PC: 0x480052)
1: package main
2:
3: import "os"
4:
5: func main() {
=> 6: fi, _ := os.Lstat("/this/path/does/not/exist")
7: fi.Size()
8: }
(dlv)
> main.main() ./debugme.go:7 (PC: 0x4800bf)
2:
3: import "os"
4:
5: func main() {
6: fi, _ := os.Lstat("/this/path/does/not/exist")
=> 7: fi.Size()
8: }
(dlv)
> [unrecovered-panic] runtime.fatalpanic() /usr/lib/go-1.21/src/runtime/panic.go:1188 (hits goroutine(1):1 total:1) (PC: 0x4353e4)
Warning: debugging optimized function
runtime.curg._panic.arg: interface {}(string) "runtime error: invalid memory address or nil pointer dereference"
1183: // fatalpanic implements an unrecoverable panic. It is like fatalthrow, except
1184: // that if msgs != nil, fatalpanic also prints panic messages and decrements
1185: // runningPanicDefers once main is blocked from exiting.
1186: //
1187: //go:nosplit
=>1188: func fatalpanic(msgs *_panic) {
1189: pc := getcallerpc()
1190: sp := getcallersp()
1191: gp := getg()
1192: var docrash bool
1193: // Switch to the system stack to avoid any stack growth, which
(dlv) bt
0 0x00000000004353e4 in runtime.fatalpanic
at /usr/lib/go-1.21/src/runtime/panic.go:1188
1 0x0000000000434bb9 in runtime.gopanic
at /usr/lib/go-1.21/src/runtime/panic.go:1017
2 0x000000000043373e in runtime.panicmem
at /usr/lib/go-1.21/src/runtime/panic.go:261
3 0x000000000044a0a5 in runtime.sigpanic
at /usr/lib/go-1.21/src/runtime/signal_unix.go:861
4 0x00000000004800bf in main.main
at ./debugme.go:6
5 0x0000000000437787 in runtime.main
at /usr/lib/go-1.21/src/runtime/proc.go:267
6 0x0000000000461de1 in runtime.goexit
at /usr/lib/go-1.21/src/runtime/asm_amd64.s:1650
(dlv) frame 4
> [unrecovered-panic] runtime.fatalpanic() /usr/lib/go-1.21/src/runtime/panic.go:1188 (hits goroutine(1):1 total:1) (PC: 0x4353e4)
Warning: debugging optimized function
Frame 4: ./debugme.go:6 (PC: 4800bf)
1: package main
2:
3: import "os"
4:
5: func main() {
=> 6: fi, _ := os.Lstat("/this/path/does/not/exist")
7: fi.Size()
8: }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment