Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
de42c12
ctf: add missing types
MatthewKhouzam Dec 4, 2025
568054a
ctf: make an alias cache to auto-expand ctf2 aliases
MatthewKhouzam Dec 4, 2025
e716557
ctf: fix variants can have integer selectors
MatthewKhouzam Dec 4, 2025
52b737a
ctf: introduce Dynamic Length String datatype
MatthewKhouzam Dec 5, 2025
0be7c70
ctf: add static string type
MatthewKhouzam Dec 5, 2025
8a102ca
ctf: add static-length-array
MatthewKhouzam Dec 5, 2025
1d8a646
ctf: fix if type is not declared explicity, but as a subfield
MatthewKhouzam Dec 5, 2025
8094cb3
ctf: add struct support
MatthewKhouzam Dec 5, 2025
5bed904
ctf: add dynamic length strings
MatthewKhouzam Dec 5, 2025
a37cc67
ctf: Use declared length as size for BlobDefinitions
MatthewKhouzam Dec 11, 2025
5fbb1c4
ctf: Allow structs to have ctf2 data
MatthewKhouzam Dec 11, 2025
cbb94cb
ctf: Fix SWTBot Test to have the correct error message to check
MatthewKhouzam Dec 15, 2025
85c6d11
ctf: allow declaration scopes to check if the declaration is overlapping
MatthewKhouzam Dec 11, 2025
8e27a69
ctf: support int tags in variants
MatthewKhouzam Dec 11, 2025
e5e7ffb
ctf: loosen struct check to silently accept null fields
MatthewKhouzam Dec 11, 2025
6ce2001
ctf: Attempt to correct scopeed lookups
MatthewKhouzam Dec 11, 2025
53013c4
ctf: lazy load mappings and use a tree
MatthewKhouzam Dec 12, 2025
56a8fd2
ctf: fix bug of identifier being incorrect in declarationscope
MatthewKhouzam Dec 12, 2025
1ff97a7
ctf: make integerDeclaration#equals count mappings
MatthewKhouzam Dec 12, 2025
0ea8a55
ctf: correctly parse integer size
MatthewKhouzam Dec 12, 2025
4953bf1
ctf: simplify integer declaration
MatthewKhouzam Dec 12, 2025
2026663
ctf: make lookuprole recursive
MatthewKhouzam Dec 12, 2025
fae75da
ctf: Make ctf2 trace have environment
MatthewKhouzam Dec 12, 2025
a2c6c2f
ctf: fix environment
MatthewKhouzam Dec 12, 2025
010fe19
ctf: add support for string2s in tmf
MatthewKhouzam Dec 12, 2025
fb5f92c
ctf: add float support for ctf2
MatthewKhouzam Dec 12, 2025
596875d
ctf: add double float support for ctf2
MatthewKhouzam Dec 12, 2025
d4222b8
ctf: Add unit tests
MatthewKhouzam Dec 12, 2025
eba9abf
ctf: Use constant instead of literal string
MatthewKhouzam Dec 12, 2025
eaa67c8
ctf: handle null environment
MatthewKhouzam Dec 12, 2025
04cc6de
ctf: make CTF1 parsing more rigid
MatthewKhouzam Dec 12, 2025
554cb75
ctf: improve integerdeclaration
MatthewKhouzam Dec 12, 2025
c2cdf0c
common.test: Loosen testing of logger
MatthewKhouzam Dec 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ Export-Package: org.eclipse.tracecompass.common.core.tests;x-friends:="org.eclip
Import-Package: com.google.common.base,
com.google.common.collect,
com.google.common.primitives,
com.google.gson,
org.eclipse.tracecompass.traceeventlogger
Automatic-Module-Name: org.eclipse.tracecompass.common.core.tests
Copy link
Contributor

Choose a reason for hiding this comment

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

This commit should not be in this patch?

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Export-Package: org.eclipse.tracecompass.ctf.core.tests;x-friends:="org.eclipse.
org.eclipse.tracecompass.ctf.core.tests.trace;x-internal:=true,
org.eclipse.tracecompass.ctf.core.tests.types;x-internal:=true
Import-Package: com.google.common.collect,
com.google.gson,
org.antlr.runtime;version="3.2.0",
org.apache.commons.io,
org.eclipse.test.performance,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*******************************************************************************
* Copyright (c) 2025 Ericsson
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/

package org.eclipse.tracecompass.ctf.core.tests.types;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.eclipse.tracecompass.ctf.core.event.types.IntegerDeclaration;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.internal.ctf.core.event.metadata.JsonStructureFieldMemberMetadataNode;
import org.junit.Test;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;

/**
* Integration test class for CTF2 parsing functionality
*/
public class CTF2IntegrationTest {

/**
* Test parsing integer with mappings for enumeration-like behavior
*
* @throws Exception if parsing fails
*/
@Test
public void testIntegerWithMappings() throws Exception {
CTFTrace trace = new CTFTrace();

JsonObject fieldClass = new JsonObject();
fieldClass.add("type", new JsonPrimitive("fixed-length-unsigned-integer"));
fieldClass.add("length", new JsonPrimitive(8));
fieldClass.add("byte-order", new JsonPrimitive("le"));

// Add mappings for enumeration-like behavior
JsonObject mappings = new JsonObject();
JsonArray range1 = new JsonArray();
range1.add(new JsonPrimitive(0));
range1.add(new JsonPrimitive(0));
JsonArray ranges1 = new JsonArray();
ranges1.add(range1);
mappings.add("ZERO", ranges1);

JsonArray range2 = new JsonArray();
range2.add(new JsonPrimitive(1));
range2.add(new JsonPrimitive(1));
JsonArray ranges2 = new JsonArray();
ranges2.add(range2);
mappings.add("ONE", ranges2);

fieldClass.add("mappings", mappings);

JsonStructureFieldMemberMetadataNode node = new JsonStructureFieldMemberMetadataNode(null, "fixed-length-unsigned-integer", "test", "int_field", fieldClass);

IntegerDeclaration result = org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.integer.IntegerDeclarationParser.INSTANCE.parse(node,
new org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.integer.IntegerDeclarationParser.Param(trace));

assertNotNull(result);
assertEquals(8, result.getLength());
assertNotNull(result.getMappings());
assertEquals(2, result.getMappings().size());
assertTrue(result.getMappings().containsKey("ZERO"));
assertTrue(result.getMappings().containsKey("ONE"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*******************************************************************************
* Copyright (c) 2025 Ericsson
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/

package org.eclipse.tracecompass.ctf.core.tests.types;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.nio.ByteOrder;

import org.eclipse.tracecompass.ctf.core.event.types.FloatDeclaration;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.internal.ctf.core.event.metadata.JsonStructureFieldMemberMetadataNode;
import org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.floatingpoint.FloatDeclarationParser;
import org.junit.Test;

import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;

/**
* Test class for FloatDeclarationParser CTF2 support
*/
public class FloatDeclarationParserTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should test 16, 128 and K, where K is greater than 128 and a multiple of 32


/**
* Test parsing 32-bit floating point from CTF2 JSON
*
* @throws Exception if parsing fails
*/
@Test
public void testCTF2Float32Parsing() throws Exception {
CTFTrace trace = new CTFTrace();

JsonObject fieldClass = new JsonObject();
fieldClass.add("length", new JsonPrimitive(32));
fieldClass.add("byte-order", new JsonPrimitive("le"));

JsonStructureFieldMemberMetadataNode node = new JsonStructureFieldMemberMetadataNode(null, "test", "test", "float_field", fieldClass);

FloatDeclaration result = FloatDeclarationParser.INSTANCE.parse(node,
new FloatDeclarationParser.Param(trace));

assertNotNull(result);
assertEquals(8, result.getExponent());
assertEquals(24, result.getMantissa());
assertEquals(ByteOrder.LITTLE_ENDIAN, result.getByteOrder());
}

/**
* Test parsing 64-bit floating point from CTF2 JSON
*
* @throws Exception if parsing fails
*/
@Test
public void testCTF2Float64Parsing() throws Exception {
CTFTrace trace = new CTFTrace();

JsonObject fieldClass = new JsonObject();
fieldClass.add("length", new JsonPrimitive(64));
fieldClass.add("byte-order", new JsonPrimitive("be"));
fieldClass.add("alignment", new JsonPrimitive(8));

JsonStructureFieldMemberMetadataNode node = new JsonStructureFieldMemberMetadataNode(null, "test", "test", "double_field", fieldClass);

FloatDeclaration result = FloatDeclarationParser.INSTANCE.parse(node,
new FloatDeclarationParser.Param(trace));

assertNotNull(result);
assertEquals(11, result.getExponent());
assertEquals(53, result.getMantissa());
assertEquals(ByteOrder.BIG_ENDIAN, result.getByteOrder());
assertEquals(8, result.getAlignment());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*******************************************************************************
* Copyright (c) 2025 Ericsson
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/

package org.eclipse.tracecompass.ctf.core.tests.types;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.eclipse.tracecompass.internal.ctf.core.event.metadata.JsonTraceMetadataNode;
import org.junit.Test;

import com.google.gson.JsonObject;

/**
* Test class for JsonTraceMetadataNode environment parsing
*/
public class JsonTraceMetadataNodeTest {

/**
* Test parsing environment object from CTF2 JSON
*
* @throws Exception if parsing fails
*/
@Test
public void testEnvironmentParsing() throws Exception {
JsonTraceMetadataNode node = new JsonTraceMetadataNode(null, "trace-class", "test");

JsonObject environment = new JsonObject();
environment.addProperty("hostname", "test-host");
environment.addProperty("domain", "kernel");
environment.addProperty("tracer_name", "lttng-modules");

// Simulate Gson deserialization by setting the field directly
java.lang.reflect.Field envField = JsonTraceMetadataNode.class.getDeclaredField("fEnvironment");
envField.setAccessible(true);
envField.set(node, environment);

node.initialize();

assertNotNull(node.getEnvironment());
assertEquals("test-host", node.getEnvironment().get("hostname").getAsString());
assertEquals("kernel", node.getEnvironment().get("domain").getAsString());
assertEquals("lttng-modules", node.getEnvironment().get("tracer_name").getAsString());
}
Comment on lines +31 to +51
Copy link

@coderabbitai coderabbitai bot Dec 12, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Avoid brittle reflection on private field fEnvironment (and hard-coded name) if a test seam exists.

This test will silently become invalid on any refactor/rename of JsonTraceMetadataNode.fEnvironment, and may fail under stronger encapsulation (JPMS / tightened setAccessible). Prefer constructing the node via the real Gson deserialization path, or add a test-only seam (e.g., package-private setter/constructor) to inject JsonObject without reflection.

If reflection is unavoidable, at least centralize field access to a helper to keep failures actionable and reduce duplication.

🤖 Prompt for AI Agents
In
ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/JsonTraceMetadataNodeTest.java
around lines 31 to 51, the test uses brittle reflection to set the private field
fEnvironment; replace this with a stable seam: either (preferred) construct the
node via real Gson deserialization by building a JSON string containing the
"environment" object and calling gson.fromJson(...) to obtain a
JsonTraceMetadataNode instance, or add a package-private/testing constructor or
setter on JsonTraceMetadataNode that accepts a JsonObject environment and use
that from the test; if reflection truly cannot be removed, centralize the
reflective access into a single private helper in the test that looks up the
field by name once and throws a clear, actionable exception on failure so
refactors fail loudly.

Copy link
Contributor

Choose a reason for hiding this comment

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

false

Copy link

Choose a reason for hiding this comment

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

@arfio, understood — I'll leave the reflection approach as-is. Feel free to reach out if you'd like to revisit this later! 🐰


/**
* Test UID and packet header parsing
*
* @throws Exception if parsing fails
*/
@Test
public void testUidAndPacketHeader() throws Exception {
JsonTraceMetadataNode node = new JsonTraceMetadataNode(null, "trace-class", "test");

// Simulate Gson deserialization
java.lang.reflect.Field uidField = JsonTraceMetadataNode.class.getDeclaredField("fUid");
uidField.setAccessible(true);
uidField.set(node, "test-uid-123");

node.initialize();

assertEquals("test-uid-123", node.getUid());
}
Comment on lines +58 to +70
Copy link

@coderabbitai coderabbitai bot Dec 12, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Test name doesn’t match coverage: no packet header is set/asserted.

testUidAndPacketHeader only asserts getUid(). Either rename to testUidParsing() or actually inject fPacketHeader (with a minimal JsonStructureFieldMetadataNode) and assert initialize() wires it (e.g., getPacketHeader() not null and/or child linkage if accessible).

🤖 Prompt for AI Agents
In
ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/JsonTraceMetadataNodeTest.java
around lines 58 to 70, the test named testUidAndPacketHeader only sets and
asserts the UID but does not set or assert any packet header; either rename the
test to testUidParsing() or modify it to inject a minimal fPacketHeader (create
a JsonStructureFieldMetadataNode instance, set it via reflection like fUid was
set), call initialize(), and add assertions that getPacketHeader() returns
non-null (and optionally verify the child linkage or expected type) to ensure
initialize() wires the packet header correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

true

Copy link

Choose a reason for hiding this comment

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

@arfio, thank you for confirming!

Would you like to address this in the current PR by either:

  1. Renaming the test to testUidParsing() to match what it actually tests, or
  2. Adding packet header injection and assertions to truly cover both UID and packet header?

If you prefer to defer this to a follow-up, that works too—just let me know!

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*******************************************************************************
* Copyright (c) 2025 Ericsson
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/

package org.eclipse.tracecompass.ctf.core.tests.types;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.eclipse.tracecompass.ctf.core.event.metadata.DeclarationScope;
import org.eclipse.tracecompass.ctf.core.event.types.FloatDeclaration;
import org.eclipse.tracecompass.ctf.core.event.types.IDeclaration;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.internal.ctf.core.event.metadata.JsonStructureFieldMemberMetadataNode;
import org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.TypeAliasParser;
import org.junit.Test;

import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;

/**
* Test class for TypeAliasParser CTF2 field type support
*/
public class TypeAliasParserTest {

/**
* Test parsing fixed-length floating point field class
*
* @throws Exception if parsing fails
*/
@Test
public void testFixedLengthFloatingPointParsing() throws Exception {
CTFTrace trace = new CTFTrace();
DeclarationScope scope = new DeclarationScope(null, "test");

JsonObject fieldClass = new JsonObject();
fieldClass.add("type", new JsonPrimitive("fixed-length-floating-point-number"));
fieldClass.add("length", new JsonPrimitive(32));
fieldClass.add("byte-order", new JsonPrimitive("le"));

JsonStructureFieldMemberMetadataNode node = new JsonStructureFieldMemberMetadataNode(null, "fixed-length-floating-point-number", "test", "float_field", fieldClass);

IDeclaration result = TypeAliasParser.INSTANCE.parse(node,
new TypeAliasParser.Param(trace, scope));

assertNotNull(result);
assertTrue(result instanceof FloatDeclaration);

FloatDeclaration floatDecl = (FloatDeclaration) result;
assertTrue(floatDecl.getExponent() > 0);
assertTrue(floatDecl.getMantissa() > 0);
}

/**
* Test parsing static-length string field class
*
* @throws Exception if parsing fails
*/
@Test
public void testStaticLengthStringParsing() throws Exception {
CTFTrace trace = new CTFTrace();
DeclarationScope scope = new DeclarationScope(null, "test");

JsonObject fieldClass = new JsonObject();
fieldClass.add("type", new JsonPrimitive("static-length-string"));
fieldClass.add("length", new JsonPrimitive(16));
fieldClass.add("encoding", new JsonPrimitive("utf-8"));

JsonStructureFieldMemberMetadataNode node = new JsonStructureFieldMemberMetadataNode(null, "static-length-string", "test", "string_field", fieldClass);

IDeclaration result = TypeAliasParser.INSTANCE.parse(node,
new TypeAliasParser.Param(trace, scope));

assertNotNull(result);
}

/**
* Test parsing dynamic-length string field class
*
* @throws Exception if parsing fails
*/
@Test
public void testDynamicLengthStringParsing() throws Exception {
// Test that the parser doesn't throw an exception for dynamic length strings
// The actual parsing logic may not be fully implemented yet
CTFTrace trace = new CTFTrace();
DeclarationScope scope = new DeclarationScope(null, "test");

JsonObject fieldClass = new JsonObject();
fieldClass.add("type", new JsonPrimitive("dynamic-length-string"));
fieldClass.add("encoding", new JsonPrimitive("utf-8"));

JsonStructureFieldMemberMetadataNode node = new JsonStructureFieldMemberMetadataNode(null, "dynamic-length-string", "test", "dyn_string_field", fieldClass);

try {
IDeclaration result = TypeAliasParser.INSTANCE.parse(node,
new TypeAliasParser.Param(trace, scope));
// If we get here without exception, the basic parsing works
assertNotNull(result);
} catch (Exception e) {
// For now, just verify the parser recognizes the type
assertTrue("Parser should handle dynamic-length-string type",
e.getMessage() == null || !e.getMessage().contains("Invalid field class"));
}
}
Comment on lines +89 to +111
Copy link

@coderabbitai coderabbitai bot Dec 15, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Clarify implementation status of dynamic-length string parsing

The comment and try-catch structure suggest the parsing logic "may not be fully implemented yet." If this feature is incomplete, consider:

  1. Marking the test with @Ignore and a TODO comment with a tracking issue
  2. Or document the expected behavior more clearly in the test
  3. Or implement the missing functionality before merging

Tests that allow both success and certain failures make it difficult to detect regressions.

Do you want me to search the codebase to verify if DynamicLengthStringParser is fully implemented?

🤖 Prompt for AI Agents
In
ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/TypeAliasParserTest.java
around lines 89-111, the test for dynamic-length-string currently swallows
failures in a try/catch which makes regressions undetectable; first check
whether DynamicLengthStringParser is implemented—if it is not, annotate the test
with @Ignore and add a one-line TODO with a tracking issue/PR number explaining
why it’s ignored; if the parser is implemented, remove the lenient try/catch,
assert the parsed result (assertNotNull) and/or assert specific expected
behavior, and fail the test on any exception so the test reliably detects
regressions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the assert in the catch clause, the test should throw in certain cases? If the parser fails, the test should also fail no?

Copy link

Choose a reason for hiding this comment

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

Rate Limit Exceeded

@arfio have exceeded the limit for the number of chat messages per hour. Please wait 2 minutes and 23 seconds before sending another message.

}
2 changes: 1 addition & 1 deletion ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
Bundle-Version: 5.0.2.qualifier
Bundle-Version: 5.1.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.tracecompass.ctf.core;singleton:=true
Bundle-ActivationPolicy: lazy
Expand Down
Loading
Loading