# US 10,372,581 B1 · Instrumentation of program code for dynamic analysis

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

- Number: US 10,372,581 B1
- Document ID: US10372581B1
- Status: Granted
- Kind: B1
- Application number: 12/605,193
- Filed: 2009-10-23
- Granted: 2019-08-06
- Earliest claimed: 2008-10-24
- Assignees: Quest Software, Inc.
- Applicants: John R. MacMillan
- Inventors: John R. MacMillan
- Web page: https://patentgrep.com/patent/US10372581B1

## CPC

- G06F 11/3466: {Performance evaluation by tracing or monitoring}
- G06F 11/3409: {for performance assessment}
- G06F 11/3636: {by tracing the execution of the program}
- G06F 11/302: {where the computing system component is a software system}
- G06F 11/3072: {where the reporting involves data filtering, e.g. pattern matching, time or event triggered, adaptive or policy-based reporting}
- G06F 11/3476: {Data logging (G06F11/14, G06F11/2205 take precedence)}
- G06F 11/3495: {for systems}
- G06F 2201/865: Monitoring of software
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Systems and methods for using a synchronization mechanism to dynamically update instrumentation during program execution are described herein. Using the synchronization mechanism, a decision tree structure of instruments can be avoided, saving processing resources. The synchronization mechanism can be a field or the like that is declared using a synchronization primitive. For example, the synchronization primitive can be a volatile or synchronized keyword in some programming languages. The field can refer to a currently-selected instrument implementation, thereby avoiding using a decision-tree structure to find a desired instrument implementation.

## Claims

### Claim 1

A system for dynamically changing instrumentation used to profile a program during program execution, the system comprising:
memory comprising computer-executable instructions stored thereon, the instructions configured to implement:
a provisioner configured to insert into code of a program an event generator comprising a static call to a static instrument, the static instrument acting as a placeholder instrument, the static instrument comprising:
first and second instrument implementations, wherein at least one of the first and second instrument implementations is configured to gather data from the program in response to being invoked;
first and second event handlers configured to be responsive to an event generated by the event generator, wherein the first event handler invokes the first instrument implementation and the second event handler invokes the second instrument implementation; and
a synchronization field that is declared using a synchronization primitive, the synchronization field comprising a reference to the first event handler, the synchronization field configured to enable dynamic selecting, during execution of the program, of which event handler of the first and second event handlers is invoked in response to the static call, wherein changes made to the synchronization field during the execution are visible during the execution to multiple threads of the program;
an instrument implementation selector configured to dynamically select, during execution of the program, according to an instrumentation setting specified in a table, one of the first and second instrument implementations used to analyze the program during execution of the program by at least:
receiving a user selection of program analysis criteria via the table, the user-selected program analysis criteria specifying at least one of an inclusion and an exclusion of a category pattern; and
based at least in part on the user-selected program analysis criteria, updating the synchronization field to refer to the second event handler of the static instrument instead of the first event handler of the static instrument such that the second instrument implementation is invoked, instead of the first instrument implementation, in response to the event generated by the event generator, wherein the second instrument implementation is configured to profile the program; and
one or more processors configured to implement the computer-executable instructions.

### Claim 2 (depends on 1)

The system of claim 1, wherein the event comprises a method event.

### Claim 3 (depends on 1)

The system of claim 1, wherein the event comprises an object event.

### Claim 4

