Skip to content

ctf: Add new field classes to complete ctf2 parsing#400

Merged
arfio merged 2 commits into
eclipse-tracecompass:masterfrom
arfio:ctf2-fixes
May 29, 2026
Merged

ctf: Add new field classes to complete ctf2 parsing#400
arfio merged 2 commits into
eclipse-tracecompass:masterfrom
arfio:ctf2-fixes

Conversation

@arfio

@arfio arfio commented May 22, 2026

Copy link
Copy Markdown
Contributor

What it does

  • Add the support for the following ctf2 field classes: Fixed-length boolean field class and Dynamic-length BLOB field class
  • Fixes part of CTF2 Field classes missing #376

How to test

Follow-ups

  • Support for fixed-length-bit-map, fixed-length-bit-array, optional

Review checklist

  • As an author, I have thoroughly tested my changes and carefully followed the instructions in this template

Summary by CodeRabbit

  • New Features

    • Fixed-length boolean fields: configurable bit length, byte order, and alignment
    • Dynamic-length blob fields: length-sourced blobs that carry media-type info
    • Blob field display: shows media type and Base64-encoded content
  • Documentation / Parsing

    • TSDL metadata parsing extended to handle dynamic blobs and fixed-length booleans, plus media-type support
  • Tests

    • New unit tests covering boolean parsing/decoding and dynamic blob parsing/handling

Review Change Stack

@arfio arfio requested a review from MatthewKhouzam May 22, 2026 13:54
@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: facb56f1-66dc-48bf-bf58-cac2597f12d6

📥 Commits

Reviewing files that changed from the base of the PR and between 1710b1f and 8ab931d.

📒 Files selected for processing (17)
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/BooleanDeclarationParserTest.java
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/BooleanDeclarationTest.java
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/BooleanDefinitionTest.java
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/DynamicBlobDeclarationTest.java
  • ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BlobDeclaration.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BlobDefinition.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BooleanDeclaration.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BooleanDefinition.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDeclaration.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDefinition.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/BlobDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/DynamicBlobDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/TypeAliasParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/bool/BooleanDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/JsonMetadataStrings.java
  • ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java
✅ Files skipped from review due to trivial changes (1)
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BlobDeclaration.java
🚧 Files skipped from review as they are similar to previous changes (13)
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/BooleanDeclarationParserTest.java
  • ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF
  • ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/bool/BooleanDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/BlobDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/JsonMetadataStrings.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BooleanDefinition.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BooleanDeclaration.java
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/BooleanDeclarationTest.java
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/DynamicBlobDeclarationTest.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDefinition.java
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/BooleanDefinitionTest.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDeclaration.java

📝 Walkthrough

Walkthrough

Adds fixed-length boolean and dynamic-length blob types with declarations/definitions, TSDL parsers, TypeAlias wiring, event-field rendering (Base64 with media type), unit tests, JSON metadata constants, and bumps bundle version to 5.2.0.

Changes

CTF Type System Expansion: Boolean and Dynamic Blob Support

Layer / File(s) Summary
Metadata Constants and Version
ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF, ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/JsonMetadataStrings.java
Bundle version updated to 5.2.0.qualifier. New JSON metadata constants added for FIXED_LENGTH_BOOLEAN, FIXED_LENGTH_BIT_ARRAY, FIXED_LENGTH_BIT_MAP, DYNAMIC_LENGTH_BLOB, OPTIONAL, and MEDIA_TYPE.
Boolean Declaration, Parser, Definition, and Tests
ctf/org.eclipse.tracecompass.ctf.core/src/.../BooleanDeclaration.java, .../BooleanDefinition.java, .../metadata/tsdl/bool/BooleanDeclarationParser.java, ctf/org.eclipse.tracecompass.ctf.core.tests/src/.../Boolean*Test.java, ctf/org.eclipse.tracecompass.ctf.core/src/.../TypeAliasParser.java
Adds BooleanDeclaration (length, byte order, alignment) and BooleanDefinition; BooleanDeclarationParser parses fixed-length boolean TSDL metadata; TypeAliasParser routes FIXED_LENGTH_BOOLEAN. Tests cover parsing, construction, accessors, equivalence, and decoding.
Dynamic Blob Declaration, Parser, Definition
ctf/org.eclipse.tracecompass.ctf.core/src/.../BlobDeclaration.java, .../BlobDefinition.java, .../DynamicBlobDeclaration.java, .../DynamicBlobDefinition.java, .../metadata/tsdl/DynamicBlobDeclarationParser.java, .../metadata/tsdl/BlobDeclarationParser.java, ctf/org.eclipse.tracecompass.ctf.core/src/.../TypeAliasParser.java
Adds dynamic-length blob declaration/definition carrying media type; DynamicBlobDeclarationParser extracts length-field-location and optional media-type; BlobDefinition gains getType(); BlobDeclarationParser fixes media-type key usage; TypeAliasParser routes DYNAMIC_LENGTH_BLOB.
Event Field Rendering Integration
ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java
CtfTmfEventField.parseField() recognizes BlobDefinition and DynamicBlobDefinition and constructs CTFHexBlobField that Base64-encodes bytes and prefixes the media type.
Tests: Dynamic Blob Parsing
ctf/org.eclipse.tracecompass.ctf.core.tests/src/.../DynamicBlobDeclarationTest.java
Unit tests validate dynamic blob extraction across aligned, empty, standard, and large scenarios and preserve media type metadata.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • bhufmann
  • PatrickTasse

