| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2015 Ericsson |
| 3 | * |
| 4 | * All rights reserved. This program and the accompanying materials |
| 5 | * are made available under the terms of the Eclipse Public License v1.0 |
| 6 | * which accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Matthew Khouzam - Initial API and implementation |
| 11 | *******************************************************************************/ |
| 12 | |
| 13 | package org.lttng.scope.lttng.kernel.core.analysis.os.handlers.internal; |
| 14 | |
| 15 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; |
| 16 | import org.lttng.scope.lttng.kernel.core.analysis.os.Attributes; |
| 17 | import org.lttng.scope.lttng.kernel.core.trace.layout.ILttngKernelEventLayout; |
| 18 | |
| 19 | import ca.polymtl.dorsal.libdelorean.ITmfStateSystemBuilder; |
| 20 | import ca.polymtl.dorsal.libdelorean.exceptions.AttributeNotFoundException; |
| 21 | |
| 22 | /** |
| 23 | * Process free event handler |
| 24 | */ |
| 25 | public class ProcessFreeHandler extends KernelEventHandler { |
| 26 | |
| 27 | /** |
| 28 | * Constructor |
| 29 | * |
| 30 | * @param layout |
| 31 | * event layout |
| 32 | */ |
| 33 | public ProcessFreeHandler(ILttngKernelEventLayout layout) { |
| 34 | super(layout); |
| 35 | } |
| 36 | |
| 37 | @Override |
| 38 | public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws AttributeNotFoundException { |
| 39 | |
| 40 | Integer cpu = KernelEventHandlerUtils.getCpu(event); |
| 41 | Integer tid = ((Long) event.getContent().getField(getLayout().fieldTid()).getValue()).intValue(); |
| 42 | |
| 43 | String threadAttributeName = Attributes.buildThreadAttributeName(tid, cpu); |
| 44 | if (threadAttributeName == null) { |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | /* |
| 49 | * Remove the process and all its sub-attributes from the current state |
| 50 | */ |
| 51 | int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeThreads(ss), threadAttributeName); |
| 52 | ss.removeAttribute(KernelEventHandlerUtils.getTimestamp(event), quark); |
| 53 | } |
| 54 | } |