# US 2019/0317877 A1 · Application state monitoring

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

- Number: US 2019/0317877 A1
- Document ID: US20190317877A1
- Status: Published application
- Kind: A1
- Application number: 15/955,160
- Filed: 2018-04-17
- Published: 2019-10-17
- Earliest claimed: 2018-04-17
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Zheng Chen; Jinsong Ji; Ke Wen Lin; Qing Shan Zhang
- Web page: https://patentgrep.com/patent/US20190317877A1

## CPC

- G06F 11/364: {tracing values on a bus}
- G06F 8/44: {Encoding}
- G06F 11/3624: {by performing operations on the source code, e.g. via a compiler}
- G06F 11/3636: {by tracing the execution of the program}
- G06F 11/3644: {by instrumenting at runtime}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Embodiments of the present disclosure relate to methods, systems, and computer program products for monitoring a state of an application. A target object that is to be monitored in an application may be determined in response to receiving a monitoring configuration. A position of the target object in source codes of the application may be identified. A state of the target object may be monitored in response to the application being traced to a location corresponding to the position.

## Claims

### Claim 1

A computer-implemented method, comprising:
in response to receiving a monitoring configuration, determining, by a processor, a target object that is to be monitored using the monitoring configuration;
identifying, automatically by the processor, one or more positions of the target object in source code of an application, the one or more positions being positions in the source code at which the target object is to be monitored according to the monitoring configuration;
inserting, automatically by the processor, a logging command at each of the one or more positions; and
monitoring a state of the target object in response to the application being traced to a location corresponding to at least one of the one or more positions by executing the logging command.

### Claim 2 (depends on 1)

The computer-implemented method of claim 1, wherein the method is implemented in a compiler running on the processor, the method further comprising:
generating, by the compiler, the logging command for logging the state of the target object,
wherein inserting the logging command at each of the one or more positions comprises adding, by the compiler and into object code that is built from the source code, a first logging command at a location corresponding to a first position of the one or more positions in the source code.

### Claim 3 (depends on 2)

The computer-implemented method of claim 2, wherein the identifying the one or more positions comprises:
searching for a candidate position in the source code at which an address of the target object is accessed by a request; and
identifying the candidate position as one of the one or more positions.

### Claim 4 (depends on 3)

The computer-implemented method of claim 3, wherein the identifying the candidate position as one of the one or more positions comprises:
determining that a type of the target object matches a type of an object accessed by the request at the candidate position.

### Claim 5 (depends on 2)

The computer-implemented method of claim 2, further comprising:
determining a scope in the source code for monitoring the target object,
wherein the one or more positions are within the scope in the source code.

### Claim 6 (depends on 5)

The computer-implemented method of claim 5, wherein the monitoring the state of the target object comprises:
executing the logging command by running the object code.

### Claim 7 (depends on 5)

The computer-implemented method of claim 5, wherein the generating the logging command comprises:
determining a format of the target object based on an intermediate representation obtained from the compiler that compiles the source code and builds the object code from the source code,
wherein the logging command is generated based on the format.

### Claim 8 (depends on 7)

The computer-implemented method of claim 7, wherein the generating the logging command further comprises:
determining one or more readable strings for logging the state of the target object based on the intermediate representation; and
generating the logging command based on the one or more readable strings.

### Claim 9 (depends on 7)

The computer-implemented method of claim 7, the method further comprising:
executing the application with the logging command;
analyzing, automatically by the processor, output generated by execution of the logging command when the application traces to the location;
determining, automatically by the processor, based on the analyzed output, that the application contains a bug; and
modifying, automatically by the processor, the source code to remove the bug.

### Claim 10

A system comprising:
a computer-readable memory unit; and
a processor communicatively coupled to the computer-readable memory unit, the processor being configured to perform a method comprising:
receiving a monitoring configuration for an application;
determining, by a compiler and in response to receiving the monitoring configuration, a target object that is to be monitored in the application using the monitoring configuration;
identifying, automatically by the compiler, a monitored position of the target object in source code of the application, the monitored position being a position in the source code at which the target object is to be monitored according to the monitoring configuration;
generating, automatically by the compiler, a logging command for logging a state of the target object;
inserting, automatically by the compiler and into the source code, the logging command at a location corresponding to the monitored position in the source code;
monitoring the state of the target object in response to the application being traced to a location corresponding to the monitored position by executing the logging command.

