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
0
votes
0 answers

Control Flow Graph & Cyclomatic Complexity for the following code

I have to find the CFG and complexity for this code, but I'm kind of confused by conflicting results. Would appreciate some opinions and help if possible. Here's the code snippet: public function checkCredentials() { // 0 if (username.length < 5 ||…
VenoM
  • 453
  • 3
  • 9
  • 17
0
votes
0 answers

How to draw control flow graph fro this code or question?

I didn't understand how to proceed with the numbers and continous Do's.
0
votes
1 answer

Clarification on what exactly constitutes as a continue target in Vulkan SPIR-V

I'm trying to understand the SPIR-V spec, understanding for loops for example. In the beginning of the 1.6 revision 2 spec, the following example (taking only part of it for consisveness) for (int i = 0; i < 4; ++i) color *= multiplier; turns…
Krupip
  • 4,404
  • 2
  • 32
  • 54
0
votes
2 answers

How to determine if a BasicBlock is controled by a `if`

I want to use LLVM to analyze if a basic block is affected by a control flow of an if(i.e., br instruction). "A basic block BB is NOT affected by br" means that no matter which of two blocks the br goes to BB will be executed for sure. I use an…
Tim He
  • 350
  • 2
  • 13
0
votes
1 answer

Soot - Get JimpleBody from a CFG

I'd like to get UnitGraph from a Java Class. I load it by ClassFile and get the method_info of main(). Then I create a CFG and try to convert it into a UnitGraph. My method is to get JimpleBody of the CFG and then create a UnitGraph. However, I…
0
votes
0 answers

Get Control flow graph with address as shown in the assembly

Hi I am trying to get a control flow graph with basic block's detailed address in it, i.e. if the CFG tells me about a basic block, it should also tells me the start/end assembly address of that basic block. I have tried gcc -fdump-tree-cfg-address…
Chen
  • 27
  • 2
0
votes
1 answer

Is Control Flow Graph(CFG) subset of Abstract Syntax Tree (AST)?

I know that Control Flow Graph(CFG) can be built from Abstract Syntax Tree (AST). However, it is not clear to me whether CFG is a subset of AST? As an example, given a CFG can we go back to AST?
Exploring
  • 2,493
  • 11
  • 56
  • 97
0
votes
1 answer

not able to generate controll flow graphs for big programs using LLVM clang

I want to create a software-generated control flow diagram for this code using LLVM CFG https://github.com/inmcm/Simon_Speck_Ciphers/blob/master/C/speck.c But when I followed the instructions given on the LLVM webpage…
arc111
  • 1
  • 1
0
votes
0 answers

Make control flow graph (CFG) visible

Since I need to generate source-level CFG, I used CFG::buildCFG from libclang and can get the following example output: [B0 (EXIT)] Preds (2): B1 B2 [B1] 1: n->l->x = n->x 2: traverse(n->l) 3: traverse(n->r) 4: return; Preds…
zwdong
  • 1
0
votes
1 answer

Is there a way to maximize the max flow of a graph by adjusting the weights within a certain range?

I've been learning about flow graphs and from what I've learned, a flow graph is a directed, weighted graph that has a certain maximum flow that can be calculated. However, is there a way to randomly weight the graph with values between a certain…
0
votes
1 answer

Roslyn: Reconstruct code from BasicBlocks in a CFG

In Roslyn, a control flow graph has the list of BasicBlocks which constitute the program. Is it possible to get code statements from each block to reconstruct the entire code?
0
votes
1 answer

How do I convert .bin code property graph to json?

How can I convert a code property graph(cpg) obtained from joern (https://joern.io/) from .bin format to .json format for feeding it to a graph machine learning library for classification. Note: CPG = AST + Control Flow Graph + Program Dependency…
0
votes
1 answer

Control flow graph

consider this control flow graph. we need to find total independents liner path. when we use "V(g) = e-n+2 = 7-6+2 = 3" but if i count manually i got 4 independents liner path. paths are: "0=>1=>3=>5", "0 => 1 => 3 => 4 =>…
0
votes
1 answer

What would happen if a control flow graph consists of multiple start and/or stop nodes when calculating Cyclomatic Complexity

I want to know how will it affect to the Cyclomatic Complexity when having multiple start or stop nodes in a control flow diagram.If you could explain the relationship between Cyclomatic Complexity and Start/Stop nodes it will be a great help.
0
votes
2 answers

How to properly use ControlFlowGraph from roslyn code analysis in C#

I cannot understand why I am getting an error (using VS2017) for the code in below related to not finding the class ControlFlowGraph which is supposed to be part of the package Microsoft.CodeAnalysis.FlowAnalysis: using System; using…