github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/runtime/trace.go (about) 1 // Copyright 2014 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build !goexperiment.exectracer2 6 7 // Go execution tracer. 8 // The tracer captures a wide range of execution events like goroutine 9 // creation/blocking/unblocking, syscall enter/exit/block, GC-related events, 10 // changes of heap size, processor start/stop, etc and writes them to a buffer 11 // in a compact form. A precise nanosecond-precision timestamp and a stack 12 // trace is captured for most events. 13 // See https://golang.org/s/go15trace for more info. 14 15 package runtime 16 17 // StartTraceは現在のプロセスのトレースを有効にします。 18 // トレース中はデータがバッファされ、[ReadTrace] を介して利用可能です。 19 // トレースが既に有効化されている場合、StartTraceはエラーを返します。 20 // ほとんどのクライアントは [runtime/trace] パッケージや [testing] パッケージの-test.traceフラグを直接呼び出す代わりに使用するべきです。 21 func StartTrace() error 22 23 // StopTraceは、以前に有効にされていた場合にトレースを停止します。 24 // StopTraceは、トレースのすべての読み取りが完了するまで戻りません。 25 func StopTrace() 26 27 // ReadTrace はバイナリ追跡データの次のチャンクを返します。データが利用可能になるまでブロックされます。もし追跡がオフになっており、オンの間に蓄積されたデータがすべて返された場合、ReadTrace は nil を返します。呼び出し元は、再度 ReadTrace を呼び出す前に返されたデータをコピーする必要があります。 28 // ReadTrace は一度に1つの goroutine から呼び出す必要があります。 29 func ReadTrace() []byte