Skip to content

Commit

Permalink
567256: Improve help and minor updates
Browse files Browse the repository at this point in the history
Help updates

Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=567256

Change-Id: Ibbe8bfde44b6b741f18b376934df74d850391233
  • Loading branch information
ajohnson1 committed Sep 22, 2020
1 parent bdedfe8 commit 62b847a
Show file tree
Hide file tree
Showing 37 changed files with 3,194 additions and 1,575 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2018 SAP AG and IBM Corporation.
* Copyright (c) 2008, 2020 SAP AG and IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -30,13 +30,15 @@
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.Argument.Advice;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.annotations.HelpUrl;
import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.snapshot.ISnapshot;
import org.eclipse.mat.snapshot.model.IObject;
import org.eclipse.mat.util.IProgressListener;

@CommandName("big_drops_in_dominator_tree")
@Icon("/META-INF/icons/big_drops.gif")
@HelpUrl("/org.eclipse.mat.ui.help/reference/findingmemoryleak.html#ref_findingmemoryleak__big_drops")
public class BigDropsQuery implements IQuery, IResultTree
{
private final static int ROOT_ID = -1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2010 SAP AG.
* Copyright (c) 2008, 2020 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -32,6 +32,7 @@
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.Category;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.annotations.HelpUrl;
import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.query.annotations.Menu;
import org.eclipse.mat.query.annotations.Menu.Entry;
Expand All @@ -48,6 +49,7 @@
@Menu( { @Entry(icon = "/META-INF/icons/class_refs_outbound.gif"), //
@Entry(options = "-inbound", icon = "/META-INF/icons/class_refs_inbound.gif") //
})
@HelpUrl("/org.eclipse.mat.ui.help/reference/querymatrix.html#ref_querymatrix__show_objects_by_class")
public class ClassReferrersQuery implements IQuery
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2010 SAP AG and IBM Corporation.
* Copyright (c) 2008, 2020 SAP AG and IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -18,6 +18,7 @@
import org.eclipse.mat.query.IResult;
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.annotations.HelpUrl;
import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.snapshot.Histogram;
import org.eclipse.mat.snapshot.ISnapshot;
Expand All @@ -28,6 +29,7 @@

@CommandName("histogram")
@Icon("/META-INF/icons/show_histogram.gif")
@HelpUrl("/org.eclipse.mat.ui.help/reference/querymatrix.html#ref_querymatrix__histogram")
public class HistogramQuery implements IQuery
{
public enum Grouping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
@CommandName("leakhunter2")
@Icon("/META-INF/icons/leak.gif")
@HelpUrl("/org.eclipse.mat.ui.help/tasks/runningleaksuspectreport.html")
@HelpUrl("/org.eclipse.mat.ui.help/tasks/runningleaksuspectreport.html#task_runningleaksuspectreport__compare")
public class LeakHunterQuery2 extends LeakHunterQuery
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2010 SAP AG.
* Copyright (c) 2008, 2020 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -15,6 +15,7 @@
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.Category;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.annotations.HelpUrl;
import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.query.annotations.Menu;
import org.eclipse.mat.query.annotations.Menu.Entry;
Expand All @@ -29,6 +30,7 @@
@Menu( { @Entry(icon = "/META-INF/icons/list_outbound.gif"), //
@Entry(options = "-inbound", icon = "/META-INF/icons/list_inbound.gif") //
})
@HelpUrl("/org.eclipse.mat.ui.help/reference/querymatrix.html#ref_querymatrix__list_objects")
public class ObjectListQuery implements IQuery
{
@Argument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -859,9 +859,15 @@ private void addReferenceStatistic(SectionSpec componentReport, Histogram histog
{
IInstance obj = (IInstance) snapshot.getObject(objectId);

ObjectReference ref = ReferenceQuery.getReferent(obj);
if (ref != null)
referentSet.add(ref.getObjectId());
try
{
ObjectReference ref = ReferenceQuery.getReferent(obj);
if (ref != null)
referentSet.add(ref.getObjectId());
}
catch (SnapshotException e)
{
}
if (ticks.isCanceled())
break;
}
Expand Down Expand Up @@ -946,6 +952,7 @@ private void addReferenceStatistic(SectionSpec componentReport, Histogram histog
* but through others.
*/
int maxpaths = 10;
double factor = 0.6;

/*
* Examine per class of the referred-to objects - as they might have different uses.
Expand Down Expand Up @@ -978,7 +985,7 @@ private void addReferenceStatistic(SectionSpec componentReport, Histogram histog
.setArgument("objects", ai.toArray()) //$NON-NLS-1$
.setArgument("maxpaths", maxpaths) //$NON-NLS-1$
.setArgument("maxobjs", maxsuspectspertype) //$NON-NLS-1$
.setArgument("factor", 0.6) //$NON-NLS-1$
.setArgument("factor", factor) //$NON-NLS-1$
.execute(ticks);
if (result instanceof CompositeResult)
{
Expand All @@ -989,6 +996,24 @@ private void addReferenceStatistic(SectionSpec componentReport, Histogram histog
commentSpec.set(Params.Html.IS_IMPORTANT, Boolean.TRUE.toString());
QuerySpec child1 = new QuerySpec(MessageUtil.format(Messages.ComponentReportQuery_ExampleLeakDetails, cr.getLabel()), cr1);
child1.set(Params.Html.COLLAPSED, Boolean.TRUE.toString());
// Set the command for further analysis later
if (ai.size() <= 30)
{
try
{
StringBuilder sb = new StringBuilder("reference_leak"); //$NON-NLS-1$
sb.append(" -maxpaths ").append(maxpaths); //$NON-NLS-1$
sb.append(" -maxobjs ").append(maxsuspectspertype); //$NON-NLS-1$
sb.append(" -factor ").append(factor); //$NON-NLS-1$
for (int i : ai.toArray())
{
sb.append(" 0x").append(Long.toHexString(snapshot.mapIdToAddress(i))); //$NON-NLS-1$
}
child1.setCommand(sb.toString());
}
catch (SnapshotException e)
{} // Ignore if problem
}
overview.add(child1);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ private String oqlLoader(String name, long loaderAddress)
//"select * from objects (select objects a from objects (dominators(-1)) a) b"+ //$NON-NLS-1$
"select objects b as \"" + name + "\" from objects (select objects a from objects (dominators(-1)) a) b"+ //$NON-NLS-1$ //$NON-NLS-2$
" where"+ //$NON-NLS-1$
" b.@objectAddress = " + loaderAddress + "L or"+ //$NON-NLS-1$ //$NON-NLS-2$
" b implements org.eclipse.mat.snapshot.model.IClassLoader and b.@objectAddress = " + loaderAddress + "L or"+ //$NON-NLS-1$ //$NON-NLS-2$
" b implements org.eclipse.mat.snapshot.model.IClass and b.@classLoaderAddress = " + loaderAddress + "L or"+ //$NON-NLS-1$ //$NON-NLS-2$
" (b implements org.eclipse.mat.snapshot.model.IClassLoader) = false and (b implements org.eclipse.mat.snapshot.model.IClass) = false and b.@clazz.@classLoaderAddress = " + loaderAddress + "L"; //$NON-NLS-1$ //$NON-NLS-2$
" b implements org.eclipse.mat.snapshot.model.IClassLoader = false and b implements org.eclipse.mat.snapshot.model.IClass = false and b.@clazz.@classLoaderAddress = " + loaderAddress + "L"; //$NON-NLS-1$ //$NON-NLS-2$
//" $ {snapshot}.isClass(b.@objectId) and b.@classLoaderAddress = " + loaderAddress + "L or"+ //$NON-NLS-1$ //$NON-NLS-2$
//" $ {snapshot}.isClassLoader(b.@objectId) = false and $ {snapshot}.isClass(b.@objectId) = false and b.@clazz.@classLoaderAddress = " + loaderAddress + "L"; //$NON-NLS-1$ //$NON-NLS-2$
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.eclipse.mat.query.ResultMetaData;
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.annotations.HelpUrl;
import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.query.annotations.Menu;
import org.eclipse.mat.query.annotations.Menu.Entry;
Expand All @@ -62,6 +63,7 @@
@Entry(options = "-excludes java.lang.ref.PhantomReference:referent java.lang.ref.WeakReference:referent java.lang.ref.Finalizer:referent java.lang.Runtime:<Unfinalized>"), //
@Entry(options = "-excludes java.lang.ref.Reference:referent java.lang.Runtime:<Unfinalized>") //
})
@HelpUrl("/org.eclipse.mat.ui.help/reference/inspections/merge_shortest_paths.html")
public class MultiplePath2GCRootsQuery implements IQuery
{
public enum Grouping
Expand Down Expand Up @@ -520,15 +522,20 @@ public String suffix(Object row)
public URL getIcon(Object row)
{
Node n = (Node) row;
return n.paths.size() == 1 && n.paths.get(0)[0] == n.objectId
? Icons.forObject(snapshot, n.objectId) : Icons.outbound(snapshot, n.objectId);
return hasChildren(row)
? Icons.outbound(snapshot, n.objectId) : Icons.forObject(snapshot, n.objectId);
}

@Override
public boolean hasChildren(Object row)
{
Node n = (Node) row;
return !(n.paths.size() == 1 && n.paths.get(0)[0] == n.objectId);
for (int p[] : n.paths)
{
if (p[0] != n.objectId)
return true;
}
return false;
}

@Override
Expand Down Expand Up @@ -730,7 +737,7 @@ public URL getIcon(Object row)
Node n = (Node) row;
if (mergeFromRoots)
{
if (n.paths.size() == 1 && n.level == n.paths.get(0).length - 1)
if (!hasChildren(row))
return Icons.CLASS;
return Icons.CLASS_OUT;
}
Expand All @@ -742,7 +749,12 @@ public URL getIcon(Object row)
public boolean hasChildren(Object row)
{
Node n = (Node) row;
return !(n.paths.size() == 1 && n.level == n.paths.get(0).length - 1);
for (int p[] : n.paths)
{
if (n.level != p.length - 1)
return true;
}
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,10 @@ else if (this.query.getSelectClause().getSelectList().isEmpty() || this.query.ge

private Object doSubQuery(IProgressListener monitor) throws SnapshotException
{
int percentages[] = new int[] {300,100};
// If there is a WHERE clause then allocate more ticks for processing that
int percentages[] = query.getWhereClause() == null ?
new int[] {300,100}
: new int[] {200,200};
SimpleMonitor listener = new SimpleMonitor(query.toString(), monitor, percentages);
OQLQueryImpl subQuery = new OQLQueryImpl(this.ctx, query.getFromClause().getSubSelect());
Object result = subQuery.internalExecute(listener.nextMonitor());
Expand All @@ -1616,13 +1619,20 @@ else if (result instanceof AbstractCustomTableResultSet)
else if (result instanceof Iterable)
{
List<Object> r = new ArrayList<Object>();

if (result instanceof Collection)
{
int count = ((Collection<?>)result).size();
String task = query.getWhereClause() != null ? "WHERE " + query.getWhereClause() : Messages.OQLQueryImpl_Selecting; //$NON-NLS-1$
monitor.beginTask(task, count);
}
for (Object obj : (Iterable<?>) result)
{
if (accept(obj, monitor))
r.add(obj);
if (monitor.isCanceled())
throw new IProgressListener.OperationCanceledException();
if (result instanceof Collection)
monitor.worked(1);
}

return r.isEmpty() ? null : select(r, monitor);
Expand All @@ -1632,13 +1642,16 @@ else if (result.getClass().isArray())
List<Object> r = new ArrayList<Object>();

int length = Array.getLength(result);
String task = query.getWhereClause() != null ? "WHERE " + query.getWhereClause() : Messages.OQLQueryImpl_Selecting; //$NON-NLS-1$
monitor.beginTask(task, length);
for (int ii = 0; ii < length; ii++)
{
Object obj = Array.get(result, ii);
if (accept(obj, monitor))
r.add(obj);
if (monitor.isCanceled())
throw new IProgressListener.OperationCanceledException();
monitor.worked(1);
}
return r.isEmpty() ? null : select(r, monitor);
}
Expand Down Expand Up @@ -1835,7 +1848,9 @@ private Object doMethodCall(IProgressListener listener) throws SnapshotException
this.ctx.setSubject(this.ctx.getSnapshot());
IProgressListener old = ctx.getProgressListener();
this.ctx.setProgressListener(smlistener.nextMonitor());
this.ctx.getProgressListener().subTask("FROM "+query.getFromClause().toString()); //$NON-NLS-1$
Object result = method.compute(this.ctx);
this.ctx.getProgressListener().done();
this.ctx.setProgressListener(old);
listener = smlistener.nextMonitor();

Expand All @@ -1848,13 +1863,20 @@ private Object doMethodCall(IProgressListener listener) throws SnapshotException
else if (result instanceof Iterable)
{
List<Object> r = new ArrayList<Object>();

if (result instanceof Collection)
{
int length = ((Collection<?>)result).size();
String task = query.getWhereClause() != null ? "WHERE " + query.getWhereClause() : Messages.OQLQueryImpl_Selecting; //$NON-NLS-1$
listener.beginTask(task, length);
}
for (Object obj : (Iterable<?>) result)
{
if (accept(obj, listener))
r.add(obj);
if (listener.isCanceled())
throw new IProgressListener.OperationCanceledException();
if (result instanceof Collection)
listener.worked(1);
}

return r.isEmpty() ? null : select(r, listener);
Expand All @@ -1864,13 +1886,16 @@ else if (result.getClass().isArray())
List<Object> r = new ArrayList<Object>();

int length = Array.getLength(result);
String task = query.getWhereClause() != null ? "WHERE " + query.getWhereClause() : Messages.OQLQueryImpl_Selecting; //$NON-NLS-1$
listener.beginTask(task, length);
for (int ii = 0; ii < length; ii++)
{
Object obj = Array.get(result, ii);
if (accept(obj, listener))
r.add(obj);
if (listener.isCanceled())
throw new IProgressListener.OperationCanceledException();
listener.worked(1);
}

return r.isEmpty() ? null : select(r, listener);
Expand Down Expand Up @@ -2118,6 +2143,9 @@ private boolean accept(Object object, IProgressListener mon) throws SnapshotExce

private Object filterAndSelect(IntResult objectIds, IProgressListener listener) throws SnapshotException
{
String task = query.getWhereClause() != null ? "WHERE " + query.getWhereClause() : Messages.OQLQueryImpl_Selecting; //$NON-NLS-1$
listener.beginTask(task, objectIds.size());

IntResult filteredSet = createIntResult(objectIds.size());

for (IntIterator iter = objectIds.iterator(); iter.hasNext();)
Expand All @@ -2128,6 +2156,7 @@ private Object filterAndSelect(IntResult objectIds, IProgressListener listener)
int id = iter.nextInt();
if (accept(id, listener))
filteredSet.add(id);
listener.worked(1);
}

return filteredSet.isEmpty() ? null : select(filteredSet, listener);
Expand Down Expand Up @@ -2223,7 +2252,8 @@ private Object filterAndSelect(IStructuredResult result, IProgressListener liste
IStructuredResult irt = (IStructuredResult)result;
List<?>elements = irt instanceof IResultTree ? ((IResultTree)irt).getElements() : null;
int count = irt instanceof IResultTable ? ((IResultTable)irt).getRowCount() : elements.size();
listener.beginTask(Messages.OQLQueryImpl_Selecting, count);
String task = query.getWhereClause() != null ? "WHERE " + query.getWhereClause() : Messages.OQLQueryImpl_Selecting; //$NON-NLS-1$
listener.beginTask(task, count);
for (int ii = 0; ii < count; ii++)
{
if (listener.isCanceled())
Expand All @@ -2244,7 +2274,8 @@ private Object filterAndSelect(IStructuredResult result, IProgressListener liste
private Object filterAndSelect(AbstractCustomTableResultSet result, IProgressListener listener) throws SnapshotException
{
List<Object> r = new ArrayList<Object>();
listener.beginTask(Messages.OQLQueryImpl_Selecting, result.getRowCount() * 2);
String task = query.getWhereClause() != null ? "WHERE " + query.getWhereClause() : Messages.OQLQueryImpl_Selecting; //$NON-NLS-1$
listener.beginTask(task, result.getRowCount() * 2);
IProgressListener old = this.ctx.getProgressListener();
this.ctx.setProgressListener(new SilentProgressListener(listener));
for (AbstractCustomTableResultSet.RowMap rowobj : result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
</substep>
</substeps>
</step>
<step>
<step id="overview">
<cmd>
<b>Examine the Overview</b>
</cmd>
Expand Down Expand Up @@ -198,7 +198,7 @@
</p>
</stepresult>
</step>
<step>
<step id="histogram">
<cmd>
<b>Get the Histogram</b>
</cmd>
Expand Down
Loading

0 comments on commit 62b847a

Please sign in to comment.