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
.lttng
.scope
.lttng
.kernel
.core
.event
.aspect
;
15 import static org
.lttng
.scope
.common
.core
.NonNullUtils
.nullToEmptyString
;
17 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
18 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
19 import org
.eclipse
.jdt
.annotation
.NonNull
;
20 import org
.eclipse
.jdt
.annotation
.Nullable
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.ITmfEventAspect
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.TmfCpuAspect
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceUtils
;
25 import org
.lttng
.scope
.lttng
.kernel
.core
.analysis
.os
.KernelAnalysisModule
;
26 import org
.lttng
.scope
.lttng
.kernel
.core
.analysis
.os
.KernelThreadInformationProvider
;
29 * This aspect finds the ID of the thread running from this event using the
30 * {@link KernelAnalysisModule}.
32 * @author Geneviève Bastien
34 public final class KernelTidAspect
implements ITmfEventAspect
<Integer
> {
36 /** The singleton instance */
37 public static final KernelTidAspect INSTANCE
= new KernelTidAspect();
39 private static final IProgressMonitor NULL_MONITOR
= new NullProgressMonitor();
41 private KernelTidAspect() {
45 public String
getName() {
46 return nullToEmptyString(Messages
.KernelTidAspect_Name
);
50 public String
getHelpText() {
51 return nullToEmptyString(Messages
.KernelTidAspect_HelpText
);
55 public @Nullable Integer
resolve(ITmfEvent event
) {
56 return resolve(event
, false, NULL_MONITOR
);
60 public @Nullable Integer
resolve(@NonNull ITmfEvent event
, boolean block
, final IProgressMonitor monitor
) {
61 /* Find the CPU this event is run on */
62 Integer cpu
= TmfTraceUtils
.resolveIntEventAspectOfClassForEvent(event
.getTrace(),
63 TmfCpuAspect
.class, event
);
68 /* Find the analysis module for the trace */
69 KernelAnalysisModule analysis
= TmfTraceUtils
.getAnalysisModuleOfClass(event
.getTrace(),
70 KernelAnalysisModule
.class, KernelAnalysisModule
.ID
);
71 if (analysis
== null) {
74 long ts
= event
.getTimestamp().toNanos();
75 while (block
&& !analysis
.isQueryable(ts
) && !monitor
.isCanceled()) {
78 } catch (InterruptedException e
) {
82 return KernelThreadInformationProvider
.getThreadOnCpu(analysis
, cpu
, ts
);