init
loadSSA
main
printUsage
printVersion
n2
Kind: Control Flow Graph
Name: github.com/SilverRainZ/go-ssaviz.init
Package: github.com/SilverRainZ/go-ssaviz
Synthetic: package initializer
n3
0:
entry P:0 S:2
t0 = *init$guard
bool
if t0 goto 2 else 1
n5
1:
init.start P:1 S:1
*init$guard = true:bool
t1 = flag.init()
()
t2 = fmt.init()
()
t3 = log.init()
()
t4 = os.init()
()
t5 = os/signal.init()
()
t6 = sort.init()
()
t7 = syscall.init()
()
t8 = github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.init()
()
t9 = golang.org/x/tools/go/packages.init()
()
t10 = golang.org/x/tools/go/ssa.init()
()
t11 = golang.org/x/tools/go/ssa/ssautil.init()
()
t12 = flag.NewFlagSet("ssaviz":string, 1:flag.ErrorHandling)
*flag.FlagSet
*fset = t12
jump 2
n3->n5
n4
2:
init.done P:2 S:0
return
n3->n4
n5->n4
n2
Kind: Control Flow Graph
Name: github.com/SilverRainZ/go-ssaviz.loadSSA
Package: github.com/SilverRainZ/go-ssaviz
Location: /home/la/git/go-ssaviz/main.go:138:6
n3
0:
entry P:0 S:2
t0 = new golang.org/x/tools/go/packages.Config (complit)
*golang.org/x/tools/go/packages.Config
t1 = &t0.Mode [#0]
*golang.org/x/tools/go/packages.LoadMode
*t1 = 991:golang.org/x/tools/go/packages.LoadMode
t2 = golang.org/x/tools/go/packages.Load(t0, pkgPaths...)
([]*golang.org/x/tools/go/packages.Package, error)
t3 = extract t2 #0
[]*golang.org/x/tools/go/packages.Package
t4 = extract t2 #1
error
t5 = t4 != nil:error
bool
if t5 goto 1 else 2
n4
1:
if.then P:1 S:0
t6 = new [2]any (varargs)
*[2]any
t7 = &t6[0:int]
*any
t8 = make any <- []string (pkgPaths)
any
*t7 = t8
t9 = &t6[1:int]
*any
t10 = change interface any <- error (t4)
any
*t9 = t10
t11 = slice t6[:]
[]any
t12 = fmt.Errorf("failed to load pa...":string, t11...)
error
return nil:*golang.org/x/tools/go/ssa.Program, nil:[]*golang.org/x/tools/go/ssa.Package, t12
n3->n4
n5
2:
if.done P:1 S:1
t13 = len(t3)
int
jump 3
n3->n5
n12
10:
if.then P:1 S:1
t47 = &t19.PkgPath [#2]
*string
t48 = *t47
string
t49 = new [2]any (varargs)
*[2]any
t50 = &t49[0:int]
*any
t51 = make any <- string ("load pkg:":string)
any
*t50 = t51
t52 = &t49[1:int]
*any
t53 = make any <- string (t48)
any
*t52 = t53
t54 = slice t49[:]
[]any
t55 = log.Println(t54...)
()
jump 11
n13
11:
if.done P:2 S:1
t56 = &t3[t14]
**golang.org/x/tools/go/packages.Package
*t56 = t19
t57 = t14 + 1:int
int
jump 3
n12->n13
n6
3:
rangeindex.loop P:3 S:2
t14 = phi [2: 0:int, 8: t14, 11: t57] #ptr
int
t15 = phi [2: -1:int, 8: t16, 11: t16]
int
t16 = t15 + 1:int
int
t17 = t16 < t13
bool
if t17 goto 4 else 5
n13->n6
n5->n6
n7
4:
rangeindex.body P:1 S:1
t18 = &t3[t16]
**golang.org/x/tools/go/packages.Package
t19 = *t18
*golang.org/x/tools/go/packages.Package
t20 = local golang.org/x/tools/go/packages.Error (err)
*golang.org/x/tools/go/packages.Error
t21 = &t19.Errors [#3]
*[]golang.org/x/tools/go/packages.Error
t22 = *t21
[]golang.org/x/tools/go/packages.Error
t23 = len(t22)
int
jump 6
n6->n7
n14
5:
rangeindex.done P:1 S:0
t24 = slice t3[:t14]
[]*golang.org/x/tools/go/packages.Package
t25 = golang.org/x/tools/go/ssa/ssautil.AllPackages(t24, 0:golang.org/x/tools/go/ssa.BuilderMode)
(*golang.org/x/tools/go/ssa.Program, []*golang.org/x/tools/go/ssa.Package)
t26 = extract t25 #0
*golang.org/x/tools/go/ssa.Program
t27 = extract t25 #1
[]*golang.org/x/tools/go/ssa.Package
t28 = (*golang.org/x/tools/go/ssa.Program).Build(t26)
()
return t26, t27, nil:error
n6->n14
n8
6:
rangeindex.loop P:2 S:2
t29 = phi [4: -1:int, 7: t30]
int
t30 = t29 + 1:int
int
t31 = t30 < t23
bool
if t31 goto 7 else 8
n7->n8
n9
7:
rangeindex.body P:1 S:1
t32 = &t22[t30]
*golang.org/x/tools/go/packages.Error
t33 = *t32
golang.org/x/tools/go/packages.Error
*t20 = t33
t34 = *t20
golang.org/x/tools/go/packages.Error
t35 = new [2]any (varargs)
*[2]any
t36 = &t35[0:int]
*any
t37 = make any <- *golang.org/x/tools/go/packages.Package (t19)
any
*t36 = t37
t38 = &t35[1:int]
*any
t39 = make any <- golang.org/x/tools/go/packages.Error (t34)
any
*t38 = t39
t40 = slice t35[:]
[]any
t41 = log.Printf("skip pkg %s due t...":string, t40...)
()
jump 6
n8->n9
n10
8:
rangeindex.done P:1 S:2
t42 = &t19.Errors [#3]
*[]golang.org/x/tools/go/packages.Error
t43 = *t42
[]golang.org/x/tools/go/packages.Error
t44 = len(t43)
int
t45 = t44 == 0:int
bool
if t45 goto 9 else 3
n8->n10
n9->n8
n10->n6
n11
9:
if.then P:1 S:2
t46 = *github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Debug
bool
if t46 goto 10 else 11
n10->n11
n11->n12
n11->n13
n2
Kind: Control Flow Graph
Name: github.com/SilverRainZ/go-ssaviz.main
Package: github.com/SilverRainZ/go-ssaviz
Location: /home/la/git/go-ssaviz/main.go:33:6
n3
0:
entry P:0 S:2
t0 = *fset
*flag.FlagSet
t1 = &t0.Usage [#0]
*func()
*t1 = main$1
t2 = *fset
*flag.FlagSet
t3 = (*flag.FlagSet).BoolVar(t2, help, "h":string, false:bool, "print this help m...":string)
()
t4 = *fset
*flag.FlagSet
t5 = (*flag.FlagSet).BoolVar(t4, ver, "V":string, false:bool, "print version and...":string)
()
t6 = *fset
*flag.FlagSet
t7 = (*flag.FlagSet).BoolVar(t6, github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Debug, "v":string, false:bool, "print verbose log":string)
()
t8 = *fset
*flag.FlagSet
t9 = (*flag.FlagSet).StringVar(t8, out, "o":string, "ssaviz.html":string, "HTML report for o...":string)
()
t10 = *fset
*flag.FlagSet
t11 = (*flag.FlagSet).BoolVar(t10, view, "view":string, false:bool, "view HTML report ...":string)
()
t12 = *fset
*flag.FlagSet
t13 = *os.Args
[]string
t14 = slice t13[1:int:]
[]string
t15 = (*flag.FlagSet).Parse(t12, t14)
error
t16 = new chan os.Signal (sigs)
*chan os.Signal
t17 = make chan os.Signal 1:int
chan os.Signal
*t16 = t17
t18 = *t16
chan os.Signal
t19 = changetype chan<- os.Signal <- chan os.Signal (t18)
chan<- os.Signal
t20 = new [2]os.Signal (varargs)
*[2]os.Signal
t21 = &t20[0:int]
*os.Signal
t22 = make os.Signal <- syscall.Signal (2:syscall.Signal)
os.Signal
*t21 = t22
t23 = &t20[1:int]
*os.Signal
t24 = make os.Signal <- syscall.Signal (15:syscall.Signal)
os.Signal
*t23 = t24
t25 = slice t20[:]
[]os.Signal
t26 = os/signal.Notify(t19, t25...)
()
t27 = make closure main$2 [t16]
func()
go t27()
t28 = *help
bool
if t28 goto 1 else 2
n4
1:
if.then P:1 S:1
t29 = printUsage(nil:error)
()
jump 2
n3->n4
n5
2:
if.done P:2 S:2
t30 = *ver
bool
if t30 goto 3 else 4
n3->n5
n4->n5
n12
10:
rangeindex.loop P:2 S:2
t54 = phi [9: -1:int, 13: t55]
int
t55 = t54 + 1:int
int
t56 = t55 < t53
bool
if t56 goto 11 else 12
n13
11:
rangeindex.body P:1 S:1
t57 = &t42[t55]
**golang.org/x/tools/go/ssa.Package
t58 = *t57
*golang.org/x/tools/go/ssa.Package
t59 = &t58.Members [#2]
*map[string]golang.org/x/tools/go/ssa.Member
t60 = *t59
map[string]golang.org/x/tools/go/ssa.Member
t61 = range t60
iter
jump 13
n12->n13
n19
12:
rangeindex.done P:1 S:2
t62 = *t52
[]*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Graph
t63 = make closure main$3 [t52]
func(i int, j int) bool
t64 = make any <- []*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Graph (t62)
any
t65 = sort.Slice(t64, t63)
()
t66 = *t52
[]*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Graph
t67 = github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Report(t66)
(*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.HTML, error)
t68 = extract t67 #0
*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.HTML
t69 = extract t67 #1
error
t70 = t69 != nil:error
bool
if t70 goto 18 else 19
n12->n19
n14
13:
rangeiter.loop P:3 S:2
t71 = next t61
(ok bool, k invalid type, v golang.org/x/tools/go/ssa.Member)
t72 = extract t71 #0
bool
if t72 goto 14 else 10
n13->n14
n20
18:
if.then P:1 S:1
t91 = new [1]any (varargs)
*[1]any
t92 = &t91[0:int]
*any
t93 = change interface any <- error (t69)
any
*t92 = t93
t94 = slice t91[:]
[]any
t95 = log.Fatalf("failed to build r...":string, t94...)
()
jump 19
n19->n20
n21
19:
if.done P:2 S:2
t96 = *out
string
t97 = (*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.HTML).Save(t68, t96)
error
t98 = t97 != nil:error
bool
if t98 goto 20 else 21
n19->n21
n14->n12
n15
14:
rangeiter.body P:1 S:2
t73 = extract t71 #2
golang.org/x/tools/go/ssa.Member
t74 = typeassert,ok t73.(*golang.org/x/tools/go/ssa.Function)
(value *golang.org/x/tools/go/ssa.Function, ok bool)
t75 = extract t74 #0
*golang.org/x/tools/go/ssa.Function
t76 = extract t74 #1
bool
if t76 goto 15 else 13
n14->n15
n15->n14
n16
15:
if.done P:1 S:2
t77 = github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Build("Control Flow Graph":github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Kind, t75)
(*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Graph, error)
t78 = extract t77 #0
*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Graph
t79 = extract t77 #1
error
t80 = t79 != nil:error
bool
if t80 goto 16 else 17
n15->n16
n17
16:
if.then P:1 S:1
t81 = new [1]any (varargs)
*[1]any
t82 = &t81[0:int]
*any
t83 = change interface any <- error (t79)
any
*t82 = t83
t84 = slice t81[:]
[]any
t85 = log.Printf("failed to build g...":string, t84...)
()
jump 17
n16->n17
n18
17:
if.done P:2 S:1
t86 = *t52
[]*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Graph
t87 = new [1]*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Graph (varargs)
*[1]*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Graph
t88 = &t87[0:int]
**github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Graph
*t88 = t78
t89 = slice t87[:]
[]*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Graph
t90 = append(t86, t89...)
[]*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Graph
*t52 = t90
jump 13
n16->n18
n17->n18
n18->n14
n20->n21
n22
20:
if.then P:1 S:1
t99 = new [1]any (varargs)
*[1]any
t100 = &t99[0:int]
*any
t101 = change interface any <- error (t97)
any
*t100 = t101
t102 = slice t99[:]
[]any
t103 = log.Fatalf("failed to save re...":string, t102...)
()
jump 21
n21->n22
n23
21:
if.done P:2 S:2
t104 = *view
bool
if t104 goto 22 else 23
n21->n23
n6
3:
if.then P:1 S:1
t31 = printVersion()
()
jump 4
n5->n6
n7
4:
if.done P:2 S:2
t32 = *fset
*flag.FlagSet
t33 = (*flag.FlagSet).Args(t32)
[]string
t34 = len(t33)
int
t35 = t34 == 0:int
bool
if t35 goto 5 else 7
n5->n7
n22->n23
n24
22:
if.then P:1 S:2
t105 = (*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.HTML).View(t68)
error
t106 = t105 != nil:error
bool
if t106 goto 24 else 23
n23->n24
n26
23:
if.done P:3 S:0
return
n23->n26
n24->n26
n25
24:
if.then P:1 S:1
t107 = new [1]any (varargs)
*[1]any
t108 = &t107[0:int]
*any
t109 = change interface any <- error (t105)
any
*t108 = t109
t110 = slice t107[:]
[]any
t111 = log.Fatalf("failed to view re...":string, t110...)
()
jump 23
n24->n25
n25->n26
n6->n7
n8
5:
if.then P:1 S:1
t36 = new [1]string (slicelit)
*[1]string
t37 = &t36[0:int]
*string
*t37 = "./...":string
t38 = slice t36[:]
[]string
jump 6
n7->n8
n27
7:
if.else P:1 S:1
jump 6
n7->n27
n9
6:
if.done P:2 S:2
t39 = phi [5: t38, 7: t33] #pkgPaths
[]string
t40 = loadSSA(t39)
(*golang.org/x/tools/go/ssa.Program, []*golang.org/x/tools/go/ssa.Package, error)
t41 = extract t40 #0
*golang.org/x/tools/go/ssa.Program
t42 = extract t40 #1
[]*golang.org/x/tools/go/ssa.Package
t43 = extract t40 #2
error
t44 = t43 != nil:error
bool
if t44 goto 8 else 9
n8->n9
n10
8:
if.then P:1 S:1
t45 = new [2]any (varargs)
*[2]any
t46 = &t45[0:int]
*any
t47 = make any <- []string (t39)
any
*t46 = t47
t48 = &t45[1:int]
*any
t49 = change interface any <- error (t43)
any
*t48 = t49
t50 = slice t45[:]
[]any
t51 = log.Fatalf("failed to load SS...":string, t50...)
()
jump 9
n9->n10
n11
9:
if.done P:2 S:1
t52 = new []*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Graph (graphs)
*[]*github.com/SilverRainZ/go-ssaviz/pkg/ssaviz.Graph
t53 = len(t42)
int
jump 10
n9->n11
n27->n9
n10->n11
n11->n12
n2
Kind: Control Flow Graph
Name: github.com/SilverRainZ/go-ssaviz.printUsage
Package: github.com/SilverRainZ/go-ssaviz
Location: /home/la/git/go-ssaviz/main.go:109:6
n3
0:
entry P:0 S:2
t0 = err != nil:error
bool
if t0 goto 1 else 2
n4
1:
if.then P:1 S:1
t1 = *os.Stderr
*os.File
t2 = make io.Writer <- *os.File (t1)
io.Writer
t3 = new [1]any (varargs)
*[1]any
t4 = &t3[0:int]
*any
t5 = change interface any <- error (err)
any
*t4 = t5
t6 = slice t3[:]
[]any
t7 = fmt.Fprintf(t2, "error: %s\n":string, t6...)
(n int, err error)
jump 2
n3->n4
n5
2:
if.done P:2 S:2
t8 = *os.Stderr
*os.File
t9 = make io.Writer <- *os.File (t8)
io.Writer
t10 = new [1]any (varargs)
*[1]any
t11 = &t10[0:int]
*any
t12 = make any <- string ("ssaviz":string)
any
*t11 = t12
t13 = slice t10[:]
[]any
t14 = fmt.Fprintf(t9, "USAGE: %s [OPTION...":string, t13...)
(n int, err error)
t15 = *os.Stderr
*os.File
t16 = make io.Writer <- *os.File (t15)
io.Writer
t17 = new [1]any (varargs)
*[1]any
t18 = &t17[0:int]
*any
t19 = make any <- string ("Visualize Go SSA ...":string)
any
*t18 = t19
t20 = slice t17[:]
[]any
t21 = fmt.Fprintln(t16, t20...)
(n int, err error)
t22 = *os.Stderr
*os.File
t23 = make io.Writer <- *os.File (t22)
io.Writer
t24 = fmt.Fprintln(t23, nil:[]any...)
(n int, err error)
t25 = *os.Stderr
*os.File
t26 = make io.Writer <- *os.File (t25)
io.Writer
t27 = fmt.Fprintf(t26, "PKGPATH:\n":string, nil:[]any...)
(n int, err error)
t28 = *os.Stderr
*os.File
t29 = make io.Writer <- *os.File (t28)
io.Writer
t30 = new [1]any (varargs)
*[1]any
t31 = &t30[0:int]
*any
t32 = make any <- string ("./...":string)
any
*t31 = t32
t33 = slice t30[:]
[]any
t34 = fmt.Fprintf(t29, "\tpath of go packa...":string, t33...)
(n int, err error)
t35 = *os.Stderr
*os.File
t36 = make io.Writer <- *os.File (t35)
io.Writer
t37 = fmt.Fprintf(t36, "OPTIONS:\n":string, nil:[]any...)
(n int, err error)
t38 = *fset
*flag.FlagSet
t39 = (*flag.FlagSet).PrintDefaults(t38)
()
t40 = err != nil:error
bool
if t40 goto 3 else 4
n3->n5
n4->n5
n6
3:
if.then P:1 S:1
t41 = os.Exit(2:int)
()
jump 4
n5->n6
n7
4:
if.done P:2 S:0
t42 = os.Exit(0:int)
()
return
n5->n7
n6->n7
n2
Kind: Control Flow Graph
Name: github.com/SilverRainZ/go-ssaviz.printVersion
Package: github.com/SilverRainZ/go-ssaviz
Location: /home/la/git/go-ssaviz/main.go:130:6
n3
0:
entry P:0 S:0
t0 = new [2]any (varargs)
*[2]any
t1 = &t0[0:int]
*any
t2 = make any <- string ("ssaviz":string)
any
*t1 = t2
t3 = &t0[1:int]
*any
t4 = make any <- string ("0.1.0":string)
any
*t3 = t4
t5 = slice t0[:]
[]any
t6 = fmt.Println(t5...)
(n int, err error)
t7 = new [1]any (varargs)
*[1]any
t8 = &t7[0:int]
*any
t9 = make any <- string ("Visualize Go SSA ...":string)
any
*t8 = t9
t10 = slice t7[:]
[]any
t11 = fmt.Println(t10...)
(n int, err error)
t12 = fmt.Println(nil:[]any...)
(n int, err error)
t13 = new [2]any (varargs)
*[2]any
t14 = &t13[0:int]
*any
t15 = make any <- string ("Author:":string)
any
*t14 = t15
t16 = &t13[1:int]
*any
t17 = make any <- string ("Shengyu Zhang <si...":string)
any
*t16 = t17
t18 = slice t13[:]
[]any
t19 = fmt.Println(t18...)
(n int, err error)
t20 = os.Exit(0:int)
()
return