PRAT: Protocol Representation and Analysis Toolkit
PRAT is a research artifact and command-line toolkit for identifying feature-specific code in C/C++/Rust projects using differential coverage analysis.
Given a target project and a named feature, PRAT builds the target twice: once with the feature enabled, and once with it disabled. It runs coverage-producing workloads in both configurations, diffs the resulting coverage files, and reports the source lines associated with the feature.
Static Demo: Mosquitto TLS
The current portfolio demo uses precomputed artifacts from a local smoke run:
-
Target: Mosquitto v2.0.15
-
Feature: TLS
-
Run date: 2026-04-25
-
Command:
prat App/mosquitto TLS --output /tmp/prat-smoke
This demo is static on purpose. Running PRAT means running target build systems, compilers, and workloads, so a public personal-site version should show pinned outputs rather than execute arbitrary submitted repositories.
Pipeline
The pipeline is:
-
Discover the named feature and target adapter.
-
Compile the project with the feature enabled and coverage instrumentation.
-
Run the workload and collect enabled coverage.
-
Compile the project with the feature disabled and coverage instrumentation.
-
Run the workload and collect disabled coverage.
-
Diff coverage files.
-
Extract feature-specific source lines.
-
Generate HTML, JSON, and DOT reports.
Top Affected Files
| File | Removable lines |
|---|---|
conf.c | 326 |
net_mosq.c | 291 |
net.c | 257 |
security_default.c | 223 |
client_shared.c | 160 |
options.c | 155 |
handle_connect.c | 102 |
password_mosq.c | 77 |
Reproduce Locally
git clone <repo-url> cd PRAT python3 -m venv .venv source .venv/bin/activate pip install -e ".[dev]" ./scripts/fetch-targets.sh mosquitto prat App/mosquitto TLS --output results/mosquitto-tls
What This Demonstrates
-
Feature discovery from build configuration files.
-
Feature-on and feature-off builds with coverage instrumentation.
-
Dynamic coverage collection using gcov or llvm-cov.
-
Coverage diffing and extraction of feature-specific source lines.
-
Static reports for inspection and follow-up analysis.
-
Optional source removal and verification workflows for local experiments.
