debug

package
v5.2.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package debug defines useful profiling utils that came originally with go-ethereum. Copyright 2016 The go-ethereum Authors This file is part of the go-ethereum library.

The go-ethereum library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The go-ethereum library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var (
	// PProfFlag to enable pprof HTTP server.
	PProfFlag = &cli.BoolFlag{
		Name:  "pprof",
		Usage: "Enables the pprof HTTP server.",
	}
	// PProfPortFlag to specify HTTP server listening port.
	PProfPortFlag = &cli.IntFlag{
		Name:  "pprofport",
		Usage: "pprof HTTP server listening port.",
		Value: 6060,
	}
	// PProfAddrFlag to specify HTTP server address.
	PProfAddrFlag = &cli.StringFlag{
		Name:  "pprofaddr",
		Usage: "pprof HTTP server listening interface.",
		Value: "127.0.0.1",
	}
	// MemProfileRateFlag to specify the mem profiling rate.
	MemProfileRateFlag = &cli.IntFlag{
		Name:  "memprofilerate",
		Usage: "Turns on memory profiling with the given rate.",
		Value: runtime.MemProfileRate,
	}
	// MutexProfileFractionFlag to specify the mutex profiling rate.
	MutexProfileFractionFlag = &cli.IntFlag{
		Name:  "mutexprofilefraction",
		Usage: "Turns on mutex profiling with the given rate.",
	}
	// BlockProfileRateFlag to specify the block profiling rate.
	BlockProfileRateFlag = &cli.IntFlag{
		Name:  "blockprofilerate",
		Usage: "Turns on block profiling with the given rate.",
	}
	// CPUProfileFlag to specify where to write the CPU profile.
	CPUProfileFlag = &cli.StringFlag{
		Name:  "cpuprofile",
		Usage: "Writes CPU profile to the given file.",
	}
	// TraceFlag to specify where to write the trace execution profile.
	TraceFlag = &cli.StringFlag{
		Name:  "trace",
		Usage: "Writes execution trace to the given file.",
	}
)
View Source
var Handler = new(HandlerT)

Handler is the global debugging handler.

Memsize is the memsizeui Handler(?).

Functions

func Exit

func Exit(ctx *cli.Context)

Exit stops all running profiles, flushing their output to the respective file.

func Setup

func Setup(ctx *cli.Context) error

Setup initializes profiling based on the CLI flags. It should be called as early as possible in the program.

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) BlockProfile

func (*HandlerT) BlockProfile(file string, nsec uint) error

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

func (h *HandlerT) CPUProfile(file string, nsec uint) error

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) GcStats

func (*HandlerT) GcStats() *debug.GCStats

GcStats returns GC statistics.

func (*HandlerT) GoTrace

func (h *HandlerT) GoTrace(file string, nsec uint) error

GoTrace turns on tracing for nsec seconds and writes trace data to file.

func (*HandlerT) MemStats

func (*HandlerT) MemStats() *runtime.MemStats

MemStats returns detailed runtime memory statistics.

func (*HandlerT) MutexProfile

func (*HandlerT) MutexProfile(file string, nsec uint) error

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

func (*HandlerT) SetBlockProfileRate(rate int)

SetBlockProfileRate sets the rate of goroutine block profile data collection. rate 0 disables block profiling.

func (*HandlerT) SetGCPercent

func (*HandlerT) SetGCPercent(v int) int

SetGCPercent sets the garbage collection target percentage. It returns the previous setting. A negative value disables GC.

func (*HandlerT) SetMutexProfileFraction

func (*HandlerT) SetMutexProfileFraction(rate int)

SetMutexProfileFraction sets the rate of mutex profiling.

func (*HandlerT) Stacks

func (*HandlerT) Stacks() string

Stacks returns a printed representation of the stacks of all goroutines.

func (*HandlerT) StartCPUProfile

func (h *HandlerT) StartCPUProfile(file string) error

StartCPUProfile turns on CPU profiling, writing to the given file.

func (*HandlerT) StartGoTrace

func (h *HandlerT) StartGoTrace(file string) error

StartGoTrace turns on tracing, writing to the given file.

func (*HandlerT) StopCPUProfile

func (h *HandlerT) StopCPUProfile() error

StopCPUProfile stops an ongoing CPU profile.

func (*HandlerT) StopGoTrace

func (h *HandlerT) StopGoTrace() error

StopGoTrace stops an ongoing trace.

func (*HandlerT) WriteBlockProfile

func (*HandlerT) WriteBlockProfile(file string) error

WriteBlockProfile writes a goroutine blocking profile to the given file.

func (*HandlerT) WriteMemProfile

func (*HandlerT) WriteMemProfile(file string) error

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

func (*HandlerT) WriteMutexProfile(file string) error

WriteMutexProfile writes a goroutine blocking profile to the given file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL