Reversibly instrumenting a computer software application

A method, system, and computer program product for reversibly instrumenting a computer software application is described. The method may comprise creating a map indicating a plurality of locations of application instruction sections within instructions of a computer software application. The method may further comprise inserting a plurality of instrumentation sections into the computer software application instructions. The method may also comprise updating the map to indicate the locations of the instrumentation sections within the computer software application instructions, where the indications in the map of the locations of the instrumentation sections are distinguishable from the indications in the map of the locations of the application instruction sections. The method may additionally comprise updating the map to indicate a change in any of the locations of any of the application instruction sections within the computer software application instructions subsequent to inserting the instrumentation sections.

FIELD OF THE INVENTION

The invention relates to computer software analysis and design in general.

BACKGROUND OF THE INVENTION

Developers of computer software applications may use tools to create models of their applications. Developers may begin developing an application by first creating a model of the application, and then using tools to automatically generate computer software application code from the model. In other instances, such as where developers work with pre-existing legacy application code, developers may use tools to create a model of an application based on the pre-existing code. Unfortunately, not all aspects of the pre-existing code may be reflected in the model. Furthermore, once a model of an application and the application code are in hand, a developer may wish to make changes to the code and have them reflected in the model, and vice versa, yet not all changes that are made to the code may be reflected in the model. Thus, if the model is used to regenerate the code entirely, such as when instrumenting the code to include instructions that are used to monitor the behavior of the application during execution, as well as when removing such instrumentation, any aspects of the code that are not reflected in the model may be overwritten.

SUMMARY OF THE INVENTION

In one aspect of the invention a method may be provided for reversibly instrumenting a computer software application. The method may include creating a map indicating a plurality of locations of application instruction sections within instructions of a computer software application. The method may further include inserting a plurality of instrumentation sections into the computer software application instructions. The method may also include updating the map to indicate the locations of the instrumentation sections within the computer software application instructions, where the indications in the map of the locations of the instrumentation sections may be distinguishable from the indications in the map of the locations of the application instruction sections. The method may additionally include updating the map to indicate a change in any of the locations of any of the application instruction sections within the computer software application instructions subsequent to inserting the instrumentation sections. The map may be consulted to facilitate the removal of the instrumentation sections from the computer software application instructions, and thereafter the map may be updated.

A system and computer program product embodying the invention may also be provided.

DETAILED DESCRIPTION OF THE INVENTION

The invention is now described within the context of one or more embodiments, although the description is intended to be illustrative of the invention as a whole, and is not to be construed as limiting the invention to the embodiments shown. It is appreciated that various modifications may occur to those skilled in the art that, while not specifically shown herein, are nevertheless within the true spirit and scope of the invention.

Reference is now made toFIG. 1which is a simplified conceptual illustration of a system for reversibly instrumenting a computer software application, constructed and operative in accordance with an embodiment of the invention. In the system ofFIG. 1, a mapper100may be configured to create a map102of the instructions of a computer software application, such as where the instructions are in the form of source code or bytecode, where map102may indicate the locations of one or more sections of application instructions. Mapper100may typically express the location of an application instruction section as a pair of numbers, such as corresponding to the line numbers of the first and last instructions of the application instruction section relative to the first instruction in a data file, or to the line number of the first instruction of the application instruction section and the number of instructions in the section. Mapper100may also indicate the type of each section within map102, such as being of any one of a number of predefined section types104. Section types104may, for example, be used to distinguish between instruction sections that are represented by corresponding elements in a model of the computer software application, which may include public classes, private classes, function calls, and preprocesser commands, and those that do not, such as instrumentation instruction sections as will be described hereinbelow.

A code insertion manager106may be configured to insert into the computer software application instructions one or more instrumentation sections of instructions, such as in order to monitor the behavior of the application during execution. Code insertion manager106may mark the boundaries of each instrumentation section within the computer software application instructions, such as with “//Begin Instrumentation” and “//End Instrumentation” comments that may be part of an instrumentation section.

A map updater108may be configured to update map102to include the instrumentation sections and to indicate the locations of the instrumentation sections within the computer software application instructions. Map updater108may typically express the location of an instrumentation section in the same manner as the application instruction sections, but where the indications in map102of the locations of the instrumentation sections are distinguishable from the indications in map102of the locations of the application instruction sections. This may, for example, by accomplished by indicating within map102that the instrumentation sections are of a different section type than those of the application instruction sections, such as where the instrumentation sections are indicated in map102as being instrumentation-type sections, whereas the application instruction sections are indicated in map102as being of section types other than instrumentation-type sections. Map updater108may also be configured to update map102to indicate a change in any of the locations of any of the application instruction sections within the computer software application instructions subsequent to any instrumentation sections being inserted into the computer software application instructions, either by code insertion manager106or manually.

