Questions tagged [control-flow-graph]

A control flow graph (CFG) in computer science is a representation, using graph notation, of all paths that might be traversed through a program during its execution.

A control flow graph (CFG) in computer science is a representation, using graph notation, of all paths that might be traversed through a program during its execution.
In a control flow graph each node in the graph represents a basic block, i.e. a straight-line piece of code without any jumps or jump targets; jump targets start a block, and jumps end a block. Directed edges are used to represent jumps in the control flow. There are, in most presentations, two specially designated blocks: the entry block, through which control enters into the flow graph, and the exit block, through which all control flow leaves.

Reference

138 questions
5
votes
3 answers

llvm dumping control flow graph to file inside a pass

I want to build a control flow graph diagram in llvm in one of my passes. I currently use the following to show the CFG block->getParent()->viewCFG(); //block is a basic block The problem is that it pops up a windows. I just want to dump the cfg at…
simpleuser
  • 479
  • 5
  • 16
5
votes
2 answers

peephole optimization patterns

I've been reading up on local optimization compiler techniques but I keep not getting how they're implemented. The idea is that the optimizer looks at a 'window' of the code every time and somehow detects patterns and replaces them with more…
4
votes
2 answers

How are control flow graphs built in cases where the jump destination is based on a dynamic environment value?

In studying reverse engineering, it's frequently occurred to me that since I can pass any location (that I have permission to access) as the argument, a jump instruction with some non-hardcoded or "non deterministic" target (as in it's not defined…
J.Todd
  • 707
  • 1
  • 12
  • 34
4
votes
1 answer

Extracting the Control Flow Graph from the gcc output

I am trying to extract the Control Flow Graph from the assembly code that gcc produces. I have manage to dump the CFG of several IRs (rtl phases) into .vcg files using the arguments -fdump-rtl-* and -dv. Is there any way to do the same thing but for…
Michalis Vichos
  • 285
  • 2
  • 11
4
votes
1 answer

llvm - get the first instruction of the basic block referred to in the label field of instruction of type br

I'm trying to write a pass that will check the control flow of a code. Given a br instruction, I need to access the basic blocks referred to in the label fields. For example, for the code: for(i = 0; i < count; i++){ sum = add(sum, array[i]); …
mikasa
  • 783
  • 1
  • 11
  • 29
4
votes
1 answer

Getting full binary control flow graph from Radare2

I want to get a full control flow graph of a binary (malware) using radare2. I followed this post from another question on SO. I wanted to ask if instead of ag there is another command that gives the control flow graph of the whole binary and not…
user7487817
4
votes
3 answers

Call graph generator for OCaml or Reason

I want to analyze a OCaml/Reason code repository and understand calls between various functions. Is there a tool that provides such functionality?
xennygrimmato
  • 2,646
  • 7
  • 25
  • 47
4
votes
0 answers

Can Intel's icc compiler produce AST, CFG, and/or IR?

When using clang, I've found it useful to examine the abstract syntax tree (AST), control-flow graph (CFG), and LLVM IR that it produces. I've started looking at Intel's icc compiler (version 15.0.2), and I can't find any documentation that tells me…
4
votes
1 answer

How can I obtain data flow graph along with c-use and p-use variables of a C code?

Is there any online tool/software(open-source preferred) that makes data flow graph of a C code and also gives p-use and c-use variables in it.
3
votes
1 answer

Control Flow Graph : properly identify loop "condition"

I have this C# code sample (but language is absolutely not important) : public static void NestedSimple(int[] a, int n) { for(int i = 0; i < n && i < 12; i++) { a[i] += 1; } } Once compiled, I get this…
Regis Portalez
  • 4,675
  • 1
  • 29
  • 41
3
votes
1 answer

What should be modified in C++ source to generate control flow graph showing name of functions and operators as well?

There is my C++ program to build a CFG presentation as a png file: #include #include #include #include int partitionFunc(std::string &str, int startInd, int endInd) { int primIndex = startInd; int…
3
votes
2 answers

Create control flow graph for c# code using the .Net compiler Roslyn

I can't find a way to construct a control flow graph for c# code using Roslyn. I know there is a namespace in the Roslyn compiler called "Microsoft.CodeAnalysis.FlowAnalysis" that contains some classes to create a control flow graph but I don't…
Hamza
  • 440
  • 7
  • 20
3
votes
1 answer

How can I influence Graphviz/dot to make nicer control-flow graphs by removing snaking and better edge crossings?

I am drawing control-flow graphs for Python programs and would like to influence which kind of edges should not be crossed over. Is there a way to do this? Consider this simple Python program: try: a += 1 except: a += 2 else: a = 3 And…
rocky
  • 7,226
  • 3
  • 33
  • 74
3
votes
3 answers

How do I visualize with precision what happens after the last command of the main pathway of a program?

I have been drawing educational comics that explain basic programming concepts. At the moment, I'm doing one about control flow, and one area boggles my mind: What the computer does, after finishing all the commands of the program's final main…
3
votes
0 answers

control edge rendering of a network in vis.js

I am working on a control flow graph visualizer using vis.js. it's like the example provided by the maintainesr here. the following image shows the result: I want control the way edges are drawn: out arrows start from the bottom and in arrows end…
1
2
3
9 10