Last active
July 30, 2021 23:42
-
-
Save EllipticEllipsis/8e5b23e819b9e0bdd52ec38b7b282405 to your computer and use it in GitHub Desktop.
Finds all mentions of functions in z_sub_s in code. Can easily modify it to look at overlays or other directories, and use other files, and makes graphviz-compatible output
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
| #!/bin/bash | |
| # with quotes | |
| while read line ; do grep -Fr "$line" asm/non_matchings/code ; done < <(find asm/non_matchings/code/z_sub_s/ -type f -exec basename {} .s \;) | grep -v 'glabel' | awk -F':|\\s+' '/%lo/ { next } /%hi/ { type="hilo" } /jal/ { type="jal" } { filefunc=gensub(/.*\/(.*)\/(.*)\.s/,"\\1,\\2","g",$1) ; gsub(/%hi\(|\)/,"") ; print filefunc","$NF","type } ' | awk -F, 'BEGIN { printf "digraph {\ncompound=true;\n\n" } { arr[$1] = arr[$1]" \""$2"\"" ; print "\""$2"\" -> \""$3"\"" } END { print "" ; for (file in arr) { print "subgraph cluster_"file" {" ; print arr[file]";" ; printf " style = filled;\n label = \"%s\";\n}\n\n" , file } print "}" }' | |
| # without quotes | |
| # while read line ; do grep -Fr "$line" asm/non_matchings/code ; done < <(find asm/non_matchings/code/z_sub_s/ -type f -exec basename {} .s \;) | grep -v 'glabel' | awk -F':|\\s+' '/%lo/ { next } /%hi/ { type="hilo" } /jal/ { type="jal" } { filefunc=gensub(/.*\/(.*)\/(.*)\.s/,"\\1,\\2","g",$1) ; gsub(/%hi\(|\)/,"") ; print filefunc","$NF","type } ' | awk -F, 'BEGIN { printf "digraph {\ncompound=true;\n\n" } { arr[$1] = arr[$1]" "$2 ; print $2" -> "$3 } END { print "" ; for (file in arr) { print "subgraph cluster_"file" {" ; print arr[file]";" ; printf " style = filled;\n label = \"%s\";\n}\n\n" , file } print "}" }' | |
| # TODO | |
| # - take arguments for callee functions directory and sought callers rather than | |
| # - maybe pass straight to graphviz with | dot -Tsvg > name.svg | |
| # - or | dot -Tpng > name.png | |
| # - implement colours for jal/hilo (functionality currently unused) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment