summaryrefslogtreecommitdiff
path: root/vendor/github.com/jtolds/gls/stack_tags_main.go
blob: 4da89e44f8e8da2d7bedfc79f6d260aad9daea0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// +build !js

package gls

// This file is used for standard Go builds, which have the expected runtime
// support

import (
	"runtime"
)

var (
	findPtr = func() uintptr {
		var pc [1]uintptr
		n := runtime.Callers(4, pc[:])
		if n != 1 {
			panic("failed to find function pointer")
		}
		return pc[0]
	}

	getStack = func(offset, amount int) (stack []uintptr, next_offset int) {
		stack = make([]uintptr, amount)
		stack = stack[:runtime.Callers(offset, stack)]
		if len(stack) < amount {
			return stack, 0
		}
		return stack, offset + len(stack)
	}
)