use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class AbstractProviderTest method getCallStack.
/**
* Get the callstack for the given timestamp, for this particular trace
*/
private static String[] getCallStack(ITmfStateSystem ss, int pid, String threadName, long timestamp) {
try {
String processName = (pid == CallStackStateProvider.UNKNOWN_PID) ? CallStackStateProvider.UNKNOWN : Integer.toString(pid);
int stackAttribute = ss.getQuarkAbsolute("Processes", processName, threadName, "CallStack");
List<ITmfStateInterval> state = ss.queryFullState(timestamp);
int depth = state.get(stackAttribute).getStateValue().unboxInt();
int stackTop = ss.getQuarkRelative(stackAttribute, String.valueOf(depth));
ITmfStateValue expectedValue = state.get(stackTop).getStateValue();
ITmfStateInterval interval = StateSystemUtils.querySingleStackTop(ss, timestamp, stackAttribute);
assertNotNull(interval);
assertEquals(expectedValue, interval.getStateValue());
String[] ret = new String[depth];
for (int i = 0; i < depth; i++) {
int quark = ss.getQuarkRelative(stackAttribute, String.valueOf(i + 1));
ret[i] = Long.toHexString(state.get(quark).getStateValue().unboxLong());
}
return ret;
} catch (AttributeNotFoundException e) {
fail(e.getMessage());
} catch (StateSystemDisposedException e) {
fail(e.getMessage());
}
fail();
return null;
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class UstDebugInfoAnalysisModule method getMatchingFile.
/**
* Get the binary file (executable or library) that corresponds to a given
* instruction pointer, at a given time.
*
* @param ts
* The timestamp
* @param vpid
* The VPID of the process we are querying for
* @param ip
* The instruction pointer of the trace event. Normally comes
* from a 'ip' context.
* @return A {@link UstDebugInfoLoadedBinaryFile} object, describing the
* binary file and its base address.
* @noreference Meant to be used internally by
* {@link UstDebugInfoBinaryAspect} only.
*/
@VisibleForTesting
@Nullable
public UstDebugInfoLoadedBinaryFile getMatchingFile(long ts, long vpid, long ip) {
try {
final ITmfStateSystem ss = getStateSystem();
if (ss == null) {
/* State system might not yet be initialized */
return null;
}
// $NON-NLS-1$
List<Integer> possibleBaddrQuarks = ss.getQuarks(String.valueOf(vpid), "*");
List<ITmfStateInterval> state = ss.queryFullState(ts);
/* Get the most probable base address from all the known ones */
OptionalLong potentialBaddr = possibleBaddrQuarks.stream().filter(quark -> Objects.equals(1, state.get(quark).getValue())).map(ss::getAttributeName).mapToLong(Long::parseLong).filter(baddr -> baddr <= ip).max();
if (!potentialBaddr.isPresent()) {
return null;
}
long baddr = potentialBaddr.getAsLong();
final int baddrQuark = ss.getQuarkAbsolute(String.valueOf(vpid), String.valueOf(baddr));
final int memszQuark = ss.getQuarkRelative(baddrQuark, UstDebugInfoStateProvider.MEMSZ_ATTRIB);
final long memsz = state.get(memszQuark).getStateValue().unboxLong();
/* Make sure the 'ip' fits the range of this object. */
if (!(ip < baddr + memsz)) {
/*
* Not the correct memory range after all. We do not have
* information about the library that was loaded here.
*/
return null;
}
final int pathQuark = ss.getQuarkRelative(baddrQuark, UstDebugInfoStateProvider.PATH_ATTRIB);
String filePath = state.get(pathQuark).getStateValue().unboxStr();
final int buildIdQuark = ss.getQuarkRelative(baddrQuark, UstDebugInfoStateProvider.BUILD_ID_ATTRIB);
ITmfStateValue buildIdValue = state.get(buildIdQuark).getStateValue();
String buildId = unboxStrOrNull(buildIdValue);
final int debugLinkQuark = ss.getQuarkRelative(baddrQuark, UstDebugInfoStateProvider.DEBUG_LINK_ATTRIB);
ITmfStateValue debugLinkValue = state.get(debugLinkQuark).getStateValue();
String debugLink = unboxStrOrNull(debugLinkValue);
final int isPicQuark = ss.getQuarkRelative(baddrQuark, UstDebugInfoStateProvider.IS_PIC_ATTRIB);
boolean isPic = state.get(isPicQuark).getStateValue().unboxInt() != 0;
// The baddrQuark interval lasts for the time this file is loaded
ITmfStateInterval validityInterval = state.get(baddrQuark);
return new UstDebugInfoLoadedBinaryFile(baddr, filePath, buildId, debugLink, isPic, validityInterval.getStartTime(), validityInterval.getEndTime());
} catch (AttributeNotFoundException | TimeRangeException | StateSystemDisposedException e) {
/* Either the data is not available yet, or incomplete. */
return null;
}
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class InMemoryBackendTest method testDoQuery.
/**
* Query the state system
*/
@Test
public void testDoQuery() {
List<@Nullable ITmfStateInterval> interval = new ArrayList<>(NUMBER_OF_ATTRIBUTES);
for (int i = 0; i < NUMBER_OF_ATTRIBUTES; i++) {
interval.add(null);
}
IStateHistoryBackend backend = fixture;
assertNotNull(backend);
try {
backend.doQuery(interval, 950);
} catch (TimeRangeException | StateSystemDisposedException e) {
fail(e.getMessage());
}
assertEquals(NUMBER_OF_ATTRIBUTES, interval.size());
testInterval(interval.get(0), 900, 990, 9);
testInterval(interval.get(1), 901, 991, 9);
testInterval(interval.get(2), 902, 992, 9);
testInterval(interval.get(3), 903, 993, 9);
testInterval(interval.get(4), 904, 994, 9);
testInterval(interval.get(5), 905, 995, 9);
testInterval(interval.get(6), 906, 996, 9);
testInterval(interval.get(7), 907, 997, 9);
testInterval(interval.get(8), 908, 998, 9);
testInterval(interval.get(9), 909, 999, 9);
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class InMemoryBackendTest method testQueryAttribute.
/**
* Test single attribute then compare it to a full query
*/
@Test
public void testQueryAttribute() {
try {
IStateHistoryBackend backend = fixture;
assertNotNull(backend);
ITmfStateInterval[] interval = new TmfStateInterval[10];
for (int i = 0; i < 10; i++) {
interval[i] = backend.doSingularQuery(950, i);
}
testInterval(interval[0], 900, 990, 9);
testInterval(interval[1], 901, 991, 9);
testInterval(interval[2], 902, 992, 9);
testInterval(interval[3], 903, 993, 9);
testInterval(interval[4], 904, 994, 9);
testInterval(interval[5], 905, 995, 9);
testInterval(interval[6], 906, 996, 9);
testInterval(interval[7], 907, 997, 9);
testInterval(interval[8], 908, 998, 9);
testInterval(interval[9], 909, 999, 9);
List<@Nullable ITmfStateInterval> intervalQuery = new ArrayList<>(NUMBER_OF_ATTRIBUTES);
for (int i = 0; i < NUMBER_OF_ATTRIBUTES; i++) {
intervalQuery.add(null);
}
backend.doQuery(intervalQuery, 950);
ITmfStateInterval[] ref = intervalQuery.toArray(new ITmfStateInterval[0]);
assertArrayEquals(ref, interval);
} catch (TimeRangeException | StateSystemDisposedException e) {
fail(e.getMessage());
}
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class StateSystem method queryFullState.
// --------------------------------------------------------------------------
// Regular query methods (sent to the back-end)
// --------------------------------------------------------------------------
@Override
public List<ITmfStateInterval> queryFullState(long t) throws TimeRangeException, StateSystemDisposedException {
if (isDisposed) {
throw new StateSystemDisposedException();
}
try (ScopeLog log = new // $NON-NLS-1$
ScopeLog(// $NON-NLS-1$
LOGGER, // $NON-NLS-1$
Level.FINER, // $NON-NLS-1$
"StateSystem:FullQuery", "ssid", getSSID(), "ts", t)) {
// $NON-NLS-1$ //$NON-NLS-2$
final int nbAttr = getNbAttributes();
List<@Nullable ITmfStateInterval> stateInfo = new ArrayList<>(nbAttr);
/*
* Bring the size of the array to the current number of attributes
*/
for (int i = 0; i < nbAttr; i++) {
stateInfo.add(null);
}
/*
* If we are currently building the history, also query the
* "ongoing" states for stuff that might not yet be written to the
* history.
*/
if (transState.isActive()) {
transState.doQuery(stateInfo, t);
}
/* Query the storage backend */
backend.doQuery(stateInfo, t);
/*
* We should have previously inserted an interval for every
* attribute.
*/
for (ITmfStateInterval interval : stateInfo) {
if (interval == null) {
// $NON-NLS-1$
throw new IllegalStateException("Incoherent interval storage");
}
}
return stateInfo;
}
}
Aggregations