# US 10,310,927 B2 · Operating a trace procedure for a computer program

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 10,310,927 B2
- Document ID: US10310927B2
- Status: Granted
- Kind: B2
- Application number: 14/922,304
- Filed: 2015-10-26
- Published: 2016-11-10
- Granted: 2019-06-04
- Earliest claimed: 2015-05-06
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Thomas Hess; Martin Raitza; Ralf Richter; Philip Sebastian Schulz; Markus K. Strasser
- Web page: https://patentgrep.com/patent/US10310927B2

## CPC

- G06F 11/0778: {Dumping, i.e. gathering error/state information after a fault for later diagnosis}
- G06F 11/0787: {Storage of error reports, e.g. persistent data storage, storage using memory protection}
- G06F 11/079: {Root cause analysis, i.e. error or fault diagnosis (in a hardware test environment G06F11/22; in a software test environment G06F11/36)}
- G06F 11/3612: {by runtime analysis (performance monitoring G06F11/3466)}
- G06F 11/3636: {by tracing the execution of the program}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method is provided for operating a trace procedure, which traces execution of a computer program, where the program uses different callable modules. A program stack is used to store trace buffer information and an error state, and the modules include calls of the trace procedure. The method includes: (i) when entering execution of a module, storing the current write position of the trace buffer and a cleared error flag in the current frame of the stack; (ii) in case of an error condition during execution of the program, setting the error flag in the current frame; and (iii) when leaving execution of a module, determining if the error flag is set, and if not, then rewinding the trace buffer to the write position stored in the current frame, and deleting the current write position of the trace buffer and the error flag from the stack.

## Claims

### Claim 1

A method comprising:
operating a trace procedure, the trace procedure tracing execution of a computer program in a trace buffer using a program stack, the computer program using different callable modules, and the trace buffer being distinct from the program stack, wherein the trace buffer is a last-in, first-out data structure, the program stack is used to store trace buffer information and an execution error state, and the callable modules comprise calls of the trace procedure, the operating comprising:
(i) when entering execution of a callable module on the program stack, tracing the callable module using the trace buffer, and storing in a current stack frame of the program stack a current write position of the trace buffer, the current write position indicating the write position of the trace buffer at time of entering execution of the callable module, and storing an associated execution error flag in the current frame of the stack, the associated execution error flag being stored as a cleared error flag representative of no execution error;
(ii) in case of an execution error condition occurring during execution of the callable module, setting the associated execution error flag in the current frame of the stack to indicate the execution error condition; and
(iii) when leaving execution of the callable module:
determining if the associated execution error flag in the current frame of the stack is set based on an execution error occurring, and based on the associated execution error flag not being set, then changing the trace buffer by rewinding the trace buffer to the write position stored in the current frame of the stack, thereby removing trace of the callable module from the trace buffer;
based on the execution error flag in the current frame not being set, further rolling back reference in the stack to the trace buffer by deleting from the stack the current write position of the trace buffer and the associated execution error flag in the current frame of the stack; and
wherein when leaving execution of the callable module and the associated execution error flag is set in the current frame of the stack, leaving the write position of the trace buffer unchanged, thereby leaving trace of the callable module in the trace buffer.

### Claim 2 (depends on 1)

The method of claim 1, wherein where the computer program comprises an object oriented computer program code, the operating further comprises:
(i) when entering execution of the callable module, storing the current write position of the trace buffer into a trace management object, the current write position indicating the write position before the callable module is executed; and
(ii) when leaving execution of a module:
determining if the associated execution error flag is set based on an execution error occurring, and based on the associated execution error flag not being set, then changing the trace buffer by rewinding the trace buffer to the write position stored in the trace management object, thereby removing trace of the callable module from the trace buffer; and
removing the trace management object from the stack.

### Claim 3 (depends on 1)

The method of claim 1, wherein where the computer program comprises object oriented program code, a trace management object is used containing the write position of the trace buffer and methods for clearing and setting of the associated execution error flag.

### Claim 4 (depends on 3)

The method of claim 3, wherein where the computer program comprises object oriented program code, when leaving execution of a module, the trace management object is automatically deleted.

### Claim 5 (depends on 1)

The method of claim 1, wherein the callable module is a procedure or a function of the computer program.

### Claim 6 (depends on 1)

The method of claim 1, wherein the callable module comprises entering a new context scope in the stack.

### Claim 7 (depends on 1)

The method of claim 1, further comprising managing trace statements of the computer program by an object on the stack.

### Claim 8 (depends on 1)

The method of claim 1, further comprising providing a trace output which dynamically grows and shrinks dependent on the stack state and content.
