]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/debug: eliminate temporary variadicity from SetCrashOutput
authorAlan Donovan <adonovan@google.com>
Wed, 15 May 2024 21:41:56 +0000 (17:41 -0400)
committerAlan Donovan <adonovan@google.com>
Thu, 16 May 2024 15:19:04 +0000 (15:19 +0000)
Updates #67182

Change-Id: I33fc8c515f4a9d120262ba30f61aea80ede5e9f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/585420
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Austin Clements <austin@google.com>
api/next/42888.txt
src/runtime/debug/example_monitor_test.go
src/runtime/debug/stack.go
src/runtime/debug/stack_test.go
src/runtime/traceback_system_test.go

index dcba97b9fa136a4f8a76aeac877cf70194292f52..279536f2abe5bd0ab64151444616fd140162cd33 100644 (file)
@@ -1,2 +1,2 @@
 pkg runtime/debug, type CrashOptions struct #67182
-pkg runtime/debug, func SetCrashOutput(*os.File, ...CrashOptions) error #42888
+pkg runtime/debug, func SetCrashOutput(*os.File, CrashOptions) error #42888
index 5a1f4e1417bc550f2f4acbdf334be7d7208a9575..b077e7adb3139b0086998023521acc0e0d63489e 100644 (file)
@@ -91,7 +91,7 @@ func monitor() {
        if err != nil {
                log.Fatalf("StdinPipe: %v", err)
        }
-       debug.SetCrashOutput(pipe.(*os.File)) // (this conversion is safe)
+       debug.SetCrashOutput(pipe.(*os.File), debug.CrashOptions{}) // (this conversion is safe)
        if err := cmd.Start(); err != nil {
                log.Fatalf("can't start monitor: %v", err)
        }
index dc7dc5d569e53ba15bfe272cec5a902180a6270a..d7a860b7dc941bceb2ac230c3b5bf51bed431586 100644 (file)
@@ -46,14 +46,7 @@ type CrashOptions struct {
 // To disable this additional crash output, call SetCrashOutput(nil).
 // If called concurrently with a crash, some in-progress output may be written
 // to the old file even after an overriding SetCrashOutput returns.
-//
-// TODO(adonovan): the variadic ... is a short-term measure to avoid
-// breaking the call in x/telemetry; it will be removed before the
-// go1.23 freeze.
-func SetCrashOutput(f *os.File, opts ...CrashOptions) error {
-       if len(opts) > 1 {
-               panic("supply at most 1 CrashOptions")
-       }
+func SetCrashOutput(f *os.File, opts CrashOptions) error {
        fd := ^uintptr(0)
        if f != nil {
                // The runtime will write to this file descriptor from
index 289749ccb4982b90d9c2d55955581a5e50cbca4b..e1559303f05fe08f7219ed39c482169d22f9f391 100644 (file)
@@ -13,6 +13,7 @@ import (
        "os/exec"
        "path/filepath"
        "runtime"
+       "runtime/debug"
        . "runtime/debug"
        "strings"
        "testing"
@@ -29,7 +30,7 @@ func TestMain(m *testing.M) {
                if err != nil {
                        log.Fatal(err)
                }
-               if err := SetCrashOutput(f); err != nil {
+               if err := SetCrashOutput(f, debug.CrashOptions{}); err != nil {
                        log.Fatal(err) // e.g. EMFILE
                }
                println("hello")
index 5131e44e64bbb2d42ac419f9c161703e9097a0ad..ece58e806d51c1f7638d9e03a2e7f46db9be8355 100644 (file)
@@ -28,7 +28,7 @@ func crash() {
        // Ensure that we get pc=0x%x values in the traceback.
        debug.SetTraceback("system")
        writeSentinel(os.Stdout)
-       debug.SetCrashOutput(os.Stdout)
+       debug.SetCrashOutput(os.Stdout, debug.CrashOptions{})
 
        go func() {
                // This call is typically inlined.