-
Notifications
You must be signed in to change notification settings - Fork 27
Ctf 2 fix draft #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MatthewKhouzam
wants to merge
30
commits into
eclipse-tracecompass:master
Choose a base branch
from
MatthewKhouzam:ctf-2-fix-draft
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Ctf 2 fix draft #367
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
5bf37e4
ctf: add missing types
MatthewKhouzam 2aa03bf
ctf: make an alias cache to auto-expand ctf2 aliases
MatthewKhouzam eba41ce
ctf: fix variants can have integer selectors
MatthewKhouzam 79dbd0e
ctf: introduce Dynamic Length String datatype
MatthewKhouzam 786ad69
ctf: add static string type
MatthewKhouzam 5b37d63
ctf: add static-length-array
MatthewKhouzam 08559a2
ctf: fix if type is not declared explicity, but as a subfield
MatthewKhouzam 398bd94
ctf: add struct support
MatthewKhouzam 2ee982f
ctf: add Dynamic Length Arrays
MatthewKhouzam 4e067d5
ctf: Use declared length as size for BlobDefinitions
MatthewKhouzam 923f11f
ctf: Allow structs to have ctf2 data
MatthewKhouzam 83e5ef3
ctf: Fix SWTBot Test to have the correct error message to check
MatthewKhouzam d2aabca
ctf: allow declaration scopes to check if the declaration is overlapping
MatthewKhouzam 7ec4b00
ctf: support int tags in variants
MatthewKhouzam c174d38
ctf: loosen struct check to silently accept null fields
MatthewKhouzam 5f17ca0
ctf: Attempt to correct scoped lookups
MatthewKhouzam 4e002f0
ctf: lazy load mappings and use a tree
MatthewKhouzam f9f5808
ctf: fix bug of identifier being incorrect in declarationscope
MatthewKhouzam c2979e2
ctf: make integerDeclaration#equals count mappings
MatthewKhouzam 01b68ef
ctf: correctly parse integer size
MatthewKhouzam 95a125c
ctf: simplify integer declaration
MatthewKhouzam ca45851
ctf: Make ctf2 trace have environment
MatthewKhouzam a01acee
ctf: add support for string2s in tmf
MatthewKhouzam 3de8b50
ctf: add float support for ctf2
MatthewKhouzam 7ea59ad
ctf: add double float support for ctf2
MatthewKhouzam 96e1fb0
ctf: Add unit tests
MatthewKhouzam a72348f
ctf: make CTF1 parsing more rigid
MatthewKhouzam 96f95b8
ctf: improve integerdeclaration
MatthewKhouzam c0ff747
ctf: Update alignment parser to support CTF2
MatthewKhouzam b2a0ffb
common.test: Loosen testing of logger
MatthewKhouzam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
197 changes: 95 additions & 102 deletions
197
...pass.common.core.tests/src/org/eclipse/tracecompass/common/core/tests/log/LoggerTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/CTF2IntegrationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
|
|
||
arfio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * 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")); | ||
| } | ||
| } | ||
81 changes: 81 additions & 0 deletions
81
...e.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/FloatDeclarationParserTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
|
|
||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * Test class for FloatDeclarationParser CTF2 support | ||
| */ | ||
| public class FloatDeclarationParserTest { | ||
arfio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * 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()); | ||
| } | ||
| } | ||
71 changes: 71 additions & 0 deletions
71
...re.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/JsonTraceMetadataNodeTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()); | ||
| } | ||
|
|
||
| /** | ||
| * Test UID header parsing | ||
| * | ||
| * @throws Exception if parsing fails | ||
| */ | ||
| @Test | ||
| public void testUidParsing() 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()); | ||
| } | ||
| } |
115 changes: 115 additions & 0 deletions
115
...ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/TypeAliasParserTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| /******************************************************************************* | ||
| * 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.event.types.IntegerDeclaration; | ||
| 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; | ||
|
|
||
arfio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * 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"); | ||
|
|
||
| // Register a length field in the scope | ||
| IntegerDeclaration lengthDecl = IntegerDeclaration.UINT_5L_DECL; | ||
| scope.registerIdentifier("length", lengthDecl); | ||
|
|
||
| JsonObject fieldClass = new JsonObject(); | ||
| fieldClass.add("type", new JsonPrimitive("dynamic-length-string")); | ||
| fieldClass.add("encoding", new JsonPrimitive("utf-8")); | ||
| JsonObject lengthFieldLocation = new JsonObject(); | ||
| lengthFieldLocation.add("path", new JsonPrimitive("length")); | ||
| fieldClass.add("length-field-location", lengthFieldLocation); | ||
|
|
||
| JsonStructureFieldMemberMetadataNode node = new JsonStructureFieldMemberMetadataNode(null, "dynamic-length-string", "test", "dyn_string_field", fieldClass); | ||
|
|
||
| IDeclaration result = TypeAliasParser.INSTANCE.parse(node, | ||
| new TypeAliasParser.Param(trace, scope)); | ||
| // If we get here without exception, the basic parsing works | ||
| assertNotNull(result); | ||
|
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.