3.4 KiB
Call Graph Generator 🌟🔗🌟
Overview 🔍🌟📃
This project generates a call graph from an executable binary compiled with debugging symbols. The call graph is output in the DOT format, which can be visualized using tools like Graphviz. The project comprises the following components: 🔎🔧💡
- Shell Script: Orchestrates the call graph generation process by invoking
gdb
to extract function call information. - C Code: Provides a minimal example of a program whose call graph can be analyzed.
- AWK Script: Converts parsed call data into a DOT graph for visualization.
Features 🔦🎨🛠
- Extracts function call relationships from binaries.
- Outputs in DOT format for easy visualization.
- Includes a minimal C example program for testing.
- Validates input for robustness and usability.
Prerequisites
Software Requirements 🌐🛠️📊
gdb
(GNU Debugger)awk
(orgawk
for enhanced features)gcc
(GNU Compiler Collection)- Graphviz (optional, for visualizing the DOT file)
System Requirements 🎮🔱📦
- Linux or Unix-like operating system
- A terminal with permissions to execute scripts
Project Structure 🔨🔧🔮
project/
|-- README.md # This file
|-- callgraph.sh # Shell script for generating the call graph
|-- example.c # C program to test call graph generation
|-- generate_graph.awk # AWK script to generate DOT file from call data
Installation 🔄🎮🌐
-
Clone the repository:
git clone <repository-url> cd project
-
Make the scripts executable: 🛠️🔧
chmod +x callgraph.sh generate_graph.awk
-
Ensure the necessary tools are installed: 🔧🌱🌎
sudo apt install gdb gcc graphviz
Usage 🛠️🔗🔄
1. Compile the Example Program
Compile the included example.c
program with debugging symbols:
gcc -g -o example example.c
2. Generate the Call Graph 🎮🌄🏋️♂️
Run the shell script with the compiled binary:
./callgraph.sh ./example > callgraph.txt
3. Generate the DOT Graph 🌍🔍📦
Use the AWK script to convert the call graph data into a DOT file:
./generate_graph.awk callgraph.txt > callgraph.dot
4. Visualize the Graph (Optional) 📝🎮🎨
Render the DOT file using Graphviz:
dot -Tpng callgraph.dot -o callgraph.png
Open callgraph.png
to view the generated graph. 🎨🌄
Example 🌟🌄
Input (Function Call Data)
foo bar
bar baz
baz qux
Output (DOT Format)
digraph G {
"foo" -> "bar";
"bar" -> "baz";
"baz" -> "qux";
}
Visualized Graph
The graph will show the relationships between functions as directed edges. 🔧🎨🌧️
Contributing 🌟🌈
- Fork the repository.
- Create a new branch:
git checkout -b feature-name
- Make your changes and commit:
git commit -m "Add feature"
- Push to your branch:
git push origin feature-name
- Open a pull request.
License 🌄🔍🎮
This project is licensed under the AGPL License. See the LICENSE file for details.
Acknowledgments 🌟🔗🔧
- The GNU Project for
gdb
andgcc
. - Graphviz for the graph visualization tools.
Contact 🌐📦🌎
For questions or feedback, please open an issue in the repository.