...
1
2
3
4
5 package trace
6
7 import (
8 "fmt"
9 "internal/trace"
10 "internal/trace/traceviewer"
11 tracev2 "internal/trace/v2"
12 "time"
13 )
14
15
16
17 func viewerFrames(stk tracev2.Stack) []*trace.Frame {
18 var frames []*trace.Frame
19 stk.Frames(func(f tracev2.StackFrame) bool {
20 frames = append(frames, &trace.Frame{
21 PC: f.PC,
22 Fn: f.Func,
23 File: f.File,
24 Line: int(f.Line),
25 })
26 return true
27 })
28 return frames
29 }
30
31 func viewerGState(state tracev2.GoState, inMarkAssist bool) traceviewer.GState {
32 switch state {
33 case tracev2.GoUndetermined:
34 return traceviewer.GDead
35 case tracev2.GoNotExist:
36 return traceviewer.GDead
37 case tracev2.GoRunnable:
38 return traceviewer.GRunnable
39 case tracev2.GoRunning:
40 return traceviewer.GRunning
41 case tracev2.GoWaiting:
42 if inMarkAssist {
43 return traceviewer.GWaitingGC
44 }
45 return traceviewer.GWaiting
46 case tracev2.GoSyscall:
47
48 return traceviewer.GRunning
49 default:
50 panic(fmt.Sprintf("unknown GoState: %s", state.String()))
51 }
52 }
53
54 func viewerTime(t time.Duration) float64 {
55 return float64(t) / float64(time.Microsecond)
56 }
57
View as plain text