1 /*******************************************************************************
2 * Copyright (c) 2016 EfficiOS Inc., Alexandre Montplaisir
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.lttng2
.ust
.core
.analysis
.debuginfo
;
12 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.nullToEmptyString
;
16 import org
.eclipse
.jdt
.annotation
.Nullable
;
17 import org
.eclipse
.tracecompass
.internal
.lttng2
.ust
.core
.analysis
.debuginfo
.FileOffsetMapper
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.ITmfEventAspect
;
22 * Aspect for the function location obtained with the UST debug info.
24 * @author Alexandre Montplaisir
27 public class UstDebugInfoFunctionAspect
implements ITmfEventAspect
<FunctionLocation
> {
29 /** Singleton instance */
30 public static final UstDebugInfoFunctionAspect INSTANCE
= new UstDebugInfoFunctionAspect();
32 private UstDebugInfoFunctionAspect() {}
35 public String
getName() {
36 return nullToEmptyString(Messages
.UstDebugInfoAnalysis_FunctionAspectName
);
40 public String
getHelpText() {
41 return nullToEmptyString(Messages
.UstDebugInfoAnalysis_FunctionAspectHelpText
);
45 public @Nullable FunctionLocation
resolve(ITmfEvent event
) {
46 /* Resolve the binary callsite first. */
47 BinaryCallsite bc
= UstDebugInfoBinaryAspect
.INSTANCE
.resolve(event
);
52 return getFunctionFromBinaryLocation(bc
);
56 * Get a function location starting directly from a binary callsite, instead
57 * of from a trace event.
60 * The binary callsite, representing a binary and offset within
62 * @return The corresponding function location
65 public static @Nullable FunctionLocation
getFunctionFromBinaryLocation(BinaryCallsite bc
) {
66 String functionName
= FileOffsetMapper
.getFunctionNameFromOffset(
67 new File(bc
.getBinaryFilePath()),
70 if (functionName
== null) {
74 /* We do not track the offset inside the function at this time */
75 return new FunctionLocation(functionName
, null);