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