Movatterモバイル変換


[0]ホーム

URL:


raw

packagestandard library
go1.25.5Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:9Imported by:0

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Overview

Package raw provides an interface to interpret and emit Go execution traces.It can interpret and emit execution traces in its wire format as well as abespoke but simple text format.

The readers and writers in this package perform no validation on or ordering ofthe input, and so are generally unsuitable for analysis. However, they're veryuseful for testing and debugging the tracer in the runtime and more sophisticatedtrace parsers.

Text format specification

The trace text format produced and consumed by this package is a line-orientedformat.

The first line in each text trace is the header line.

Trace Go1.XX

Following that is a series of event lines. Each event begins with anevent name, followed by zero or more named unsigned integer arguments.Names are separated from their integer values by an '=' sign. Names canconsist of any UTF-8 character except '='.

For example:

EventName arg1=23 arg2=55 arg3=53

Any amount of whitespace is allowed to separate each token. Whitespaceis identified via unicode.IsSpace.

Some events have additional data on following lines. There are two suchspecial cases.

The first special case consists of events with trailing byte-oriented data.The trailer begins on the following line from the event. That line consistsof a single argument 'data' and a Go-quoted string representing the byte datawithin. Note: an explicit argument for the length is elided, because it'sjust the length of the unquoted string.

For example:

String id=5data="hello world\x00"

These events are identified in their spec by the HasData flag.

The second special case consists of stack events. These events are identifiedby the IsStack flag. These events also have a trailing unsigned integer argumentdescribing the number of stack frame descriptors that follow. Each stack framedescriptor is on its own line following the event, consisting of four signedinteger arguments: the PC, an integer describing the function name, an integerdescribing the file name, and the line number in that file that function was atat the time the stack trace was taken.

For example:

Stack id=5 n=2pc=1241251 func=3 file=6 line=124pc=7534345 func=6 file=3 line=64

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeEvent

type Event struct {Versionversion.VersionEvtracev2.EventTypeArgs    []uint64Data    []byte}

Event is a simple representation of a trace event.

Note that this typically includes much more than justtimestamped events, and it also represents parts of thetrace format's framing. (But not interpreted.)

func (*Event)EncodedSizeadded ingo1.24.0

func (e *Event) EncodedSize()int

EncodedSize returns the canonical encoded size of an event.

func (*Event)String

func (e *Event) String()string

String returns the canonical string representation of the event.

This format is the same format that is parsed by the TextReaderand emitted by the TextWriter.

typeReader

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

Reader parses trace bytes with only very basic validationinto an event stream.

funcNewReader

func NewReader(rio.Reader) (*Reader,error)

NewReader creates a new reader for the trace wire format.

func (*Reader)ReadEvent

func (r *Reader) ReadEvent() (Event,error)

ReadEvent reads and returns the next trace event in the byte stream.

func (*Reader)Version

func (r *Reader) Version()version.Version

Version returns the version of the trace that we're reading.

typeTextReader

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

TextReader parses a text format trace with only very basic validationinto an event stream.

funcNewTextReader

func NewTextReader(rio.Reader) (*TextReader,error)

NewTextReader creates a new reader for the trace text format.

func (*TextReader)ReadEvent

func (r *TextReader) ReadEvent() (Event,error)

ReadEvent reads and returns the next trace event in the text stream.

func (*TextReader)Version

func (r *TextReader) Version()version.Version

Version returns the version of the trace that we're reading.

typeTextWriter

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

TextWriter emits the text format of a trace.

funcNewTextWriter

func NewTextWriter(wio.Writer, vversion.Version) (*TextWriter,error)

NewTextWriter creates a new write for the trace text format.

func (*TextWriter)WriteEvent

func (w *TextWriter) WriteEvent(eEvent)error

WriteEvent writes a single event to the stream.

typeWriter

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

Writer emits the wire format of a trace.

It may not produce a byte-for-byte compatible trace from what isproduced by the runtime, because it may be missing extra paddingin the LEB128 encoding that the runtime adds but isn't necessarywhen you know the data up-front.

funcNewWriter

func NewWriter(wio.Writer, vversion.Version) (*Writer,error)

NewWriter creates a new byte format writer.

func (*Writer)WriteEvent

func (w *Writer) WriteEvent(eEvent)error

WriteEvent writes a single event to the trace wire format stream.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp