Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add callgraphutil.WriteDOT #27

Merged
merged 5 commits into from
Jan 5, 2024
Merged

Add callgraphutil.WriteDOT #27

merged 5 commits into from
Jan 5, 2024

Conversation

picatz
Copy link
Owner

@picatz picatz commented Jan 5, 2024

This PR adds the callgraphutil.WriteDOT function which can write a given *callgraph.Graph in DOT format to an io.Writer.

Example

Loading ./... packages from this repository, and using Graphviz's "Force-Directed Placement" layout (fdp) produces:

repo, _, err := cloneGitHubRepository(context.Background(), "picatz", "taint")
if err != nil {
t.Fatal(err)
}
pkgs, err := loadPackages(context.Background(), repo, "./...")
if err != nil {
t.Fatal(err)
}
mainFn, srcFns, err := loadSSA(context.Background(), pkgs)
if err != nil {
t.Fatal(err)
}
cg, err := loadCallGraph(context.Background(), mainFn, srcFns)
if err != nil {
t.Fatal(err)
}
output := &bytes.Buffer{}
err = callgraphutil.WriteDOT(output, cg)
if err != nil {
t.Fatal(err)
}

$ sfdp -Tsvg taint.dot -o taint.svg

taint

@picatz picatz merged commit e98ee4e into main Jan 5, 2024
1 check passed
@picatz picatz deleted the write-dot branch January 5, 2024 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant