Control Flow Graph generator for code in C++ [closed]
Asked Answered
O

2

10

I'm looking for Control Flow Graph generator for source code written in C++. Do you know any open-source, static generator?

I would like to use it in my graduation project to generate control flow graph and highlight paths which has been executed during the execution of analyzed application.

I've already written entire engine to log executed lines.

Thank you for all answers.

Outcaste answered 12/11, 2016 at 13:17 Comment(3)
These kind of questions are explicitly off-topic here. Read point #4 from this help center article.Nonstandard
Asking for software recommendations is off-topic on stackoverflow, but you can probably ask your question on software recommendations.Plaided
Not open source, but see https://mcmap.net/q/1167476/-how-can-one-create-a-data-flow-graph-dfg-sdfg-for-any-application-from-its-source-codeTriable
L
6

You can use clang or llvm.

First compile your program to llvm ir

clang++ -emit-llvm -S prog.cpp -o prog.ll

Then use opt to generate the control flow graph.

opt --dot-cfg prog.ll

This outputs a dot file which can be viewed with graphviz. On a mac you can do brew install graphviz and run the following to generate a png.

dot -Tpng cfg.main.dot -o main.png

You should have one dot file for every function in your program so it may be easier to write a script to automatically convert them all to pngs

Leek answered 22/3, 2018 at 16:59 Comment(0)
C
0

CoFlo is a Free and Open Source source code analysis tool which generates and analyzes control flow graphs from C and C++ source.

Cuspidor answered 8/9, 2017 at 4:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.