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 stk.Frames(func(f trace.StackFrame) bool {
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 return true
26 })
27 return frames
28 }
29
30 func viewerGState(state trace.GoState, inMarkAssist bool) traceviewer.GState {
31 switch state {
32 case trace.GoUndetermined:
33 return traceviewer.GDead
34 case trace.GoNotExist:
35 return traceviewer.GDead
36 case trace.GoRunnable:
37 return traceviewer.GRunnable
38 case trace.GoRunning:
39 return traceviewer.GRunning
40 case trace.GoWaiting:
41 if inMarkAssist {
42 return traceviewer.GWaitingGC
43 }
44 return traceviewer.GWaiting
45 case trace.GoSyscall:
46
47 return traceviewer.GRunning
48 default:
49 panic(fmt.Sprintf("unknown GoState: %s", state.String()))
50 }
51 }
52
53 func viewerTime(t time.Duration) float64 {
54 return float64(t) / float64(time.Microsecond)
55 }
56
View as plain text