Skip to main content

OCCTRE

OCCTRE (Object Code Coverage Trace Enlighter) records instruction-level execution information from a program that is controlled through GDB. It starts or attaches to a target, single-steps the program between two labels, and maps every observed instruction back to its source location.

It answers the questions that come up when the tests of an embedded target run only on a simulator, a debug probe, or in a qualification setup:

  • Which machine instructions of the test binary were actually executed, and how often was each of them seen?
  • Which source file and line belong to every executed instruction?
  • Which successor address did a conditional branch actually take?
  • Which load and store instructions were observed, and at which decoded data address?

Every run writes two equivalent reports next to the test binary, <binary>.csv for scripts and CI, and <binary>.md for review. OCCTRE reports what one execution showed; it does not calculate a coverage percentage.

A useful setup needs three external programs next to OCCTRE itself: a target such as QEMU, SIS, gdbserver, or a hardware debug monitor; a GDB that understands the test binary and its architecture; and an addr2line for the same binary format.

Installation

The latest release is published on PyPI. Install it with pipx, which keeps the tool in its own virtual environment:

pipx install occtre

pipx is packaged as pipx or python-pipx by most distributions. Plain pip works too, inside a virtual environment:

python3 -m venv .venv
. .venv/bin/activate
pip install occtre

Arch Linux users can install the occtre package from the AUR with an AUR helper such as yay -S occtre.

OCCTRE requires Python 3.11 or newer. The target tools are deliberately not Python dependencies: their executable paths are selected in the configuration file, so native and cross-development toolchains can be used side by side.

Quick start

Trace a QEMU target

Copy the template that is closest to the target from occtre/configuration/templates, adjust the tool paths, and run OCCTRE on the test binary:

occtre --binary build/test-program --config qemu_sparc.toml

The report is written next to the test binary. A Markdown report produced by the instruction-jump recorder looks like this:

| Address    | Label(+off)            | Instruction (hex)   | Instruction                    | Opcode   |   Executed | Branch taken   |
|:-----------|:-----------------------|:--------------------|:-------------------------------|:---------|-----------:|:---------------|
| 0x0002026c | fmodf+4                | 05 1f df ff         | sethi  %hi(0x7f7ffc00), %g2    | sethi    |          1 | []             |
| 0x00003554 | nextafterf_test_fun+60 | d1 07 bf fc         | ld  [ %fp + -4 ], %f8          | ld       |          1 | []             |
| 0x000229c0 | nextafterf+136         | 22 bf ff f3         | be,a   0x2298c <nextafterf+84> | be,a     |          1 | ['0x000035dc'] |
| 0x000035dc | fmaxf_test_fun+20      | b8 17 20 38         | or  %i4, 0x38, %i4             | or       |          1 | []             |

The Markdown table shows the columns the selected recorder fills. The CSV report carries all columns, address, location, instruction_hex, instruction_opcode, instruction_decoded, instruction_str, count, source_code, and branch_jumps, in a stable order. Existing files at those two paths are replaced.

Bound the traced region

The recorder single-steps from start-label to stop-label, so the test binary should carry the symbols named there. Compile with debug information if the report shall contain source files and lines.

[recorder]
name = "InstructionJumpRecorder"
binary-path = "{test_binary}"
start-label = "ExecuteTestRun"
stop-label  = "TearDownTestRun"

{test_binary}, {task_host}, {task_port}, and {task_target} are substituted in process options and endpoints. The endpoint of an externally started target can also be passed on the command line.

Select what to record

name in [recorder] Fills Notes
InstructionRecorder count per executed address Answers which instructions ran and how often.
InstructionJumpRecorder branch_jumps in addition Records the observed successors of recognized control-flow instructions.
DataAccessRecorder instruction_decoded in addition Experimental, implemented for the SPARC V8 load and store set.

