@Override
  public ITmfEvent parseEvent(final ITmfContext context) {

    if (!(fEventStream instanceof TmfTraceStub)) {
      return null;
    }

    // Highly inefficient...
    final RandomAccessFile stream = ((TmfTraceStub) fEventStream).getStream();
    if (stream == null) {
      return null;
    }

    //           String name = eventStream.getName();
    //           name = name.substring(name.lastIndexOf('/') + 1);

    // no need to use synchronized since it's already cover by the calling method

    long location = 0;
    if (context != null && context.getLocation() != null) {
      location = (Long) context.getLocation().getLocationInfo();
      try {
        stream.seek(location);

        final long ts = stream.readLong();
        stream.readUTF(); /* Previously source, now unused */
        final String type = stream.readUTF();
        stream.readInt(); /* Previously reference, now unused */
        final int typeIndex = Integer.parseInt(type.substring(typePrefix.length()));
        final String[] fields = new String[typeIndex];
        for (int i = 0; i < typeIndex; i++) {
          fields[i] = stream.readUTF();
        }

        final StringBuffer content = new StringBuffer("[");
        if (typeIndex > 0) {
          content.append(fields[0]);
        }
        for (int i = 1; i < typeIndex; i++) {
          content.append(", ").append(fields[i]);
        }
        content.append("]");

        final TmfEventField root =
            new TmfEventField(ITmfEventField.ROOT_FIELD_ID, content.toString(), null);
        final ITmfEvent event =
            new TmfEvent(
                fEventStream,
                ITmfContext.UNKNOWN_RANK,
                fEventStream.createTimestamp(ts * 1000000L),
                fTypes[typeIndex],
                root);
        return event;
      } catch (final EOFException e) {
      } catch (final IOException e) {
      }
    }
    return null;
  }
Ejemplo n.º 2
0
 @Override
 public GdbTraceEvent parseEvent(ITmfContext context) {
   if (context.getRank() >= fNbFrames) {
     return null;
   }
   // work-around to ensure that the select and parse of trace frame will
   // be atomic
   GdbTraceEvent event = fGdbTpRef.selectAndReadFrame(context.getRank());
   fLocation++;
   return event;
 }