When you're doing z/OS maintenance and production support tasks you will routinely have to do two fairly involved analysis processes:
- Control Flow Analysis - where you build a "mental map" of how the PL/1 procedures and functions, COBOL paragraphs and sections or HLASM routines hang together via the operational control flow constructs in the code (PERFORM, etc.). "in the code" - means from the source code only.
- Data Flow Analysis - where you need to trace the flow a value within one or more programs - as it's moved, assigned, and used in computations and I/O from field-to-field, and record-to-record
Note that we're talking "static" analysis in this discussion, where you're gaining program understanding by reading the source code. There is a complementary form of code analysis known as "Dynamic Analysis" where you learn how a program operates by viewing the source as it executes "live" during a Debug session. Dynamic Analysis is useful primarily (although not only) for Control Flow Analysis, as it presents live program operations, executable statement by executable statement.
In a subsequent blog I'll tackle Dynamic Control Flow Analysis and RDz/Data Flow Analysis - as usual, I'll take on the easy topic first
COBOL Program Control Flow Analysis - Steps
In Control Flow Analysis there are (usually) two things you're doing:
- Top-down building a mental image - essentially a hierarchy chart of how the program hangs together from the level of paragraphs/sections. Or if the program contains "fall thru" with GO TO statements that are not referencing a PERFORM THRU paragraph EXIT - understanding the different combination paths that can occur with PERFORMs and GO TOs.
- Bottom-up understanding of what is in each paragraph/section by studying the code - line by line and variable by variable.
For our example we'll use a fairly simple, structured COBOL program and the tools in RDz 7.6. The process is as follows:
- Select the starting paragraph for your analysis - possibly using the Outline View
- Select the paragraph name and from the Context Menu select: Open Perform Hierarchy -
- This opens a View of the paraphs in the Perform Chain or GO TO statements within the scope of the starting paragraph.
- Note that the Perform Hierarchy View looks similar to the Outline View except that each performed paragraph is indented to show any nested relationship: i.e. A Performs B Performs C looks like:
- Because of the visual nesting shown, the Perform Hierarchy is - essentially - your top-down mental image of how the program is structured - so all that's left on your part is to access, read and understand the source lines in each paragraph/section - by:
- Clicking a paragraph name in the Perform Hierarchy
- Accessing the paragraph declaration by pressing F3 or using the Context Menu
- Reading the paragraph
- Using the back arrow key on the top of your toolbar (or press: Alt+the left arrow key on your PC) to return to your previous place in the source
- Continue down the path
Before ending, it might be worthwhile to point out that, IBM products such as Asset Analyzer - which integrates into RDz very nicely - are set up to do Control and Data Flow Analysis.