# US 2013/0159964 A1 · System and method for systematic error injection in generated code

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

- Number: US 2013/0159964 A1
- Document ID: US20130159964A1
- Status: Published application
- Kind: A1
- Application number: 13/327,481
- Filed: 2011-12-15
- Published: 2013-06-20
- Earliest claimed: 2011-12-15
- Assignees: The MathWorks, Inc.
- Inventors: Peter S. Szpak
- Web page: https://patentgrep.com/patent/US20130159964A1

## CPC

- G06F 11/3688: {for test execution, e.g. scheduling of test suites}
- G06F 11/3684: {for test design, e.g. generating new test cases}
- G06F 11/3696: {Methods or tools to render software testable}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A system and method introduces one or more errors into computer programming code generated from a model or other source program. The one or more errors are not present in the model, but are introduced into the code generated from the model. The one or more errors may simulate one or more bugs in the code generation process. The generated code, including the one or more introduced errors, may be analyzed by one or more verification tools. The one or more verification tools examine the generated code in an effort to detect the one or more errors that were introduced. The one or more verification tools may compare the generated code to the model or source program. If the one or more verification tools is able to detect the one or more introduced errors, then the one or more verification tools may be considered to be validated.

## Claims

### Claim 1

A non-transitory, computer-readable storage medium with an executable program stored thereon, where the program instructs a processor to:
receive a model having executable semantics;
generate code from the model;
introduce one or more errors into the code generated from the model, where the one or more errors introduced into the generated code are not present in the model; and
analyze the generated code that includes the one or more introduced errors.

### Claim 2 (depends on 1)

The non-transitory, computer-readable storage medium of claim 1 wherein the analyze instruction is performed to detect the one or more errors introduced into the generated code.

### Claim 3 (depends on 1)

The non-transitory, computer-readable storage medium of claim 1, wherein the analyze instruction includes comparing the generated code having the one or more introduced errors to the model.

### Claim 4 (depends on 1)

The non-transitory, computer-readable storage medium of claim 1, wherein the program further instructs the processor to:
receive a class of error, wherein
the one or more errors introduced into the generated code are of the received class.

### Claim 5 (depends on 4)

The non-transitory, computer-readable storage medium of claim 4 wherein the class of error is selected from the group consisting of:
a statement out of order execution,
an incorrect translation of a math operation,
a write after write,
an unitialized read,
an incorrect literal,
an incorrect data dependency,
an incorrect sample time,
a missing type cast,
an incorrect array indexing,
an unprotected multi-task access,
a variable shadowing, and
a memory leak.

### Claim 6 (depends on 5)

The non-transitory, computer-readable storage medium of claim 5 wherein the class of error is selected by a user or programmatically.

### Claim 7 (depends on 1)

The non-transitory, computer-readable storage medium of claim 1 wherein
the generated code is source code conforming to a computer programming language.

### Claim 8 (depends on 7)

The non-transitory, computer-readable storage medium of claim 7 wherein the computer programming language is selected from the group consisting of:
C,
C++,
C#,
Ada,
SystemC,
Java, and
a Hardware Description Language (HDL).

### Claim 9 (depends on 1)

The non-transitory, computer-readable storage medium of claim 1 wherein the instruction to analyze is performed by a verification tool, and the executable program further instructs the processor to:
determine whether the verification tool detects the one or more errors introduced into the generated code.

### Claim 10 (depends on 9)

The non-transitory, computer-readable storage medium of claim 9 wherein the executable program further instructs the processor to:
receive a selection of the verification tool.

### Claim 11 (depends on 10)

The non-transitory, computer-readable storage medium of claim 10 wherein the selection of the verification tool is received from a user.

### Claim 12 (depends on 9)

The non-transitory, computer-readable storage medium of claim 9 wherein the executable program further instructs the processor to:
provide an Application Programming Interface (API) through which information on
the one or more errors introduced into the generated code,
the analysis performed by the verification tool, or
the one or more errors introduced into the generated code, and the analysis performed by the verification tool
is obtained.

### Claim 13 (depends on 1)

The non-transitory, computer-readable storage medium of claim 1 wherein the executable program further instructs the processor to:
generate a report having information concerning the one or more errors introduced into the generated code, and
provide the report to an output device.

### Claim 14 (depends on 13)

The non-transitory, computer-readable storage medium of claim 13 wherein the information includes a location of the one or more errors within the generated code.

### Claim 15 (depends on 1)

The non-transitory, computer-readable storage medium of claim 1 wherein
the instruction to introduce one or more errors is performed by a code generation tool, and
the one or more errors simulate a bug in the code generation tool.

### Claim 16 (depends on 1)

The non-transitory, computer-readable medium of claim 1, wherein the program further instructs the processor to:
execute the model to produce a set of model results; and
execute the generated code to produce a set of generated code results, wherein the analyze instruction includes comparing the model results to the generated code results.

### Claim 17

A method comprising:
receiving a computer source program, the source program conforming to a first programming language;
storing the received computer source program in a memory;
translating by a processor coupled to the memory, the received computer source program into a new format conforming to a second programming language that is different from the first programming language;
during the translating of the received source program, introducing one or more errors into the new format of the received source program, where the one or more introduced errors do not exist in the received source program; and
analyzing the translated source program in an effort to detect the one or more introduced errors.

### Claim 18 (depends on 17)

The method of claim 17 wherein
the translating includes performing at least one optimization, and
the one or more introduced errors relate to the at least one optimization.

### Claim 19 (depends on 17)

The method of claim 17 wherein
the analyzing includes comparing the source program to the new format in the effort to detect the one or more introduced errors.

### Claim 20 (depends on 17)

The method of claim 17 wherein the analyzing is performed by a selected verification tool.

### Claim 21 (depends on 17)

The method of claim 17 further comprising:
receiving a selection of an error class, wherein
the one or more introduced errors belong to the selected error class.

### Claim 22 (depends on 17)

The method of claim 17 wherein
a number of errors are introduced into the new format, and
the number of errors is user-selected or programmatically determined.

### Claim 23

An apparatus comprising:
means for receiving an executable model;
means for generating computer programming code from the executable model;
means for introducing one or more errors, not appearing in the model, into the computer programming code generated from the model; and
means for verifying the generated code, where the verifying means attempts to detect the one or more errors introduced into the generated computer programming code.

### Claim 24 (depends on 23)

The apparatus of claim 23 wherein the executable model is a graphical model, a text-based model, or a combination graphical and text-based model.

### Claim 25

A machine comprising:
a model editor configured to receive a system model having executable semantics;
a simulation engine implemented by a first processing logic to execute the system model;
a code generation unit implemented by the first or a second processing logic to generate computer programming code from the system model; and
an error injection system implemented by the first, second or a third processing logic to introduce an error into the generated programming code, where
the error is not present in the system model, and
the error simulates a bug in the code generation unit.

### Claim 26 (depends on 25)

The machine of claim 25 wherein
the system model has a plurality of portions and each portion of the system model corresponds to a different scope, and
the error injection system is further configured to receive a designation of a given scope for the error, and to introduce the error in the portion of the system model that corresponds to the given scope.

### Claim 27 (depends on 25)

The machine of claim 25 wherein
the error injection system provides an Application Programming Interface (API) through which information on the error introduced into the generated code is obtained.

### Claim 28 (depends on 27)

The machine of claim 27 further comprising
a high-level technical computing environment implemented by the first, second, third, or a fourth processing logic to
utilize the API to obtain the information on the introduced error from the error injection system, and
process the obtained information from within the high-level technical computing environment.
