Created
November 12, 2024 01:40
-
-
Save retpolanne/3e2326b0290d68308ff7074e98b9e2f0 to your computer and use it in GitHub Desktop.
Generate control-flow graph from source code using ollama and graphviz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# Usage | |
# ./gen-dot-llm.sh filename.java Function | |
temp_jpg=$(mktemp) | |
full_prompt=$(mktemp) | |
prompt="generate a control-flow graph from the following code in dot language. | |
Consider only the function $2. Output only the raw dot code without any other words. | |
Do not format as markdown." | |
code="$(cat $1)" | |
echo "$prompt" >> $full_prompt | |
echo "$code" >> $full_prompt | |
ollama run qwen2.5-coder < $full_prompt | dot -Tjpg > /tmp/dot.jpg | |
echo "Saved graph in /tmp/dot.jpg" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment