Commit | Line | Data |
---|---|---|
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 | ||
0f7a12d3 | 13 | package org.eclipse.tracecompass.analysis.os.linux.core.kernel; |
312f397a GB |
14 | |
15 | import org.eclipse.jdt.annotation.Nullable; | |
16 | import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxTidAspect; | |
d8e841d9 | 17 | import org.eclipse.tracecompass.analysis.os.linux.core.tid.TidAnalysisModule; |
312f397a GB |
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 | |
6d16f5a9 | 24 | * {@link KernelAnalysisModule}. |
312f397a GB |
25 | * |
26 | * @author Geneviève Bastien | |
0f7a12d3 | 27 | * @since 2.0 |
312f397a | 28 | */ |
9049e763 AM |
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 | } | |
312f397a GB |
36 | |
37 | @Override | |
38 | public @Nullable Integer resolve(ITmfEvent event) { | |
39 | /* Find the CPU this event is run on */ | |
b3867ecc | 40 | Integer cpu = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(), |
312f397a | 41 | TmfCpuAspect.class, event); |
b3867ecc | 42 | if (cpu == null) { |
312f397a GB |
43 | return null; |
44 | } | |
312f397a GB |
45 | |
46 | /* Find the analysis module for the trace */ | |
d8e841d9 MK |
47 | TidAnalysisModule analysis = TmfTraceUtils.getAnalysisModuleOfClass(event.getTrace(), |
48 | TidAnalysisModule.class, TidAnalysisModule.ID); | |
312f397a GB |
49 | if (analysis == null) { |
50 | return null; | |
51 | } | |
d8e841d9 | 52 | return analysis.getThreadOnCpuAtTime(cpu, event.getTimestamp().toNanos()); |
312f397a GB |
53 | } |
54 | ||
55 | } |