Search in sources :

Example 1 with TmfDeviceAspect

use of org.eclipse.tracecompass.tmf.core.event.aspect.TmfDeviceAspect in project tracecompass by tracecompass.

the class CallsiteStateProvider method getRootAttribute.

/**
 * Get or create the root attribute for the specified event. This attribute
 * is the parent of the {@value #FILES} and {@value #LINES} attributes.
 *
 * @param event
 *            the event
 * @return the root attribute or {@link ITmfStateSystem#INVALID_ATTRIBUTE}
 */
protected int getRootAttribute(ITmfEvent event) {
    String deviceId = null;
    String deviceType = null;
    ITmfTrace trace = event.getTrace();
    for (ITmfEventAspect<?> aspect : trace.getEventAspects()) {
        if (aspect instanceof TmfDeviceAspect) {
            TmfDeviceAspect deviceAspect = (TmfDeviceAspect) aspect;
            Object result = deviceAspect.resolve(event);
            if (result != null) {
                deviceId = result.toString();
                deviceType = deviceAspect.getDeviceType();
                break;
            }
        }
    }
    if (deviceId == null) {
        return ITmfStateSystem.INVALID_ATTRIBUTE;
    }
    ITmfStateSystemBuilder ssb = Objects.requireNonNull(getStateSystemBuilder());
    return ssb.getQuarkRelativeAndAdd(fDevicesQuark, String.valueOf(trace.getUUID()), deviceType, deviceId);
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfStateSystemBuilder(org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder) TmfDeviceAspect(org.eclipse.tracecompass.tmf.core.event.aspect.TmfDeviceAspect)

Example 2 with TmfDeviceAspect

use of org.eclipse.tracecompass.tmf.core.event.aspect.TmfDeviceAspect 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)

Aggregations

TmfDeviceAspect (org.eclipse.tracecompass.tmf.core.event.aspect.TmfDeviceAspect)2 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)2 ITmfStateSystemBuilder (org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder)1 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)1 ITmfCallsiteResolver (org.eclipse.tracecompass.tmf.core.analysis.callsite.ITmfCallsiteResolver)1 TmfCpuAspect (org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect)1 ITmfCallsite (org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite)1