Adding instrumentation to a body of code to enable generation of code coverage data
AssigneeInternational Business Machines Corporation
InventorsIan O. Partridge, Adam J. Pilkington, David S. Renshaw, Andrew Taylor
Life of this patent
Estimating the term…
Abstract
A method apparatus and computer program product is disclosed for adding instrumentation to a body of code to enable generation of code coverage data for said body of code in which used instrumentation code is arranged to be optimized out by a compiler.
Claims15
A method for adding instrumentation to a body of code to enable generation of code coverage data for said body of code, said method comprising the steps of:
- identifying one or more code sections in a body of code for adding instrumentation so as to determine whether or not said code sections are covered during subsequent processing of said body of code;
- associating a data structure with said body of code, said data structure comprising one or more data elements, each said data element corresponding exclusively to one of said code sections and each said data element being settable between a first state indicating that said corresponding code section has not been processed and a second state indicating that said corresponding code section has been processed;
- associating a unique code element with each said code section, said code element being arranged when processed to set said data element corresponding exclusively to said code section into said second state so as to indicate that said code section has been processed, said unique code element being further arranged, having set said exclusively corresponding data element to said second state, for removal during subsequent optimization of said body of code;
- automatically inserting one or more of said unique code elements in said body of code;
- and
- associating a further code element with said body of code, said further code element being arranged to prevent removal of said data structure during subsequent optimization of said body of code when all of said data elements are set to said second state.
An apparatus to add instrumentation to a body of code to enable generation of code coverage data for said body of code, said apparatus comprising:
- a processor;
- and
- a memory comprising instructions executable by the processor, the instructions including:
- first logic to identify one or more code sections in a body of code for adding instrumentation so as to determine whether or not said code sections are covered during subsequent processing of said body of code;
- second logic to associate a data structure with said body of code, said data structure comprising one or more data elements, each said data element corresponding exclusively to one of said code sections and each said data element being settable between an first state indicating that said corresponding code section has not been processed and a second state indicating that said corresponding code section has been processed;
- third logic to associate a unique code element with each said code section, said code element being arranged when processed to set said data element corresponding exclusively to said code section into said second state so as to indicate that said code section has been processed, said unique code element being further arranged, having set said exclusively corresponding data element to said second state, for removal during subsequent optimization of said body of code;
- fourth logic to associate a further code element with said body of code, said further code element being arranged to prevent removal of said data structure during subsequent optimization of said body of code when all of said data elements are set to said second state;
- and
- wherein one or more of said unique code elements is automatically inserted in said body of code.
A computer program product comprising:
- a non-transitory computer readable storage medium;
- and
- computer usable code stored on the computer readable storage medium, wherein the computer usable code includes;
- a data structure associated with said computer usable code, said data structure comprising one or more data elements, each said data element corresponding exclusively to a code section of said computer usable code and each said data element being settable from a first state indicating that said corresponding code section has not been processed to a second state indicating that said corresponding code section has been processed;
- and
- one or more unique code elements each associated with one of said code sections of said computer usable code, said code elements being arranged when processed by the running of said computer usable code to set only said data element corresponding exclusively to said code section into said second state so as to indicate that said code section has been processed, said code elements being further arranged, having set said exclusively corresponding data element to said second state, for removal during subsequent optimization of said computer usable code, said code elements being further arranged to ensure that said data structure is not identifiable for removal during said subsequent optimization of said program.
Dependencies are inferred from the claim text.