Giter Club home page Giter Club logo

rtl2dot's Introduction

rtl2dot

Create C callgraphs from gcc rtldumps via GraphViz.

Based on egypt, rewritten in python with added support for configurable root nodes and omission by regex. May or may not work with C++ code.

Usage

Compile your code with -fdump-rtl-expand (eg. by running make CFLAGS=-fdump-rtl-expand). This will generate some new files, most commonly with the extension .expand.

Run rtl2dot myproject.beepbop.expand | dot -Tsvg > myproject.svg to get a graph of the main function of your project.

Valid options are:

  • --ignore <regex> Regular expression describing function names to be ignored
  • --root <function> Select the function to use as root node of the graph
  • --local Ignore functions that are not defined within the rtl dump (most likely library functions)
  • --indirect Draw a dashed line when the address of a function is taken

Any other arguments are treated as input files. If no input files are given, input is expected on stdin.

Example

./rtl2dot.py smtpd.expand --root core_loop --ignore "client_send|logprintf|common_*" --local | dot -Tsvg > smtpd.svg

License

This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar and reproduced below.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004

Copyright (C) 2004 Sam Hocevar [email protected]

Everyone is permitted to copy and distribute verbatim or modified 
copies of this license document, and changing it is allowed as long 
as the name is changed. 

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.

rtl2dot's People

Contributors

cbdevnet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rtl2dot's Issues

rtl2dot crashes if indirect "calls" reference each other

rtl2dot crashes with a stack overflow if there is a cycle among functions referring to each other indirectly. for example:

void a(void);
void b(void);

void a(void) {
    void (*p)(void) = b;
}
void b(void) {
    void (*p)(void) = a;
}

int main(void) {
    a();
    b();
}

output:

digraph callgraph {
"main" -> "b";
"b" -> "a" [style="dashed"];
"a" -> "b" [style="dashed"];
"b" -> "a" [style="dashed"];
"a" -> "b" [style="dashed"];
"b" -> "a" [style="dashed"];
[...]
Traceback (most recent call last):
  File "./rtl2dot.py", line 117, in <module>
    dump(root)
  File "./rtl2dot.py", line 99, in dump
    dump(ref)
[...]
  File "./rtl2dot.py", line 90, in dump
    if calls[func][ref] == "call" or indirects:
RecursionError: maximum recursion depth exceeded in comparison

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.