Search in sources :

Example 26 with TimeRangeException

use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.

the class InputOutputStateProvider method eventHandle.

@Override
protected void eventHandle(@Nullable ITmfEvent event) {
    if (event == null) {
        return;
    }
    final String eventName = event.getName();
    try {
        final ITmfStateSystemBuilder ss = NonNullUtils.checkNotNull(getStateSystemBuilder());
        /*
             * Feed event to the history system if it's known to cause a state
             * transition.
             */
        KernelEventHandler handler = fEventNames.get(eventName);
        if (handler == null) {
            if (isSyscallExit(eventName)) {
                handler = fSysExitHandler;
            } else if (isSyscallEntry(eventName)) {
                handler = fSysEntryHandler;
            }
        }
        if (handler != null) {
            handler.handleEvent(ss, event);
        }
    } catch (TimeRangeException | StateValueTypeException | AttributeNotFoundException e) {
        // $NON-NLS-1$
        Activator.getDefault().logError("Exception while building the IO state system", e);
    }
}
Also used : KernelEventHandler(org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers.KernelEventHandler) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) ITmfStateSystemBuilder(org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder) StateValueTypeException(org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException)

Example 27 with TimeRangeException

use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.

the class ThreadStatusDataProvider method fetchTree.

@Override
@NonNull
public TmfModelResponse<@NonNull TmfTreeModel<@NonNull TimeGraphEntryModel>> fetchTree(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    if (fLastEnd == Long.MAX_VALUE) {
        return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), filter(Objects.requireNonNull(fTraceEntry), fTidToEntry, fetchParameters)), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
    }
    fModule.waitForInitialization();
    ITmfStateSystem ss = fModule.getStateSystem();
    if (ss == null) {
        return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.ANALYSIS_INITIALIZATION_FAILED);
    }
    /*
         * As we are caching the intermediate result, we only want a single thread to
         * update them.
         */
    synchronized (fBuildMap) {
        boolean complete = ss.waitUntilBuilt(0);
        @NonNull List<@NonNull TimeGraphEntryModel> list = Collections.emptyList();
        /* Don't query empty state system */
        if (ss.getNbAttributes() > 0 && ss.getStartTime() != Long.MIN_VALUE) {
            long end = ss.getCurrentEndTime();
            fLastEnd = Long.max(fLastEnd, ss.getStartTime());
            TreeMultimap<Integer, ITmfStateInterval> threadData = TreeMultimap.create(Comparator.naturalOrder(), Comparator.comparing(ITmfStateInterval::getStartTime));
            /*
                 * Create a List with the threads' PPID and EXEC_NAME quarks for the 2D query .
                 */
            List<Integer> quarks = new ArrayList<>(ss.getQuarks(Attributes.THREADS, WILDCARD, Attributes.EXEC_NAME));
            quarks.addAll(ss.getQuarks(Attributes.THREADS, WILDCARD, Attributes.PPID));
            quarks.addAll(ss.getQuarks(Attributes.THREADS, WILDCARD, Attributes.PID));
            try {
                for (ITmfStateInterval interval : ss.query2D(quarks, Long.min(fLastEnd, end), end)) {
                    if (monitor != null && monitor.isCanceled()) {
                        return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
                    }
                    threadData.put(interval.getAttribute(), interval);
                }
            } catch (TimeRangeException | StateSystemDisposedException e) {
                return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, e.getClass().getName() + ':' + String.valueOf(e.getMessage()));
            }
            // update the trace Entry.
            TimeGraphEntryModel traceEntry = new TimeGraphEntryModel(fTraceId, -1, getTrace().getName(), ss.getStartTime(), end);
            fTraceEntry = traceEntry;
            for (Integer threadQuark : ss.getQuarks(Attributes.THREADS, WILDCARD)) {
                String threadAttributeName = ss.getAttributeName(threadQuark);
                Pair<Integer, Integer> entryKey = Attributes.parseThreadAttributeName(threadAttributeName);
                int threadId = entryKey.getFirst();
                if (threadId < 0) {
                    // ignore the 'unknown' (-1) thread
                    continue;
                }
                int execNameQuark = ss.optQuarkRelative(threadQuark, Attributes.EXEC_NAME);
                int ppidQuark = ss.optQuarkRelative(threadQuark, Attributes.PPID);
                int pidQuark = ss.optQuarkRelative(threadQuark, Attributes.PID);
                NavigableSet<ITmfStateInterval> ppidIntervals = threadData.get(ppidQuark);
                NavigableSet<ITmfStateInterval> pidIntervals = threadData.get(pidQuark);
                for (ITmfStateInterval execNameInterval : threadData.get(execNameQuark)) {
                    if (monitor != null && monitor.isCanceled()) {
                        return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
                    }
                    updateEntry(threadQuark, entryKey, ppidIntervals, execNameInterval, pidIntervals);
                }
            }
            fLastEnd = end;
            list = filter(traceEntry, fTidToEntry, fetchParameters);
        }
        for (TimeGraphEntryModel model : list) {
            fEntryMetadata.put(model.getId(), model.getMetadata());
        }
        if (complete) {
            fBuildMap.clear();
            fLastEnd = Long.MAX_VALUE;
            return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), list), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
        }
        return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), list), ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
    }
}
Also used : TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) ArrayList(java.util.ArrayList) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) NonNull(org.eclipse.jdt.annotation.NonNull) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 28 with TimeRangeException

