20
20
import org.eclipse.linuxtools.ctf.core.event.EventDeclaration;
21
21
import org.eclipse.linuxtools.ctf.core.event.EventDefinition;
22
22
import org.eclipse.linuxtools.ctf.core.event.types.Definition;
23
import org.eclipse.linuxtools.ctf.core.event.types.EnumDefinition;
24
23
import org.eclipse.linuxtools.ctf.core.event.types.IDefinitionScope;
25
24
import org.eclipse.linuxtools.ctf.core.event.types.IntegerDefinition;
25
import org.eclipse.linuxtools.ctf.core.event.types.SimpleDatatypeDefinition;
26
26
import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
27
27
import org.eclipse.linuxtools.ctf.core.event.types.StructDefinition;
28
28
import org.eclipse.linuxtools.ctf.core.event.types.VariantDefinition;
295
Definition cpuiddef = getStreamPacketContextDef()
296
.lookupDefinition("cpu_id"); //$NON-NLS-1$
297
if (cpuiddef instanceof IntegerDefinition) {
298
currentCpu = (int) ((IntegerDefinition) cpuiddef)
297
if (this.getCurrentPacket().getTarget() != null) {
298
this.currentCpu = (int) this.getCurrentPacket()
302
302
* Read number of lost events
304
Definition lostEventsdef = getStreamPacketContextDef()
305
.lookupDefinition("events_discarded"); //$NON-NLS-1$
306
if (cpuiddef instanceof IntegerDefinition) {
307
lostEvents = (int) ((IntegerDefinition) lostEventsdef)
305
int totalLostEvents = (int) this.getCurrentPacket()
307
lostEventsInThisPacket = totalLostEvents - lostEvents;
308
lostEvents = totalLostEvents;
309
currentPacket.setLostEvents(lostEventsInThisPacket);
344
345
* If there was a problem reading the trace
346
347
public EventDefinition readNextEvent() throws CTFReaderException {
347
/* WARNING: This is very LTTng-specific. */
348
/* WARNING: This is still LTTng-specific. */
348
349
Long eventID = null;
349
350
long timestamp = 0;
351
if (lostEvents > lostSoFar) {
352
if (lostEventsInThisPacket > lostSoFar) {
352
353
EventDefinition eventDef = EventDeclaration
353
354
.getLostEventDeclaration().createDefinition(
354
355
streamInputReader);
370
371
* Check for an event id.
372
EnumDefinition idEnumDef = (EnumDefinition) sehd
373
SimpleDatatypeDefinition idDef = (SimpleDatatypeDefinition) sehd
373
374
.lookupDefinition("id"); //$NON-NLS-1$
374
assert (idEnumDef != null);
376
eventID = idEnumDef.getIntegerValue();
375
IntegerDefinition timestampDef = sehd.lookupInteger("timestamp"); //$NON-NLS-1$
376
eventID = idDef.getIntegerValue();
379
379
* Check for the variant v.
381
381
VariantDefinition variantDef = (VariantDefinition) sehd
382
382
.lookupDefinition("v"); //$NON-NLS-1$
383
assert (variantDef != null);
386
* Get the variant current field
388
StructDefinition variantCurrentField = (StructDefinition) variantDef
390
assert (variantCurrentField != null);
393
* Try to get the id field in the current field of the variant. If
394
* it is present, it overrides the previously read event id.
396
IntegerDefinition idIntegerDef = (IntegerDefinition) variantCurrentField
397
.lookupDefinition("id"); //$NON-NLS-1$
398
if (idIntegerDef != null) {
399
eventID = idIntegerDef.getValue();
383
if (variantDef != null) {
386
* Get the variant current field
388
StructDefinition variantCurrentField = (StructDefinition) variantDef
392
* Try to get the id field in the current field of the variant.
393
* If it is present, it overrides the previously read event id.
395
IntegerDefinition idIntegerDef = (IntegerDefinition) variantCurrentField
396
.lookupDefinition("id"); //$NON-NLS-1$
397
if (idIntegerDef != null) {
398
eventID = idIntegerDef.getValue();
403
timestampDef = (IntegerDefinition) variantCurrentField
404
.lookupDefinition("timestamp"); //$NON-NLS-1$
405
IntegerDefinition timestampDef = (IntegerDefinition) variantCurrentField
406
.lookupDefinition("timestamp"); //$NON-NLS-1$
407
assert (timestampDef != null);
410
409
* Calculate the event timestamp.
412
411
timestamp = calculateTimestamp(timestampDef);
414
EventDefinition eventDef = events.get(eventID);
415
if (eventDef == null) {
416
throw new CTFReaderException("Incorrect event id : " + eventID); //$NON-NLS-1$
416
420
* Read the stream event context.
423
427
* Get the right event definition using the event id.
425
EventDefinition eventDef = events.get(eventID);
426
if (eventDef == null) {
427
throw new CTFReaderException("Incorrect event id : " + eventID); //$NON-NLS-1$
431
432
* Read the event context.
433
if (eventDef.getContext() != null) {
434
eventDef.getContext().read(currentBitBuffer);
434
if (eventDef.getEventContext() != null) {
435
eventDef.getEventContext().read(currentBitBuffer);