diff --git a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/MetadataTest.java b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/MetadataTest.java index 7599c5f761..ec4b770faf 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/MetadataTest.java +++ b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/MetadataTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2014 Ericsson + * Copyright (c) 2013, 2024 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 @@ -346,6 +346,6 @@ public void testParse() throws CTFException { setUp(); assertEquals(new UUID(0xd18e637435a1cd42L, 0x8e70a9cffa712793L), CtfTestTraceUtils.getTrace(testTrace).getUUID()); assertEquals(1332166405241713920.0, CtfTestTraceUtils.getTrace(testTrace).getClock().getClockOffset(), 200.0); - assertEquals(8, CtfTestTraceUtils.getTrace(testTrace).getEnvironment().size()); + assertEquals(10, CtfTestTraceUtils.getTrace(testTrace).getEnvironment().size()); } } diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java index a3282f1dde..14555ae18a 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2023 Ericsson, Ecole Polytechnique de Montreal and others + * Copyright (c) 2011, 2024 Ericsson, Ecole Polytechnique de Montreal and others * * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 which @@ -29,9 +29,9 @@ import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -154,6 +154,18 @@ public String toString() { private static final FileFilter METADATA_FILE_FILTER = new MetadataFileFilter(); private static final Comparator METADATA_COMPARATOR = new MetadataComparator(); + /** + * Clock offset property + * + * @since 6.1 + */ + public static final String CLOCK_OFFSET = "clock_offset"; //$NON-NLS-1$ + + /** + * Clock scale property + */ + private static final String CLOCK_SCALE = "clock_scale"; //$NON-NLS-1$ + private final DeclarationScope fScope = new DeclarationScope(null, MetadataStrings.TRACE); private boolean fUUIDMismatchWarning = false; @@ -777,7 +789,11 @@ public void addStream(ICTFStream stream) throws ParseException { * (key, value) */ public Map getEnvironment() { - return Collections.unmodifiableMap(fEnvironment); + Map env = new LinkedHashMap<>(); + env.putAll(fEnvironment); + env.put(CLOCK_OFFSET, String.valueOf(getOffset())); + env.put(CLOCK_SCALE, String.valueOf(getTimeScale())); + return env; } /** diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java index 9044098568..5f8eacea06 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2015 Ericsson + * Copyright (c) 2012, 2024 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License 2.0 which @@ -245,7 +245,7 @@ public void testGetName() { @Test public void testGetTraceProperties() { int result = fixture.getProperties().size(); - assertEquals(10, result); + assertEquals(11, result); assertEquals(String.valueOf(1332166405241713987L), fixture.getProperties().get("clock_offset")); } diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java index d34aebde0d..7e43aa030d 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2017 Ericsson, École Polytechnique de Montréal + * Copyright (c) 2012, 2024 Ericsson, École Polytechnique de Montréal * * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 which @@ -113,7 +113,9 @@ public class CtfTmfTrace extends TmfTrace * Clock offset property * * @since 1.2 + * @deprecated use {@link CTFTrace#CLOCK_OFFSET} instead */ + @Deprecated public static final String CLOCK_OFFSET = "clock_offset"; //$NON-NLS-1$ /** @@ -584,7 +586,6 @@ public Map getProperties() { return properties; } properties.putAll(trace.getEnvironment()); - properties.put(CLOCK_OFFSET, Long.toUnsignedString(trace.getOffset())); properties.put(Messages.CtfTmfTrace_HostID, getHostId()); return properties; }