Skip to content

Commit

Permalink
resolve symbols for diff flame graph so that it works on function nam…
Browse files Browse the repository at this point in the history
…es rather than pointers

Signed-off-by: Matthew Khouzam <[email protected]>
Change-Id: I17bf17de4bc7210ea291da9d749360d76965333c
  • Loading branch information
MatthewKhouzam committed Aug 26, 2024
1 parent 35f968d commit 6b6c6de
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,41 @@ public DifferentialCallGraphProvider refreshDiffCG(@Nullable IProgressMonitor mo

Collection<WeightedTree<ICallStackSymbol>> originalTree = new ArrayList<>();
Collection<WeightedTree<ICallStackSymbol>> diffTree = new ArrayList<>();
WeightedTreeSet<ICallStackSymbol, Object> callGraphA = mergeCallGraph(fStartA, fEndA, getTraceListA());
List<String> tla = getTraceListA();
WeightedTreeSet<ICallStackSymbol, Object> callGraphA = mergeCallGraph(fStartA, fEndA, tla);

Collection<@NonNull ?> processes = callGraphA.getTreesForNamed(MERGE);
for (Object process : processes) {
originalTree.add((AggregatedCalledFunction) process);
String label = ""; //$NON-NLS-1$
for(String trace : tla) {
ICallGraphProvider2 reg = fTraceCallGraphRegistry.get(trace);
if (reg != null) {
label = reg.toDisplayString((AggregatedCallSite) process);
if (!label.startsWith("0x")) { //$NON-NLS-1$
break;
}
}
}
AggregatedCalledFunction p = new ResolvedFunction(label, (AggregatedCalledFunction)process);
originalTree.add(p);
}

WeightedTreeSet<ICallStackSymbol, Object> callGraphB = mergeCallGraph(fStartB, fEndB, getTraceListB());
List<String> tlb = getTraceListB();
WeightedTreeSet<ICallStackSymbol, Object> callGraphB = mergeCallGraph(fStartB, fEndB, tlb);
processes = callGraphB.getTreesForNamed(MERGE);
for (Object process : processes) {
diffTree.add((AggregatedCalledFunction) process);
String label = ""; //$NON-NLS-1$
for(String trace : tlb) {
ICallGraphProvider2 reg = fTraceCallGraphRegistry.get(trace);
if (reg != null) {
label = reg.toDisplayString((AggregatedCallSite) process);
if (!label.startsWith("0x")) { //$NON-NLS-1$
break;
}
}
}
AggregatedCalledFunction p = new ResolvedFunction(label, (AggregatedCalledFunction)process);
diffTree.add(p);
}

Collection<DifferentialWeightedTree<ICallStackSymbol>> trees;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*******************************************************************************
* Copyright (c) 2024 Ericsson
*
* 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.internal.executioncomparison.core;

import java.util.Collection;
import java.util.Objects;

import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.profiling.core.base.ICallStackSymbol;
import org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph2.AggregatedCalledFunction;
import org.eclipse.tracecompass.tmf.core.symbols.ISymbolProvider;

/**
* A pre-resolved function. Basically has an overridden equals on the name
*/
@SuppressWarnings("restriction")
public final class ResolvedFunction extends AggregatedCalledFunction {
private static class CSS implements ICallStackSymbol {
private String fLabel;

public CSS(String label) {
fLabel = label;
}

@Override
public String resolve(Collection<ISymbolProvider> providers) {
return fLabel;
}

@Override
public int hashCode() {
return Objects.hash(fLabel);
}

@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
CSS other = (CSS) obj;
return Objects.equals(fLabel, other.fLabel);
}

}

private final String fLabel;

ResolvedFunction(String label, AggregatedCalledFunction toCopy) {
super(toCopy);
fLabel = label;
}

@Override
public ICallStackSymbol getObject() {
return new CSS(fLabel);
}
}

0 comments on commit 6b6c6de

Please sign in to comment.