Skip to content

Commit

Permalink
7332: Show stacktraces for constant values from stacktrace pool
Browse files Browse the repository at this point in the history
Reviewed-by: hirt
  • Loading branch information
Jean-Philippe Bempel committed Sep 7, 2021
1 parent 0e794a9 commit ff29931
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private class ConstantPoolsPageUi implements IPageUI {
private static final String SASH_ELEMENT = "sash"; //$NON-NLS-1$

private final IItemCollection constPoolItems;
private final IPageContainer container;
private final SashForm sash;
private final ItemHistogram byTypeTable;
private final ItemHistogram constantValueTable;
Expand All @@ -124,6 +125,7 @@ private class ConstantPoolsPageUi implements IPageUI {
private ItemHistogramWithInput constantHistogram;

ConstantPoolsPageUi(Composite parent, FormToolkit toolkit, IPageContainer pageContainer, IState state) {
container = pageContainer;
constPoolItems = getDataSource().getConstantPools();
selectionConstPoolItems = constPoolItems;
selectionConstantItems = getDataSource().getConstants();
Expand Down Expand Up @@ -153,6 +155,7 @@ private class ConstantPoolsPageUi implements IPageUI {
byTypeHistogram = new ItemHistogramWithInput(byTypeTable);
constantHistogram = new ItemHistogramWithInput(constantValueTable);
byTypeHistogram.addListener(this::typeHistogramListener);
constantHistogram.addListener(container::showSelection);

PersistableSashForm.loadState(sash, state.getChild(SASH_ELEMENT));
byTypeFilter.loadState(state.getChild(TYPE_FILTER));
Expand All @@ -164,6 +167,7 @@ private void typeHistogramListener(IItemCollection constantPoolType) {
IItemCollection filteredItems = getDataSource().getConstants()
.apply(ItemFilters.equals(JdkAttributes.CONSTANT_TYPE, poolName));
constantHistogram.setInput(filteredItems);
container.showSelection(filteredItems);
}

private void onTypeFilterChange(IItemFilter filter) {
Expand Down Expand Up @@ -192,5 +196,4 @@ public ConstantPoolsPage(IPageDefinition dpd, StreamModel items, IPageContainer
public IPageUI display(Composite parent, FormToolkit toolkit, IPageContainer pageContainer, IState state) {
return new ConstantPoolsPageUi(parent, toolkit, pageContainer, state);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
package org.openjdk.jmc.flightrecorder.internal.parser;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
Expand All @@ -45,6 +46,8 @@
import java.util.function.Consumer;

import org.openjdk.jmc.common.IDescribable;
import org.openjdk.jmc.common.IMCFrame;
import org.openjdk.jmc.common.IMCStackTrace;
import org.openjdk.jmc.common.collection.FastAccessNumberMap;
import org.openjdk.jmc.common.item.IAccessorKey;
import org.openjdk.jmc.common.item.IAttribute;
Expand All @@ -55,9 +58,13 @@
import org.openjdk.jmc.common.item.IType;
import org.openjdk.jmc.common.item.ItemCollectionToolkit;
import org.openjdk.jmc.common.unit.IQuantity;
import org.openjdk.jmc.common.unit.StructContentType;
import org.openjdk.jmc.common.unit.UnitLookup;
import org.openjdk.jmc.common.util.MemberAccessorToolkit;
import org.openjdk.jmc.flightrecorder.IParserStats.IEventStats;
import org.openjdk.jmc.flightrecorder.stacktrace.FrameSeparator;
import org.openjdk.jmc.flightrecorder.stacktrace.FrameSeparator.FrameCategorization;
import org.openjdk.jmc.flightrecorder.stacktrace.StacktraceFormatToolkit;

public class ParserStats {
private short majorVersion;
Expand Down Expand Up @@ -197,7 +204,7 @@ public String getDescription() {

@Override
public List<IAttribute<?>> getAttributes() {
return null;
return Collections.emptyList();
}

@Override
Expand Down Expand Up @@ -253,7 +260,7 @@ public String getDescription() {

@Override
public List<IAttribute<?>> getAttributes() {
return null;
return Collections.emptyList();
}

@Override
Expand All @@ -273,8 +280,20 @@ public <M> IMemberAccessor<M, IItem> getAccessor(IAccessorKey<M> attribute) {
return ((IMemberAccessor<M, IItem>) MemberAccessorToolkit.<IItem, Object, Object> constant(typeName));
}
if ("constant".equals(attribute.getIdentifier())) {
if (constant instanceof IMCStackTrace) {
IMCFrame imcFrame = ((IMCStackTrace) constant).getFrames().get(0);
String str = StacktraceFormatToolkit.formatFrame(imcFrame,
new FrameSeparator(FrameCategorization.METHOD, false));
return ((IMemberAccessor<M, IItem>) MemberAccessorToolkit.<IItem, Object, Object> constant(str));
}
return ((IMemberAccessor<M, IItem>) MemberAccessorToolkit.<IItem, Object, Object> constant(constant));
}
if ("stackTrace".equals(attribute.getIdentifier())) {
if (constant instanceof IMCStackTrace) {
return (IMemberAccessor<M, IItem>) MemberAccessorToolkit
.<IItem, IMCStackTrace, IMCStackTrace> constant((IMCStackTrace) constant);
}
}
return null;
}

Expand Down

0 comments on commit ff29931

Please sign in to comment.