package debug

import "cuelang.org/go/internal/golangorgx/gopls/debug"

Package debug exports debug information for gopls.

Index

Constants

const (
	PlainText = PrintMode(iota)
	Markdown
	HTML
	JSON
)

Variables

var AnalysisTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 168 byte string literal not displayed */,
))
var BaseTemplate = template.Must(template.New("").Parse("" /* 935 byte string literal not displayed */,
)).Funcs(template.FuncMap{
	"fuint64":  fuint64,
	"fuint32":  fuint32,
	"fcontent": fcontent,
	"localAddress": func(s string) string {

		host, port, err := net.SplitHostPort(s)
		if err != nil {
			return s
		}
		ip := net.ParseIP(host)
		if ip == nil {
			return s
		}
		if ip.IsLoopback() || ip.IsUnspecified() {
			return "localhost:" + port
		}
		return s
	},
})
var CacheTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 335 byte string literal not displayed */,
))
var ClientTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 335 byte string literal not displayed */,
))
var DebugTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse(`
{{define "title"}}GoPls Debug pages{{end}}
{{define "body"}}
<a href="/debug/pprof">Profiling</a>
{{end}}
`))
var FileTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 282 byte string literal not displayed */,
))
var InfoTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse(`
{{define "title"}}Gopls version information{{end}}
{{define "body"}}
{{.}}
{{end}}
`))
var MainTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 612 byte string literal not displayed */,
))
var MemoryTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 1890 byte string literal not displayed */,
))
var RPCTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 717 byte string literal not displayed */,
))
var ServerTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 262 byte string literal not displayed */,
))
var SessionTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 568 byte string literal not displayed */,
))
var TraceTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 1269 byte string literal not displayed */,
))

TraceTmpl extends BaseTemplate and renders a TraceResults, e.g. from getData().

Functions

func PrintVersionInfo

func PrintVersionInfo(_ context.Context, w io.Writer, verbose bool, mode PrintMode) error

PrintVersionInfo writes version information to w, using the output format specified by mode. verbose controls whether additional information is written, including section headers.

func StdTrace

func StdTrace(exporter event.Exporter) event.Exporter

func WithInstance

func WithInstance(ctx context.Context, agent string) context.Context

WithInstance creates debug instance ready for use using the supplied configuration and stores it in the returned context.

Types

type Client

type Client struct {
	Session      *cache.Session
	DebugAddress string
	Logfile      string
	GoplsPath    string
	ServerID     string
	Service      protocol.Server
}

A Client is an incoming connection from a remote client.

type Instance

type Instance struct {
	Logfile       string
	StartTime     time.Time
	ServerAddress string
	OCAgentConfig string

	LogWriter io.Writer

	State *State
	// contains filtered or unexported fields
}

An Instance holds all debug information associated with a gopls instance.

func GetInstance

func GetInstance(ctx context.Context) *Instance

func (*Instance) AddService

func (i *Instance) AddService(s protocol.Server, session *cache.Session)

func (*Instance) DebugAddress

func (i *Instance) DebugAddress() string

func (*Instance) ListenedDebugAddress

func (i *Instance) ListenedDebugAddress() string

func (*Instance) PrintServerInfo

func (i *Instance) PrintServerInfo(ctx context.Context, w io.Writer)

PrintServerInfo writes HTML debug info to w for the Instance.

func (*Instance) Serve

func (i *Instance) Serve(ctx context.Context, addr string) (string, error)

Serve starts and runs a debug server in the background on the given addr. It also logs the port the server starts on, to allow for :0 auto assigned ports.

func (*Instance) SetLogFile

func (i *Instance) SetLogFile(logfile string, isDaemon bool) (func(), error)

SetLogFile sets the logfile for use with this instance.

type PrintMode

type PrintMode int

type Rpcs

type Rpcs struct {
	Inbound  []*rpcStats // stats for incoming lsp rpcs sorted by method name
	Outbound []*rpcStats // stats for outgoing lsp rpcs sorted by method name
	// contains filtered or unexported fields
}

func (*Rpcs) ProcessEvent

func (r *Rpcs) ProcessEvent(ctx context.Context, ev core.Event, lm label.Map) context.Context

type Server

type Server struct {
	ID           string
	DebugAddress string
	Logfile      string
	GoplsPath    string
	ClientID     string
}

A Server is an outgoing connection to a remote LSP server.

type ServerVersion

type ServerVersion struct {
	*debug.BuildInfo
	Version string
}

ServerVersion is the format used by gopls to report its version to the client. This format is structured so that the client can parse it easily.

func VersionInfo

func VersionInfo() *ServerVersion

VersionInfo returns the build info for the gopls process. If it was not built in module mode, we return a GOPATH-specific message with the hardcoded version.

type State

type State struct {
	// contains filtered or unexported fields
}

State holds debugging information related to the server state.

func (*State) Analysis

func (st *State) Analysis() (_ analysisTmpl)

Analysis returns the global Analysis template value.

func (*State) Bugs

func (st *State) Bugs() []bug.Bug

func (*State) Cache

func (st *State) Cache(id string) *cache.Cache

Cache returns the Cache that matches the supplied id.

func (*State) Caches

func (st *State) Caches() []*cache.Cache

Caches returns the set of Cache objects currently being served.

func (*State) Client

func (st *State) Client(id string) *Client

Client returns the Client matching the supplied id.

func (*State) Clients

func (st *State) Clients() []*Client

Clients returns the set of Clients currently being served.

func (*State) Servers

func (st *State) Servers() []*Server

Servers returns the set of Servers the instance is currently connected to.

func (*State) Session

func (st *State) Session(id string) *cache.Session

Session returns the Session that matches the supplied id.

func (*State) Sessions

func (st *State) Sessions() []*cache.Session

Sessions returns the set of Session objects currently being served.

func (*State) View

func (st *State) View(id string) *cache.View

View returns the View that matches the supplied id.

func (*State) Views

func (st *State) Views() []*cache.View

Views returns the set of View objects currently being served.

type TraceResults

type TraceResults struct {
	Traces   []*traceSet
	Selected *traceSet
	Recent   []spanStartEnd
}

A TraceResults is the subject for the /trace HTML template.

Source Files

info.go metrics.go rpc.go serve.go trace.go

Directories

PathSynopsis
internal/golangorgx/gopls/debug/logPackage log provides helper methods for exporting log events to the internal/event package.
Version
v0.12.0 (latest)
Published
Jan 30, 2025
Platform
linux/amd64
Imports
36 packages
Last checked
7 hours ago

Tools for package owners.