Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/runtime/pprof/label.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package pprof

// TinyGo does not implement pprof goroutine labels, but callers such as
// google.golang.org/grpc reference the label API. Provide inert stubs so they
// compile: labels are simply not attached.

import "context"

// LabelSet is a set of profiling labels (unused under TinyGo).
type LabelSet struct{}

// Labels returns a LabelSet from key/value pairs. Inert under TinyGo.
func Labels(args ...string) LabelSet { return LabelSet{} }

// Label returns the value of the named label; always ("", false) under TinyGo.
func Label(ctx context.Context, key string) (string, bool) { return "", false }

// ForLabels iterates the labels on ctx; a no-op under TinyGo.
func ForLabels(ctx context.Context, f func(key, value string) bool) {}

// WithLabels returns ctx unchanged under TinyGo (labels are not stored).
func WithLabels(ctx context.Context, labels LabelSet) context.Context { return ctx }

// SetGoroutineLabels is a no-op under TinyGo.
func SetGoroutineLabels(ctx context.Context) {}

// Do calls f with ctx; labels are ignored under TinyGo.
func Do(ctx context.Context, labels LabelSet, f func(context.Context)) { f(ctx) }
7 changes: 7 additions & 0 deletions src/runtime/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ func (f *Func) FileLine(pc uintptr) (file string, line int) {
return "", 0
}

// Entry returns the entry address of the function. Stubbed like the rest of
// runtime.Func on TinyGo; provided so callers that reference it (e.g.
// github.com/stretchr/testify/mock via FileLine(f.Entry())) compile.
func (f *Func) Entry() uintptr {
return 0
}

func Caller(skip int) (pc uintptr, file string, line int, ok bool) {
return 0, "", 0, false
}
Expand Down
Loading