use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.

the class ThreadStatusDataProvider method fetchRowModel.

@Override
@NonNull
public TmfModelResponse<@NonNull TimeGraphModel> fetchRowModel(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, IProgressMonitor monitor) {
    ITmfStateSystem ss = fModule.getStateSystem();
    if (ss == null) {
        return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.ANALYSIS_INITIALIZATION_FAILED);
    }
    TreeMultimap<Integer, ITmfStateInterval> intervals = TreeMultimap.create(Comparator.naturalOrder(), Comparator.comparing(ITmfStateInterval::getStartTime));
    SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
    Map<Long, Integer> selectedIdsToQuarks = getSelectedIdsToQuarks(filter);
    Collection<Integer> stateAndSyscallQuarks = addSyscall(selectedIdsToQuarks.values(), ss);
    Collection<Long> times = getTimes(ss, filter);
    try {
        /* Do the actual query */
        for (ITmfStateInterval interval : ss.query2D(stateAndSyscallQuarks, times)) {
            if (monitor != null && monitor.isCanceled()) {
                return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
            }
            intervals.put(interval.getAttribute(), interval);
        }
    } catch (TimeRangeException | StateSystemDisposedException e) {
        return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, String.valueOf(e.getMessage()));
    }
    Map<@NonNull Integer, @NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull Object>>> predicates = new HashMap<>();
    Multimap<@NonNull Integer, @NonNull String> regexesMap = DataProviderParameterUtils.extractRegexFilter(fetchParameters);
    if (regexesMap != null) {
        predicates.putAll(computeRegexPredicate(regexesMap));
    }
    @NonNull List<@NonNull ITimeGraphRowModel> rows = new ArrayList<>();
    for (Entry<Long, Integer> entry : selectedIdsToQuarks.entrySet()) {
        int quark = entry.getValue();
        NavigableSet<ITmfStateInterval> states = intervals.get(quark);
        NavigableSet<ITmfStateInterval> syscalls = intervals.get(ss.optQuarkRelative(quark, Attributes.SYSTEM_CALL));
        if (monitor != null && monitor.isCanceled()) {
            return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
        }
        List<ITimeGraphState> eventList = new ArrayList<>();
        states.forEach(i -> {
            ITimeGraphState timegraphState = createTimeGraphState(i, syscalls);
            Long key = Objects.requireNonNull(entry.getKey());
            applyFilterAndAddState(eventList, timegraphState, key, predicates, monitor);
        });
        rows.add(new TimeGraphRowModel(entry.getKey(), eventList));
    }
    return new TmfModelResponse<>(new TimeGraphModel(rows), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) ArrayList(java.util.ArrayList) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) ITimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel) TimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphRowModel) Predicate(java.util.function.Predicate) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) ITimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) NonNull(org.eclipse.jdt.annotation.NonNull) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) TimeGraphModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel) ITimeGraphState(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState) AtomicLong(java.util.concurrent.atomic.AtomicLong) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 29 with TimeRangeException

use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.

the class ThreadStatusDataProvider method filter.

/**
 * Filter the threads from a {@link TreeMultimap} according to if they are
 * active or not
 * @param traceEntry
 *
 * @param tidToEntry
 *            Threads to filter
 * @param filter
 *            time range to query
 * @return a list of the active threads
 */
