Skip to content

feat(ctrace): centralize diagnostics and add verbose CLI mode - #2638

Merged
thorstendb-ARM merged 12 commits into
mainfrom
feat/ctrace-compact-csv-messages
Oct 1, 2026
Merged

thorstendb-ARM merged 12 commits into
mainfrom
feat/ctrace-compact-csv-messages

Conversation

@thorstendb-ARM

@thorstendb-ARM thorstendb-ARM commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Changes

CSV and normal CLI trace diagnostics now share compact cause/count text. --verbose / -v adds native decoder
details and bounded RAW-file inspection context; CSV remains compact in both modes.

  • Centralize ctrace-owned diagnostic templates in MessageCatalog.inc, with generated IDs, compact/detailed text, typed
    parameter adapters and C++17 format validation. No new dependencies.
  • Carry typed RAW locations that distinguish exact byte positions, formatter hints and input progress. Inspection
    windows are limited to 128 bytes, clipped to the input size and frame-aligned for formatted input. Packet previews
    contain at most 16 bytes with explicit truncation and file/deformatted provenance.
  • Preserve overflow counts, first/last positions, up to three samples and route-specific SYNC anchors. Unknown SYNC
    positions stay unknown. Verbose input context includes absolute path, size, format/framing, configuration and version;
    ambiguous values are quoted/escaped.
  • Preserve severity, exit/failure behavior, filters, route attribution and partial output. Operational errors retain
    actionable causes. Configuration/statistics information requires verbose; byte-skip information remains visible normally.
  • Document the design and RAW-coordinate limitations in tools/ctrace/docs/message-system-design.md.
    No CSV column or CTF schema changes.

Output example

Actual Release CSV diagnostic from trace-event.raw:

796135,,overflow,,,,,Trace overflow; timestamp discontinuity

Normal CLI uses the same message:

[warning] Trace overflow; timestamp discontinuity: inputChannel=SWO, input=./trace-event.SWO.raw

Verbose output adds overflow_count=1, raw_offset=9998, position_kind=exact, SYNC offsets 0/9999 and
read_offset=9934 / read_length=128. Overflow alone remains non-failing (exit 0). Inspect the window with
xxd:

xxd -g 1 -s 9934 -l 128 ./trace-event.SWO.raw

For formatted TB input, positions are formatter hints and packet bytes are deformatted payload, not a contiguous file
range. Read windows are inspection aids, not guaranteed standalone replay captures. Recovery spans count affected RAW
bytes separately from skipped protocol payload.

Checklist

  • 🤖 This change is covered by unit tests (if applicable).
  • 🤹 Manual testing has been performed (if necessary).
  • 🛡️ Security impacts have been considered (if relevant).
  • 📖 Documentation updates are complete (if required).
  • 🧠 Third-party dependencies and TPIP updated (if required). No dependency changes.

Preserve typed diagnostic parameters through decoder, recovery and abort paths. Render compact CSV notes and retain detailed CLI wording, including byte-skip causes.

Centralize CLI-only diagnostics, document the message-system design and coverage audit, and update catalog, transport and output regression tests.
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Test Results

    6 files     12 suites   11s ⏱️
  528 tests   528 ✅  0 💤 0 ❌
1 584 runs  1 566 ✅ 18 💤 0 ❌

Results for commit 1a9233c.

♻️ This comment has been updated with latest results.

Comment thread tools/ctrace/src/model/DiagnosticMessages.cpp Fixed
Move detailed and compact templates into one validated C++17 catalog. Keep typed adapters and preserve output contracts, restore empty initialization diagnostics, extend error and CSV escaping coverage, and correct public documentation.
Restore the requested carry-over clarification: issue #2573 is closed, while public channel selection and transport format/framing remain separate follow-up work.
Keep the public interface focused on formatting. Derive expected argument counts independently in catalog tests instead of exposing production functions solely for tests.
Comment thread tools/ctrace/src/model/Messages.cpp Fixed
Comment thread tools/ctrace/src/model/Messages.cpp Fixed
Comment thread tools/ctrace/src/model/Messages.cpp Fixed
Comment thread tools/ctrace/src/model/Messages.cpp Fixed
Comment thread tools/ctrace/src/model/Messages.cpp Fixed
Comment thread tools/ctrace/src/model/Messages.cpp Fixed
Comment thread tools/ctrace/src/model/Messages.cpp Fixed
Use explicit cursor loops for template scanning and rendering. Keep constexpr-only validation helpers inline in a dedicated implementation namespace, with catalog storage and runtime helpers private. Preserve compile-time validation and output behavior.
@thorstendb-ARM thorstendb-ARM changed the title feat(ctrace): centralize messages and compact CSV diagnostics feat(ctrace): centralize diagnostics and add verbose CLI mode Oct 1, 2026
Comment thread tools/ctrace/src/diagnostics/TraceIssueReporter.cpp Fixed
Comment thread tools/ctrace/src/diagnostics/TraceIssueReporter.cpp Fixed
Build the detailed fields directly in their destination vector and move
it into the reporter. This retains the explicit sample-offset formatter
call while avoiding const initializer-list copies and an uncovered GCC
source-line attribution on that temporary. Values and order stay unchanged.
Build the bounded offset list directly in finish() and remove its
single-use static helper. The previous explicit call still triggered
CodeQL despite runtime coverage proving the function was exercised.
Keep the same values and field order without suppressing the diagnostic
or exporting a private implementation detail.
Integrate the ctrace-ref to ref rename from #2637 while preserving
the central message catalog and compact/verbose diagnostic behavior.
Resolve fixture integrity hashes for renamed YAML and compact CSV.

Validation: macOS arm64 Release build; all seven ctrace CTest entries pass.
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.00%. Comparing base (82c8946) to head (1a9233c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2638      +/-   ##
==========================================
+ Coverage   78.69%   79.00%   +0.30%     
==========================================
  Files         199      207       +8     
  Lines       32802    33279     +477     
  Branches    19167    19311     +144     
==========================================
+ Hits        25814    26291     +477     
  Misses       4661     4661              
  Partials     2327     2327              
Flag Coverage Δ
ctrace-cov 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
tools/ctrace/src/CtraceMain.cpp 100.00% <100.00%> (ø)
tools/ctrace/src/cli/CliParser.cpp 100.00% <100.00%> (ø)
tools/ctrace/src/control/DecodeConsumers.cpp 100.00% <100.00%> (ø)
tools/ctrace/src/control/FileDecodeJob.cpp 100.00% <100.00%> (ø)
tools/ctrace/src/control/TraceDirectoryJob.cpp 100.00% <100.00%> (ø)
tools/ctrace/src/decode/CortexMPostDecoder.cpp 100.00% <100.00%> (ø)
tools/ctrace/src/decode/CortexMPostDecoder.h 100.00% <ø> (ø)
tools/ctrace/src/decode/CortexMStreamDecoder.cpp 100.00% <100.00%> (ø)
tools/ctrace/src/decode/DecodePipeline.cpp 100.00% <100.00%> (ø)
tools/ctrace/src/decode/DwtPacketDecoder.cpp 100.00% <100.00%> (ø)
... and 37 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ReinhardKeil pushed a commit to Open-CMSIS-Pack/cmsis-toolbox that referenced this pull request Oct 1, 2026
## Changes

Document `ctrace --verbose` / `-v` in the CLI option list and briefly
explain detailed stderr diagnostics versus
the default compact messages.

Companion specification for [devtools
#2638](Open-CMSIS-Pack/devtools#2638).

Checked with MkDocs build, rendered-section inspection, and `git diff
--check`. Markdownlint reports no new findings
relative to `main` (45 existing findings).

## Checklist

- [x] 🤖 Unit tests: not applicable; documentation only.
- [x] 🤹 Manual verification: documentation build and rendered section
checked.
- [x] 🛡️ Security impacts considered; documentation only.
- [x] 📖 Documentation updates complete.
- [x] 🧠 No third-party dependency or TPIP changes.

@jreineckearm jreineckearm left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, probably have another look after the next drop if more can be refactored in the central parts of the messaging system. Then you could also consider calling it logging as messaging could also mean asynchronous message posting.

@thorstendb-ARM
thorstendb-ARM merged commit 105d531 into main Oct 1, 2026
23 checks passed
@thorstendb-ARM
thorstendb-ARM deleted the feat/ctrace-compact-csv-messages branch October 1, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants