# US 2018/0322033 A1 · Code Coverage Tracking For A Microcontroller Program

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

- Number: US 2018/0322033 A1
- Document ID: US20180322033A1
- Status: Published application
- Kind: A1
- Application number: 15/916,509
- Filed: 2018-03-09
- Published: 2018-11-08
- Earliest claimed: 2017-05-02
- Assignees: Microchip Technology Incorporated
- Applicants: Microchip Technology Incorporated
- Inventors: Joseph Drzewiecki; James McInnes
- Web page: https://patentgrep.com/patent/US20180322033A1

## CPC

- G06F 11/3676: {for coverage analysis}
- G06F 8/33: Intelligent editors
- G06F 11/3688: {for test execution, e.g. scheduling of test suites}
- G06F 11/3698: Environments for analysis, debugging or testing of software
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A microcontroller may include a processor and at least one memory device storing (a) program code of a program defining a plurality of dominator arcs based on logical relationships among basic blocks (instructions) in the program code; and (b) a set of instrumentation points consisting of a subset of the program code basic blocks that correspond with the plurality of dominator arcs, each instrumentation point being located in a respective dominator arc. A code coverage implementation program (e.g., IDE or compiler) may be configured to instrument each instrumentation point in the program code with execution tracking instruction(s) to store or generate execution recording information. A testing tool may be used to execute the program on the microcontroller, wherein execution of each respective instrumentation point in the program code causes the respective execution tracking instruction to store or generate execution recording information indicating that the dominator arc corresponding with that instrumentation point has been executed by the testing tool.

## Claims

### Claim 1

A system for code coverage tracking, the system comprising:
a microcontroller comprising:
a processor; and
at least one memory device storing:
program code of a program, the program code defining a plurality of basic blocks and a plurality of dominator arcs based on logical relationships among the plurality of basic blocks; and
a set of instrumentation points in the program code consisting of a subset of the plurality of basic blocks of the program code, the set of instrumentation points corresponding with the plurality of dominator arcs wherein each instrumentation point is located in a respective one of the plurality of dominator arcs;
a code coverage instrumentation program configured to instrument each instrumentation point in the program code with a respective execution tracking instruction to store or generate execution recording information; and
a testing tool configured to execute the program on the microcontroller, wherein execution of each respective instrumentation point in the program code causes the respective execution tracking instruction to store or generate execution recording information,
wherein the execution recording information stored or generated for each instrumentation point indicates that the dominator arc corresponding with the respective instrumentation point has been executed by the testing tool.

### Claim 2 (depends on 1)

The system of claim 1, wherein storing or generating execution recording information for a respective instrumentation point comprises storing a single bit indicating that the respective instrumentation point has been executed.

### Claim 3 (depends on 1)

The system of claim 1, wherein the code coverage tracking further includes:
identifying a set of instrumentation points consisting of selected basic blocks in the plurality of dominator arcs, wherein the set of instrumentation points provides complete code coverage tracking of the program;
determining that a respective instrumentation point has been executed via the testing tool, and in response, storing in a memory device of the microcontroller a bit array indicating that the respective instrumentation point has been executed, the bit array including a single bit for each of the instrumentation points.

### Claim 4 (depends on 1)

The system of claim 1, wherein:
a respective dominator arc includes multiple basic blocks of the plurality of basic blocks; and
storing or generating execution recording information for a respective instrumentation point comprises storing or generating data indicating that each of the multiple basic blocks of the respective dominator arc has been executed.

### Claim 5 (depends on 1)

The system of claim 1, comprising identifying the plurality of dominator arcs in the program by a process including:
generating information representing a directed graph of the plurality of basic blocks;
generating a dominator tree based on the information representing the directed graph of the plurality of basic blocks; and
using the dominator tree to identify the plurality of dominator arcs.

### Claim 6 (depends on 1)

The system of claim 1, wherein the processor is configured to both (a) execute the program code using the testing tool and (b) execute the code execution tracking instructions to perform code coverage tracking of the execution of the program code without a serial, network, or other connection of the microcontroller to a peripheral device to determine the code coverage.

### Claim 7 (depends on 1)

