@@ -18,7 +18,8 @@ public class LTTngEvent
1818 : IKeyedDataType < string >
1919 {
2020 private readonly ICtfEvent ctfEvent ;
21- private readonly IEventDescriptor eventDescriptor ;
21+ private readonly IEventDescriptor eventDescriptor ;
22+ private readonly CtfTimestamp adjustedCtfTimestamp ;
2223
2324 internal LTTngEvent ( ICtfEvent ctfEvent )
2425 {
@@ -39,8 +40,13 @@ internal LTTngEvent(ICtfEvent ctfEvent)
3940
4041 this . ctfEvent = ctfEvent ;
4142 this . eventDescriptor = eventDescriptor ;
43+ }
4244
43- /// streamDefinedEventContext
45+ internal LTTngEvent ( LTTngEvent lttngEvent , long timestampAdjustmentNano ) : this ( lttngEvent . ctfEvent )
46+ {
47+ long adjustedTimestamp = Math . Max ( 0 , ( long ) lttngEvent . ctfEvent . Timestamp . NanosecondsFromClockBase + timestampAdjustmentNano ) ;
48+ CtfTimestamp origCtfTimestamp = lttngEvent . ctfEvent . Timestamp ;
49+ this . adjustedCtfTimestamp = new CtfTimestamp ( origCtfTimestamp . BaseIntegerValue , adjustedTimestamp , origCtfTimestamp . ClockDescriptor , origCtfTimestamp . ClockName ) ;
4450 }
4551
4652 /// <summary>
@@ -56,18 +62,18 @@ internal LTTngEvent(ICtfEvent ctfEvent)
5662 /// <summary>
5763 /// Event timestamp. Nanoseconds from the CTF clock the timestamp is associated with.
5864 /// </summary>
59- public Timestamp Timestamp => new Timestamp ( ( long ) this . ctfEvent . Timestamp . NanosecondsFromClockBase ) ;
65+ public Timestamp Timestamp => new Timestamp ( ( long ) ( adjustedCtfTimestamp ? . NanosecondsFromClockBase ?? this . ctfEvent . Timestamp . NanosecondsFromClockBase ) ) ;
6066
6167 /// <summary>
6268 /// Event time as a wall clock.
6369 /// </summary>
64- public DateTime WallClockTime => this . ctfEvent . Timestamp . GetDateTime ( ) ;
70+ public DateTime WallClockTime => adjustedCtfTimestamp ? . GetDateTime ( ) ?? this . ctfEvent . Timestamp . GetDateTime ( ) ;
6571
6672 /// <summary>
6773 /// CTF timestamp
6874 /// </summary>
69- public CtfTimestamp CtfTimestamp => this . ctfEvent . Timestamp ;
70-
75+ public CtfTimestamp CtfTimestamp => adjustedCtfTimestamp ?? this . ctfEvent . Timestamp ;
76+
7177 /// <summary>
7278 /// Event header as defined in the stream for this event.
7379 /// </summary>
0 commit comments