e2a2a6d9cd9630724ff01e72e4bde525f277a68e
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / analysis / os / linux / core / kernel / KernelTidAspect.java
1 /*******************************************************************************
2 * Copyright (c) 2015 École Polytechnique de Montréal
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.analysis.os.linux.core.kernel;
14
15 import org.eclipse.jdt.annotation.Nullable;
16 import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxTidAspect;
17 import org.eclipse.tracecompass.analysis.os.linux.core.tid.TidAnalysisModule;
18 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
19 import org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect;
20 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
21
22 /**
23 * This aspect finds the ID of the thread running from this event using the
24 * {@link KernelAnalysisModule}.
25 *
26 * @author Geneviève Bastien
27 * @since 2.0
28 */
29 public final class KernelTidAspect extends LinuxTidAspect {
30
31 /** The singleton instance */
32 public static final KernelTidAspect INSTANCE = new KernelTidAspect();
33
34 private KernelTidAspect() {
35 }
36
37 @Override
38 public @Nullable Integer resolve(ITmfEvent event) {
39 /* Find the CPU this event is run on */
40 Integer cpu = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(),
41 TmfCpuAspect.class, event);
42 if (cpu == null) {
43 return null;
44 }
45
46 /* Find the analysis module for the trace */
47 TidAnalysisModule analysis = TmfTraceUtils.getAnalysisModuleOfClass(event.getTrace(),
48 TidAnalysisModule.class, TidAnalysisModule.ID);
49 if (analysis == null) {
50 return null;
51 }
52 return analysis.getThreadOnCpuAtTime(cpu, event.getTimestamp().toNanos());
53 }
54
55 }
This page took 0.033869 seconds and 5 git commands to generate.