Skip to content

Commit b9df9a6

Browse files
committed
tmf.ctf: Re-initialize start and endtime after transform is applied
With this the start and endtime is correct when opening the experiment that has automatically applied timestamp transformation applied. fixes #323 Signed-off-by: Bernd Hufmann <[email protected]>
1 parent f71a42e commit b9df9a6

File tree

1 file changed

+31
-11
lines changed
  • ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace

1 file changed

+31
-11
lines changed

ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import org.eclipse.tracecompass.tmf.core.event.aspect.TmfBaseAspects;
6666
import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
6767
import org.eclipse.tracecompass.tmf.core.project.model.ITmfPropertiesProvider;
68+
import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform;
6869
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
6970
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
7071
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
@@ -218,18 +219,11 @@ public void initTrace(final IResource resource, final String path, final Class<?
218219

219220
try {
220221
this.fTrace = new CTFTrace(path);
221-
CtfTmfContext ctx;
222222
/* Set the start and (current) end times for this trace */
223-
ctx = (CtfTmfContext) seekEvent(0L);
224-
CtfTmfEvent event = getNext(ctx);
225-
if ((ctx.getLocation().equals(CtfIterator.NULL_LOCATION)) || (ctx.getCurrentEvent() == null)) {
226-
/* Handle the case where the trace is empty */
227-
this.setStartTime(TmfTimestamp.BIG_BANG);
228-
} else {
229-
final ITmfTimestamp curTime = event.getTimestamp();
230-
this.setStartTime(curTime);
231-
long endTime = Math.max(curTime.getValue(), fTrace.getCurrentEndTime());
232-
this.setEndTime(TmfTimestamp.fromNanos(endTime));
223+
CtfTmfContext ctx = resetTimes();
224+
225+
if (ctx == null) {
226+
return;
233227
}
234228
/*
235229
* Register every event type. When you call getType, it will register a trace to
@@ -913,4 +907,30 @@ public Path trim(@NonNull TmfTimeRange range, @NonNull Path destinationPath, @No
913907
return null;
914908
}
915909

910+
@Override
911+
public void setTimestampTransform(final ITmfTimestampTransform tt) {
912+
super.setTimestampTransform(tt);
913+
resetTimes();
914+
}
915+
916+
private @Nullable CtfTmfContext resetTimes() {
917+
/* Set the start and (current) end times for this trace */
918+
CtfTmfContext ctx = (CtfTmfContext) seekEvent(0L);
919+
CtfTmfEvent event = getNext(ctx);
920+
/* Verify context is valid. It's only invalid trace if trace.init() hasn't been called) */
921+
if ((ctx != null) && (ctx.getLocation() != null)) {
922+
if ((ctx.getLocation().equals(CtfIterator.NULL_LOCATION)) || (ctx.getCurrentEvent() == null)) {
923+
/* Handle the case where the trace is empty */
924+
this.setStartTime(TmfTimestamp.BIG_BANG);
925+
} else {
926+
final ITmfTimestamp curTime = event.getTimestamp();
927+
this.setStartTime(curTime);
928+
long endTime = createTimestamp(fTrace.getCurrentEndTime()).getValue();
929+
endTime = Math.max(curTime.getValue(), endTime);
930+
this.setEndTime(TmfTimestamp.fromNanos(endTime));
931+
}
932+
return ctx;
933+
}
934+
return null;
935+
}
916936
}

0 commit comments

Comments
 (0)