@NonNull
private List<@NonNull TimeGraphEntryModel> filter(TimeGraphEntryModel traceEntry, TreeMultimap<Integer, ThreadEntryModel.Builder> tidToEntry, @NonNull Map<@NonNull String, @NonNull Object> parameters) {
    // avoid putting everything as a child of the swapper thread.
    Boolean isActiveFilter = DataProviderParameterUtils.extractBoolean(parameters, ACTIVE_THREAD_FILTER_KEY);
    if (!Boolean.TRUE.equals(isActiveFilter)) {
        ImmutableList.Builder<TimeGraphEntryModel> builder = ImmutableList.builder();
        builder.add(traceEntry);
        for (ThreadEntryModel.Builder entryBuilder : tidToEntry.values()) {
            builder.add(build(entryBuilder));
        }
        return builder.build();
    }
    ITmfStateSystem ss = fModule.getStateSystem();
    if (ss == null) {
        return Collections.emptyList();
    }
    List<@NonNull Long> filter = DataProviderParameterUtils.extractTimeRequested(parameters);
    if (filter == null || filter.isEmpty()) {
        return Collections.emptyList();
    }
    long start = Long.max(filter.get(0), ss.getStartTime());
    long end = Long.min(filter.get(filter.size() - 1), ss.getCurrentEndTime());
    if (start > end) {
        return Collections.emptyList();
    }
    List<@NonNull Long> selectedItems = DataProviderParameterUtils.extractSelectedItems(parameters);
    if (selectedItems != null) {
        Set<Long> cpus = Sets.newHashSet(selectedItems);
        List<@NonNull Integer> quarks = ss.getQuarks(Attributes.THREADS, WILDCARD, Attributes.CURRENT_CPU_RQ);
        Set<TimeGraphEntryModel> models = new HashSet<>();
        models.add(traceEntry);
        Map<Integer, Integer> rqToPidCache = new HashMap<>();
        try {
            for (ITmfStateInterval interval : ss.query2D(quarks, Long.max(ss.getStartTime(), start), end)) {
                Object o = interval.getValue();
                if (o instanceof Number && cpus.contains(((Number) o).longValue())) {
                    int attribute = interval.getAttribute();
                    try {
                        // Get the name of the thread
                        int nameQuark = ss.getQuarkRelative(ss.getParentAttributeQuark(attribute), Attributes.EXEC_NAME);
                        Iterable<@NonNull ITmfStateInterval> names2d = ss.query2D(Collections.singleton(nameQuark), interval.getStartTime(), interval.getEndTime());
                        Iterable<@NonNull String> names = Iterables.transform(names2d, intervalName -> String.valueOf(intervalName.getValue()));
                        int tid = rqToPidCache.computeIfAbsent(attribute, a -> Attributes.parseThreadAttributeName(ss.getAttributeName(ss.getParentAttributeQuark(a))).getFirst());
                        // Skip Idle (thread 0)
                        if (tid == 0) {
                            continue;
                        }
                        for (ThreadEntryModel.Builder model : tidToEntry.get(tid)) {
                            if (interval.getStartTime() <= model.getEndTime() && model.getStartTime() <= interval.getEndTime()) {
                                ThreadEntryModel build = build(model);
                                if (!Iterables.any(names, name -> name.equals(build.getName()))) {
                                    continue;
                                }
                                models.add(build);
                            }
                        }
                    } catch (AttributeNotFoundException e) {
                        // $NON-NLS-1$
                        Activator.getDefault().logWarning("Unable to get the quark for the attribute name", e);
                    }
                }
            }
        } catch (IndexOutOfBoundsException | TimeRangeException e) {
            // $NON-NLS-1$
            Activator.getDefault().logError("Invalid query parameters", e);
        } catch (StateSystemDisposedException e) {
            return Collections.emptyList();
        }
        return Lists.newArrayList(models);
    }
    ImmutableList.Builder<TimeGraphEntryModel> builder = ImmutableList.builder();
    builder.add(traceEntry);
    for (ThreadEntryModel.Builder thread : tidToEntry.values()) {
        Integer statusQuark = fQuarkMap.get(thread.getId());
        if (statusQuark == null) {
            continue;
        }
        QuarkIterator iterator = new QuarkIterator(ss, statusQuark, start, end);
        Iterator<Object> values = Iterators.transform(iterator, ITmfStateInterval::getValue);
        if (Iterators.any(values, ACTIVE_STATES::contains)) {
            builder.add(build(thread));
        }
    }
    return builder.build();
}
Also used : ITmfCallsite(org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite) OsStrings(org.eclipse.tracecompass.analysis.os.linux.core.model.OsStrings) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) ITmfEventAspect(org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect) Attributes(org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes) TmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.TmfStateInterval) Pair(org.eclipse.tracecompass.tmf.core.util.Pair) LinuxTidAspect(org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxTidAspect) Nullable(org.eclipse.jdt.annotation.Nullable) TreeMultimap(com.google.common.collect.TreeMultimap) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Map(java.util.Map) ITmfCallsiteResolver(org.eclipse.tracecompass.tmf.core.analysis.callsite.ITmfCallsiteResolver) TmfStrings(org.eclipse.tracecompass.tmf.core.TmfStrings) LinuxStyle(org.eclipse.tracecompass.internal.analysis.os.linux.core.registry.LinuxStyle) OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ImmutableSet(com.google.common.collect.ImmutableSet) TmfCpuAspect(org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) Collection(java.util.Collection) FetchParametersUtils(org.eclipse.tracecompass.internal.tmf.core.model.filters.FetchParametersUtils) IOutputStyleProvider(org.eclipse.tracecompass.tmf.core.model.IOutputStyleProvider) Set(java.util.Set) ITimeGraphDataProvider(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider) NavigableSet(java.util.NavigableSet) OutputStyleModel(org.eclipse.tracecompass.tmf.core.model.OutputStyleModel) Sets(com.google.common.collect.Sets) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) Objects(java.util.Objects) List(java.util.List) TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) Entry(java.util.Map.Entry) CallsiteAnalysis(org.eclipse.tracecompass.internal.tmf.core.analysis.callsite.CallsiteAnalysis) AnnotationModel(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationModel) NonNull(org.eclipse.jdt.annotation.NonNull) AnnotationCategoriesModel(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationCategoriesModel) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) Iterables(com.google.common.collect.Iterables) CommonStatusMessage(org.eclipse.tracecompass.tmf.core.model.CommonStatusMessage) ITimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) HashMap(java.util.HashMap) TimeGraphModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel) Multimap(com.google.common.collect.Multimap) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) EventAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.EventAnnotationProvider) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Activator(org.eclipse.tracecompass.internal.analysis.os.linux.core.Activator) TimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphRowModel) StateValues(org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.StateValues) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) TimeGraphArrow(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphArrow) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) ITimeGraphArrow(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) ITmfResponse(org.eclipse.tracecompass.tmf.core.response.ITmfResponse) ITimeGraphState(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState) Iterator(java.util.Iterator) ProcessStatus(org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus) TimeGraphState(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphState) DataProviderParameterUtils(org.eclipse.tracecompass.tmf.core.dataprovider.DataProviderParameterUtils) IKernelTrace(org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace) AtomicLong(java.util.concurrent.atomic.AtomicLong) QuarkIterator(org.eclipse.tracecompass.statesystem.core.StateSystemUtils.QuarkIterator) AbstractTmfTraceDataProvider(org.eclipse.tracecompass.internal.tmf.core.model.AbstractTmfTraceDataProvider) TmfTraceUtils(org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils) Comparator(java.util.Comparator) ITimeGraphStateFilter(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphStateFilter) Collections(java.util.Collections) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ImmutableList(com.google.common.collect.ImmutableList) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) QuarkIterator(org.eclipse.tracecompass.statesystem.core.StateSystemUtils.QuarkIterator) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) HashSet(java.util.HashSet) TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) AtomicLong(java.util.concurrent.atomic.AtomicLong) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 30 with TimeRangeException

