trace

package
v0.0.0-...-3940e3f Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EntryEnter is an enter trace entry.
	EntryEnter = 0x01
	// EntryLeave is an leave trace entry.
	EntryLeave = 0x02
	// EntryInstruction is an instruction trace entry.
	EntryInstruction = 0x03
	// EntryEnd is an end trace entry.
	EntryEnd = 0x04
)

Variables

This section is empty.

Functions

func PrintTrace

func PrintTrace(w io.Writer, r io.Reader, names Names) error

Types

type Decoder

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

A Decoder decodes trace entries from an io.Reader.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder creates a new decoder that reads from the given io.Reader.

func (*Decoder) Entry

func (t *Decoder) Entry() Entry

Entry returns the trace entry decoded by the last call to Next, if any.

func (*Decoder) Error

func (t *Decoder) Error() error

Error returns the error encoutered during decoding, if any.

func (*Decoder) Next

func (t *Decoder) Next() bool

Next decodes the next entry in the trace. Next returns false if an error occurs or if the end of the trace has been reached and true otherwise.

type EndEntry

type EndEntry struct{}

func (*EndEntry) Encode

func (t *EndEntry) Encode(w io.Writer) error

Encode encodes an end trace entry to the given writer.

An end trace entry is encoded as follows:

0x04

func (*EndEntry) Kind

func (t *EndEntry) Kind() EntryKind

type EnterEntry

type EnterEntry struct {
	ModuleName        string           `json:"moduleName"`
	FunctionIndex     uint32           `json:"functionIndex"`
	FunctionSignature wasm.FunctionSig `json:"functionSignature"`
}

func (*EnterEntry) Encode

func (t *EnterEntry) Encode(w io.Writer) error

Encode encodes an enter trace entry to the given writer.

An enter trace entry is encoded as follows:

0x01 | Module Name vec(byte) | FunctionIndex u32 | FunctionSignature

The signature is encoded in its WASM format. The function index is LEB128-encoded.

func (*EnterEntry) Kind

func (t *EnterEntry) Kind() EntryKind

type Entry

type Entry interface {
	// Kind returns the kind of the trace entry.
	Kind() EntryKind
	// Encode encodes the trace entry to the given writer.
	Encode(w io.Writer) error
	// contains filtered or unexported methods
}

A Entry represents a single entry in an execution trace.

func Decode

func Decode(r io.Reader) ([]Entry, error)

Decode decodes an execution trace from the given reader.

type EntryKind

type EntryKind byte

EntryKind describes the type of a trace entry.

type InstructionEntry

type InstructionEntry struct {
	IP          int              `json:"ip"`
	Instruction code.Instruction `json:"instruction"`
	ArgTypes    []wasm.ValueType `json:"argTypes"`
	ResultTypes []wasm.ValueType `json:"resultTypes"`
	Args        []uint64         `json:"args"`
	Results     []uint64         `json:"results"`
}

func (*InstructionEntry) Encode

func (t *InstructionEntry) Encode(w io.Writer) error

Encode encodes an instruction trace entry to the given writer.

An instruction trace entry is encoded as follows:

0x03 | IP (u32) | Instruction | Args vec(byte, u64) | Results vec(byte, u64)

The instruction is encoded in its WASM format. The instruction pointer, args, and results are all LEB128-encoded.

func (*InstructionEntry) Kind

func (t *InstructionEntry) Kind() EntryKind

type LeaveEntry

type LeaveEntry struct{}

func (*LeaveEntry) Encode

func (t *LeaveEntry) Encode(w io.Writer) error

Encode encodes a leave trace entry to the given writer.

A leave trace entry is encoded as follows:

0x02

func (*LeaveEntry) Kind

func (t *LeaveEntry) Kind() EntryKind

type Names

type Names interface {
	FunctionName(moduleName string, index uint32) (string, bool)
	LocalName(moduleName string, functionIndex, localIndex uint32) (string, bool)
}

type Printer

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

func NewPrinter

func NewPrinter(names Names) *Printer

func (*Printer) Print

func (p *Printer) Print(w io.Writer, entry Entry) error

Print prints a textual representation of the given trace entry to the given io.Writer.

Jump to

Keyboard shortcuts

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