From 5654323b1d6fa62f69691193a273f4fba19fe0ab Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Thu, 10 Oct 2024 11:58:24 -0400 Subject: [PATCH] uftrace: demangle c++ names Use CDT's cppFilt to demange c++ names if available. Signed-off-by: Matthew Khouzam --- .../META-INF/MANIFEST.MF | 3 ++- .../internal/uftrace/core/trace/Uftrace.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tracetypes/org.eclipse.tracecompass.incubator.uftrace.core/META-INF/MANIFEST.MF b/tracetypes/org.eclipse.tracecompass.incubator.uftrace.core/META-INF/MANIFEST.MF index 993c3de78..6c28aec5f 100644 --- a/tracetypes/org.eclipse.tracecompass.incubator.uftrace.core/META-INF/MANIFEST.MF +++ b/tracetypes/org.eclipse.tracecompass.incubator.uftrace.core/META-INF/MANIFEST.MF @@ -23,5 +23,6 @@ Export-Package: org.eclipse.tracecompass.incubator.internal.uftrace.core;x-frien org.eclipse.tracecompass.incubator.internal.uftrace.core.trace;x-friends:="org.eclipse.tracecompass.incubator.uftrace.core.tests" Import-Package: com.google.common.collect, org.apache.commons.io, - org.apache.commons.lang3.math + org.apache.commons.lang3.math, + org.eclipse.cdt.utils Automatic-Module-Name: org.eclipse.tracecompass.incubator.uftrace.core diff --git a/tracetypes/org.eclipse.tracecompass.incubator.uftrace.core/src/org/eclipse/tracecompass/incubator/internal/uftrace/core/trace/Uftrace.java b/tracetypes/org.eclipse.tracecompass.incubator.uftrace.core/src/org/eclipse/tracecompass/incubator/internal/uftrace/core/trace/Uftrace.java index 83b594e12..cd1cff6fe 100644 --- a/tracetypes/org.eclipse.tracecompass.incubator.uftrace.core/src/org/eclipse/tracecompass/incubator/internal/uftrace/core/trace/Uftrace.java +++ b/tracetypes/org.eclipse.tracecompass.incubator.uftrace.core/src/org/eclipse/tracecompass/incubator/internal/uftrace/core/trace/Uftrace.java @@ -27,6 +27,7 @@ import java.util.Set; import org.apache.commons.io.FilenameUtils; +import org.eclipse.cdt.utils.CPPFilt; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IProgressMonitor; @@ -39,6 +40,7 @@ import org.eclipse.tracecompass.incubator.analysis.core.aspects.ProcessNameAspect; import org.eclipse.tracecompass.incubator.internal.uftrace.core.Activator; import org.eclipse.tracecompass.incubator.internal.uftrace.core.trace.SymParser.Symbol; +import org.eclipse.tracecompass.internal.tmf.core.callstack.FunctionNameMapper; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.event.ITmfEventType; import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect; @@ -491,9 +493,15 @@ private Map getMap() { private static class UfTraceSymbolProvider implements ISymbolProvider { private Uftrace fTrace; + private CPPFilt fCppFilt; public UfTraceSymbolProvider(Uftrace trace) { fTrace = trace; + try { + fCppFilt = new CPPFilt(); + } catch (IOException e) { + Activator.getInstance().logError("Could not load CPP Filt, C++ functions will be mangled." , e); //$NON-NLS-1$ + } } @Override @@ -526,6 +534,9 @@ public TmfResolvedSymbol getSymbol(int tid, long timestamp, long address) { Symbol value = floorEntry.getValue(); if (value != null) { String name = String.valueOf(value.getName()); + if(fCppFilt != null) { + name = FunctionNameMapper.nameFromCppFilt(fCppFilt, name); + } return new TmfResolvedSymbol(address, name); } }