### Claim 11 (depends on 10)

The system of claim 10, wherein the method performed by the processor further comprises:
compiling, by the compiler, the source code into binary object code, wherein the binary object code includes the logging command.

### Claim 12 (depends on 10)

The system of claim 10, wherein the identifying the monitored position comprises:
searching for a candidate position in the source code at which an address of the target object is accessed by a request; and
identifying the candidate position as the monitored position.

### Claim 13 (depends on 12)

The system of claim 12, wherein the identifying the candidate position as the monitored position comprises:
identifying the candidate position as the position in response to a type of the target object being matched with a type of an object accessed by the request.

### Claim 14

(canceled)

### Claim 15

(canceled)

### Claim 16

(canceled)

### Claim 17

A computer program product for detecting bugs in an application, the computer program product comprising a computer readable storage medium having program instructions embodied therewith, the program instructions executable by a processor to cause the processor to perform a method comprising:
determining, in response to receiving a monitoring configuration, a target object that is to be monitored in an application using the monitoring configuration;
identifying, automatically, a position of the target object in source code of the application;
generating, automatically by a compiler, a logging command for logging a state of the target object;
inserting, automatically by the compiler and into object code that is built from the source code, the logging command at a location corresponding to the position in the source code;
monitoring the state of the target object in response to the application being traced to a location corresponding to the position by executing the logging command,
determining, automatically, based on the monitoring, that the application contains a bug that affects the state of the target object at the position; and
modifying, automatically, the source code to remove the bug from the application.

### Claim 18 (depends on 17)

The computer program product of claim 17, wherein the identifying the position comprises:
searching for a candidate position in the source code at which an address of the target object is accessed by a request; and
identifying the candidate position as the position.

### Claim 19

(canceled)

### Claim 20 (depends on 17)

The computer program product of claim 17, wherein the generating a logging command further comprises:
determining a format of the target object based on an intermediate representation obtained from the compiler that compiles the source code and builds object code from the source code;
determining one or more readable strings for logging the state of the target object based on the intermediate representation; and
generating the logging command based on the one or more readable strings and the format.

### Claim 21 (depends on 1)

The computer-implemented method of claim 1, wherein the monitoring configuration establishes a rule that only positions where a value of the target object is changed are to be monitored, and wherein identifying the one or more positions of the target object comprises:
identifying a plurality of positions in the source code that include the target object;
analyzing the source code to determine a first set of positions and a second set of positions,
wherein the first set of positions includes positions in the source code where the value of the target object is not changed by execution of the code at that position and the second set of positions includes positions in the source code where the value of the target object is changed by execution of the code at that position; and
selecting, as the one or more positions, the second set of positions.

### Claim 22 (depends on 1)

The computer-implemented method of claim 1, wherein the monitoring configuration includes a list of target objects, each target object in the list of target object having an associated identifier and one or more monitoring rules that define when the target object is to be monitored, and wherein identifying the one or more positions of the target object includes:
analyzing, by a parser, the monitoring configuration to determine which objects in the source code are target objects, and to determine the one or more monitoring rules associated with each target object.

### Claim 23 (depends on 1)

The computer-implemented method of claim 1, wherein:
the target object is defined by a class having two or more types, each type having an associated variable;
the monitoring configuration identifies the target object by its class;
the method further comprises determining, based on a definition of the class, each of the two or more variables of the target object;
identifying the one or more positions of the target object includes identifying positions of each of the two or more variables in the source code; and
monitoring the state of the target object includes monitoring a value of each of the two or more variables during execution of the application in a debugging environment.

### Claim 24 (depends on 10)

The system of claim 10, wherein the method performed by the processor further comprises:
determining, based on the monitoring, that the application contains a bug that affects the state of the target object at the monitored position;
modifying the source code to remove the bug from the application;
removing, automatically, the logging command from the source code; and
compiling, by the compiler and after removing the logging command from the source code, the source code into binary object code for the application.
