Dynagrok is a dynamic analysis tool for Go. It generates control flow graphs, call graphs and control depence graphs. It even has a random code mutator. It also performs a number of analyses, such as:
- Code clone detection
- Statistical fault localization
- Test case pruning
The following process chooses ~/dev/go-research for dynagrok's GOROOT, ~/dev/dynagrok for dynagrok's GOPATH. You can set these to different locations, but make sure you're consistent about it.
Make sure you have a working go installation, with proper configuration. The official website can help with this.
Dep is the unofficial dependency management tool of Go. It is required to set up dynagrok for the first time. Run the following command:
go get -u github.com/golang/dep/cmd/dep
For compiling instrumented binaries, Dynagrok uses an augmented version of the Go compiler. Rather than messing with the Go compiler you use every day, you'll want to have a separate one for use with Dynagrok.
Go compilers compile themselves, but they need help from a bootstrap compiler. Go 1.4 is our bootstrap compiler. We'll install this to ~/go1.4, but you can put it wherever you like, as long as you set $GO_BOOTSTRAP to that directory.
Install the right go1.4 for your platform. Binaries can be found here. You may follow the instructions here but do not set your GOROOT or GOPATH to this.
We'll clone this to ~/dev
cd ~/dev
git clone https://go.googlesource.com/go go-research
cd go-research
git checkout release-branch.go1.8
cd ~/dev/go-research/src
./all.bash
We'll create this at ~/dev/dynagrok, and it will be the root of the GOPATH for dynagrok, but the project itself will live in ~/dev/dynagrok/src/github.com/timtadh/dynagrok
mkdir -p ~/dev/dynagrok/{src,bin,lib}
mkdir -p ~/dev/dynagrok/src/github.com/timtadh/
cd ~/dev/dynagrok/src/github.com/timtadh
git clone http://github.com/timtadh/dynagrok
cd ~/dev/dynagrok/src/github.com/timtadh/dynagrok
git submodule init # initialize submodules
git submodule update # install submodules (requires github to have your ssh key)
The .activate
script sets the environment to their proper values for a dynagrok
session. It must be sourced before every session. The last line of the file
is for building a sub-utility and ought to be removed.
vim .activate # Edit `.activate` to remove the last line
source .activate
Then,
dep ensure # install remaining dependencies
Build dynagrok
go install github.com/timtadh/dynagrok
Compile an example program:
dynagrok -r ~/dev/go-research -d ~/dev/dynagrok/src/github.com/timtadh/dynagrok
-g ~/dev/dynagrok/src/github.com/timtadh/dynagrok/examples objectstate
--keep-work -w /tmp/work dynagrok/examples/linkedlist
At the start of each dynagrok session, make sure to run
source .activate
dynagrok --help
should also be helpful for viewing usage information.