The architecture in [parser] selects the instruction decoder. ARM, MSP430, PowerPC, RISC-V, SPARC V8, and x86 are supported; SPARC V8 delay slots and annulled branches are resolved before a successor is recorded.

Machine-readable report

The CSV report is meant to be post-processed. Decoded data addresses, for example, can be correlated with symbols by standard binary utilities:

mlr --csv cut -f instruction_decoded test-program.csv \
  | grep -E -i -o "0x[0-9a-f]+" | sort -u

nm -S -n -C --line-numbers test-program | grep ADDRESS_WITHOUT_0x

Those commands are examples rather than part of OCCTRE, and their options depend on the binary format, relocation model, and toolchain.

Command-line options

Option Purpose
-b, --binary Test binary to trace. Required.
-c, --config Path to the configuration file. Defaults to ./config.toml.
-H, --host Host part of the GDB endpoint, overriding the configuration.
-p, --port Port part of the GDB endpoint, overriding the configuration.
-t, --target Complete GDB endpoint, such as HOST:PORT or /dev/tty.
-v, --version Print the version and exit.

--target cannot be combined with --host or --port. The execution reference documents the run lifecycle, the configuration sections, and the process handling in detail.

Exit status

Status Meaning
0 The trace completed and both reports were written.
N The exit code of a target, debugger, or addr2line process that failed, propagated by OCCTRE.
1 A configuration file that cannot be read, an unknown recorder name, or another unhandled error.
2 Invalid arguments, including --target combined with --host or --port.

Scope and limitations

OCCTRE reports observed execution data, not a coverage measurement. Before using a report as evidence:

  • OCCTRE does not enumerate the instructions of the binary, so there is no denominator for a percentage; the expected instruction and branch sets have to be defined separately.
  • branch_jumps lists the successors that were observed, not a static inventory of all possible branch outcomes.
  • Data-access decoding is experimental and limited to SPARC V8.
  • Optimisation, inlining, stripped symbols, relocation, PIE, and address space randomisation change how runtime addresses relate to the static binary.
  • Confirm that the configured start and stop labels bound the intended code, compare a sample of rows against an independent GDB disassembly, and keep the configuration, binary, tool versions, and log with the report.

The evaluation guide explains every column, the recorder modes, and this validation guidance.

License

The OCCTRE source code implemented by Celeres is licensed under the Mozilla Public License 2.0, identified by the SPDX expression MPL-2.0. Third-party libraries remain subject to their own license terms.

Development

Setup for the development environment, the test suite, the pre-commit hooks, the documentation build, and the release build are described in CONTRIBUTING.md.

Metadata

Release files for occtre 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for occtre 1.0.0
File Size Uploaded Provenance Actions
occtre-1.0.0.tar.gz 115.8 kB Without provenance Details for occtre-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for occtre 1.0.0
File Interpreter ABI Platform Actions
occtre-1.0.0-py3-none-any.whl Python 3 none any Details for occtre-1.0.0-py3-none-any.whl

Total release size: 165.5 kB

Release files / occtre-1.0.0.tar.gz

Download URL occtre-1.0.0.tar.gz
Size 115.8 kB
Tags Source
SHA-256 checksum
How to use checksums
87edfde9ffbf58cd88fe88cdb81b9f6a9baf061a0f4803dc03a51bd934280a66
BLAKE2b-256 checksum
How to use checksums
b04bcaff302c8dd864b0841ecac6e21138f1bccff495b96348fb7f15e6b337d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.11.2 Linux/7.0.2-2-pve

Release files / occtre-1.0.0-py3-none-any.whl

Download URL occtre-1.0.0-py3-none-any.whl
Size 49.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6586f03a4cc4903e7a47b9658d0c14d063d58ec235723d456401f722184c53f0
BLAKE2b-256 checksum
How to use checksums
cead193445e86d72902328cd082e3d0bcd8752483aa8d51d6ecd361dfbbd69ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.11.2 Linux/7.0.2-2-pve

Security for occtre 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page