Skip to content

Commit 4ea39e3

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 4ea39e3

File tree

1 file changed

+27
-12
lines changed
  • ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace

1 file changed

+27
-12
lines changed

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

Lines changed: 27 additions & 12 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,19 +219,9 @@ 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));
233-
}
223+
CtfTmfContext ctx = resetTimes();
224+
234225
/*
235226
* Register every event type. When you call getType, it will register a trace to
236227
* that type in the TmfEventTypeManager
@@ -913,4 +904,28 @@ public Path trim(@NonNull TmfTimeRange range, @NonNull Path destinationPath, @No
913904
return null;
914905
}
915906

907+
@Override
908+
public void setTimestampTransform(final ITmfTimestampTransform tt) {
909+
super.setTimestampTransform(tt);
910+
resetTimes();
911+
}
912+
913+
private CtfTmfContext resetTimes() {
914+
CtfTmfContext ctx;
915+
/* Set the start and (current) end times for this trace */
916+
ctx = (CtfTmfContext) seekEvent(0L);
917+
CtfTmfEvent event = getNext(ctx);
918+
if ((ctx.getLocation().equals(CtfIterator.NULL_LOCATION)) || (ctx.getCurrentEvent() == null)) {
919+
/* Handle the case where the trace is empty */
920+
this.setStartTime(TmfTimestamp.BIG_BANG);
921+
} else {
922+
final ITmfTimestamp curTime = event.getTimestamp();
923+
this.setStartTime(curTime);
924+
long endTime = createTimestamp(fTrace.getCurrentEndTime()).getValue();
925+
endTime = Math.max(curTime.getValue(), endTime);
926+
this.setEndTime(TmfTimestamp.fromNanos(endTime));
927+
}
928+
return ctx;
929+
}
930+
916931
}

0 commit comments

Comments
 (0)