From 596c16e0458060aec0c81cccaef3070a1d6daf81 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 23 Mar 2010 20:48:23 -0700 Subject: runtime: add memory profiling, disabled. no way to get the data out yet. add prototype for runtime.Callers, missing from last CL. R=r CC=golang-dev https://golang.org/cl/713041 --- src/pkg/runtime/extern.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/pkg/runtime/extern.go') diff --git a/src/pkg/runtime/extern.go b/src/pkg/runtime/extern.go index 2ee20cd35a..1e8c1b1df0 100644 --- a/src/pkg/runtime/extern.go +++ b/src/pkg/runtime/extern.go @@ -21,11 +21,17 @@ func Goexit() func Breakpoint() // Caller reports file and line number information about function invocations on -// the calling goroutine's stack. The argument is the number of stack frames to +// the calling goroutine's stack. The argument skip is the number of stack frames to // ascend, with 0 identifying the the caller of Caller. The return values report the // program counter, file name, and line number within the file of the corresponding // call. The boolean ok is false if it was not possible to recover the information. -func Caller(n int) (pc uintptr, file string, line int, ok bool) +func Caller(skip int) (pc uintptr, file string, line int, ok bool) + +// Callers fills the slice pc with the program counters of function invocations +// on the calling goroutine's stack. The argument skip is the number of stack frames +// to skip before recording in pc, with 0 starting at the caller of Caller. +// It returns the number of entries written to pc. +func Callers(skip int, pc []int) int // mid returns the current os thread (m) id. func mid() uint32 @@ -168,3 +174,19 @@ func GOROOT() string { // A trailing + indicates that the tree had local modifications // at the time of the build. func Version() string { return defaultVersion } + +// MemProfileKind specifies how frequently to record +// memory allocations in the memory profiler. +type MemProfileKind int + +const ( + MemProfileNone MemProfileKind = iota // no profiling + MemProfileSample // profile random sample + MemProfileAll // profile every allocation +) + +// SetMemProfileKind sets the fraction of memory allocations +// that are recorded and reported in the memory profile. +// Profiling an allocation has a small overhead, so the default +// is to profile only a random sample, weighted by block size. +func SetMemProfileKind(kind MemProfileKind) -- cgit v1.3-5-g9baa