A code deletion manager110may be configured to remove any of the instrumentation sections from the computer software application instructions by consulting map102. For example, code deletion manager110may remove any instrumentation sections that had been inserted into the computer software application instructions, such as when testing of the computer software application is completed. Map updater108may be configured to update map102to remove the locations of the removed instrumentation sections, and to indicate a change in any of the locations of any of the application instruction sections within the computer software application instructions subsequent to the instrumentation sections being removed from the computer software application instructions.

Map updater108may also be configured to update map102as described hereinabove to reflect any modifications made to application instruction sections and/or instrumentation sections that result in any changes in the number of lines of the instructions of any of the sections and/or to the locations of any of the sections. This includes modifications that are made directly to the instructions of the computer software application, as well as modifications that are made to a model of the computer software application that are then automatically made to the instructions of the computer software application using known techniques. Map updater108may be configured to detect manual changes made to instrumentation sections within the computer software application instructions, such as changes in their locations, by identifying instrumentation section boundary markings within the computer software application instructions, and to update map102accordingly.

Any of the elements shown inFIG. 1may be executed by or otherwise made accessible to a computer112, such as by implementing any of the elements in computer hardware and/or in computer software embodied in a physically-tangible, computer-readable medium in accordance with conventional techniques.

The system ofFIG. 1may be appreciated in the context of an exemplary operational scenario with reference toFIGS. 2A-2F. InFIG. 2Aa simplified set of instructions200of a computer software application may be shown, of which a map202may be created as shown inFIG. 2B. Map202may be created as described hereinabove with reference toFIG. 1, where, as shown inFIG. 2C, different sections204of the set of instructions200may be represented in map202with icons206representing various section types. The location of each section204in the set of instructions200may be represented in map202by mapping the section204to starting and ending line numbers208of each section204in the set of instructions200as follows:The “#ifndef Car_H” section location is: start:=1, end:=1The “Car_H” global Variable section location is: start:=2, end:=2The “Car” Class section location is: start:=5, end:=13The “Drive” Operation section location is: start:=8, end:=8The “color” Attribute section location is: start:=12, end:=12The “#endif” section location is: start:=15, end:=15

InFIG. 2Dthe set of instructions200may be shown as a set of instructions200′ after the insertion of instrumentation instructions. InFIG. 2Emap202may be shown as a map202′ after being updated to represent the inserted sections of instrumentation instructions. As shown inFIG. 2F, the location of each inserted section may be represented in map202′, and the locations of the previous sections may be updated as follows:The “#ifndef Car_H” section location is: start:=5, end:=5The “Car_H” global Variable section location is: start:=6, end:=6The “Car” Class section location is: start:=9, end:=24The “Drive” Operation section location is: start:=15, end:=15The “color” Attribute section location is: start:=23, end:=23The “#endif” section location is: start:=33, end:=33

Reference is now made toFIG. 3which is a simplified flowchart illustration of an exemplary method of operation of the system ofFIG. 1, operative in accordance with an embodiment of the invention. In the method ofFIG. 3, a map of the instructions of a computer software application may be created, where sections of application instructions, their locations within the application instructions, and their section types may be indicated (operation300). One or more sections of instrumentation instructions may be inserted into the computer software application instructions, such as instrumentation code that may be automatically inserted by an application development tool (operation302). The map may be updated to include the instrumentation sections and indicate the locations of the instrumentation sections within the computer software application instructions (operation304). The map may be updated to indicate a change in any of the locations of any of the application instruction sections within the computer software application instructions subsequent to any instrumentation sections being inserted into the computer software application instructions (operation306). Any of the instrumentation sections may be removed from their locations within the computer software application instructions as indicated by the map, such as when a developer wishes to have all instrumentation sections automatically removed from the application instructions (operation308). The map may be updated to remove the locations of the removed instrumentation sections (operation310), and to indicate a change in any of the locations of any of the application instruction sections within the computer software application instructions subsequent to the instrumentation sections being removed from the computer software application instructions (operation312).

Referring now toFIG. 4, block diagram400illustrates an exemplary hardware implementation of a computing system in accordance with which one or more components/methodologies of the invention (e.g., components/methodologies described in the context ofFIGS. 1-3) may be implemented, according to an embodiment of the invention.

As shown, the techniques for controlling access to at least one resource may be implemented in accordance with a processor410, a memory412, I/O devices414, and a network interface416, coupled via a computer bus418or alternate connection arrangement.

It will be appreciated that any of the elements described hereinabove may be implemented as a computer program product embodied in a computer-readable medium, such as in the form of computer program instructions stored on magnetic or optical storage media or embedded within computer hardware, and may be executed by or otherwise accessible to a computer (not shown).

While the methods and apparatus herein may or may not have been described with reference to specific computer hardware or software, it is appreciated that the methods and apparatus described herein may be readily implemented in computer hardware or software using conventional techniques.