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
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)
}
// 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
"os/exec"
"path/filepath"
"runtime"
+ "runtime/debug"
. "runtime/debug"
"strings"
"testing"
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")
// 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.