Data Flow Analysis
When you're first getting started with unfamiliar code, Imagix 4D's Subsystem Architecture diagrams provide an overall view of the program structure and its components. Beginning with high level views, you can see the fundamental subsystems, layers, interfaces and dependencies that make up your software.
The next step in program understanding is achieved through the Structure views. These graphical views show you structural aspects like the files, classes, or functions containing particular portions of your code, and are very useful when pursuing specific questions of the program logic. Imagix 4D offers elaborate means of program browsing through graphs and single click connections between graphical, source code, and textual descriptions of the code.
Data flow analysis provides insight into program behavior and identification of potential problem areas beyond these, by using static analysis to follow the program control flow over multiple levels and to track how data is manipulated during these execution paths. Doing this for a whole program looking at all variables and all possible execution paths is called global data flow analysis. Besides tracking variables through a sequence of calls and all the statements performed in between, the analysis also follows variables that are passed as reference parameters, pointers that are set on variables, and calls that are made through function pointers.
From the resulting information, the analysis is able to determine all possible places where a variable is set or read, meaning not just the obvious assignments of the variable itself but also where it is used through pointers set to the variable. The analysis can also determine whether there are program paths that violate rules like variables shouldn't be read before set or variables should only be set if within calls to functions that synchronize concurrent access.
Data Flow Displays
Imagix 4D presents the information gained from global data flow analysis in a number of graphical views and hyperlinked reports (the Flow Check reports). The reports and graphs answer questions about the software and point out potential problem areas:
|Are there any variables that are not set and read?||Unused Variables reports variable usage that might be a sign of a logic problem. The report does not only show top level variables but also members of struct or class variables that are inconsistently used.|
|How is the value of a variable calculated through the chain of assignments of the variables in its assignment expression?||Variable Dependencies reports the flow of variable values that go into the calculation of each variable. The Calculation Tree graphs this for one specific variable at a time. Alternatively, it can show the assignment statements that contribute to the value in a flow diagram. These help identify potential logic problems in calculating values and resolve why unexpected values sometimes occur.|
|Are there any uses of the variable before it is set?||Uninitialized Variables Read reports occurances of the common programming error of using variables that are not yet set.|
|Are there any assignments to the variable that are not used afterwards?||Useless Assignments reports assignments that have no further use, typically a sign that either another variable is supposed to be set or that some code is missing to make use of the assignment.|
For real-time and concurrent programs, Imagix 4D further enhances this information by combining it with task, critical region and event definitions that the user supplies. It can then show these views and reports:
|Which tasks collaborate with each other through shared data?||UML Task Collaboration Diagram graphs the task interaction and shared data in a system.|
|How does shared data flow between tasks?||Variable Flow Between Tasks reports potential irregularities in how the shared data is produced and consumed between tasks, another refinement of the UML Task Collaboration diagram.|
|Where do tasks set or read shared data? Is the sharing protected through critical regions?||Variables Set in Multiple Tasks reports a complete listing of the places where tasks use shared data and whether they are protected against concurrent access. Data sharing is presented on level lower than in the UML Task Collaboration diagram, and helps identify concurrency issues.|
|How does shared data flow within a task?||Out of Step (Z) Variables reports how shared data is processed in a typical path through the functions within a task. The report specifically helps to find logic errors in recurring tasks that typically compute outputs based on new incoming data, where reading the old value could be problematic (the task would be out of step).|
|Are critical regions consistent?||Mismatched Critical Regions and Calls in Critical Regions report on the use of critical regions, as marked by an entry and exit statements in C/C++. The reports check for such issues as entries and exits don't match, which could result in deadlocks occurring or resources being withheld that slow down the overall system.|
|How tasks collaborate with each other through events?||Event Transition Between Tasks and Event Calls in Tasks report on tasking systems that use events to communicate and transfer control between tasks. The reports help with understanding of tasking interaction and detecting potential deadlock issues.|