mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 12:07:17 +00:00
26 lines
427 B
Go
26 lines
427 B
Go
package debug
|
|
|
|
import (
|
|
"runtime"
|
|
)
|
|
|
|
// Callers returns given number of callers with packages
|
|
func Callers(show int) []string {
|
|
fpcs := make([]uintptr, show)
|
|
n := runtime.Callers(2, fpcs)
|
|
if n == 0 {
|
|
return nil
|
|
}
|
|
|
|
callers := make([]string, 0, len(fpcs))
|
|
for _, p := range fpcs {
|
|
caller := runtime.FuncForPC(p - 1)
|
|
if caller == nil {
|
|
continue
|
|
}
|
|
callers = append(callers, caller.Name())
|
|
}
|
|
|
|
return callers
|
|
}
|