lttng.ust: Implement a symbol provider for LTTng-UST traces
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.ust.ui / src / org / eclipse / tracecompass / internal / lttng2 / ust / ui / analysis / debuginfo / UstDebugInfoSymbolProvider.java
1 /*******************************************************************************
2 * Copyright (c) 2016 EfficiOS Inc. and others
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
10 package org.eclipse.tracecompass.internal.lttng2.ust.ui.analysis.debuginfo;
11
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.BinaryCallsite;
15 import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoAnalysisModule;
16 import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoBinaryAspect;
17 import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoSourceAspect;
18 import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
19 import org.eclipse.tracecompass.tmf.core.event.lookup.TmfCallsite;
20 import org.eclipse.tracecompass.tmf.ui.symbols.DefaultSymbolProvider;
21 import org.eclipse.tracecompass.tmf.ui.symbols.ISymbolProviderPreferencePage;
22
23 /**
24 * Symbol provider for UST traces with debug information.
25 *
26 * @author Alexandre Montplaisir
27 * @see UstDebugInfoAnalysisModule
28 */
29 public class UstDebugInfoSymbolProvider extends DefaultSymbolProvider {
30
31 /**
32 * Create a new {@link UstDebugInfoSymbolProvider} for the given trace
33 *
34 * @param trace
35 * A non-null trace
36 */
37 public UstDebugInfoSymbolProvider(LttngUstTrace trace) {
38 super(trace);
39 }
40
41 /**
42 * Sets the configured path prefix. Usually called from the preferences
43 * page.
44 *
45 * @param newPathPrefix
46 * The new path prefix to use
47 */
48 void setConfiguredPathPrefix(LttngUstTrace.SymbolProviderConfig newConfig) {
49 getTrace().setSymbolProviderConfig(newConfig);
50 }
51
52 @Override
53 public @NonNull LttngUstTrace getTrace() {
54 /* Type enforced at constructor */
55 return (LttngUstTrace) super.getTrace();
56 }
57
58 @Override
59 public @Nullable String getSymbolText(int pid, long timestamp, long address) {
60 TmfCallsite callsite = getSymbolInfo(pid, timestamp, address);
61 return (callsite == null ? null : callsite.getFunctionName());
62 }
63
64 @Override
65 public @Nullable TmfCallsite getSymbolInfo(int pid, long timestamp, long address) {
66 BinaryCallsite bc = UstDebugInfoBinaryAspect.getBinaryCallsite(getTrace(), pid, timestamp, address);
67 if (bc == null) {
68 return null;
69 }
70
71 return UstDebugInfoSourceAspect.getSourceCallsite(getTrace(), bc);
72 }
73
74 @Override
75 public @NonNull ISymbolProviderPreferencePage createPreferencePage() {
76 return new UstDebugInfoSymbolProviderPreferencePage(this);
77 }
78
79 }
This page took 0.102846 seconds and 6 git commands to generate.