File: frame.go

package info (click to toggle)
runc 1.0.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,836 kB
  • sloc: sh: 1,571; ansic: 1,236; makefile: 136
file content (33 lines) | stat: -rw-r--r-- 603 bytes parent folder | download | duplicates (4)
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
31
32
33
package stacktrace

import (
	"path/filepath"
	"runtime"
	"strings"
)

func newFrame(frame runtime.Frame) Frame {
	pack, name := parseFunctionName(frame.Function)
	return Frame{
		File:     filepath.Base(frame.File),
		Function: name,
		Package:  pack,
		Line:     frame.Line,
	}
}

func parseFunctionName(name string) (string, string) {
	i := strings.LastIndex(name, ".")
	if i == -1 {
		return "", name
	}
	return name[:i], name[i+1:]
}

// Frame contains all the information for a stack frame within a go program
type Frame struct {
	File     string
	Function string
	Package  string
	Line     int
}