mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: add available godoc link
Change-Id: Ifb4844efddcb0369b0302eeab72394eeaf5c8072 Reviewed-on: https://go-review.googlesource.com/c/go/+/540022 Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: shuang cui <imcusg@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
fa903593fb
commit
6a1bbca2b3
18 changed files with 43 additions and 43 deletions
|
|
@ -61,8 +61,8 @@ import (
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Some C functions accept a void* argument that points to an arbitrary
|
// Some C functions accept a void* argument that points to an arbitrary
|
||||||
// data value supplied by the caller. It is not safe to coerce a cgo.Handle
|
// data value supplied by the caller. It is not safe to coerce a [cgo.Handle]
|
||||||
// (an integer) to a Go unsafe.Pointer, but instead we can pass the address
|
// (an integer) to a Go [unsafe.Pointer], but instead we can pass the address
|
||||||
// of the cgo.Handle to the void* parameter, as in this variant of the
|
// of the cgo.Handle to the void* parameter, as in this variant of the
|
||||||
// previous example:
|
// previous example:
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -202,8 +202,8 @@ func (p *cpuProfile) addExtra() {
|
||||||
// The details of generating that format have changed,
|
// The details of generating that format have changed,
|
||||||
// so this functionality has been removed.
|
// so this functionality has been removed.
|
||||||
//
|
//
|
||||||
// Deprecated: Use the runtime/pprof package,
|
// Deprecated: Use the [runtime/pprof] package,
|
||||||
// or the handlers in the net/http/pprof package,
|
// or the handlers in the [net/http/pprof] package,
|
||||||
// or the testing package's -test.cpuprofile flag instead.
|
// or the testing package's -test.cpuprofile flag instead.
|
||||||
func CPUProfile() []byte {
|
func CPUProfile() []byte {
|
||||||
panic("CPUProfile no longer available")
|
panic("CPUProfile no longer available")
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
// GOMAXPROCS sets the maximum number of CPUs that can be executing
|
// GOMAXPROCS sets the maximum number of CPUs that can be executing
|
||||||
// simultaneously and returns the previous setting. It defaults to
|
// simultaneously and returns the previous setting. It defaults to
|
||||||
// the value of runtime.NumCPU. If n < 1, it does not change the current setting.
|
// the value of [runtime.NumCPU]. If n < 1, it does not change the current setting.
|
||||||
// This call will go away when the scheduler improves.
|
// This call will go away when the scheduler improves.
|
||||||
func GOMAXPROCS(n int) int {
|
func GOMAXPROCS(n int) int {
|
||||||
if GOARCH == "wasm" && n > 1 {
|
if GOARCH == "wasm" && n > 1 {
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ func SetTraceback(level string)
|
||||||
//
|
//
|
||||||
// The memory limit is always respected by the Go runtime, so to
|
// The memory limit is always respected by the Go runtime, so to
|
||||||
// effectively disable this behavior, set the limit very high.
|
// effectively disable this behavior, set the limit very high.
|
||||||
// math.MaxInt64 is the canonical value for disabling the limit,
|
// [math.MaxInt64] is the canonical value for disabling the limit,
|
||||||
// but values much greater than the available memory on the underlying
|
// but values much greater than the available memory on the underlying
|
||||||
// system work just as well.
|
// system work just as well.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ func PrintStack() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stack returns a formatted stack trace of the goroutine that calls it.
|
// Stack returns a formatted stack trace of the goroutine that calls it.
|
||||||
// It calls runtime.Stack with a large enough buffer to capture the entire trace.
|
// It calls [runtime.Stack] with a large enough buffer to capture the entire trace.
|
||||||
func Stack() []byte {
|
func Stack() []byte {
|
||||||
buf := make([]byte, 1024)
|
buf := make([]byte, 1024)
|
||||||
for {
|
for {
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ func (e errorAddressString) Error() string {
|
||||||
// The address provided is best-effort.
|
// The address provided is best-effort.
|
||||||
// The veracity of the result may depend on the platform.
|
// The veracity of the result may depend on the platform.
|
||||||
// Errors providing this method will only be returned as
|
// Errors providing this method will only be returned as
|
||||||
// a result of using runtime/debug.SetPanicOnFault.
|
// a result of using [runtime/debug.SetPanicOnFault].
|
||||||
func (e errorAddressString) Addr() uintptr {
|
func (e errorAddressString) Addr() uintptr {
|
||||||
return e.addr
|
return e.addr
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
/*
|
/*
|
||||||
Package runtime contains operations that interact with Go's runtime system,
|
Package runtime contains operations that interact with Go's runtime system,
|
||||||
such as functions to control goroutines. It also includes the low-level type information
|
such as functions to control goroutines. It also includes the low-level type information
|
||||||
used by the reflect package; see reflect's documentation for the programmable
|
used by the reflect package; see [reflect]'s documentation for the programmable
|
||||||
interface to the run-time type system.
|
interface to the run-time type system.
|
||||||
|
|
||||||
# Environment Variables
|
# Environment Variables
|
||||||
|
|
@ -285,10 +285,10 @@ func Caller(skip int) (pc uintptr, file string, line int, ok bool) {
|
||||||
// It returns the number of entries written to pc.
|
// It returns the number of entries written to pc.
|
||||||
//
|
//
|
||||||
// To translate these PCs into symbolic information such as function
|
// To translate these PCs into symbolic information such as function
|
||||||
// names and line numbers, use CallersFrames. CallersFrames accounts
|
// names and line numbers, use [CallersFrames]. CallersFrames accounts
|
||||||
// for inlined functions and adjusts the return program counters into
|
// for inlined functions and adjusts the return program counters into
|
||||||
// call program counters. Iterating over the returned slice of PCs
|
// call program counters. Iterating over the returned slice of PCs
|
||||||
// directly is discouraged, as is using FuncForPC on any of the
|
// directly is discouraged, as is using [FuncForPC] on any of the
|
||||||
// returned PCs, since these cannot account for inlining or return
|
// returned PCs, since these cannot account for inlining or return
|
||||||
// program counter adjustment.
|
// program counter adjustment.
|
||||||
func Callers(skip int, pc []uintptr) int {
|
func Callers(skip int, pc []uintptr) int {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ metric sets may not intersect.
|
||||||
|
|
||||||
Metrics are designated by a string key, rather than, for example, a field name in
|
Metrics are designated by a string key, rather than, for example, a field name in
|
||||||
a struct. The full list of supported metrics is always available in the slice of
|
a struct. The full list of supported metrics is always available in the slice of
|
||||||
Descriptions returned by All. Each Description also includes useful information
|
Descriptions returned by [All]. Each [Description] also includes useful information
|
||||||
about the metric.
|
about the metric.
|
||||||
|
|
||||||
Thus, users of this API are encouraged to sample supported metrics defined by the
|
Thus, users of this API are encouraged to sample supported metrics defined by the
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ type Sample struct {
|
||||||
// Implemented in the runtime.
|
// Implemented in the runtime.
|
||||||
func runtime_readMetrics(unsafe.Pointer, int, int)
|
func runtime_readMetrics(unsafe.Pointer, int, int)
|
||||||
|
|
||||||
// Read populates each Value field in the given slice of metric samples.
|
// Read populates each [Value] field in the given slice of metric samples.
|
||||||
//
|
//
|
||||||
// Desired metrics should be present in the slice with the appropriate name.
|
// Desired metrics should be present in the slice with the appropriate name.
|
||||||
// The user of this API is encouraged to re-use the same slice between calls for
|
// The user of this API is encouraged to re-use the same slice between calls for
|
||||||
|
|
@ -32,7 +32,7 @@ func runtime_readMetrics(unsafe.Pointer, int, int)
|
||||||
//
|
//
|
||||||
// Note that re-use has some caveats. Notably, Values should not be read or
|
// Note that re-use has some caveats. Notably, Values should not be read or
|
||||||
// manipulated while a Read with that value is outstanding; that is a data race.
|
// manipulated while a Read with that value is outstanding; that is a data race.
|
||||||
// This property includes pointer-typed Values (for example, Float64Histogram)
|
// This property includes pointer-typed Values (for example, [Float64Histogram])
|
||||||
// whose underlying storage will be reused by Read when possible. To safely use
|
// whose underlying storage will be reused by Read when possible. To safely use
|
||||||
// such values in a concurrent setting, all data must be deep-copied.
|
// such values in a concurrent setting, all data must be deep-copied.
|
||||||
//
|
//
|
||||||
|
|
@ -40,7 +40,7 @@ func runtime_readMetrics(unsafe.Pointer, int, int)
|
||||||
// must share no underlying memory. When in doubt, create a new []Sample from
|
// must share no underlying memory. When in doubt, create a new []Sample from
|
||||||
// scratch, which is always safe, though may be inefficient.
|
// scratch, which is always safe, though may be inefficient.
|
||||||
//
|
//
|
||||||
// Sample values with names not appearing in All will have their Value populated
|
// Sample values with names not appearing in [All] will have their Value populated
|
||||||
// as KindBad to indicate that the name is unknown.
|
// as KindBad to indicate that the name is unknown.
|
||||||
func Read(m []Sample) {
|
func Read(m []Sample) {
|
||||||
runtime_readMetrics(unsafe.Pointer(&m[0]), len(m), cap(m))
|
runtime_readMetrics(unsafe.Pointer(&m[0]), len(m), cap(m))
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ValueKind is a tag for a metric Value which indicates its type.
|
// ValueKind is a tag for a metric [Value] which indicates its type.
|
||||||
type ValueKind int
|
type ValueKind int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
|
|
@ -330,11 +330,11 @@ func isGoPointerWithoutSpan(p unsafe.Pointer) bool {
|
||||||
// There is no guarantee that finalizers will run before a program exits,
|
// There is no guarantee that finalizers will run before a program exits,
|
||||||
// so typically they are useful only for releasing non-memory resources
|
// so typically they are useful only for releasing non-memory resources
|
||||||
// associated with an object during a long-running program.
|
// associated with an object during a long-running program.
|
||||||
// For example, an os.File object could use a finalizer to close the
|
// For example, an [os.File] object could use a finalizer to close the
|
||||||
// associated operating system file descriptor when a program discards
|
// associated operating system file descriptor when a program discards
|
||||||
// an os.File without calling Close, but it would be a mistake
|
// an os.File without calling Close, but it would be a mistake
|
||||||
// to depend on a finalizer to flush an in-memory I/O buffer such as a
|
// to depend on a finalizer to flush an in-memory I/O buffer such as a
|
||||||
// bufio.Writer, because the buffer would not be flushed at program exit.
|
// [bufio.Writer], because the buffer would not be flushed at program exit.
|
||||||
//
|
//
|
||||||
// It is not guaranteed that a finalizer will run if the size of *obj is
|
// It is not guaranteed that a finalizer will run if the size of *obj is
|
||||||
// zero bytes, because it may share same address with other zero-size
|
// zero bytes, because it may share same address with other zero-size
|
||||||
|
|
@ -357,14 +357,14 @@ func isGoPointerWithoutSpan(p unsafe.Pointer) bool {
|
||||||
// the object is reachable until it is no longer required.
|
// the object is reachable until it is no longer required.
|
||||||
// Objects stored in global variables, or that can be found by tracing
|
// Objects stored in global variables, or that can be found by tracing
|
||||||
// pointers from a global variable, are reachable. For other objects,
|
// pointers from a global variable, are reachable. For other objects,
|
||||||
// pass the object to a call of the KeepAlive function to mark the
|
// pass the object to a call of the [KeepAlive] function to mark the
|
||||||
// last point in the function where the object must be reachable.
|
// last point in the function where the object must be reachable.
|
||||||
//
|
//
|
||||||
// For example, if p points to a struct, such as os.File, that contains
|
// For example, if p points to a struct, such as os.File, that contains
|
||||||
// a file descriptor d, and p has a finalizer that closes that file
|
// a file descriptor d, and p has a finalizer that closes that file
|
||||||
// descriptor, and if the last use of p in a function is a call to
|
// descriptor, and if the last use of p in a function is a call to
|
||||||
// syscall.Write(p.d, buf, size), then p may be unreachable as soon as
|
// syscall.Write(p.d, buf, size), then p may be unreachable as soon as
|
||||||
// the program enters syscall.Write. The finalizer may run at that moment,
|
// the program enters [syscall.Write]. The finalizer may run at that moment,
|
||||||
// closing p.d, causing syscall.Write to fail because it is writing to
|
// closing p.d, causing syscall.Write to fail because it is writing to
|
||||||
// a closed file descriptor (or, worse, to an entirely different
|
// a closed file descriptor (or, worse, to an entirely different
|
||||||
// file descriptor opened by a different goroutine). To avoid this problem,
|
// file descriptor opened by a different goroutine). To avoid this problem,
|
||||||
|
|
@ -509,11 +509,11 @@ okarg:
|
||||||
// // No more uses of p after this point.
|
// // No more uses of p after this point.
|
||||||
//
|
//
|
||||||
// Without the KeepAlive call, the finalizer could run at the start of
|
// Without the KeepAlive call, the finalizer could run at the start of
|
||||||
// syscall.Read, closing the file descriptor before syscall.Read makes
|
// [syscall.Read], closing the file descriptor before syscall.Read makes
|
||||||
// the actual system call.
|
// the actual system call.
|
||||||
//
|
//
|
||||||
// Note: KeepAlive should only be used to prevent finalizers from
|
// Note: KeepAlive should only be used to prevent finalizers from
|
||||||
// running prematurely. In particular, when used with unsafe.Pointer,
|
// running prematurely. In particular, when used with [unsafe.Pointer],
|
||||||
// the rules for valid uses of unsafe.Pointer still apply.
|
// the rules for valid uses of unsafe.Pointer still apply.
|
||||||
func KeepAlive(x any) {
|
func KeepAlive(x any) {
|
||||||
// Introduce a use of x that the compiler can't eliminate.
|
// Introduce a use of x that the compiler can't eliminate.
|
||||||
|
|
|
||||||
|
|
@ -792,7 +792,7 @@ func BlockProfile(p []BlockProfileRecord) (n int, ok bool) {
|
||||||
// If len(p) >= n, MutexProfile copies the profile into p and returns n, true.
|
// If len(p) >= n, MutexProfile copies the profile into p and returns n, true.
|
||||||
// Otherwise, MutexProfile does not change p, and returns n, false.
|
// Otherwise, MutexProfile does not change p, and returns n, false.
|
||||||
//
|
//
|
||||||
// Most clients should use the runtime/pprof package
|
// Most clients should use the [runtime/pprof] package
|
||||||
// instead of calling MutexProfile directly.
|
// instead of calling MutexProfile directly.
|
||||||
func MutexProfile(p []BlockProfileRecord) (n int, ok bool) {
|
func MutexProfile(p []BlockProfileRecord) (n int, ok bool) {
|
||||||
lock(&profBlockLock)
|
lock(&profBlockLock)
|
||||||
|
|
@ -1169,7 +1169,7 @@ func goroutineProfileWithLabelsSync(p []StackRecord, labels []unsafe.Pointer) (n
|
||||||
// If len(p) >= n, GoroutineProfile copies the profile into p and returns n, true.
|
// If len(p) >= n, GoroutineProfile copies the profile into p and returns n, true.
|
||||||
// If len(p) < n, GoroutineProfile does not change p and returns n, false.
|
// If len(p) < n, GoroutineProfile does not change p and returns n, false.
|
||||||
//
|
//
|
||||||
// Most clients should use the runtime/pprof package instead
|
// Most clients should use the [runtime/pprof] package instead
|
||||||
// of calling GoroutineProfile directly.
|
// of calling GoroutineProfile directly.
|
||||||
func GoroutineProfile(p []StackRecord) (n int, ok bool) {
|
func GoroutineProfile(p []StackRecord) (n int, ok bool) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -284,7 +284,7 @@ func (s *atomicSpanSetSpinePointer) Load() spanSetSpinePointer {
|
||||||
|
|
||||||
// Stores the spanSetSpinePointer.
|
// Stores the spanSetSpinePointer.
|
||||||
//
|
//
|
||||||
// It has the same semantics as atomic.UnsafePointer.
|
// It has the same semantics as [atomic.UnsafePointer].
|
||||||
func (s *atomicSpanSetSpinePointer) StoreNoWB(p spanSetSpinePointer) {
|
func (s *atomicSpanSetSpinePointer) StoreNoWB(p spanSetSpinePointer) {
|
||||||
s.a.StoreNoWB(p.p)
|
s.a.StoreNoWB(p.p)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,14 @@ type Pinner struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pin pins a Go object, preventing it from being moved or freed by the garbage
|
// Pin pins a Go object, preventing it from being moved or freed by the garbage
|
||||||
// collector until the Unpin method has been called.
|
// collector until the [Pinner.Unpin] method has been called.
|
||||||
//
|
//
|
||||||
// A pointer to a pinned object can be directly stored in C memory or can be
|
// A pointer to a pinned object can be directly stored in C memory or can be
|
||||||
// contained in Go memory passed to C functions. If the pinned object itself
|
// contained in Go memory passed to C functions. If the pinned object itself
|
||||||
// contains pointers to Go objects, these objects must be pinned separately if they
|
// contains pointers to Go objects, these objects must be pinned separately if they
|
||||||
// are going to be accessed from C code.
|
// are going to be accessed from C code.
|
||||||
//
|
//
|
||||||
// The argument must be a pointer of any type or an unsafe.Pointer.
|
// The argument must be a pointer of any type or an [unsafe.Pointer].
|
||||||
// It's safe to call Pin on non-Go pointers, in which case Pin will do nothing.
|
// It's safe to call Pin on non-Go pointers, in which case Pin will do nothing.
|
||||||
func (p *Pinner) Pin(pointer any) {
|
func (p *Pinner) Pin(pointer any) {
|
||||||
if p.pinner == nil {
|
if p.pinner == nil {
|
||||||
|
|
@ -61,7 +61,7 @@ func (p *Pinner) Pin(pointer any) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unpin unpins all pinned objects of the Pinner.
|
// Unpin unpins all pinned objects of the [Pinner].
|
||||||
func (p *Pinner) Unpin() {
|
func (p *Pinner) Unpin() {
|
||||||
p.pinner.unpin()
|
p.pinner.unpin()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ func (l *labelMap) String() string {
|
||||||
return "{" + strings.Join(keyVals, ", ") + "}"
|
return "{" + strings.Join(keyVals, ", ") + "}"
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithLabels returns a new context.Context with the given labels added.
|
// WithLabels returns a new [context.Context] with the given labels added.
|
||||||
// A label overwrites a prior label with the same key.
|
// A label overwrites a prior label with the same key.
|
||||||
func WithLabels(ctx context.Context, labels LabelSet) context.Context {
|
func WithLabels(ctx context.Context, labels LabelSet) context.Context {
|
||||||
parentLabels := labelValue(ctx)
|
parentLabels := labelValue(ctx)
|
||||||
|
|
@ -72,7 +72,7 @@ func WithLabels(ctx context.Context, labels LabelSet) context.Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Labels takes an even number of strings representing key-value pairs
|
// Labels takes an even number of strings representing key-value pairs
|
||||||
// and makes a LabelSet containing them.
|
// and makes a [LabelSet] containing them.
|
||||||
// A label overwrites a prior label with the same key.
|
// A label overwrites a prior label with the same key.
|
||||||
// Currently only the CPU and goroutine profiles utilize any labels
|
// Currently only the CPU and goroutine profiles utilize any labels
|
||||||
// information.
|
// information.
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ import (
|
||||||
// mutex - stack traces of holders of contended mutexes
|
// mutex - stack traces of holders of contended mutexes
|
||||||
//
|
//
|
||||||
// These predefined profiles maintain themselves and panic on an explicit
|
// These predefined profiles maintain themselves and panic on an explicit
|
||||||
// Add or Remove method call.
|
// [Profile.Add] or [Profile.Remove] method call.
|
||||||
//
|
//
|
||||||
// The heap profile reports statistics as of the most recently completed
|
// The heap profile reports statistics as of the most recently completed
|
||||||
// garbage collection; it elides more recent allocation to avoid skewing
|
// garbage collection; it elides more recent allocation to avoid skewing
|
||||||
|
|
@ -127,7 +127,7 @@ import (
|
||||||
// the program began (including garbage-collected bytes).
|
// the program began (including garbage-collected bytes).
|
||||||
//
|
//
|
||||||
// The CPU profile is not available as a Profile. It has a special API,
|
// The CPU profile is not available as a Profile. It has a special API,
|
||||||
// the StartCPUProfile and StopCPUProfile functions, because it streams
|
// the [StartCPUProfile] and [StopCPUProfile] functions, because it streams
|
||||||
// output to a writer during profiling.
|
// output to a writer during profiling.
|
||||||
type Profile struct {
|
type Profile struct {
|
||||||
name string
|
name string
|
||||||
|
|
@ -242,7 +242,7 @@ func Profiles() []*Profile {
|
||||||
return all
|
return all
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name returns this profile's name, which can be passed to Lookup to reobtain the profile.
|
// Name returns this profile's name, which can be passed to [Lookup] to reobtain the profile.
|
||||||
func (p *Profile) Name() string {
|
func (p *Profile) Name() string {
|
||||||
return p.name
|
return p.name
|
||||||
}
|
}
|
||||||
|
|
@ -260,9 +260,9 @@ func (p *Profile) Count() int {
|
||||||
// Add adds the current execution stack to the profile, associated with value.
|
// Add adds the current execution stack to the profile, associated with value.
|
||||||
// Add stores value in an internal map, so value must be suitable for use as
|
// Add stores value in an internal map, so value must be suitable for use as
|
||||||
// a map key and will not be garbage collected until the corresponding
|
// a map key and will not be garbage collected until the corresponding
|
||||||
// call to Remove. Add panics if the profile already contains a stack for value.
|
// call to [Profile.Remove]. Add panics if the profile already contains a stack for value.
|
||||||
//
|
//
|
||||||
// The skip parameter has the same meaning as runtime.Caller's skip
|
// The skip parameter has the same meaning as [runtime.Caller]'s skip
|
||||||
// and controls where the stack trace begins. Passing skip=0 begins the
|
// and controls where the stack trace begins. Passing skip=0 begins the
|
||||||
// trace in the function calling Add. For example, given this
|
// trace in the function calling Add. For example, given this
|
||||||
// execution stack:
|
// execution stack:
|
||||||
|
|
@ -515,7 +515,7 @@ func printStackRecord(w io.Writer, stk []uintptr, allFrames bool) {
|
||||||
|
|
||||||
// Interface to system profiles.
|
// Interface to system profiles.
|
||||||
|
|
||||||
// WriteHeapProfile is shorthand for Lookup("heap").WriteTo(w, 0).
|
// WriteHeapProfile is shorthand for [Lookup]("heap").WriteTo(w, 0).
|
||||||
// It is preserved for backwards compatibility.
|
// It is preserved for backwards compatibility.
|
||||||
func WriteHeapProfile(w io.Writer) error {
|
func WriteHeapProfile(w io.Writer) error {
|
||||||
return writeHeap(w, 0)
|
return writeHeap(w, 0)
|
||||||
|
|
@ -765,8 +765,8 @@ var cpu struct {
|
||||||
// Go code built with -buildmode=c-archive or -buildmode=c-shared.
|
// Go code built with -buildmode=c-archive or -buildmode=c-shared.
|
||||||
// StartCPUProfile relies on the SIGPROF signal, but that signal will
|
// StartCPUProfile relies on the SIGPROF signal, but that signal will
|
||||||
// be delivered to the main program's SIGPROF signal handler (if any)
|
// be delivered to the main program's SIGPROF signal handler (if any)
|
||||||
// not to the one used by Go. To make it work, call os/signal.Notify
|
// not to the one used by Go. To make it work, call [os/signal.Notify]
|
||||||
// for syscall.SIGPROF, but note that doing so may break any profiling
|
// for [syscall.SIGPROF], but note that doing so may break any profiling
|
||||||
// being done by the main program.
|
// being done by the main program.
|
||||||
func StartCPUProfile(w io.Writer) error {
|
func StartCPUProfile(w io.Writer) error {
|
||||||
// The runtime routines allow a variable profiling rate,
|
// The runtime routines allow a variable profiling rate,
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ func runtime_getProfLabel() unsafe.Pointer
|
||||||
|
|
||||||
// SetGoroutineLabels sets the current goroutine's labels to match ctx.
|
// SetGoroutineLabels sets the current goroutine's labels to match ctx.
|
||||||
// A new goroutine inherits the labels of the goroutine that created it.
|
// A new goroutine inherits the labels of the goroutine that created it.
|
||||||
// This is a lower-level API than Do, which should be used instead when possible.
|
// This is a lower-level API than [Do], which should be used instead when possible.
|
||||||
func SetGoroutineLabels(ctx context.Context) {
|
func SetGoroutineLabels(ctx context.Context) {
|
||||||
ctxLabels, _ := ctx.Value(labelContextKey{}).(*labelMap)
|
ctxLabels, _ := ctx.Value(labelContextKey{}).(*labelMap)
|
||||||
runtime_setProfLabel(unsafe.Pointer(ctxLabels))
|
runtime_setProfLabel(unsafe.Pointer(ctxLabels))
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Frames may be used to get function/file/line information for a
|
// Frames may be used to get function/file/line information for a
|
||||||
// slice of PC values returned by Callers.
|
// slice of PC values returned by [Callers].
|
||||||
type Frames struct {
|
type Frames struct {
|
||||||
// callers is a slice of PCs that have not yet been expanded to frames.
|
// callers is a slice of PCs that have not yet been expanded to frames.
|
||||||
callers []uintptr
|
callers []uintptr
|
||||||
|
|
@ -70,9 +70,9 @@ type Frame struct {
|
||||||
funcInfo funcInfo
|
funcInfo funcInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// CallersFrames takes a slice of PC values returned by Callers and
|
// CallersFrames takes a slice of PC values returned by [Callers] and
|
||||||
// prepares to return function/file/line information.
|
// prepares to return function/file/line information.
|
||||||
// Do not change the slice until you are done with the Frames.
|
// Do not change the slice until you are done with the [Frames].
|
||||||
func CallersFrames(callers []uintptr) *Frames {
|
func CallersFrames(callers []uintptr) *Frames {
|
||||||
f := &Frames{callers: callers}
|
f := &Frames{callers: callers}
|
||||||
f.frames = f.frameStore[:0]
|
f.frames = f.frameStore[:0]
|
||||||
|
|
@ -642,7 +642,7 @@ func (md *moduledata) funcName(nameOff int32) string {
|
||||||
return gostringnocopy(&md.funcnametab[nameOff])
|
return gostringnocopy(&md.funcnametab[nameOff])
|
||||||
}
|
}
|
||||||
|
|
||||||
// FuncForPC returns a *Func describing the function that contains the
|
// FuncForPC returns a *[Func] describing the function that contains the
|
||||||
// given program counter address, or else nil.
|
// given program counter address, or else nil.
|
||||||
//
|
//
|
||||||
// If pc represents multiple functions because of inlining, it returns
|
// If pc represents multiple functions because of inlining, it returns
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue