Skip to content

Ctrace exception return - #2587

Merged
thorstendb-ARM merged 9 commits into
mainfrom
ctrace-exception-return
Sep 2, 2026
Merged

Ctrace exception return#2587
thorstendb-ARM merged 9 commits into
mainfrom
ctrace-exception-return

Conversation

@thorstendb-ARM

Copy link
Copy Markdown
Contributor

Fixes

  • Correctly represents exception return transitions in generated CTF traces.

Changes

  • Preserve entered, exited, and returned exception actions in CTF output.
  • Distinguish trace-originated events from synthetic lane-closing events.
  • Add a dedicated Return lane to the Trace Compass analysis.
  • Order exception lanes as ThreadMode, Return, followed by individual exceptions.
  • Reset active exception state on overflow or data loss, leaving unknown intervals as gaps.
  • Extend unit and integration tests for the new event semantics and visualization.

Validation

  • Built ctrace, CtraceUnitTests, and CtraceIntegTests.
  • All six ctrace test targets pass.
  • Converted a real SWO exception trace with the current build.
  • Validated the generated CTF using Babeltrace 2.
  • Verified the state-system result in Trace Compass Trace Server.

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).

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Test Results

  4 files    4 suites   1s ⏱️
185 tests 185 ✅ 0 💤 0 ❌
370 runs  363 ✅ 7 💤 0 ❌

Results for commit 0f8047d.

♻️ This comment has been updated with latest results.

@thorstendb-ARM
thorstendb-ARM marked this pull request as ready for review September 1, 2026 12:13
@thorstendb-ARM
thorstendb-ARM force-pushed the ctrace-exception-return branch from 7e56b3c to 6bc1f4f Compare September 1, 2026 12:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation and tests appear consistent with the new exception return/origin semantics, with only minor readability cleanup suggested in a test.

Pull request overview

Updates the ctrace CTF generation and Trace Compass analysis XML to preserve and visualize exception “return” semantics (alongside entered/exited), including distinguishing trace-derived transitions from synthetic lane reconstruction and resetting exception state on discontinuities.

Changes:

  • Extend the CTF exception event schema with a Returned action and an ExceptionOrigin field, and update encoding/decoding accordingly.
  • Update exception lane tracking to emit Enter/Exit/Return transitions with trace vs synthetic origin, and reset lane state on overflow/data loss.
  • Enhance Trace Compass XML to add an EXCEPTION_RETURN lane and order lanes as Thread Mode → Return → per-exception lanes; expand unit/integration tests to cover the new semantics.
File summaries
File Description
tools/ctrace/test/unit/support/CtfTestSupport.h Updates test CTF parser payload sizing for the expanded Exception event payload.
tools/ctrace/test/unit/src/output/ctf/CtfSchemaTests.cpp Extends schema density checks and adds/updates lane-tracker behavior tests for return/origin semantics.
tools/ctrace/test/unit/src/output/ctf/CtfMetadataWriterTests.cpp Validates metadata/XML includes new action/origin fields and verifies lane ordering in the generated Trace Compass XML.
tools/ctrace/test/unit/src/output/ctf/CtfEncoderTests.cpp Updates encoder tests to account for the new Exception payload origin byte.
tools/ctrace/test/unit/src/output/ctf/CtfBundleOutputTests.cpp Updates bundle-output tests for return/origin semantics and adds an overflow/discontinuity regression test.
tools/ctrace/src/output/ctf/TraceCompassXmlWriter.cpp Adds EXCEPTION_RETURN state + view entries and adjusts exception view lane ordering and matching.
tools/ctrace/src/output/ctf/CtfSchema.h Adds Returned and ExceptionOrigin to the schema with value helpers.
tools/ctrace/src/output/ctf/CtfMetadataWriter.cpp Updates exception naming (“Thread Mode”) and writes new enums/fields into the CTF metadata.
tools/ctrace/src/output/ctf/CtfExceptionLaneTracker.h Extends lane tracker API to include Return and RecordOrigin, and updates internal helper signatures.
tools/ctrace/src/output/ctf/CtfExceptionLaneTracker.cpp Implements updated lane transition logic (return + origin) and discontinuity handling semantics.
tools/ctrace/src/output/ctf/CtfEncoder.h Updates exception record emission API to include RecordOrigin.
tools/ctrace/src/output/ctf/CtfEncoder.cpp Encodes exception origin into the Exception event payload and resets lane state on overflow/data loss.
Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tools/ctrace/test/unit/src/output/ctf/CtfMetadataWriterTests.cpp Outdated
Comment thread tools/ctrace/src/output/ctf/CtfEncoder.cpp
Comment thread tools/ctrace/src/output/ctf/CtfEncoder.cpp Outdated
Comment thread tools/ctrace/src/output/ctf/CtfEncoder.h Outdated
Comment thread tools/ctrace/test/unit/src/output/ctf/CtfEncoderTests.cpp Outdated
JonatanAntoni
JonatanAntoni previously approved these changes Sep 2, 2026

@JonatanAntoni JonatanAntoni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, see some neat picking comments

@thorstendb-ARM

Copy link
Copy Markdown
Contributor Author

Thanks, addressed all review comments:

  • Simplified the concatenated XML string literal.
  • Introduced ExceptionNumber as uint16_t and use it consistently, removing masks and casts from the CTF encoder.
  • Kept writeU16(uint16_t) strict to prevent implicit truncation.
  • Centralized CTF exception-record decoding and validation in CtfTestSupport.
  • payloadSize is required before the callback so CtfStreamWriter can handle packet rollover and provide bounded record writes. I documented this requirement at the API.

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.34%. Comparing base (e9d424f) to head (0f8047d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2587      +/-   ##
==========================================
+ Coverage   72.33%   72.34%   +0.01%     
==========================================
  Files         185      185              
  Lines       30317    30334      +17     
  Branches    17892    17894       +2     
==========================================
+ Hits        21929    21946      +17     
  Misses       6079     6079              
  Partials     2309     2309              
Flag Coverage Δ
ctrace-cov 99.80% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
tools/ctrace/src/decode/DwtPacketDecoder.cpp 100.00% <100.00%> (ø)
tools/ctrace/src/model/TraceEvent.h 100.00% <ø> (ø)
tools/ctrace/src/output/ctf/CtfEncoder.cpp 100.00% <100.00%> (ø)
.../ctrace/src/output/ctf/CtfExceptionLaneTracker.cpp 100.00% <100.00%> (ø)
tools/ctrace/src/output/ctf/CtfMetadataWriter.cpp 100.00% <100.00%> (ø)
tools/ctrace/src/output/ctf/CtfSchema.h 100.00% <100.00%> (ø)
tools/ctrace/src/output/ctf/CtfStreamWriter.h 100.00% <ø> (ø)
...ls/ctrace/src/output/ctf/TraceCompassXmlWriter.cpp 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@thorstendb-ARM
thorstendb-ARM merged commit 40ac621 into main Sep 2, 2026
25 of 26 checks passed
@thorstendb-ARM
thorstendb-ARM deleted the ctrace-exception-return branch September 2, 2026 12:01
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