use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder in project tracecompass by tracecompass.
the class CounterStateProvider method eventHandle.
@Override
protected void eventHandle(@NonNull ITmfEvent event) {
ITmfStateSystemBuilder ss = getStateSystemBuilder();
if (ss == null) {
return;
}
for (ITmfEventAspect<?> aspect : fCounterAspects) {
if (aspect instanceof CounterAspect) {
CounterAspect counterAspect = (CounterAspect) aspect;
if (counterAspect.getGroups().length > 0) {
int rootQuark = ss.getQuarkAbsoluteAndAdd(CounterAnalysis.GROUPED_COUNTER_ASPECTS_ATTRIB);
handleGroupedCounterAspect(event, ss, counterAspect, rootQuark);
} else {
int rootQuark = ss.getQuarkAbsoluteAndAdd(CounterAnalysis.UNGROUPED_COUNTER_ASPECTS_ATTRIB);
handleCounterAspect(event, ss, counterAspect, rootQuark);
}
}
}
}
use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder in project tracecompass by tracecompass.
the class UstDebugInfoStateProvider method eventHandle.
@Override
protected void eventHandle(ITmfEvent event) {
// Should we handle this event?
String name = event.getName();
Integer index = fEventNames.get(name);
if (index == null) {
/* Untracked event type */
return;
}
/*
* We require the "vpid" context to build the state system. The rest of
* the analysis also needs the "ip" context, but the state provider part
* does not.
*/
Integer vpid = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(), LinuxPidAspect.class, event);
if (vpid == null) {
return;
}
@NonNull final ITmfStateSystemBuilder ss = checkNotNull(getStateSystemBuilder());
int intIndex = index.intValue();
switch(intIndex) {
case STATEDUMP_START_INDEX:
{
handleStatedumpStart(event, vpid, ss);
break;
}
case STATEDUMP_BIN_INFO_INDEX:
handleBinInfo(event, vpid, ss, true);
break;
case DL_DLOPEN_INDEX:
handleBinInfo(event, vpid, ss, false);
break;
case STATEDUMP_BUILD_ID_INDEX:
handleBuildId(event, vpid, ss, true);
break;
case DL_BUILD_ID_INDEX:
handleBuildId(event, vpid, ss, false);
break;
case STATEDUMP_DEBUG_LINK_INDEX:
handleDebugLink(event, vpid, ss, true);
break;
case DL_DEBUG_LINK_INDEX:
handleDebugLink(event, vpid, ss, false);
break;
case DL_DLCLOSE_INDEX:
{
handleClose(event, vpid, ss);
break;
}
default:
/* Ignore other events */
break;
}
}
use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder in project tracecompass by tracecompass.
the class StateSystemTest method testSetAndQueryOngoing.
/**
* Test modifying or updating the state value, then querying it
*/
@Test
public void testSetAndQueryOngoing() {
ITmfStateSystemBuilder ss = fSs;
assertNotNull(ss);
long time = 10;
int quark = ss.getQuarkAbsoluteAndAdd("Test");
// Modify the attribute, then query the ongoing value
long val = 10L;
ss.modifyAttribute(time, val, quark);
// Query the state value
ITmfStateValue ongoingState = ss.queryOngoingState(quark);
assertTrue(ongoingState.getType() == Type.LONG);
assertEquals(val, ongoingState.unboxLong());
// Query the value
Object ongoing = ss.queryOngoing(quark);
assertTrue(ongoing instanceof Long);
assertEquals(val, ongoing);
// Modify with a state value, the query the ongoing value
val = 12L;
ss.modifyAttribute(time + 1, val, quark);
// Query the state value
ongoingState = ss.queryOngoingState(quark);
assertTrue(ongoingState.getType() == Type.LONG);
assertEquals(val, ongoingState.unboxLong());
// Query the value
ongoing = ss.queryOngoing(quark);
assertTrue(ongoing instanceof Long);
assertEquals(val, ongoing);
// Update the ongoing value with a state value, then query
val = 14L;
ss.updateOngoingState(TmfStateValue.newValue(val), quark);
// Query the state value
ongoingState = ss.queryOngoingState(quark);
assertTrue(ongoingState.getType() == Type.LONG);
assertEquals(val, ongoingState.unboxLong());
// Query the value
ongoing = ss.queryOngoing(quark);
assertTrue(ongoing instanceof Long);
assertEquals(val, ongoing);
// Update the ongoing value, then query
val = 16L;
ss.updateOngoingState(val, quark);
// Query the state value
ongoingState = ss.queryOngoingState(quark);
assertTrue(ongoingState.getType() == Type.LONG);
assertEquals(val, ongoingState.unboxLong());
// Query the value
ongoing = ss.queryOngoing(quark);
assertTrue(ongoing instanceof Long);
assertEquals(val, ongoing);
}
use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder in project tracecompass by tracecompass.
the class StateSystemUtilsTest method testQueryOngoingStackTop.
/**
* Test the queryOngoingStackTop() method.
*/
@Test
public void testQueryOngoingStackTop() {
IStateHistoryBackend backend = StateHistoryBackendFactory.createInMemoryBackend(DUMMY_STRING, START_TIME);
ITmfStateSystemBuilder ss = StateSystemFactory.newStateSystem(backend);
int quark = ss.getQuarkAbsoluteAndAdd(DUMMY_STRING);
assertEquals(null, StateSystemUtils.queryOngoingStackTop(ss, quark));
ss.pushAttribute(1100L, "A", quark);
assertEquals("A", StateSystemUtils.queryOngoingStackTop(ss, quark));
ss.pushAttribute(1200L, "B", quark);
assertEquals("B", StateSystemUtils.queryOngoingStackTop(ss, quark));
ss.popAttribute(1300L, quark);
assertEquals("A", StateSystemUtils.queryOngoingStackTop(ss, quark));
ss.popAttribute(1400L, quark);
assertEquals(null, StateSystemUtils.queryOngoingStackTop(ss, quark));
ss.closeHistory(1500L);
ss.dispose();
}
use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder in project tracecompass by tracecompass.
the class StateSystemUtilsTest method testIteratorOverQuarkResolution.
/**
* Test that the QuarkIterator returns the correct intervals for a range
* included in the state system range and a resolution
*/
@Test
public void testIteratorOverQuarkResolution() {
IStateHistoryBackend backend = StateHistoryBackendFactory.createInMemoryBackend(DUMMY_STRING, 1L);
ITmfStateSystemBuilder ss = StateSystemFactory.newStateSystem(backend);
try {
// Create a small state system with intervals for a resolution
int quark = ss.getQuarkAbsoluteAndAdd(DUMMY_STRING);
/**
* Here follows the state system, with each dash representing a nanosecond and
* vertical line a change of state. The time are the times that are expected to
* be queried
*
* <pre>
*
* resolution of 4: 2 6 10
* resolution of 3: 2 5 8 11
* ------|-|-|----
* </pre>
*/
ss.modifyAttribute(1L, 1, quark);
ss.modifyAttribute(7L, 2, quark);
ss.modifyAttribute(8L, 1, quark);
ss.modifyAttribute(9L, 2, quark);
ss.closeHistory(12L);
// Verify a resolution of 4
QuarkIterator iterator = new QuarkIterator(ss, quark, 2, 14, 4);
/*
* With steps of 4, there should be 2 intervals and they should be the same
* forward and backward
*/
assertTrue(iterator.hasNext());
ITmfStateInterval interval = iterator.next();
assertNotNull(interval);
assertEquals(1L, interval.getStartTime());
assertEquals(6L, interval.getEndTime());
// Check second interval forward
assertTrue(iterator.hasNext());
interval = iterator.next();
assertNotNull(interval);
assertEquals(9L, interval.getStartTime());
assertEquals(12L, interval.getEndTime());
/* There should not be a next interval */
assertFalse(iterator.hasNext());
// Check the interval backward
assertTrue(iterator.hasPrevious());
interval = iterator.previous();
assertNotNull(interval);
assertEquals(1L, interval.getStartTime());
assertEquals(6L, interval.getEndTime());
assertFalse(iterator.hasPrevious());
// Verify a resolution of 3
iterator = new QuarkIterator(ss, quark, 2, 14, 3);
/*
* With steps of 3, there should be 3 intervals and they should be the same
* forward and backward
*/
assertTrue(iterator.hasNext());
interval = iterator.next();
assertNotNull(interval);
assertEquals(1L, interval.getStartTime());
assertEquals(6L, interval.getEndTime());
// Check second interval forward
assertTrue(iterator.hasNext());
interval = iterator.next();
assertNotNull(interval);
assertEquals(8L, interval.getStartTime());
assertEquals(8L, interval.getEndTime());
// Check the interval forward
assertTrue(iterator.hasNext());
interval = iterator.next();
assertNotNull(interval);
assertEquals(9L, interval.getStartTime());
assertEquals(12L, interval.getEndTime());
/* There should not be a next interval */
assertFalse(iterator.hasNext());
// Check the first interval backward
assertTrue(iterator.hasPrevious());
interval = iterator.previous();
assertNotNull(interval);
assertEquals(8L, interval.getStartTime());
assertEquals(8L, interval.getEndTime());
// Check the second interval backward
assertTrue(iterator.hasPrevious());
interval = iterator.previous();
assertNotNull(interval);
assertEquals(1L, interval.getStartTime());
assertEquals(6L, interval.getEndTime());
assertFalse(iterator.hasPrevious());
} catch (StateValueTypeException e) {
fail(e.getMessage());
} finally {
ss.dispose();
}
}
Aggregations