use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.

the class StateSystemPushPopTest method testEmptyStack.

/**
 * Test the places where the stack is empty.
 */
@Test
public void testEmptyStack() {
    final ITmfStateSystemBuilder ss2 = ss;
    assertNotNull(ss2);
    try {
        /* At the start */
        ITmfStateInterval interval = ss.querySingleState(1, attribute);
        assertTrue(interval.getStateValue().isNull());
        interval = StateSystemUtils.querySingleStackTop(ss2, 1, attribute);
        assertEquals(null, interval);
        /* Between the two "stacks" in the state history */
        interval = ss.querySingleState(19, attribute);
        assertTrue(interval.getStateValue().isNull());
        interval = StateSystemUtils.querySingleStackTop(ss2, 19, attribute);
        assertEquals(null, interval);
        /* At the end */
        interval = ss.querySingleState(27, attribute);
        assertTrue(interval.getStateValue().isNull());
        interval = StateSystemUtils.querySingleStackTop(ss2, 27, attribute);
        assertEquals(null, interval);
    } catch (AttributeNotFoundException | TimeRangeException | StateSystemDisposedException e) {
        fail(errMsg + e.toString());
    }
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) ITmfStateSystemBuilder(org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder) Test(org.junit.Test)

Aggregations

TimeRangeException (org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException)55 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)41 StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)40 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)22 AttributeNotFoundException (org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException)20 Test (org.junit.Test)17 StateValueTypeException (org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException)15 NonNull (org.eclipse.jdt.annotation.NonNull)13 ArrayList (java.util.ArrayList)12 Nullable (org.eclipse.jdt.annotation.Nullable)11 ITmfStateValue (org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue)10 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)9 HashMap (java.util.HashMap)8 ITmfStateSystemBuilder (org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder)8 IStateHistoryBackend (org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend)8 AtomicLong (java.util.concurrent.atomic.AtomicLong)7 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)6 TimeGraphModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel)6 List (java.util.List)5 TmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.TmfStateInterval)5