In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "what is the go-callvis source code". In the daily operation, I believe many people have doubts about what the go-callvis source code is. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what is the go-callvis source code?" Next, please follow the editor to study!
Go-callvis is a static source code analysis tool that visually calls the link diagram.
Https://github.com/ofabry/go-callvis
Its implementation is very simple.
Examples handler.go output.goMakefile analysis.go go.mod images version.goREADME.md dot.go go.sum main.go
First, take a look at the main.go file
First parse a series of parameters and then call
Analysis = new (analysis) if err: = Analysis.DoAnalysis ("", tests, args); err! = nil {log.Fatal (err)}
Finally, there is a http service that can support online visualization.
Type analysis struct {opts * renderOpts prog * ssa.Program pkgs [] * ssa.Package mains [] * ssa.Package result * pointer.Result}
Defined in the analysis.go file, the focus is on code analysis through the following function
Func (a * analysis) DoAnalysis (dir string, tests bool, args [] string,) error
Call
"golang.org/x/tools/go/packages"
Inside.
Initial, err: = packages.Load (cfg, args...)
Load all the files in the package, and then call
"golang.org/x/tools/go/ssa/ssautil"
Inside.
Prog, pkgs: = ssautil.AllPackages (initial, 0) prog.Build ()
Convert the source code into ssa
Then find the main function of the entry
Mains, err: = mainPackages (pkgs)
Is to judge the package name and function name.
P.Pkg.Name () = "main" & & p.Func ("main")
And then use the
"golang.org/x/tools/go/pointer"
Pointer analysis for dependency analysis
Result, err: = pointer.Analyze (config)
At this point, the dependence analysis of the source code is completed, and then the dot language is applied to convert it into an image.
Func outputDot (fname string, outputFormat string) {/ / get cmdline default for analysis Analysis.OptsSetup ()
If e: = Analysis.ProcessListArgs (); e! = nil {log.Fatalf ("% v\ n", e)}
Output, err: = Analysis.Render ()
SSA was introduced in Go1.7, which greatly improves the performance of the compiler, but also slows down the compilation process. The following is a combination of online food and books to briefly explain the application of SSA and SSA.
SSA stands for static single-assignment, a kind of IR (intermediate representation code) that ensures that each variable is assigned only once. This can help simplify the optimization algorithm of the compiler.
Y: = 1
Y: = 2
X: = y
For example, in the above code, y = 1 is not available, which is determined by a defined reachability analysis to determine whether y is going to use 1 or 2, and SSA has an identifier that can be called version or generation.
Y1: = 1
Y2: = 2
X1: = y2
So there is no indirect value. The advantage expressed in SSA is that the irrelevant use of the same variable is expressed as different generations, which can facilitate the implementation of optimization algorithms for many compilers.
Point analysis is a static code analysis technique used to analyze the variables or memory addresses that pointers and memory references point to. Pointing analysis technology is the basis of many more complex code analysis techniques, such as compilation optimization, code defect detection and pointer modification impact analysis.
Pointing analysis refers to approximately finding out the target pointed to by the pointer expression in the source program through the analysis of the source program.
At this point, the study of "what is the source code of go-callvis" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.