A method of profiling a program during program execution, the method comprising:
by a computer system comprising computer hardware:
inserting into code of a program an event generator comprising a static call to a static agent instrument;
wherein the static agent instrument acts as a placeholder instrument and comprises:
first and second instrument implementations, wherein at least one of the first and second instrument implementations is configured to gather data from the program in response to being invoked;
first and second event handlers configured to be responsive to an event generated by the event generator, wherein the first event handler invokes the first instrument implementation and the second event handler invokes the second instrument implementation; and
a synchronization field configured to enable dynamic selecting bar an instrument implementation selector, during execution of the program, according to an instrumentation setting specified in a table, of which event handler of the first and second event handlers is invoked in response to the static call, wherein changes made to the synchronization field during the execution are visible during the execution to multiple threads of the program, wherein the synchronization field is declared using a synchronization primitive;
storing a reference to the first event handler in the synchronization field;
receiving a user selection of a program analysis preference via the table, the user-selected program analysis preference specifying at least one of an inclusion and an exclusion of a category pattern;
based at least in part on receiving the user-selected program analysis preference, updating the synchronization field of the static agent instrument to refer to the second event handler of the static agent instrument instead of the first event handler of the static agent instrument; and
calling the second event handler responsive to the event being generated by the event generator, thereby causing the second event handler to call the second instrument implementation, the second instrument implementation being configured to profile the program.

### Claim 5 (depends on 4)

The method of claim 4, further comprising providing a user interface that provides functionality for a user to provide the program analysis preference during program execution.

### Claim 6 (depends on 4)

The method of claim 4, further comprising updating the synchronization field to refer to a third event handler configured to call a third instrument implementation in response to receiving a second user program analysis preference.

### Claim 7 (depends on 4)

The method of claim 4, wherein the event comprises a method event.

### Claim 8 (depends on 4)

The method of claim 4, wherein the event comprises an object event.

### Claim 9 (depends on 4)

The method of claim 4, wherein the computer system comprises multiple computing devices.

### Claim 10 (depends on 4)

The method of claim 4, wherein the synchronization field comprises a volatile field.

### Claim 11

A non-transitory computer-readable storage medium comprising computer-executable program instructions configured to implement a method of analyzing a program, the method comprising:
by one or more processors coupled with computer memory:
inserting into code of a program an event generator comprising a static call to a static instrument, the static instrument acting as a placeholder instrument, the static instrument comprising:
first and second instrument implementations, wherein at least one of the first and second instrument implementations is configured to gather data from the program in response to being invoked;
first and second event handlers configured to be responsive to an event generated by the event generator, wherein the first event handler invokes the first instrument implementation and the second event handler invokes the second instrument implementation; and
a synchronization mechanism;
using the synchronization mechanism to reference the first event handler, wherein the synchronization mechanism is declared using a synchronization primitive, wherein the synchronization mechanism is configured to enable dynamic updating, during execution of the program, of which event handler of the first and second event handlers is invoked in response to the static call, and wherein updates made to the synchronization mechanism during the execution are visible during the execution to multiple threads of the program;
determining, during the execution of the program, whether the second instrument implementation has been selected, by an instrumentation implementation selector, according to a user-specified instrumentation setting in a table, the user-specified instrumentation setting specifying at least one of an inclusion and an exclusion of a category pattern; and
in response to determining that the second instrument implementation has been selected, updating the reference to the first event handler of the static instrument to refer to the second event handler such that the second instrument implementation is invoked, instead of the first instrument implementation, in response to the event generated by the event generator.

### Claim 12 (depends on 11)

The non-transitory computer-readable storage medium of claim 11, wherein the synchronization mechanism comprises a synchronization field.

### Claim 13 (depends on 11)

The non-transitory computer-readable storage medium of claim 11, wherein the synchronization mechanism comprises a volatile field.

### Claim 14 (depends on 11)

The non-transitory computer-readable storage medium of claim 11, wherein the synchronization mechanism comprises an operating system call.

### Claim 15 (depends on 11)

The non-transitory computer-readable storage medium of claim 11, wherein the code comprises managed code.

### Claim 16 (depends on 11)

The non-transitory computer-readable storage medium of claim 11, wherein the first event handler is configured to collect no data from the program.

### Claim 17 (depends on 11)

The non-transitory computer-readable storage medium of claim 11, wherein the first event handler is configured to collect data from the program upon entry of a routine of the program.
