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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use integer for node IDs instead of quoted string
picatz committed Jan 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 37d7842cfe9a42a5cb8e76b32c0b150bf1786121
4 changes: 2 additions & 2 deletions callgraphutil/dot.go
Original file line number Diff line number Diff line change
@@ -29,15 +29,15 @@ func WriteDOT(w io.Writer, g *callgraph.Graph) error {

// Write nodes.
for _, n := range g.Nodes {
b.WriteString(fmt.Sprintf("\t%q [label=%q];\n", fmt.Sprintf("%d", n.ID), n.Func))
b.WriteString(fmt.Sprintf("\t%d [label=%q];\n", n.ID, n.Func))

// Add edges
edges = append(edges, n.Out...)
}

// Write edges.
for _, e := range edges {
b.WriteString(fmt.Sprintf("\t%q -> %q [label=%q];\n", fmt.Sprintf("%d", e.Caller.ID), fmt.Sprintf("%d", e.Callee.ID), e.Site))
b.WriteString(fmt.Sprintf("\t%d -> %d;\n", e.Caller.ID, e.Callee.ID))
}

b.WriteString("}\n")