<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<CustomXMLTraceDefinitionList>
-<Definition name="handmade">
+<Definition name="set_aspects">
+<InputElement name="trace">
+<InputElement logentry="true" name="set_aspects">
+<InputData action="0" format="" name="Ignore"/>
+<InputElement name="field">
+<InputData action="0" format="" name="Ignore"/>
+<Attribute name="name">
+<InputData action="2" format="" name="fields"/>
+</Attribute>
+<Attribute name="type">
+<InputData action="2" format="" name="type"/>
+</Attribute>
+<Attribute name="value">
+<InputData action="2" format="" name="values"/>
+</Attribute>
+</InputElement>
+</InputElement>
+</InputElement>
+<OutputColumn name="fields"/>
+<OutputColumn name="values"/>
+<OutputColumn name="type"/>
+</Definition>
+<Definition name="events">
<TimeStampOutputFormat>T</TimeStampOutputFormat>
<InputElement name="trace">
<InputElement logentry="true" name="event">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- ***************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
+ * Copyright (c) 2014, 2015 École Polytechnique de Montréal and others
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
*
* Contributors:
* Geneviève Bastien - Initial API and implementation
+ * Patrick Tasse - Extract set_aspects in its own element
*************************************************************************** -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified" elementFormDefault="qualified">
<xs:element name="trace">
<xs:complexType>
<xs:sequence>
+ <xs:element maxOccurs="1" minOccurs="0" name="set_aspects" type="set_aspects" />
<xs:element maxOccurs="unbounded" minOccurs="0" name="event" type="event" />
</xs:sequence>
</xs:complexType>
</xs:element>
+ <xs:complexType name="set_aspects">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="field" type="field" />
+ </xs:sequence>
+ </xs:complexType>
+
<xs:complexType name="event">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="field" type="field" />
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.TmfContext;
import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation;
import org.xml.sax.SAXException;
private static final String VALUES_SEPARATOR = " \\| "; //$NON-NLS-1$
private static final String TYPE_INTEGER = "int"; //$NON-NLS-1$
private static final String TYPE_LONG = "long"; //$NON-NLS-1$
- private static final String ASPECT_SPECIAL_EVENT = "set_aspects";
private static final String ASPECT_CPU = "cpu";
private static final Long SECONDS_TO_NS = 1000000000L;
- private final CustomXmlTrace fTrace;
+ private final CustomXmlTraceDefinition fDefinition;
+ private CustomXmlTrace fTrace;
- private Collection<ITmfEventAspect> fAspects;
+ private Collection<ITmfEventAspect> fAspects = TmfTrace.BASE_ASPECTS;
/**
* Constructor. Constructs the custom XML trace with the appropriate
/* Load custom XML definition */
try (InputStream in = TmfXmlTraceStub.class.getResourceAsStream(DEVELOPMENT_TRACE_PARSER_PATH);) {
CustomXmlTraceDefinition[] definitions = CustomXmlTraceDefinition.loadAll(in);
- if (definitions.length == 0) {
+ if (definitions.length < 2) {
throw new IllegalStateException("The custom trace definition does not exist"); //$NON-NLS-1$
}
- fTrace = new CustomXmlTrace(definitions[0]);
- /* Deregister the custom XML trace */
- TmfSignalManager.deregister(fTrace);
-
- Collection<ITmfEventAspect> aspects = TmfTrace.BASE_ASPECTS;
- fAspects = aspects;
+ /* The first definition parses the 'set_aspects' event */
+ fTrace = new CustomXmlTrace(definitions[0]) {
+ @Override
+ protected ITmfTraceIndexer createIndexer(int interval) {
+ /* Use the in-memory checkpoint indexer */
+ return new TmfCheckpointIndexer(this, interval);
+ }
+ };
+ /* The second definition parses 'event' trace events */
+ fDefinition = checkNotNull(definitions[1]);
} catch (IOException e) {
throw new IllegalStateException("Cannot open the trace parser for development traces"); //$NON-NLS-1$
}
@Override
public void initTrace(@Nullable IResource resource, @Nullable String path, @Nullable Class<? extends ITmfEvent> type) throws TmfTraceException {
super.initTrace(resource, path, type);
- fTrace.initTrace(resource, path, type);
ITmfContext ctx;
+
+ /* Initialize and read the trace with the 'set_aspects' definition */
+ TmfSignalManager.deregister(fTrace);
+ fTrace.initTrace(resource, path, type);
+ ctx = seekEvent(0L);
+ /* If a set_aspects event exists, getNext() will process it */
+ getNext(ctx);
+ ctx.dispose();
+ fTrace.dispose();
+
+ /* Initialize a new trace with the trace events definition */
+ fTrace = new CustomXmlTrace(fDefinition);
+ TmfSignalManager.deregister(fTrace);
+ fTrace.initTrace(resource, path, type);
/* Set the start and (current) end times for this trace */
ctx = seekEvent(0L);
if (ctx == null) {
this.setStartTime(curTime);
this.setEndTime(curTime);
}
+ ctx.dispose();
}
@Override
fieldsArray[i] = new TmfEventField(checkNotNull(fields[i]), val, null);
}
- /* Generate the aspects for this trace if it is the aspects special event */
- String eventName = getStringValue(content, EVENT_NAME_FIELD);
- if (eventName.equals(ASPECT_SPECIAL_EVENT)) {
+ /* Generate the aspects for this trace if it is the 'set_aspects' definition */
+ if (fTrace.getDefinition() != fDefinition) {
generateAspects(fieldsArray);
- return getNext(context);
+ return null;
}
/* Create a new event with new fields and name */
ITmfEventType customEventType = event.getType();
+ String eventName = getStringValue(content, EVENT_NAME_FIELD);
TmfEventType eventType = new TmfEventType(eventName, customEventType.getRootField());
ITmfEventField eventFields = new CustomEventContent(content.getName(), content.getValue(), fieldsArray);
/*
ITmfTimestamp timestamp = new TmfNanoTimestamp(event.getTimestamp().getValue() / SECONDS_TO_NS);
TmfEvent newEvent = new TmfEvent(this, ITmfContext.UNKNOWN_RANK, timestamp, eventType, eventFields);
updateAttributes(savedContext, event);
- context.increaseRank();
-
return newEvent;
}