The system of claim 1, wherein the code coverage tracking includes:
determining that all instrumentation points in all dominator arcs have been executed via the testing tool; and
storing in the second memory data indicating that all instrumentation points have been executed, which indicates complete code coverage of the program by the testing tool.

### Claim 8 (depends on 1)

The system of claim 1, wherein the testing tool is provided on the microcontroller.

### Claim 9 (depends on 1)

The system of claim 1, wherein the code coverage instrumentation program is stored in a memory device of a development computer system separate from the microcontroller.

### Claim 10

A microcontroller, comprising:
a processor; and
at least one memory device storing:
a program including program code defining a plurality of basic blocks and a plurality of dominator arcs based on logical relationships among the plurality of basic blocks;
wherein the program code is instrumented with execution tracking instructions at each of a plurality of instrumentation points in the program code, wherein each instrumentation point is located in a corresponding one of the plurality of dominator arcs in the program code;
wherein the program is executable by a testing tool;
wherein during an execution of the program by the testing tool, the execution tracking instructions at each respective instrumentation point are configured to, upon execution of the respective instrumentation point, store or generate execution recording information in the at least one memory device indicating that the respective instrumentation point has been executed;
wherein the execution recording information stored or generated for each respective instrumentation point indicates that the dominator arc corresponding with the respective instrumentation point has been executed by the testing tool.

### Claim 11

A method for code coverage tracking of an execution of program code of a program stored in non-transitory memory, the method comprising:
identifying a plurality of basic blocks of the program code;
generating a dominator tree defining a plurality of dominator arcs based on logical relationships among the plurality of basic blocks;
identifying a set of instrumentation points in the program code consisting of a subset of the plurality of basic blocks of the program code, the set of instrumentation points corresponding with the plurality of dominator arcs wherein each instrumentation point is located in a corresponding one of the plurality of dominator arcs; and
instrumenting each instrumentation point in the program code with respective execution tracking instructions to store or generate execution recording information upon execution of the respective instrumentation point, wherein the execution recording information stored or generated upon execution of each respective instrumentation point indicates that the dominator arc corresponding with the respective instrumentation point has been executed.

### Claim 12 (depends on 11)

The method of claim 11, further comprising:
using a testing tool to execute the program, wherein execution of each respective instrumentation point in the program code causes the respective execution tracking instruction to store or generate execution recording information,
wherein the execution recording information stored or generated for each instrumentation point indicates that the dominator arc corresponding with the respective instrumentation point has been executed by the testing tool; and
accessing the stored execution recording information to determine a code coverage of the program by the testing tool.

### Claim 13 (depends on 12)

The method of claim 12, wherein the code coverage of the program is determined by execution of the program using the testing tool and accessing the execution recording information stored or generated upon execution of the respective instrumentation points without a serial, network, or other connection of the microcontroller to a peripheral device to determine the code coverage.

### Claim 14 (depends on 11)

The method of claim 11, wherein storing or generating execution recording information for a respective instrumentation point comprise storing a single bit indicating that the respective instrumentation point has been executed.

### Claim 15 (depends on 11)

The method of claim 11, wherein instrumenting each instrumentation point in the program code with respective execution tracking instructions comprises instrumenting each instrumentation point with dirty bit instructions configured to set a dirty bit in memory upon execution of the respective instrumentation point.

### Claim 16 (depends on 11)

The method of claim 11, wherein instrumenting each instrumentation point in the program code with respective execution tracking instructions comprises instrumenting each instrumentation point with instructions to modify a no-no (NOP) instruction in the program code, wherein modification of a respective NOP instructions indicates that the instrumentation point was executed.

### Claim 17 (depends on 11)

The method of claim 11, wherein:
a respective dominator arc includes multiple basic blocks of the plurality of basic blocks; and
storing or generating execution recording information for a respective instrumentation point comprises storing or generating data indicating that all basic blocks in the respective dominator arc have been executed.

### Claim 18 (depends on 11)

The method of claim 11, wherein:
the program is stored in a first memory device of the microcontroller; and
the execution tracking instructions are configured to store or generate the execution recording information in a second memory device of the microcontroller.

### Claim 19 (depends on 11)

The method of claim 11, wherein:
the program is stored in a memory device of the microcontroller; and
the execution tracking instructions are configured to store or generate the execution recording information in the same memory device of the microcontroller.
