Dismiss
InnovationQ will be updated on Sunday, Oct. 22, from 10am ET - noon. You may experience brief service interruptions during that time.
Browse Prior Art Database

A method for instrumenting computer programs to check for infinite looping.

IP.com Disclosure Number: IPCOM000015045D
Original Publication Date: 2001-Oct-30
Included in the Prior Art Database: 2003-Jun-20
Document File: 4 page(s) / 101K

Publishing Venue

IBM

Abstract

A Method for Instrumenting Computer Programs to Check for Infinite Looping Rajendra K. Bera IBM Global Services, Golden Enclave, Airport Road, Bangalore 560 017, India. Key words: Program testing, loops.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 43% of the total text.

Page 1 of 4

A method for instrumenting computer programs to check for infinite looping.

A Method for Instrumenting Computer Programs to Check for Infinite Looping

Rajendra K. Bera

IBM Global Services, Golden Enclave, Airport Road, Bangalore 560 017, India.

Key words: Program testing, loops.

Abstract. One of the problems that requires detection during code development and testing is whether a loop will go into infinite cycling. A simple method is provided here that can be used to detect such conditions.

1. Introduction

During code development one frequently encounters situations where, due to coding errors or an incorrect algorithm, a loop goes into infinite cycling. Programmers and testers can save time if the loop(s) causing such problems are detected as quickly as possible. A simple method by which a precompiler tool can, under programmer direction, insert appropriate instructions into a given program for detecting infinite cycling in loops is provided here. The precompiler tool can be made a part of the program editor to support this detection feature.

2. The method

Every time the precompiler tool detects a loop, it prompts the programmer and asks if the loop should be instrumented. If the programmer says "yes", it asks for the minimum number of cycles through which the loop must execute before declaring that the loop is trapped in an infinite cycle. The programmer can give this as a number or as an integer algebraic expression or as a Boolean expression. If given as an expression, the variables used in the expression must be variables which are visible to the loop body.

The precompiler tool generates a unique integer index variable for tracking the loop, called the tracking index, initializes the tracking index to zero and places a statement to that effect immediately prior to the loop statement (such as, index_i = 0), and sets up a conditional

1

Page 2 of 4

statement as the first executable statement in the loop body. The conditional statement is constructed to return a value "true" and deliver an error message if the value of the index variable exceeds the programmer supplied value or it exceeds the value computed by the integer algebraic expression or the Boolean expression returns a "true" value. For example, if the loop is

doi=1,n;

... ... ...
... ... ...
enddo;

then, the instrumented loop would look like

index_i = 0; // Infinite loop test

doi=1,n;
if (index_i++ > infinite_i)
error_msg("index_i", . . .); // Infinite loop test
... ... ...
... ... ...
enddo;

or

index_i = 0; // Infinite loop test

doi=1,n;
if (index_i++ > infinite_exprn)
error_msg("index_i", . . .); // Infinite loop test

... ... ...
... ... ...
enddo;

or

index_i = 0; // Infinite loop test

doi=1,n;
if (Bool_exprn)
error_msg("index_i", . . .); // Infinite loop test
... ... ...
... ... ...
enddo;

where the statements in bold have been provided by the precompiler tool, in which the italicized parts have been supplied by the programmer when queried by the precompiler tool. The function

error...