Commit | Line | Data |
---|---|---|
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 | ||
13 | package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers; | |
14 | ||
0f7a12d3 AM |
15 | import org.eclipse.tracecompass.analysis.os.linux.core.kernel.Attributes; |
16 | import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues; | |
c8f45ad2 MK |
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; | |
23 | ||
24 | /** | |
25 | * System call entry handler | |
26 | */ | |
27 | public class SysEntryHandler extends KernelEventHandler { | |
28 | ||
29 | /** | |
30 | * Constructor | |
31 | * | |
32 | * @param layout | |
33 | * event layout | |
34 | */ | |
35 | public SysEntryHandler(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.newValueString(event.getName()); | |
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_SYSCALL_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_SYSCALL_VALUE; | |
61 | ss.modifyAttribute(timestamp, value, quark); | |
62 | } | |
63 | ||
64 | } |