MCPcopy Index your code
hub / github.com/gavv/httpexpect / stacktrace

Function stacktrace

stacktrace.go:28–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26var stacktraceFuncRe = regexp.MustCompile(`^(.+/[^.]+)\.(.+)$`)
27
28func stacktrace() []StacktraceEntry {
29 callers := []StacktraceEntry{}
30 for i := 1; ; i++ {
31 pc, file, line, ok := runtime.Caller(i)
32 if !ok {
33 break
34 }
35
36 f := runtime.FuncForPC(pc)
37 if f == nil {
38 break
39 }
40
41 entry := StacktraceEntry{
42 Pc: pc,
43 File: file,
44 Line: line,
45 Func: f,
46 }
47
48 if m := stacktraceFuncRe.FindStringSubmatch(f.Name()); m != nil {
49 entry.FuncName = m[2]
50 entry.FuncPackage = m[1]
51 } else {
52 entry.FuncName = f.Name()
53 }
54
55 entry.FuncOffset = pc - f.Entry()
56
57 switch f.Name() {
58 case "main.main", "testing.tRunner":
59 entry.IsEntrypoint = true
60 }
61
62 callers = append(callers, entry)
63 }
64
65 return callers
66}

Callers 2

failMethod · 0.85

Calls 1

NameMethod · 0.65

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…