Skip to content

Instantly share code, notes, and snippets.

@rzymek
Created January 21, 2020 20:03
Show Gist options
  • Select an option

  • Save rzymek/13901235c2c589c4261e61f78798991e to your computer and use it in GitHub Desktop.

Select an option

Save rzymek/13901235c2c589c4261e61f78798991e to your computer and use it in GitHub Desktop.
Intellij Idea Call Hierarchy to graphviz dot file
# awk -f call-hierarchy-to-graph.awk call-stack.txt |dot -Tpng -o call-stack.png
BEGIN {
print "digraph {"
path[-1]="start"
}
{
depth=(match($0, /[^ ]/)-1)/4;
gsub(/^ +/,"")
match($0, /[^)]*[)]/, funcWithArgs)
match($0, /[^(]*/,funcOnly)
this=funcWithArgs[0]
#this=funcOnly[0]
#this=$0
from=path[depth-1]
to=this
lines[" \"" from "\"->\"" to "\""]++
path[depth]=this
}
END {
for (line in lines) {
print line ";"
}
print "}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment