One user-space repair task per eligible HWE debug-diag / compile-deploy base ID: 320 admitted (C 218, C++ 97, build scripts 5), 1 skipped by the content filter. Each ships a public spec with a check-to-basis table, at least two defects with single-fix fixtures, a symptom-masking fixture and an alternative correct implementation. Claude re-checked all 320: structure, the HWE quality items and trace6 Docker calibration receipts against current digests (320/320 USABLE). Difficulty is unmeasured. Known follow-up: 212 tasks use 120 ad-hoc family names; the next batch maps them to the canonical list. The batch's 1,256-line progress log stays in its factory report and the 36-local branch batch15-hwe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
1.8 KiB
C
67 lines
1.8 KiB
C
#include "trace.h"
|
|
#include <stdio.h>
|
|
|
|
static void write_failure(Trace *trace, int rc)
|
|
{
|
|
if (rc < 0) trace->error = 1;
|
|
else trace->records += 1;
|
|
}
|
|
|
|
void trace_init(Trace *trace, FILE *stream, uint32_t id)
|
|
{
|
|
if (trace == NULL) return;
|
|
trace->stream = stream;
|
|
trace->id = id;
|
|
trace->records = 0;
|
|
trace->error = 0;
|
|
}
|
|
|
|
void trace_begin(Trace *trace, uint16_t mask, unsigned budget, unsigned hold)
|
|
{
|
|
int rc;
|
|
if (trace == NULL || trace->stream == NULL) return;
|
|
if (trace->error) return;
|
|
rc = fprintf(trace->stream, "JOB %u %u %u %u\n",
|
|
trace->id, (unsigned)mask, budget, hold);
|
|
write_failure(trace, rc);
|
|
}
|
|
|
|
void trace_end(Trace *trace, unsigned outcome, unsigned reads)
|
|
{
|
|
int rc;
|
|
if (trace == NULL || trace->stream == NULL) return;
|
|
if (trace->error) return;
|
|
rc = fprintf(trace->stream, "END %u %u %u %u\n",
|
|
trace->id, outcome, reads, trace->records);
|
|
write_failure(trace, rc);
|
|
}
|
|
|
|
void trace_read(Trace *trace, unsigned cursor, uint16_t value, unsigned reads)
|
|
{
|
|
int rc;
|
|
if (trace == NULL || trace->stream == NULL) return;
|
|
if (trace->error) return;
|
|
rc = fprintf(trace->stream, "%u READ %u %u %u\n",
|
|
trace->id, cursor, (unsigned)value, reads);
|
|
write_failure(trace, rc);
|
|
}
|
|
|
|
void trace_checkpoint(Trace *trace, unsigned before, unsigned after, unsigned checkpoints)
|
|
{
|
|
int rc;
|
|
if (trace == NULL || trace->stream == NULL) return;
|
|
if (trace->error) return;
|
|
rc = fprintf(trace->stream, "%u CHECKPOINT %u %u %u\n",
|
|
trace->id, before, after, checkpoints);
|
|
write_failure(trace, rc);
|
|
}
|
|
|
|
int trace_finish(Trace *trace)
|
|
{
|
|
if (trace == NULL) return -1;
|
|
if (trace->stream == NULL) return 0;
|
|
if (trace->error) return -1;
|
|
if (fflush(trace->stream)) return -1;
|
|
return 0;
|
|
}
|