os.linux: Move Attributes class to internal package
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / internal / analysis / os / linux / core / kernel / handlers / SysExitHandler.java
CommitLineData
c8f45ad2
MK
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
13package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers;
14
0f7a12d3 15import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues;
c8f45ad2 16import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
f69045e2 17import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
c8f45ad2
MK
18import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
19import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
20import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
21import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
22import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
23
24/**
25 * System call exit handler
26 */
27public class SysExitHandler extends KernelEventHandler {
28
29 /**
30 * Constructor
31 *
32 * @param layout
33 * event layout
34 */
35 public SysExitHandler(IKernelAnalysisEventLayout layout) {
36 super(layout);
37 }
38
39 @Override
40 public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws AttributeNotFoundException {
41 Integer cpu = KernelEventHandlerUtils.getCpu(event);
42 if (cpu == null) {
43 return;
44 }
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);
51
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);
56
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);
62 }
63
64}
This page took 0.032471 seconds and 5 git commands to generate.