gocore: record global pointers not described in DWARF as roots

Currently globals are entirely defined by what we can find in DWARF, but
there are some globals (for example, runtime..interfaceSwitch.0) which
have no corresponding DWARF. This is problematic, because markObjects
uses the full set of global pointers *instead of* the roots we found to
mark objects. This is more precise, but creates a discrepancy, and
callers (such as the dominator functionality) can't actually find a path
to all listed objects.

Fix this by walking all these undescribed global pointers and recording
them explicitly as "unknown" roots. This makes viewcore much more robust
to future changes, at the expense of not being able to type the
undescribed things it finds.

This change also refactors ForEachRootPtr's internals into something
that could be executed from markObjects, and refactors markObjects to be
simpler and use the Process APIs.

Goroutine stack roots already do this, but globals do not, causing
certain intuitive invariants (like that each object in ForEachObject
should be reachable from ForEachRoot) to be violated.

Change-Id: Ie170098e5e5df929bbef5dee47b068de213a89a4
Reviewed-on: https://go-review.googlesource.com/c/debug/+/637876
Auto-Submit: Nicolas Hillegeer <aktau@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
5 files changed
tree: c7dd51bd39121c1752a458ae31f8cbdef9ffe8f5
  1. cmd/
  2. dwtest/
  3. internal/
  4. third_party/
  5. codereview.cfg
  6. CONTRIBUTING.md
  7. go.mod
  8. go.sum
  9. LICENSE
  10. README.md
README.md

Go Debug

Go Reference

This repository holds utilities and libraries for debugging Go programs.

WARNING! Please expect breaking changes and unstable APIs. Most of them are currently are at an early, experimental stage.

Report Issues / Send Patches

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.