"🐰 In streams of bits I hop and see,
New booleans, blobs, and parsers be,
Media types wrapped in Base64 cheer,
Tests hop by, asserting clear,
Hooray — the trace bits sing for me!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.37% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding new CTF2 field classes (boolean and dynamic-length BLOB) to complete CTF2 parsing support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 5

🧹 Nitpick comments (2)
ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java (1)

583-599: ⚡ Quick win

Cache formatted blob output to avoid repeated Base64 work.

getFormattedValue() re-encodes bytes on every call; with dynamic blobs this can become expensive in repeated rendering paths. Cache the formatted string once (same pattern already used by other field classes here).

♻️ Proposed refactor
 final class CTFHexBlobField extends CtfTmfEventField {
 
-    private String fBlobType;
+    private final String fBlobType;
+    private `@Nullable` String fFormattedValue;
@@
     `@Override`
-    public String getFormattedValue() {
-        String encoded = Base64.getEncoder().encodeToString(getValue());
-        return "[" + fBlobType + "]<" + encoded + '>'; //$NON-NLS-1$ //$NON-NLS-2$
+    public synchronized String getFormattedValue() {
+        if (fFormattedValue == null) {
+            String encoded = Base64.getEncoder().encodeToString(getValue());
+            fFormattedValue = "[" + fBlobType + "]<" + encoded + '>'; //$NON-NLS-1$ //$NON-NLS-2$
+        }
+        return fFormattedValue;
     }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java`
around lines 583 - 599, getFormattedValue() currently Base64-encodes getValue()
on every call; add a lazily-initialized cached String field (e.g.,
fFormattedValue) on CTFHexBlobField and compute the "[" + fBlobType + "]<" +
Base64.getEncoder().encodeToString(getValue()) + '>' only once in
getFormattedValue(), store it in the cache and return the cached value on
subsequent calls; follow the same lazy-cache pattern and naming conventions used
by other field classes, and make the cache safe for concurrent reads (e.g., a
volatile field or simple double-check idiom) so repeated rendering avoids
repeated Base64 work.
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDefinition.java (1)

58-60: ⚡ Quick win

Return a defensive copy from getBytes().

getBytes() currently exposes internal mutable state. Any caller can mutate fArray and alter this definition instance unexpectedly.

Proposed fix
     `@Override`
     public byte[] getBytes() {
-        return fArray;
+        return fArray.clone();
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDefinition.java`
around lines 58 - 60, DynamicBlobDefinition.getBytes exposes the internal
mutable byte[] fArray; change getBytes() to return a defensive copy (e.g., clone
or Arrays.copyOf) of fArray instead of the array reference, and handle the null
case consistently (return null or an empty array as appropriate) so callers
cannot mutate the internal state.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BooleanDeclaration.java`:
- Around line 50-55: In createDefinition, ensure the original ByteOrder
(variable byteOrder) is always restored on the BitBuffer even if read(input)
throws: wrap the call to read(input) (and any code that depends on the temporary
fByteOrder) in a try/finally and call input.setByteOrder(byteOrder) in the
finally block so the buffer state is restored before returning or propagating
the exception; reference createDefinition, read(Input)/read(input), fByteOrder,
input.setByteOrder(...), and BooleanDefinition to locate the change.
- Around line 58-63: The BooleanDeclaration.read method incorrectly increments
the chunk index by 1 bit; change the loop to advance by 64-bit chunks and
compute the remaining bits per iteration. Specifically, in read(BitBuffer input)
update the for-loop to iterate with "for (int i = 0; i < fLength; i += 64)" and
use "int remaining = fLength - i" then call input.get(Math.min(64, remaining),
false) so BitBuffer.get is always passed a valid chunk length and the reader
advances by full 64-bit chunks.

In
`@ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDeclaration.java`:
- Around line 41-43: The constructor DynamicBlobDeclaration currently accepts a
nullable lengthName and stores it in fLengthName, but later code (including
other occurrences around the constructor and at the usages noted) dereferences
or compares fLengthName directly; modify all comparisons and dereferences of
fLengthName (including in methods referenced near lines 51-52 and 122-123) to
handle null safely by using null-safe checks (e.g., check fLengthName != null
before calling equals/compare, or use Objects.equals(fLengthName, other) /
Objects.equals(other, fLengthName)) and avoid direct method calls on fLengthName
when it may be null, ensuring the constructor and any equality/lookup logic
account for a null lengthName value.

In
`@ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/DynamicBlobDeclarationParser.java`:
- Around line 72-79: The code currently dereferences
lengthFieldLocation/length-field-location.path without validation in
DynamicBlobDeclarationParser, which can cause runtime exceptions; update the
parsing logic to first confirm lengthFieldLocation.isJsonObject() and that the
object has JsonMetadataStrings.PATH, then ensure the path element is either a
non-empty JsonArray whose last element is a JsonPrimitive string or a
JsonPrimitive string; if any check fails (missing path, path not
object/array/string, empty array, or non-string last element) throw a
ParseException with a clear message; replace direct calls to
getAsJsonObject/getAsJsonArray/getAsString for
lengthFieldLocation/pathElement/lengthName with guarded checks that produce
deterministic ParseException errors.

In
`@ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/TypeAliasParser.java`:
- Around line 196-201: The switch branches for
JsonMetadataStrings.FIXED_LENGTH_BIT_ARRAY and
JsonMetadataStrings.FIXED_LENGTH_BIT_MAP in TypeAliasParser currently break
without assigning targetDeclaration, which later causes a null registration;
change these branches to throw a ParseException (with a clear message mentioning
the unsupported field class) instead of breaking so parsing fails fast. Locate
the switch handling field class in TypeAliasParser (the cases for
FIXED_LENGTH_BIT_ARRAY and FIXED_LENGTH_BIT_MAP) and replace the break logic
with code that raises a ParseException referencing the offending field class and
the alias name being processed, ensuring the method never reaches the later
register-type-alias path with a null targetDeclaration.

---

Nitpick comments:
In
`@ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDefinition.java`:
- Around line 58-60: DynamicBlobDefinition.getBytes exposes the internal mutable
byte[] fArray; change getBytes() to return a defensive copy (e.g., clone or
Arrays.copyOf) of fArray instead of the array reference, and handle the null
case consistently (return null or an empty array as appropriate) so callers
cannot mutate the internal state.

In
`@ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java`:
- Around line 583-599: getFormattedValue() currently Base64-encodes getValue()
on every call; add a lazily-initialized cached String field (e.g.,
fFormattedValue) on CTFHexBlobField and compute the "[" + fBlobType + "]<" +
Base64.getEncoder().encodeToString(getValue()) + '>' only once in
getFormattedValue(), store it in the cache and return the cached value on
subsequent calls; follow the same lazy-cache pattern and naming conventions used
by other field classes, and make the cache safe for concurrent reads (e.g., a
volatile field or simple double-check idiom) so repeated rendering avoids
repeated Base64 work.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 26a2a8a9-0946-48b0-805a-b76f0a0e7a86

📥 Commits

Reviewing files that changed from the base of the PR and between 3c40d1c and 4773240.

📒 Files selected for processing (13)
  • ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BlobDeclaration.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BlobDefinition.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BooleanDeclaration.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BooleanDefinition.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDeclaration.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDefinition.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/BlobDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/DynamicBlobDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/TypeAliasParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/bool/BooleanDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/JsonMetadataStrings.java
  • ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java

MatthewKhouzam
MatthewKhouzam previously approved these changes May 22, 2026

@MatthewKhouzam MatthewKhouzam 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.

Looks great. add unit tests.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/DynamicBlobDeclarationTest.java (1)

42-97: ⚡ Quick win

Add failure-path tests for guard clauses.

Current coverage is solid for success cases, but missing tests for CTFException paths (missing length field, signed length declaration, and insufficient buffer after alignment). Adding those would lock in the contract.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/DynamicBlobDeclarationTest.java`
around lines 42 - 97, Add unit tests to cover the three failure paths that
currently lack coverage: when the referenced length field is missing, when the
length field declaration is signed, and when the buffer doesn't contain enough
bytes after alignment. In DynamicBlobDeclarationTest add three `@Test` methods
that construct the same test harness (use IntegerDeclaration.createDeclaration,
StructDeclaration/StructDefinition, BitBuffer) but for each case assert that
DynamicBlobDeclaration.createDefinition(...) throws CTFException: (1) omit
adding the length field to StructDeclaration to trigger "missing length field",
(2) use an IntegerDeclaration with signed=true to trigger the "signed length"
guard, and (3) create a ByteBuffer/BitBuffer with too-small
bufferSize/startingPosition to trigger the "insufficient buffer after alignment"
guard.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDeclaration.java`:
- Around line 68-79: The bounds checks in DynamicBlobDeclaration are using bits
vs bytes incorrectly and check remaining bytes before alignment; fix by first
calling alignRead(input), then verify input.canRead((int)length * 8) (canRead
expects bit count), ensure length does not exceed Integer.MAX_VALUE as before,
and then check input.getByteBuffer().remaining() >= length (bytes) before
allocating the byte[] and calling input.get(array); update the thrown
CTFException messages to reflect the correct units (bits vs bytes) and include
the same context used in input.get(array).

---

Nitpick comments:
In
`@ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/DynamicBlobDeclarationTest.java`:
- Around line 42-97: Add unit tests to cover the three failure paths that
currently lack coverage: when the referenced length field is missing, when the
length field declaration is signed, and when the buffer doesn't contain enough
bytes after alignment. In DynamicBlobDeclarationTest add three `@Test` methods
that construct the same test harness (use IntegerDeclaration.createDeclaration,
StructDeclaration/StructDefinition, BitBuffer) but for each case assert that
DynamicBlobDeclaration.createDefinition(...) throws CTFException: (1) omit
adding the length field to StructDeclaration to trigger "missing length field",
(2) use an IntegerDeclaration with signed=true to trigger the "signed length"
guard, and (3) create a ByteBuffer/BitBuffer with too-small
bufferSize/startingPosition to trigger the "insufficient buffer after alignment"
guard.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e599f89a-4a7e-4cc7-b59b-80bb0754afce

📥 Commits

Reviewing files that changed from the base of the PR and between ee2860a and 1710b1f.

📒 Files selected for processing (17)
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/BooleanDeclarationParserTest.java
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/BooleanDeclarationTest.java
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/BooleanDefinitionTest.java
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/DynamicBlobDeclarationTest.java
  • ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BlobDeclaration.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BlobDefinition.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BooleanDeclaration.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BooleanDefinition.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDeclaration.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDefinition.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/BlobDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/DynamicBlobDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/TypeAliasParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/bool/BooleanDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/JsonMetadataStrings.java
  • ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java
✅ Files skipped from review due to trivial changes (1)
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BlobDeclaration.java
🚧 Files skipped from review as they are similar to previous changes (12)
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/BlobDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/DynamicBlobDefinition.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/JsonMetadataStrings.java
  • ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java
  • ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/BooleanDefinitionTest.java
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/BooleanDeclarationTest.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/bool/BooleanDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/BooleanDefinition.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/DynamicBlobDeclarationParser.java
  • ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/BooleanDeclarationParserTest.java
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/TypeAliasParser.java

arfio added 2 commits May 29, 2026 14:36
Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
@arfio arfio merged commit b56dba4 into eclipse-tracecompass:master May 29, 2026
5 checks passed
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.

2 participants