mirror of
https://github.com/golang/go
synced 2024-11-05 15:16:11 -07:00
0e9f43fcb6
Moves runtime/trace support (including its command line flag) behind a "gc" build tag to allow goimports to build under gccgo, which does not support runtime/trace. Updates golang/go#15544. Change-Id: I017a44089c0a4f3d3ba98815d57a141e25b3fe56 Reviewed-on: https://go-review.googlesource.com/26998 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
27 lines
483 B
Go
27 lines
483 B
Go
// Copyright 2016 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build gc
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"runtime/trace"
|
|
)
|
|
|
|
var traceProfile = flag.String("trace", "", "trace profile output")
|
|
|
|
func doTrace() func() {
|
|
if *traceProfile != "" {
|
|
bw, flush := bufferedFileWriter(*traceProfile)
|
|
trace.Start(bw)
|
|
return func() {
|
|
flush()
|
|
trace.Stop()
|
|
}
|
|
}
|
|
return func() {}
|
|
}
|