#!/usr/bin/env bash # Copyright (c) 2020 International Business Machines Corporation # Prepared by: Geert Janssen USAGE="\ Approximates a call graph using srcml and xmlstarlet.\n\ Works for any C, C++, and possibly Java source file.\n\ Output is in JSON-Graph format. Includes multiplicity.\n\ Note that preprocessor macros (#define) are not resolved;\n\ so even macro calls will be treated as regular function calls." # The abolute directory path where this script resides: SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")" . "${SCRIPT_DIR}"/callgraph_aux.sh info "Outputting in JSON-Graph format..." # JSON-Graph 'prelude': echo -e "{\n \"graph\": {" echo " \"version\": \"1.0\"," echo " \"type\": \"dag\"," echo " \"directed\": true," echo " \"root\": 0," echo " \"order\": \"dfs\"," echo " \"label\": \"call graph\"," # The nodes (in DFS order!): echo " \"nodes\": [" for ((n=0;n