Uninitialized memory watch
AssigneeInternational Business Machines Corporation
InventorsCary Lee Bates, Victor John Gettler
Life of this patent
Estimating the term…
Abstract
In the present invention, a special purpose watch function is used to find reference to uninitialized memory within a computer program during debugging. The uninitialized memory watch may be implemented singularly with respect to a given memory allocation or as a watchpoint wherein a watch is set on a memory space for each instance of a memory allocation during execution of a program. At the point where this watch is set, the program assumes that the memory targeted is uninitialized. When storage to the target memory is made, the watch function marks that segment of memory as initialized and permits continued program execution. Upon detecting a reference to the memory, a determination is made as to whether the watched memory space is initialized.
Claims44
A method for debugging code, comprising:
- setting a watchpoint configured to cause setting of an uninitialized memory watch on a memory location upon being encountered;
- in response to encountering the watchpoint during execution of the code, setting the uninitialized memory watch on the memory location, wherein the uninitialized memory watch is adapted to cause detection of a reference to the memory location during execution of the code;
- when the reference is made to the memory location during execution of the code, determining whether the memory location is initialized;
- and
- if the memory location is not initialized when the reference is made, returning a result to a user interface indicating that the reference was made.
A method for debugging code, comprising:
- setting a watchpoint configured to cause setting of an uninitialized memory watch on a selected memory location upon being encountered;
- in response to encountering the watchpoint during execution of the code, setting the uninitialized memory watch on the selected memory location, which is triggered when a reference is made to the memory location;
- if the reference is a write, executing a first Dcode to mark the memory location as initialized;
- if the reference is a read, executing a second Dcode to determine whether the memory location is initialized;
- and
- if the memory location is not initialized when the read is made, returning a result to a user interface indicating the reference.
A program product, comprising:
- a debugging program, which when executed, comprises the steps:
- allocating at least one memory location in a memory;
- setting a watchpoint configured to cause setting of an uninitialized memory watch on a memory location upon being encountered;
- in response to encountering the watchpoint during execution of the code, setting the uninitialized memory watch on the memory location, which is triggered when a reference is made to the memory location during execution of the target program;
- if the reference is a write, executing a first Dcode to mark the memory location as initialized;
- if the reference is a read, executing a second Dcode to determine whether the memory location is initialized;
- if the memory location is not initialized when the read is made, returning a result to a user interface indicating the reference;
- and a computer readable medium bearing the debugging program.
In a computer system comprising a memory and a processor configured for providing a system exception in response to references to the memory, a method for debugging a program executing in the processor, the method comprising:
- allocating at least one memory location in the memory;
- setting a watchpoint on the memory location configured to cause setting of an uninitialized memory watch on the memory location upon being encountered;
- in response to encountering the watchpoint during execution of the code, setting an uninitialized memory watch on the memory location, wherein when a reference is made to the memory location the uninitialized memory watch is triggered and causes the processor to provide the system exception;
- executing, by the processor, a first Dcode to mark the memory location as initialized if the reference is a write;
- executing, by the processor, a second Dcode to determine whether the memory location is initialized if the reference is a read;
- and
- if the memory location is not initialized when the read is made, returning a result to a user interface indicating the reference.
A method for debugging code, comprising:
- setting, by a user, a watchpoint associated with a statement calling to allocate memory;
- in response to encountering the watchpoint, setting an uninitialized memory watch on a memory location allocated by the statement, wherein the uninitialized memory watch is adapted to cause detection of a memory read operation to the memory location during execution of the code;
- encountering the watch, whereby the memory read operation is detected;
- upon detection of the memory read operation, determining whether the memory location is initialized;
- and
- if the memory location is not initialized, returning a result to a user interface indicating that the reference was made.
A program product, comprising:
- a debugging program, which when executed, comprises the steps:
- setting a watchpoint associated with a call in a target program to allocate memory;
- in response to encountering the watchpoint during execution of the target program, setting an uninitialized memory watch on a portion of memory allocated by the call, wherein the uninitialized memory watch is triggered when a reference is made to the portion of allocated memory during execution of the target program;
- if the reference is a write, executing a first Dcode to mark the allocated memory as initialized;
- if the reference is a read, executing a second Dcode to determine whether the portion of allocated memory is initialized;
- if the portion of allocated memory is not initialized when the read is made, returning a result to a user interface indicating the reference;
- and a computer readable medium bearing the debugging program.
Dependencies are inferred from the claim text.