Callygraphs/README.md
hax 0d42f3aff3 oopsiwhoospi fixed xd
Signed-off-by: hax <hax@lainlounge.xyz>
2025-01-05 18:25:31 +00:00

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: 🔎🔧💡

  1. Shell Script: Orchestrates the call graph generation process by invoking gdb to extract function call information.
  2. C Code: Provides a minimal example of a program whose call graph can be analyzed.
  3. 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 (or gawk 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 🔄🎮🌐

  1. Clone the repository:

    git clone <repository-url>
    cd project
    
  2. Make the scripts executable: 🛠️🔧

    chmod +x callgraph.sh generate_graph.awk
    
  3. 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 🌟🌈

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b feature-name
    
  3. Make your changes and commit:
    git commit -m "Add feature"
    
  4. Push to your branch:
    git push origin feature-name
    
  5. 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 and gcc.
  • Graphviz for the graph visualization tools.

Contact 🌐📦🌎

For questions or feedback, please open an issue in the repository.