]> Cypherpunks repositories - gostls13.git/commit
runtime: implement traceback iterator
authorAustin Clements <austin@google.com>
Thu, 14 Jul 2022 16:22:24 +0000 (12:22 -0400)
committerAustin Clements <austin@google.com>
Fri, 10 Mar 2023 17:59:29 +0000 (17:59 +0000)
commitf758d648b0aea95b10713864f20c957412ff9193
treef1a3be500ca7c66f5470a66ba88ad4ec16e66361
parent86b69ef329c346fc6cc9b262e97bbdce7322288c
runtime: implement traceback iterator

Currently, all stack walking logic is in one venerable, large, and
very, very complicated function: runtime.gentraceback. This function
has three distinct operating modes: printing, populating a PC buffer,
or invoking a callback. And it has three different modes of unwinding:
physical Go frames, inlined Go frames, and cgo frames. It also has
several flags. All of this logic is very interwoven.

This CL reimplements the monolithic gentraceback function as an
"unwinder" type with an iterator API. It moves all of the logic for
stack walking into this new type, and gentraceback is now a
much-simplified wrapper around the new unwinder type that still
implements printing, populating a PC buffer, and invoking a callback.
Follow-up CLs will replace uses of gentraceback with direct uses of
unwinder.

Exposing traceback functionality as an iterator API will enable a lot
of follow-up work such as simplifying the open-coded defer
implementation (which should in turn help with #26813 and #37233),
printing the bottom of deep stacks (#7181), and eliminating the small
limit on CPU stacks in profiles (#56029).

Fixes #54466.

Change-Id: I36e046dc423c9429c4f286d47162af61aff49a0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/458218
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
src/runtime/crash_unix_test.go
src/runtime/runtime2.go
src/runtime/symtab.go
src/runtime/traceback.go