Def-use chain

from Wikipedia, the free encyclopedia

A Def-Use chain is a data structure that describes successive pairs of read and write accesses to a variable .

As part of software engineering, data flow tests are carried out in white box testing using def-use chains, which enable code to be run through using test values ​​for variables.

Application example

In the following, a Def-Use chain is to be created for the variable "d". The following code finds the greatest common divisor (GGT) of two numbers "a" and "b" and is implemented in Java .

 1  public int ggt(int a, int b){
 2     int c = a;
 3     int d = b;
 4     if(c == 0)
 5        return d;
 6     while(d != 0){
 7        if(c > d)
 8           c = c - d;
 9        else
10           d = d - c;
11     }
12     return c;
13  }

To create all Def-Use-Chains for the variable "d", proceed as follows:

  1. Determination of the first write access (definition of the variables)
    In this case this corresponds to the assignment "d = b" (line 3)
  2. Determining the first read access
    In this case this corresponds to the instruction "return d"
  3. Write this information down in the following style:
    [Name of the examined variables, specific write access, specific read access]
    In this case this corresponds to [d, d = b, return d]

Now these steps are repeated, each write access being linked to each read access of the examined variables.

The result is then:

  1. [d, d = b, return d]
  2. [d, d = b, while (d! = 0)]
  3. [d, d = b, if (c> d)]
  4. [d, d = b, c = cd]
  5. [d, d = b, d = dc]
  6. [d, d = dc, while (d! = 0)]
  7. [d, d = dc, if (c> d)]
  8. [d, d = dc, c = cd]
  9. [d, d = dc, d = dc]

literature

  • Aditya P. Mathur: Foundations of Software Testing. Fundamental Algorithms and Techniques. An Undergrate and Graduate Text. A Reference for the Practicing Software Engineer . Pearson Education India, Delhi a. a. 2008, ISBN 978-81-317-0795-1 , pp. 462 (English, limited preview in Google Book search).

Individual evidence

  1. ^ Prof. Herbert Kuchen: Software Engineering, script WS09 / 10 . ( Memento of the original from January 23, 2017 in the Internet Archive ) Info: The archive link was inserted automatically and has not yet been checked. Please check the original and archive link according to the instructions and then remove this notice. (PDF; 234 kB) Westphalian Wilhelms University of Münster. Pp. 403, 407ff. Retrieved January 23, 2017. @1@ 2Template: Webachiv / IABot / www.wi1.uni-muenster.de
  2. Henning Heitkötter: Software Engineering WS09 / 10, solution to exercise sheet 6 . ( Memento of the original from January 23, 2017 in the Internet Archive ) Info: The archive link was inserted automatically and has not yet been checked. Please check the original and archive link according to the instructions and then remove this notice. (PDF; 554 kB) Westphalian Wilhelms University of Münster. P. 25. Retrieved January 23, 2017. @1@ 2Template: Webachiv / IABot / www.wi1.uni-muenster.de