]> Cypherpunks repositories - gostls13.git/commit
runtime: add GODEBUG=tracebacklabels=1 to include pprof labels in tracebacks
authorDavid Finkel <davidf@vimeo.com>
Fri, 23 May 2025 20:04:08 +0000 (16:04 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 25 Nov 2025 04:07:56 +0000 (20:07 -0800)
commit6851795fb6cda61e2c8396c36da187a2bd87b29e
tree26c06ff565a5e5910dfce7b28f180023b8699feb
parent0921e1db83d3e67032999b5a2f54f5ede8ba39b5
runtime: add GODEBUG=tracebacklabels=1 to include pprof labels in tracebacks

Copy LabelSet to an internal package as label.Set, and include (escaped)
labels within goroutine stack dumps.

Labels are added to the goroutine header as quoted key:value pairs, so
the line may get long if there are a lot of labels.

To handle escaping, we add a printescaped function to the
runtime and hook it up to the print function in the compiler with a new
runtime.quoted type that's a sibling to runtime.hex. (in fact, we
leverage some of the machinery from printhex to generate escape
sequences).

The escaping can be improved for printable runes outside basic ASCII
(particularly for languages using non-latin stripts). Additionally,
invalid UTF-8 can be improved.

So we can experiment with the output format make this opt-in via a
a new tracebacklabels GODEBUG var.

Updates #23458
Updates #76349

Change-Id: I08e78a40c55839a809236fff593ef2090c13c036
Reviewed-on: https://go-review.googlesource.com/c/go/+/694119
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
19 files changed:
doc/godebug.md
src/cmd/compile/internal/typecheck/_builtin/runtime.go
src/cmd/compile/internal/typecheck/builtin.go
src/cmd/compile/internal/walk/builtin.go
src/cmd/internal/goobj/builtinlist.go
src/go/build/deps_test.go
src/internal/runtime/pprof/label/labelset.go [new file with mode: 0644]
src/runtime/export_test.go
src/runtime/pprof/label.go
src/runtime/pprof/label_test.go
src/runtime/pprof/pprof.go
src/runtime/pprof/pprof_test.go
src/runtime/pprof/proto.go
src/runtime/pprof/runtime_test.go
src/runtime/print.go
src/runtime/print_quoted_test.go [new file with mode: 0644]
src/runtime/runtime1.go
src/runtime/traceback.go
src/runtime/traceback_test.go