1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
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
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.analysis
.os
.linux
.core
.kernel
.handlers
;
15 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.kernelanalysis
.Attributes
;
16 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.kernelanalysis
.StateValues
;
17 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.trace
.IKernelAnalysisEventLayout
;
18 import org
.eclipse
.tracecompass
.statesystem
.core
.ITmfStateSystemBuilder
;
19 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.AttributeNotFoundException
;
20 import org
.eclipse
.tracecompass
.statesystem
.core
.statevalue
.ITmfStateValue
;
21 import org
.eclipse
.tracecompass
.statesystem
.core
.statevalue
.TmfStateValue
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
25 * System call exit handler
27 public class SysExitHandler
extends KernelEventHandler
{
35 public SysExitHandler(IKernelAnalysisEventLayout layout
) {
40 public void handleEvent(ITmfStateSystemBuilder ss
, ITmfEvent event
) throws AttributeNotFoundException
{
41 Integer cpu
= KernelEventHandlerUtils
.getCpu(event
);
45 /* Assign the new system call to the process */
46 int currentThreadNode
= KernelEventHandlerUtils
.getCurrentThreadNode(cpu
, ss
);
47 int quark
= ss
.getQuarkRelativeAndAdd(currentThreadNode
, Attributes
.SYSTEM_CALL
);
48 ITmfStateValue value
= TmfStateValue
.nullValue();
49 long timestamp
= KernelEventHandlerUtils
.getTimestamp(event
);
50 ss
.modifyAttribute(timestamp
, value
, quark
);
52 /* Put the process in system call mode */
53 quark
= ss
.getQuarkRelativeAndAdd(currentThreadNode
, Attributes
.STATUS
);
54 value
= StateValues
.PROCESS_STATUS_RUN_USERMODE_VALUE
;
55 ss
.modifyAttribute(timestamp
, value
, quark
);
57 /* Put the CPU in system call (kernel) mode */
58 int currentCPUNode
= KernelEventHandlerUtils
.getCurrentCPUNode(cpu
, ss
);
59 quark
= ss
.getQuarkRelativeAndAdd(currentCPUNode
, Attributes
.STATUS
);
60 value
= StateValues
.CPU_STATUS_RUN_USERMODE_VALUE
;
61 ss
.modifyAttribute(timestamp
, value
, quark
);