Data Flow Analysis, Control Flow Graphs Flashcards
What are modern compilers
Static analysis tools to detect defects such as syntax errors
Correct data type usage
Undeclared variables
Unreachable code
This is assisted by data flow analysis and control flow analysis
Data flow analysis
Concerned with how data is used on different paths through the code
There are 3 different usage states for each data variable
Undefined - data has no defined value
Defined
Referenced - the data is used
It can’t detect errors
Data flow can detects anomalies
Ur-anomaly an undefined data item is read on a program path
Du-anomaly data item that has been assigned a value, becomes undefined without being used
Dd-anomaly a data item that has been assigned a value is assigned another value without being used in the meantime
Program flow graphs
Describes program control flow, each branch shown as separate path and loops are shown by arrows looping back to loop condition node
Control flow graph is a graphical representation of a programs control structure
Path testing
Desired paths through program executed at least once
Starting point for path testing is a program flow graph that shows nodes representing program decisions and arcs representing control flow
Statements with conditions are therefore nodes in the flow graph
What is a decision
Program point at which the control can diverge (e.g. if and case statements)
What is a junction
Program point where the Control flow can merge e.g. end if, end loop
What is a process block
Sequence of program statements uninterrupted by either decisions or junctions e.g, straight line code. A process has one entry and one exit. A program does no jump into or out of process
Paths consist of
Segments, the smallest segment is a link. A link is a single process that lies between 2 nodes.
The length of a path is number of links in a path. An entry/exit path or a complete path is a path that starts at a routines entry and ends at the same routines exit
Why are complete paths useful for testing
Difficult to set up and executed paths that start at an arbitrary statement
Difficult to stop at an arbitrary statement