blob: 137e70252b5e5a7667f36670e889231aed9f8892 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2016 École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
* accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.fused.handlers;
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
import org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.fused.FusedAttributes;
import org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.model.VirtualCPU;
import org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.model.VirtualMachine;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
/**
* @author Cédric Biancheri
*/
public class IrqExitHandler extends VMKernelEventHandler {
/**
* Constructor
*
* @param layout
* the layout
* @param sp
* the state provider
*/
public IrqExitHandler(IKernelAnalysisEventLayout layout, FusedVirtualMachineStateProvider sp) {
super(layout, sp);
}
@Override
public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) {
Integer cpu = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(), TmfCpuAspect.class, event);
if( cpu == null ) {
return;
}
FusedVirtualMachineStateProvider sp = getStateProvider();
VirtualMachine host = sp.getCurrentMachine(event);
VirtualCPU cpuObject = VirtualCPU.getVirtualCPU(host, cpu.longValue());
if (host != null && host.isGuest()) {
Integer physicalCPU = sp.getPhysicalCPU(host, cpu);
if (physicalCPU != null) {
cpu = physicalCPU;
} else {
return;
}
}
int currentThreadNode = FusedVMEventHandlerUtils.getCurrentThreadNode(cpu, ss);
Integer irqId = ((Long) event.getContent().getField(getLayout().fieldIrq()).getValue()).intValue();
/* Put this IRQ back to inactive in the resource tree */
int quark = ss.getQuarkRelativeAndAdd(FusedVMEventHandlerUtils.getNodeIRQs(cpu, ss), irqId.toString());
long timestamp = FusedVMEventHandlerUtils.getTimestamp(event);
ss.modifyAttribute(timestamp, (Object) null, quark);
/* Set the previous process back to running */
FusedVMEventHandlerUtils.setProcessToRunning(timestamp, currentThreadNode, ss);
/* Set the CPU status back to running or "idle" */
FusedVMEventHandlerUtils.cpuExitInterrupt(timestamp, cpu, ss);
quark = ss.getQuarkRelativeAndAdd(FusedVMEventHandlerUtils.getCurrentCPUNode(cpu, ss), FusedAttributes.STATUS);
Integer value = cpuObject.getStateBeforeIRQ();
ss.modifyAttribute(timestamp, value, quark);
}
}