1 /*******************************************************************************
2 * Copyright (c) 2015 École Polytechnique de Montréal
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
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.kernel
;
15 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
16 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
17 import org
.eclipse
.jdt
.annotation
.NonNull
;
18 import org
.eclipse
.jdt
.annotation
.Nullable
;
19 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.event
.aspect
.LinuxTidAspect
;
20 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.tid
.TidAnalysisModule
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.TmfCpuAspect
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceUtils
;
26 * This aspect finds the ID of the thread running from this event using the
27 * {@link KernelAnalysisModule}.
29 * @author Geneviève Bastien
32 public final class KernelTidAspect
extends LinuxTidAspect
{
34 /** The singleton instance */
35 public static final KernelTidAspect INSTANCE
= new KernelTidAspect();
37 private static final IProgressMonitor NULL_MONITOR
= new NullProgressMonitor();
39 private KernelTidAspect() {
43 public @Nullable Integer
resolve(ITmfEvent event
) {
45 return resolve(event
, false, NULL_MONITOR
);
46 } catch (InterruptedException e
) {
47 /* Should not happen since there is nothing to interrupt */
53 public @Nullable Integer
resolve(@NonNull ITmfEvent event
, boolean block
, final IProgressMonitor monitor
) throws InterruptedException
{
54 /* Find the CPU this event is run on */
55 Integer cpu
= TmfTraceUtils
.resolveIntEventAspectOfClassForEvent(event
.getTrace(),
56 TmfCpuAspect
.class, event
);
61 /* Find the analysis module for the trace */
62 TidAnalysisModule analysis
= TmfTraceUtils
.getAnalysisModuleOfClass(event
.getTrace(),
63 TidAnalysisModule
.class, TidAnalysisModule
.ID
);
64 if (analysis
== null) {
67 long ts
= event
.getTimestamp().toNanos();
68 while (block
&& !analysis
.isQueryable(ts
) && !monitor
.isCanceled()) {
71 return analysis
.getThreadOnCpuAtTime(cpu
, ts
);