tmf: Introduce resolveIntEventAspectOfClassForEvent
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / analysis / os / linux / core / kernelanalysis / KernelTidAspect.java
CommitLineData
312f397a
GB
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
13package org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis;
14
15import org.eclipse.jdt.annotation.Nullable;
16import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxTidAspect;
17import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
18import org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect;
19import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
20
21/**
22 * This aspect finds the ID of the thread running from this event using the
6d16f5a9 23 * {@link KernelAnalysisModule}.
312f397a
GB
24 *
25 * @author Geneviève Bastien
dbc7991d 26 * @since 1.0
312f397a 27 */
9049e763
AM
28public final class KernelTidAspect extends LinuxTidAspect {
29
30 /** The singleton instance */
31 public static final KernelTidAspect INSTANCE = new KernelTidAspect();
32
33 private KernelTidAspect() {
34 }
312f397a
GB
35
36 @Override
37 public @Nullable Integer resolve(ITmfEvent event) {
38 /* Find the CPU this event is run on */
b3867ecc 39 Integer cpu = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(),
312f397a 40 TmfCpuAspect.class, event);
b3867ecc 41 if (cpu == null) {
312f397a
GB
42 return null;
43 }
312f397a
GB
44
45 /* Find the analysis module for the trace */
6d16f5a9
AM
46 KernelAnalysisModule analysis = TmfTraceUtils.getAnalysisModuleOfClass(event.getTrace(),
47 KernelAnalysisModule.class, KernelAnalysisModule.ID);
312f397a
GB
48 if (analysis == null) {
49 return null;
50 }
51 Integer tid = KernelThreadInformationProvider.getThreadOnCpu(
52 analysis, cpu, event.getTimestamp().getValue());
53 if (tid != null) {
54 return tid;
55 }
56 return null;
57 }
58
59}
This page took 0.03929 seconds and 5 git commands to generate.