internal/gocore: move core of runReachable to Process.Reachable
...and turn it into an iteration so that we can later offer the option
to printe more (all) paths.
Having Process.Reachable also makes it easier to write a test for some
upcoming functionality (defer/panic as roots). In all, it seems like a
nicer separation of concerns.
I tested the main functionality by comparing the output pre- and
post-this CL. It looks identical:
$ ~/gob/go/debug-readonly/viewcore ~/tmp/viewcore/core.server_test.3024 --exe ~/tmp/viewcore/server_test --base ~/src/server reachable 203cbbf287e8 2>/dev/null
rpc.NewStreamImpl.func1
rpc.(*eventQueue).pop.q →
203cbc0dba40 rpc.eventQueue .list.ptr →
203cbbf287e8 *rpc.clientEvent
The output of the test is the more similar to the way I'd like to show
this output in the end:
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513aa8 main.main.func1.gowrap7
gocore_test.go:481: 0x55a36e512ed4 main.complicatedRetain
gocore_test.go:512: unk [SP+0x108] 0xc000047fa0 (unsafe.Pointer) → 0xc00009a0a0 (main.myObj)
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513aa8 main.main.func1.gowrap7
gocore_test.go:481: 0x55a36e512ed4 main.complicatedRetain
gocore_test.go:512: unk [SP+0xe8] 0xc000047f80 (unsafe.Pointer) → 0xc00009a0a0 (main.myObj)
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513aa8 main.main.func1.gowrap7
gocore_test.go:481: 0x55a36e512ed4 main.complicatedRetain
gocore_test.go:512: unk [SP+0xc8] 0xc000047f60 (unsafe.Pointer) → 0xc00009a0a0 (main.myObj)
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513aa8 main.main.func1.gowrap7
gocore_test.go:481: 0x55a36e512ed4 main.complicatedRetain
gocore_test.go:512: unk [SP+0x50] 0xc000047ee8 (unsafe.Pointer) → 0xc00009a0a0 (main.myObj)
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513aa8 main.main.func1.gowrap7
gocore_test.go:481: 0x55a36e512ed4 main.complicatedRetain
gocore_test.go:512: ref [SP+0x120] 0xc000047fb8 (*main.myObj) → 0xc00009a0a0 (main.myObj)
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513b08 main.main.func1.gowrap6
gocore_test.go:481: 0x55a36e5135c8 main.hardAliasRetain
gocore_test.go:512: otherRef [SP+0x20] 0xc000047790 (*main.myObj) → 0xc00009a0a0 (main.myObj)
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513b08 main.main.func1.gowrap6
gocore_test.go:481: 0x55a36e5135c8 main.hardAliasRetain
gocore_test.go:512: ref [SP+0x48] 0xc0000477b8 (*main.myObj) → 0xc00009a0a0 (main.myObj)
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513b68 main.main.func1.gowrap5
gocore_test.go:481: 0x55a36e5134d7 main.aliasRetain
gocore_test.go:512: otherRef [SP+0x30] 0xc000046fb8 (*main.myObj) → 0xc00009a0a0 (main.myObj)
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513b68 main.main.func1.gowrap5
gocore_test.go:481: 0x55a36e5134d7 main.aliasRetain
gocore_test.go:512: ref [SP+0x30] 0xc000046fb8 (*main.myObj) → 0xc00009a0a0 (main.myObj)
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513bc8 main.main.func1.gowrap4
gocore_test.go:481: 0x55a36e513347 main.hardRenameRetain
gocore_test.go:512: otherRef [SP+0x18] 0xc000046798 (*main.myObj) → 0xc00009a0a0 (main.myObj)
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513c28 main.main.func1.gowrap3
gocore_test.go:481: 0x55a36e513273 main.renameRetain
gocore_test.go:512: otherRef [SP+0x30] 0xc000045fb8 (*main.myObj) → 0xc00009a0a0 (main.myObj)
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513c28 main.main.func1.gowrap3
gocore_test.go:481: 0x55a36e513273 main.renameRetain
gocore_test.go:512: ref [SP+0x30] 0xc000045fb8 (*main.myObj) → 0xc00009a0a0 (main.myObj)
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513c88 main.main.func1.gowrap2
gocore_test.go:481: 0x55a36e5133f3 main.multiFrame1Retain
gocore_test.go:481: 0x55a36e513433 main.multiFrame2Retain
gocore_test.go:481: 0x55a36e513473 main.multiFrame3Retain
gocore_test.go:481: 0x55a36e5131b3 main.retain
gocore_test.go:512: ref [SP+0x30] 0xc000045740 (*main.myObj) → 0xc00009a0a0 (main.myObj)
gocore_test.go:475: [goroutine]
gocore_test.go:481: 0x55a36e513ce8 main.main.func1.gowrap1
gocore_test.go:481: 0x55a36e5131b3 main.retain
gocore_test.go:512: ref [SP+0x30] 0xc000044fb8 (*main.myObj) → 0xc00009a0a0 (main.myObj)
gocore_test.go:473: [global]
gocore_test.go:512: main.gPlainMyObj 0x55a36e65d080 (*main.myObj) → 0xc00009a0a0 (main.myObj)
Change-Id: I953e39fc0c3357c7c636144e80c42a6fd2d737b2
Reviewed-on: https://go-review.googlesource.com/c/debug/+/750481
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Nicolas Hillegeer <aktau@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This repository holds utilities and libraries for debugging Go programs.
WARNING! Please expect breaking changes and unstable APIs. Most of them are currently at an early, experimental stage.
This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://go.dev/doc/contribute.
The git repository is https://go.googlesource.com/debug.
The main issue tracker for the debug repository is located at https://go.dev/issues. Prefix your issue with “x/debug:” in the subject line, so it is easy to find.