-
Notifications
You must be signed in to change notification settings - Fork 11
/
AnalysisProcessNameAspect.java
65 lines (57 loc) · 2.36 KB
/
AnalysisProcessNameAspect.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*******************************************************************************
* Copyright (c) 2018 Ecole Polytechnique de Montreal
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 which
* accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.tracecompass.incubator.analysis.core.aspects;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxPidAspect;
import org.eclipse.tracecompass.incubator.analysis.core.model.IHostModel;
import org.eclipse.tracecompass.incubator.analysis.core.model.ModelManager;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
/**
* Event aspect to resolve the process name of an event. It finds the model for
* the host the aspect is from and returns the process name at the time of the
* event.
*
* @author Guillaume Champagne
* @author Alexis-Maurer Fortin
* @author Hugo Genesse
* @author Pierre-Yves Lajoie
* @author Eva Terriault
*/
public final class AnalysisProcessNameAspect extends ProcessNameAspect {
private static final AnalysisProcessNameAspect INSTANCE = new AnalysisProcessNameAspect();
private AnalysisProcessNameAspect() {
// Nothing to do
}
/**
* Get the instance of this aspect
*
* @return The instance of this aspect
*/
public static AnalysisProcessNameAspect getInstance() {
return INSTANCE;
}
@Override
public @Nullable String resolve(@NonNull ITmfEvent event) {
Object pidObj = TmfTraceUtils.resolveEventAspectOfClassForEvent(event.getTrace(), LinuxPidAspect.class, event);
if (pidObj == null) {
return null;
}
String hostId = event.getTrace().getHostId();
IHostModel model = ModelManager.getModelFor(hostId);
Integer pid = (Integer) pidObj;
ITmfTimestamp timestamp = event.getTimestamp();
String pname = model.getExecName(pid, timestamp.getValue());
return pname;
}
}