aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/export_test.go
diff options
context:
space:
mode:
authorDavid Finkel <davidf@vimeo.com>2025-05-23 16:04:08 -0400
committerGopher Robot <gobot@golang.org>2025-11-24 20:07:56 -0800
commit6851795fb6cda61e2c8396c36da187a2bd87b29e (patch)
tree26c06ff565a5e5910dfce7b28f180023b8699feb /src/runtime/export_test.go
parent0921e1db83d3e67032999b5a2f54f5ede8ba39b5 (diff)
downloadgo-6851795fb6cda61e2c8396c36da187a2bd87b29e.tar.xz
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>
Diffstat (limited to 'src/runtime/export_test.go')
-rw-r--r--src/runtime/export_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go
index 6e0360aaca..26341c4300 100644
--- a/src/runtime/export_test.go
+++ b/src/runtime/export_test.go
@@ -2064,3 +2064,15 @@ func HexdumpWords(p, bytes uintptr) string {
}
return string(buf[:n])
}
+
+// DumpPrintQuoted provides access to print(quoted()) for the tests in
+// runtime/print_quoted_test.go, allowing us to test that implementation.
+func DumpPrintQuoted(s string) string {
+ gp := getg()
+ gp.writebuf = make([]byte, 0, 1<<20)
+ print(quoted(s))
+ buf := gp.writebuf
+ gp.writebuf = nil
+
+ return string(buf)
+}