Commit | Line | Data |
---|---|---|
af3275f8 AM |
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.analysis.os.StateValues; | |
18 | import org.lttng.scope.lttng.kernel.core.trace.layout.ILttngKernelEventLayout; | |
19 | ||
20 | import ca.polymtl.dorsal.libdelorean.ITmfStateSystemBuilder; | |
21 | import ca.polymtl.dorsal.libdelorean.exceptions.AttributeNotFoundException; | |
22 | import ca.polymtl.dorsal.libdelorean.statevalue.ITmfStateValue; | |
23 | import ca.polymtl.dorsal.libdelorean.statevalue.TmfStateValue; | |
24 | ||
25 | /** | |
26 | * System call entry handler | |
27 | */ | |
28 | public class SysEntryHandler extends KernelEventHandler { | |
29 | ||
30 | /** | |
31 | * Constructor | |
32 | * | |
33 | * @param layout | |
34 | * event layout | |
35 | */ | |
36 | public SysEntryHandler(ILttngKernelEventLayout layout) { | |
37 | super(layout); | |
38 | } | |
39 | ||
40 | @Override | |
41 | public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws AttributeNotFoundException { | |
42 | Integer cpu = KernelEventHandlerUtils.getCpu(event); | |
43 | if (cpu == null) { | |
44 | return; | |
45 | } | |
46 | /* Assign the new system call to the process */ | |
47 | int currentThreadNode = KernelEventHandlerUtils.getCurrentThreadNode(cpu, ss); | |
48 | int quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.SYSTEM_CALL); | |
49 | ITmfStateValue value = TmfStateValue.newValueString(event.getName()); | |
50 | long timestamp = KernelEventHandlerUtils.getTimestamp(event); | |
51 | ss.modifyAttribute(timestamp, value, quark); | |
52 | ||
53 | /* Put the process in system call mode */ | |
54 | value = StateValues.PROCESS_STATUS_RUN_SYSCALL_VALUE; | |
55 | ss.modifyAttribute(timestamp, value, currentThreadNode); | |
56 | ||
57 | /* Put the CPU in system call (kernel) mode */ | |
58 | int currentCPUNode = KernelEventHandlerUtils.getCurrentCPUNode(cpu, ss); | |
59 | value = StateValues.CPU_STATUS_RUN_SYSCALL_VALUE; | |
60 | ss.modifyAttribute(timestamp, value, currentCPUNode); | |
61 | } | |
62 | ||
63 | } |