Search in sources :

Example 1 with ITmfCallsiteResolver

use of org.eclipse.tracecompass.tmf.core.analysis.callsite.ITmfCallsiteResolver in project tracecompass by tracecompass.

the class ResourcesStatusDataProvider method putCpuTooltip.

private void putCpuTooltip(ITmfStateSystem ss, String attributeName, Map<String, String> retMap, List<ITmfStateInterval> full, int status) {
    int currentThreadQuark = ss.optQuarkAbsolute(Attributes.CPUS, attributeName, Attributes.CURRENT_THREAD);
    if (currentThreadQuark == ITmfStateSystem.INVALID_ATTRIBUTE) {
        return;
    }
    Object currentThreadObject = full.get(currentThreadQuark).getValue();
    if (currentThreadObject instanceof Number) {
        String currentThread = currentThreadObject.toString();
        retMap.put(Messages.ResourcesStatusDataProvider_attributeTidName, currentThread);
        int execNameQuark = ss.optQuarkAbsolute(Attributes.THREADS, currentThread, Attributes.EXEC_NAME);
        if (execNameQuark != ITmfStateSystem.INVALID_ATTRIBUTE) {
            Object processName = full.get(execNameQuark).getValue();
            if (processName instanceof String) {
                retMap.put(Messages.ResourcesStatusDataProvider_attributeProcessName, (String) processName);
            }
        }
        int syscallQuark = ss.optQuarkAbsolute(Attributes.THREADS, currentThread, Attributes.SYSTEM_CALL);
        if (status == StateValues.CPU_STATUS_RUN_SYSCALL && syscallQuark != ITmfStateSystem.INVALID_ATTRIBUTE) {
            ITmfStateInterval interval = full.get(syscallQuark);
            Object syscall = interval.getValue();
            if (syscall instanceof String) {
                retMap.put(Attributes.SYSTEM_CALL, (String) syscall);
                ITmfTrace trace = getTrace();
                ITmfCallsiteResolver csAnalysis = TmfTraceUtils.getAnalysisModuleOfClass(trace, CallsiteAnalysis.class, CallsiteAnalysis.ID);
                if (csAnalysis != null) {
                    for (ITmfEventAspect<?> aspect : trace.getEventAspects()) {
                        if (aspect instanceof TmfCpuAspect) {
                            TmfDeviceAspect deviceAspect = (TmfCpuAspect) aspect;
                            List<@NonNull ITmfCallsite> callsites = csAnalysis.getCallsites(String.valueOf(trace.getUUID()), deviceAspect.getDeviceType(), attributeName, interval.getStartTime() / 2L + interval.getEndTime() / 2L);
                            if (!callsites.isEmpty()) {
                                retMap.put(TmfStrings.source(), callsites.get(0).toString());
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfCallsite(org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite) TmfCpuAspect(org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) ITmfCallsiteResolver(org.eclipse.tracecompass.tmf.core.analysis.callsite.ITmfCallsiteResolver) TmfDeviceAspect(org.eclipse.tracecompass.tmf.core.event.aspect.TmfDeviceAspect)

Example 2 with ITmfCallsiteResolver

use of org.eclipse.tracecompass.tmf.core.analysis.callsite.ITmfCallsiteResolver in project tracecompass by tracecompass.

the class ThreadStatusDataProvider method fetchTooltip.

@Override
@NonNull
public TmfModelResponse<@NonNull Map<@NonNull String, @NonNull String>> fetchTooltip(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    ITmfStateSystem ss = fModule.getStateSystem();
    if (ss == null) {
        return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.STATE_SYSTEM_FAILED);
    }
    boolean completed = ss.waitUntilBuilt(0);
    ITmfResponse.Status status = completed ? ITmfResponse.Status.COMPLETED : ITmfResponse.Status.RUNNING;
    String statusMessage = completed ? CommonStatusMessage.COMPLETED : CommonStatusMessage.RUNNING;
    // TODO server: Parameters validation should be handle separately. It
    // can be either in the data provider itself or before calling it. It
    // will avoid the creation of filters and the content of the map can be
    // use directly.
    List<@NonNull Long> selected = DataProviderParameterUtils.extractSelectedItems(fetchParameters);
    List<@NonNull Long> times = DataProviderParameterUtils.extractTimeRequested(fetchParameters);
    if (times == null || times.isEmpty() || selected == null || selected.isEmpty()) {
        return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
    }
    Integer quark = fQuarkMap.get(selected.get(0));
    if (quark == null) {
        return new TmfModelResponse<>(null, status, statusMessage);
    }
    long start = times.get(0);
    try {
        int currentCpuRqQuark = ss.optQuarkRelative(quark, Attributes.CURRENT_CPU_RQ);
        if (currentCpuRqQuark == ITmfStateSystem.INVALID_ATTRIBUTE || start < ss.getStartTime() || start > ss.getCurrentEndTime()) {
            return new TmfModelResponse<>(null, status, statusMessage);
        }
        ITmfStateInterval mainInterval = null;
        ITmfStateInterval currentCpuInterval = null;
        for (ITmfStateInterval interval : ss.query2D(ImmutableList.of(quark, currentCpuRqQuark), Collections.singleton(start))) {
            if (interval.getAttribute() == quark) {
                mainInterval = interval;
                continue;
            }
            currentCpuInterval = interval;
        }
        if (mainInterval == null || currentCpuInterval == null) {
            return new TmfModelResponse<>(null, status, statusMessage);
        }
        ITmfCallsiteResolver csAnalysis = TmfTraceUtils.getAnalysisModuleOfClass(getTrace(), CallsiteAnalysis.class, CallsiteAnalysis.ID);
        Object value = currentCpuInterval.getValue();
        if (value instanceof Integer) {
            String cpuId = String.valueOf(value);
            Map<String, String> returnValue = new LinkedHashMap<>();
            returnValue.put(TmfStrings.cpu(), cpuId);
            if (csAnalysis != null) {
                Object cpuThreadObj = mainInterval.getValue();
                if (cpuThreadObj instanceof Integer && Objects.equals(ProcessStatus.RUN_SYTEMCALL.getStateValue().unboxInt(), cpuThreadObj)) {
                    ITmfTrace trace = getTrace();
                    for (ITmfEventAspect<?> aspect : trace.getEventAspects()) {
                        if (aspect instanceof TmfCpuAspect) {
                            TmfCpuAspect deviceAspect = (TmfCpuAspect) aspect;
                            List<@NonNull ITmfCallsite> callsites = csAnalysis.getCallsites(String.valueOf(trace.getUUID()), deviceAspect.getDeviceType(), cpuId, start);
                            if (!callsites.isEmpty()) {
                                returnValue.put(TmfStrings.source(), callsites.get(0).toString());
                            }
                        }
                    }
                }
            }
            return new TmfModelResponse<>(returnValue, status, statusMessage);
        }
    } catch (StateSystemDisposedException e) {
    /* Ignored */
    }
    return new TmfModelResponse<>(null, status, statusMessage);
}
Also used : ITmfResponse(org.eclipse.tracecompass.tmf.core.response.ITmfResponse) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) ITmfCallsiteResolver(org.eclipse.tracecompass.tmf.core.analysis.callsite.ITmfCallsiteResolver) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) LinkedHashMap(java.util.LinkedHashMap) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfCallsite(org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite) TmfCpuAspect(org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect) AtomicLong(java.util.concurrent.atomic.AtomicLong) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) NonNull(org.eclipse.jdt.annotation.NonNull)

Aggregations

ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)2 ITmfCallsiteResolver (org.eclipse.tracecompass.tmf.core.analysis.callsite.ITmfCallsiteResolver)2 TmfCpuAspect (org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect)2 ITmfCallsite (org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite)2 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)2 LinkedHashMap (java.util.LinkedHashMap)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)1 StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)1 TmfDeviceAspect (org.eclipse.tracecompass.tmf.core.event.aspect.TmfDeviceAspect)1 ITmfResponse (org.eclipse.tracecompass.tmf.core.response.ITmfResponse)1 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)1