package wasmdebug

import "github.com/tetratelabs/wazero/internal/wasmdebug"

Package wasmdebug contains utilities used to give consistent search keys between stack traces and error messages. Note: This is named wasmdebug to avoid conflicts with the normal go module. Note: This only imports "api" as importing "wasm" would create a cyclic dependency.

Index

Functions

func FuncName

func FuncName(moduleName, funcName string, funcIdx uint32) string

FuncName returns the naming convention of "moduleName.funcName".

Note: "moduleName.$funcIdx" is used when the funcName is empty, as commonly the case in TinyGo.

Types

type ErrorBuilder

type ErrorBuilder interface {
	// AddFrame adds the next frame.
	//
	// * funcName should be from FuncName
	// * paramTypes should be from wasm.FunctionType
	// * resultTypes should be from wasm.FunctionType
	//
	// Note: paramTypes and resultTypes are present because signature misunderstanding, mismatch or overflow are common.
	AddFrame(funcName string, paramTypes, resultTypes []api.ValueType)

	// FromRecovered returns an error with the wasm stack trace appended to it.
	FromRecovered(recovered interface{}) error
}

ErrorBuilder helps build consistent errors, particularly adding a WASM stack trace.

AddFrame should be called beginning at the frame that panicked until no more frames exist. Once done, call Format.

func NewErrorBuilder

func NewErrorBuilder() ErrorBuilder

Source Files

debug.go

Version
v1.0.0-pre.4
Published
Dec 1, 2022
Platform
js/wasm
Imports
8 packages
Last checked
2 hours ago

Tools for package owners.