Documentation ¶
Overview ¶
Package debug provides interfaces for Go runtime debugging facilities.
Overview of debug package ¶
This package is mostly glue code making these facilities available through the CLI and RPC subsystem. If you want to use them from Go code, use package runtime instead.
Source Files
- api.go : defines the global debugging handler implementing debugging APIs.
- flags.go : defines command-line flags enabling debugging APIs.
- loudpanic.go : (deprecated) panics in a way that gets all goroutine stacks printed on stderr.
- loudpanic_fallback.go : (deprecated) implements fallback of LoudPanic.
- trace.go : implements start/stop functions of go trace.
- trace_fallback.go : implements fallback of StartGoTrace and StopGoTrace for Go < 1.5.
Index ¶
- Variables
- func CreateLogDir(logDir string)
- func Exit()
- func GetGlogger() (*log.GlogHandler, error)
- func LoudPanic(x interface{})
- func Setup(ctx *cli.Context) error
- type HandlerT
- func (*HandlerT) BacktraceAt(location string) error
- func (*HandlerT) BlockProfile(file string, nsec uint) error
- func (h *HandlerT) CpuProfile(file string, nsec uint) error
- func (*HandlerT) FreeOSMemory()
- func (*HandlerT) GcStats() *debug.GCStats
- func (h *HandlerT) GoTrace(file string, nsec uint) error
- func (h *HandlerT) IsPProfRunning() bool
- func (*HandlerT) MemStats() *runtime.MemStats
- func (*HandlerT) MutexProfile(file string, nsec uint) error
- func (*HandlerT) SetBlockProfileRate(rate int)
- func (*HandlerT) SetGCPercent(v int) int
- func (*HandlerT) SetMutexProfileFraction(rate int)
- func (h *HandlerT) SetVMLogTarget(target int) (string, error)
- func (*HandlerT) Stacks() string
- func (h *HandlerT) StartCPUProfile(file string) error
- func (h *HandlerT) StartGoTrace(file string) error
- func (h *HandlerT) StartPProf(ptrAddr *string, ptrPort *int) error
- func (h *HandlerT) StopCPUProfile() error
- func (h *HandlerT) StopGoTrace() error
- func (h *HandlerT) StopPProf() error
- func (*HandlerT) Verbosity(level int) error
- func (*HandlerT) VerbosityByID(mi int, level int) error
- func (*HandlerT) VerbosityByName(mn string, level int) error
- func (*HandlerT) Vmodule(pattern string) error
- func (*HandlerT) WriteBlockProfile(file string) error
- func (*HandlerT) WriteMemProfile(file string) error
- func (*HandlerT) WriteMutexProfile(file string) error
- func (h *HandlerT) WriteVMLog(msg string)
Constants ¶
This section is empty.
Variables ¶
var Flags = []cli.Flag{ altsrc.NewIntFlag(verbosityFlag), altsrc.NewStringFlag(vmoduleFlag), altsrc.NewStringFlag(backtraceAtFlag), altsrc.NewBoolFlag(debugFlag), altsrc.NewStringFlag(logFormatFlag), altsrc.NewStringFlag(logFileFlag), altsrc.NewBoolFlag(logRotateFlag), altsrc.NewIntFlag(logMaxSizeMBsFlag), altsrc.NewIntFlag(logMaxBackupsFlag), altsrc.NewIntFlag(logMaxAgeFlag), altsrc.NewBoolFlag(logCompressFlag), altsrc.NewBoolFlag(pprofFlag), altsrc.NewStringFlag(pprofAddrFlag), altsrc.NewIntFlag(pprofPortFlag), altsrc.NewStringFlag(memprofileFlag), altsrc.NewIntFlag(memprofilerateFlag), altsrc.NewIntFlag(blockprofilerateFlag), altsrc.NewStringFlag(cpuprofileFlag), altsrc.NewStringFlag(traceFlag), }
Flags holds all command-line flags required for debugging.
var (
Handler = new(HandlerT)
)
Handler is the global debugging handler.
var Memsize memsizeui.Handler
Functions ¶
func CreateLogDir ¶
func CreateLogDir(logDir string)
CreateLogDir creates a directory whose path is logdir as well as empty log files.
func Exit ¶
func Exit()
Exit stops all running profiles, flushing their output to the respective file.
func GetGlogger ¶
func GetGlogger() (*log.GlogHandler, error)
Types ¶
type HandlerT ¶
type HandlerT struct {
// contains filtered or unexported fields
}
HandlerT implements the debugging API. Do not create values of this type, use the one in the Handler variable instead.
func (*HandlerT) BacktraceAt ¶
BacktraceAt sets the log backtrace location. See package log for details on the pattern syntax.
func (*HandlerT) BlockProfile ¶
BlockProfile turns on goroutine profiling for nsec seconds and writes profile data to file. It uses a profile rate of 1 for most accurate information. If a different rate is desired, set the rate and write the profile manually.
func (*HandlerT) CpuProfile ¶
CpuProfile turns on CPU profiling for nsec seconds and writes profile data to file.
func (*HandlerT) FreeOSMemory ¶
func (*HandlerT) FreeOSMemory()
FreeOSMemory returns unused memory to the OS.
func (*HandlerT) IsPProfRunning ¶
IsPProfRunning returns true if the pprof HTTP server is running and false otherwise.
func (*HandlerT) MutexProfile ¶
MutexProfile turns on mutex profiling for nsec seconds and writes profile data to file. It uses a profile rate of 1 for most accurate information. If a different rate is desired, set the rate and write the profile manually.
func (*HandlerT) SetBlockProfileRate ¶
SetBlockProfileRate sets the rate of goroutine block profile data collection. rate 0 disables block profiling.
func (*HandlerT) SetGCPercent ¶
SetGCPercent sets the garbage collection target percentage. It returns the previous setting. A negative value disables GC.
func (*HandlerT) SetMutexProfileFraction ¶
SetMutexProfileFraction sets the rate of mutex profiling.
func (*HandlerT) SetVMLogTarget ¶
SetVMLogTarget sets the output target of vmlog.
func (*HandlerT) StartCPUProfile ¶
StartCPUProfile turns on CPU profiling, writing to the given file.
func (*HandlerT) StartGoTrace ¶
StartGoTrace turns on tracing, writing to the given file.
func (*HandlerT) StartPProf ¶
StartPProf starts the pprof server.
func (*HandlerT) StopCPUProfile ¶
StopCPUProfile stops an ongoing CPU profile.
func (*HandlerT) StopGoTrace ¶
StopGoTrace stops an ongoing trace.
func (*HandlerT) Verbosity ¶
Verbosity sets the log verbosity ceiling. The verbosity of individual packages and source files can be raised using Vmodule.
func (*HandlerT) VerbosityByID ¶
VerbosityByID sets the verbosity of log module with given ModuleID. Please note that VerbosityByID only works with zapLogger.
func (*HandlerT) VerbosityByName ¶
VerbosityByName sets the verbosity of log module with given name. Please note that VerbosityByName only works with zapLogger.
func (*HandlerT) Vmodule ¶
Vmodule sets the log verbosity pattern. See package log for details on the pattern syntax.
func (*HandlerT) WriteBlockProfile ¶
WriteBlockProfile writes a goroutine blocking profile to the given file.
func (*HandlerT) WriteMemProfile ¶
WriteMemProfile writes an allocation profile to the given file. Note that the profiling rate cannot be set through the API, it must be set on the command line.
func (*HandlerT) WriteMutexProfile ¶
WriteMutexProfile writes a goroutine blocking profile to the given file.
func (*HandlerT) WriteVMLog ¶
WriteVMLog writes msg to a vmlog output file.