Patent Publication Number: US-5297248-A

Title: Multi-color animation of computer program execution

Description:
This application is a continuation of application Ser. No. 07/546,056 filed Jun. 28, 1990 now abandoned. 
    
    
     BACKGROUND OF THE INVENTION 
     1. Technical Field 
     This invention relates to computer programming, and more particularly to displaying an animation of a computer program&#39;s execution. 
     2. Description of the Prior Art 
     A major challenge facing software testers is that of understanding the effect that test data has on a subject program. Techniques such as program animation bridge the gulf between the abstractness of test data and the idiomatic logic of an application under test, greatly enhancing the programmer&#39;s understanding of his or her program&#39;s operation. The programmer can then use this understanding to change the program&#39;s design to improve its performance. 
     Animation graphically displays the effect of executing one or more test cases for a computer program. The prior art in program animation may be categorized into two general areas: interpretive animation including SMALLTALK, ACTOR, etc., and executive animation such as in IBM&#39;s INSPECT FOR PL/I AND C/370 and PLITEST products which animate in &#34;real time.&#34; 
     An interpretive animator uses an execution trace of a previously execution of the program as the source of its information about the program&#39;s execution. Interpretive animators are in control at all times, making possible such functions as reverse execution and path tracing. Duisberg, U.S. Pat. No. 4,821,220, entitled &#34;System for Animating Program Operation and Displaying Time-based Relationships,&#34; discloses an interpretive-type animator for software objects. Duisberg&#39;s system uses time-based triggers to control a replay of an execution. In operation, the system records the original execution, saving time stamps at critical moments during the execution. Later, during replay, these time stamps are used to regulate and characterize the original program execution. 
     The program debuggers PLITEST, COBTEST and INSPECT of the International Business Machines Corporation (IBM), all are examples of executive animators. These products operate in real-time, and use color to highlight only the current focus of execution (i.e., the current executed statement or module) as displayed on a user&#39;s screen. 
     Algorithm animation is a distant cousin of interpretive and executive animation. Algorithm animators provide a scripted animation depicting a variety of classical programming data structures. These structures are animated so as to show traversal and data manipulation. Brown et al., U.S. Pat. No. 4,736,321, entitled &#34;Communication Method Between an Interactive Language Processor Workspace and External Processes&#34; is an example of an algorithm animator. Brown et al. disclose the invocation of an external process without having to suspend a currently executing process, passing arguments to an external process and receiving results therefrom in a currently executing APL workspace. 
     Saito et al., U.S. Pat. No. 4,730,315, entitled &#34;Diagrammatic Method of Testing Program,&#34; discloses a method for correlating FORTRAN source code and a directed acyclic graph (&#34;digraph&#34;) thereof in a step, edit, and retry interactive debug facility. Synchronism is preserved between the source code and the digraph by use of FORTRAN reserved words as pointers. 
     Beckett, U.S. Pat. No. 4,080,650, entitled &#34;Facilitating Return From an On-line Debugging Program to a Target Program Breakpoint,&#34; discloses an interactive debug utility in which control is selectively passed from within one process to an external process and returned via breakpoints. 
     There is a need for animating the execution of a computer program in a manner which visually illustrates how the parts of a program respond to various test cases by identifying parts which reach certain user-selected thresholds during their execution. 
     SUMMARY OF THE INVENTION 
     This invention comprises an improved method for animating the execution of a computer program. The basic method displays a visual representation of parts of the program, and animates that representation of the program parts in response to execution of the program. The improvement of this invention detects when thresholds of selected event occurrences are reached for the program parts, and displays the &#34;threshold-reaching&#34; parts in color. In particular, the improvement detects when occurrences of a selected event for a given part of the program reach a first threshold, and colors the displayed representation of that part with a first color. Later, when a higher second threshold for that part is reached that too is detected and the displayed representation of the part is colored a second threshold color. The second threshold color is preferably of different hue than the first color. 
     The invention also includes an improved program animation system having a display device, display and animation means, coloring means, occurrence detection means, and threshold coloring means. The display and animation means produce an animated display of a representation of the program&#39;s parts, and the coloring means allows that displayed representation to be colored. The detection means counts event occurrences for the program parts. Each of the two coloring means detects when a first threshold is reached for a part of the program, and colors the displayed representation of that part in a respective color. The threshold colors are preferably of different hues. 
     The invention also includes an article of manufacture including a recording medium and means recorded on that medium. A displaying means displays a colored representation of the program parts, and that representation is animated by animation means. Detection means detects occurrences of events for the program parts, and first and second coloring means cooperate with the displaying means to color the displayed representations of the program parts with colors as respective occurrence thresholds are reached. The threshold colors are preferably of different hues. 
     Colored animation of the frequency of execution of the tested program&#39;s parts or &#34;objects&#34; vividly illustrates the program&#39;s operation, providing a &#34;moving picture&#34; of the program as it is executed. The addition of threshold coloring graphically illustrates the &#34;hot spots&#34; of a program. 
     Other features and advantages of this invention will become apparent from the following detailed description of the presently preferred embodiment of the invention, taken in conjunction with the accompanying drawings. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a block diagram of a computerized data processing system for coloring an animation of a computer program execution based on statement execution frequencies according to this invention. 
     FIG. 2 is a flowchart of a method for coloring an animation of a computer program execution based on statement execution frequencies according to the preferred embodiment of this invention. 
     FIGS. 3A and 3B are pseudocode implementations of the method of FIG. 2. 
     FIG. 4 shows an example of an execution trace of a COBOL program. 
     FIG. 5 shows an example of screen for selecting the threshold frequencies and threshold colors. The hatching of this figure represents color. 
     FIG. 6 shows an example of a colored representation of a program source code display with the current executed statement highlighted and with other statements colored with threshold colors. The hatching of this figure represents color. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     OVERVIEW 
     This invention provides a colored animation of the execution of a computer program (the &#34;tested program&#34;) which is being tested. In this context animation is the process of recreating the execution of a computer program for purposes of understanding and testing its operation. Colored animation of the frequency of execution of the tested program&#39;s parts or &#34;objects&#34; vividly illustrates how the program responds to various test cases, and thereby helps the program developer to refine the program&#39;s design. 
     The method of this invention provides multi-color animation of a program&#39;s statements, displaying the statements in colors according to certain thresholds of execution frequency, such as the number of times each statement has been executed relative to the total number of statement executions during the test case. As the program is animated, when a given threshold is reach for a particular statement, the color in which the statement is displayed changes to visually indicate that a threshold was reached. The colors incorporate various hues to immediately graphically identify multiple thresholds. The thresholds are user-selectable and continuously variable during the animation. 
     Technical Background 
     The method uses an execution trace 10 of the tested program produced during execution. The execution trace includes a breakdown of the number of times each statement of the tested program was executed. The execution trace is created by breakpoints inserted into the tested program during its compilation. The breakpoints cause certain state information to be recorded when the tested program is later executed. Creation of execution traces is well known in the art, and will not be discussed further except as necessary to the understanding of the invention. 
     Animation Module 
     The animation is performed by an animation module 12 of conventional design. The animation module reads through the execution trace, determining the next statement to be executed based on the execution trace. This animation module is of the interpretive type discussed above, since is relies on the execution trace 10. The choice of animation module is a matter of design choice, there being several suitable animation techniques known in the art. Accordingly, the animation module 12 is not discussed further. The animated display is produced on a color video display device 14 such as a CRT by means of a conventional display driver 16. 
     Threshold Calculation and Coloring 
     The threshold module 18 handles the calculation and coloring of program statements selected by the animation module from the execution trays. After the animation module determines the next executed statement, threshold module calculates the execution frequency for that statement. The execution frequency for any statement is equal to the number of times that statement has been executed so far during the execution trace, divided by the total number of statement executions throughout the entire execution trace. Thus as the animation proceeds through the trace, the execution frequencies for the program statements increase as the statements are executed. In the beginning, while all statements have low execution frequencies, they are displayed in a default color, with only the current executed statement being displayed in a different color. 
     When a particular statement in the program reaches the first threshold frequency selected by the user, the threshold module 18 displays that statement in the threshold color assigned to the first threshold, rather than in the default color for the current executed statement. Having reached the first threshold, the statement remains in the first threshold color even after execution passes to the next statement. Thus, as animation proceeds through the execution trace, statements reaching frequency thresholds assume those thresholds, respective colors thereby visually indicating those statements which are executed most frequently. When the animation of the execution trace is complete, the colors of the statements displayed on the CRT 14 immediately identify in distinctive hues those statements which were executed most. 
     This method is shown in the flow chart of FIG. 2 and the pseudocode of FIGS. 3A and 3B. Referring first to the flow chart of FIG. 2, after the frequency thresholds and threshold colors are selected 201, the animation loops through each of the executed statements. As each executed statement becomes the &#34;current statement&#34; its number of executions is incremented by one and its execution frequency is recalculated 202. If its execution frequency is lower than the first threshold 203, the current statement is colored with the normal color for the current executed statement 204, rather than one of the threshold colors. However, if the first threshold is reached, then the current statement&#39;s execution frequency is tested against the second threshold frequency 205. If the first threshold has been reached 203 but the second threshold has not 205, then the statement is colored with the first threshold color 206. Similarly, the current statement is colored with the second and third threshold colors 208, 210. If the fourth threshold has been reached, then the statement is immediately colored with the fourth threshold color 211. After the statement has been colored on the display, the method loops to take up the next statement in the animation. 
     Referring now to the pseudocode of FIG. 3A, when the execution trace is first opened 301, a total number of statement executions in the trace is stored 302. The fourth frequency thresholds and their respective threshold colors are obtained from the user 303 and 306, together with the default colors for the current executed statement 307 and for all other statements 308. An infinite do-loop 311-330 takes up each executed statement in turn from the execution trace 312. A table of the number of times each statement has been executed so far during the trace is updated for the current statement 313, and the current statement&#39;s execution frequency is calculated 314. Referring now to FIG. 3B, current statement&#39;s execution frequency is then compared in turn with each of the frequency thresholds 315-322. As discussed above for the flow chart of FIG. 2, the current statement is colored with the threshold color of the highest threshold exceeded by that statement or with the default colored one for the current executed statement if no threshold has been reached. The current executed statement is then displayed using the color assigned at lines 315-324, and the next statement in the trace is taken up 330. 
     Advantages over the Prior Art 
     The advantages of the method of the preferred embodiment of this invention are apparent. By providing a multi-hued display of the execution frequency of program statements, this invention allows the programmer to immediately grasp the total gestalt of the program&#39;s execution. 
     Complementary and Alternative Embodiments 
     A first complementary embodiment of this invention comprises a data processing system including a general purpose digital computer programmed to execute the method of the invention, and a display device such as a CRT. Such a computer is a well known article of commerce, such as the PS/2 personal computer of IBM, and is not described further. 
     A second complementary embodiment comprises an article of manufacture for distributing a computer program for performing the method of this invention. Such an article comprises a recording medium upon which are recorded the computer instructions for performing the steps of the method of the invention. The medium is preferably a magnetic tape such as the 31/2 inch (approx. 81/2 cm) removable magnetic diskette used in a PS/2 personal computer. The instructions are recorded on the medium by conventional bulk-recording techniques and devices which are well known in the art, and which are not described further. 
     It will be appreciated that, although specific embodiments of the invention have been described herein for purposes of illustration, various modifications may be made without departing from the spirit and scope of the invention. In particular, the threshold-based coloring may be performed on a graphical representation of the program rather than on the source code. Also, beyond threshold coloring of statement executions, other events such as input/output (I/O) requests, exceptions conditions and errors may be monitored and displayed using threshold colors. Further, beyond frequencies of occurrences, other measures of events such as absolute numbers (e.g., &gt;0 error conditions, &gt;100 I/O requests per second) may be monitored and displayed using threshold colors. The animation of the execution trace may be done in both forward and reverse directions. In the reverse direction the numbers of occurrences would be decremented, rather than incremented as for the forward direction. Furthermore, the use of threshold coloring is equally applicable to executive and algorithmic animation as to the interpretive animation discussed above. 
     Accordingly, the scope of protection of this invention is limited only by the following claims and their equivalents.