7.7 Program slice strategy

7.7 Program slice strategy

7.7.1 Program slice assumptions

The program slice strategy assumes that a tool is available that will perform control and data-flow analysis on the application and provide the slicing information. Doing this analysis by hand can be quite tedious. If the variable that has an incorrect value is a local variable, intraprocedural analysis may suffice. Otherwise, interprocedural analysis is needed.

A program slice of a program, with respect to a specific location in a program and a set of variables referenced at that location, is the set of statements and predicates in the program that may affect the value of the variables at that location.

Intraprocedural analysis is performed within the scope of an individual procedure (C++ function, Java method). Interprocedural analysis is performed across the boundaries of individual procedures (C++ functions, Java methods) and is performed on all of the procedures in an executable program. It can sometimes make sense to perform interprocedural analyses within an intermediate level, such as a library or a Java package.

7.7.2 Program slice control structure

The next code sample shows the control structure for the program slice strategy.

 Identify a variable that has an incorrect value  Generate a slice of the application that shows all the      calculations that contributed to the value of      that variable, considering both control flow      and data flow  Do while there are more unexamined contributing      variables      Observe the values taken on by one of the variables      If any of the values of this variable are invalid,      Then          repeat the slicing process on this variable      End-if  End-do  The code segments that have all valid input values but  which contribute invalid values are the cause of the bug 

Debugging by Thinking. A Multidisciplinary Approach
Debugging by Thinking: A Multidisciplinary Approach (HP Technologies)
ISBN: 1555583075
EAN: 2147483647
Year: 2002
Pages: 172

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net