mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
[290462] Add tracing for VMViewerUpdate
This commit is contained in:
parent
74ee292800
commit
ef32999732
9 changed files with 173 additions and 1 deletions
|
@ -8,3 +8,6 @@ org.eclipse.cdt.dsf.ui/debug/vm/atomicUpdate = false
|
|||
|
||||
org.eclipse.cdt.dsf.ui/debug/stepping = false
|
||||
org.eclipse.cdt.dsf.ui/debug/disassembly = false
|
||||
|
||||
org.eclipse.cdt.dsf.ui/debug/vm/updates = false
|
||||
org.eclipse.cdt.dsf.ui/debug/vm/updates/regex =
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Freescale Semiconductors 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Freescale Semiconductor. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.debug.internal.ui.viewmodel;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
/**
|
||||
* Constants and utility functions used to trace VMViewerUpdate results. As
|
||||
* VMViewerUpdate is an external class, we avoid polluting that API by housing
|
||||
* these trace facilities in an internal package.
|
||||
*/
|
||||
public final class VMViewerUpdateTracing {
|
||||
|
||||
/**
|
||||
* The value of the trace option "debug/vmUpdates/regex", which is a regular
|
||||
* expression used to filter VMViewerUpdate traces.
|
||||
*/
|
||||
public final static String DEBUG_VMUPDATE_REGEX = Platform.getDebugOption("org.eclipse.cdt.dsf.ui/debug/vm/updates/regex"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Has the "debug/vmUpdates/properties" tracing option been turned on? Requires
|
||||
* "debug/vmUpdates" to also be turned on.
|
||||
*/
|
||||
public static final boolean DEBUG_VMUPDATES = DsfUIPlugin.DEBUG && "true".equals(Platform.getDebugOption("org.eclipse.cdt.dsf.ui/debug/vm/updates")); //$NON-NLS-1$//$NON-NLS-2$
|
||||
|
||||
/**
|
||||
* Looks at the optional filter (regular expression) set in the tracing
|
||||
* options for VMViewerUpdates and determines if this class passes the
|
||||
* filter (should be traced). If a filter is not set, then we trace all
|
||||
* classes. Note that for optimization reasons, we expect the caller to
|
||||
* first check that DEBUG_VMUPDATES is true before invoking us; we do not
|
||||
* check it here (other than to assert it).
|
||||
*
|
||||
* @return true if this class's activity should be traced
|
||||
*/
|
||||
public static boolean matchesFilterRegex(Class<?> clazz) {
|
||||
assert DEBUG_VMUPDATES;
|
||||
if (DEBUG_VMUPDATE_REGEX == null || DEBUG_VMUPDATE_REGEX.length() == 0) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
Pattern regex = Pattern.compile(DEBUG_VMUPDATE_REGEX);
|
||||
Matcher matcher = regex.matcher(clazz.toString());
|
||||
return matcher.find();
|
||||
}
|
||||
catch (PatternSyntaxException exc) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,9 @@ package org.eclipse.cdt.dsf.debug.ui.viewmodel.expression;
|
|||
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.VMViewerUpdateTracing;
|
||||
import org.eclipse.cdt.dsf.internal.DsfPlugin;
|
||||
import org.eclipse.cdt.dsf.internal.LoggingUtils;
|
||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.VMViewerUpdate;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
@ -73,6 +76,15 @@ class VMExpressionUpdate extends VMViewerUpdate implements IExpressionUpdate {
|
|||
} else if (rm.isSuccess()) {
|
||||
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.REQUEST_FAILED, "Incomplete elements of updates", null)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// trace our result
|
||||
if (VMViewerUpdateTracing.DEBUG_VMUPDATES && !isCanceled() && VMViewerUpdateTracing.matchesFilterRegex(this.getClass())) {
|
||||
DsfUIPlugin.debug(DsfPlugin.getDebugTime()
|
||||
+ " " + LoggingUtils.toString(this) + " marked done; element = " + LoggingUtils.toString(getElement()) + //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"\n expression = " //$NON-NLS-1$
|
||||
+ (fExpressionElement != null ? LoggingUtils.toString(fExpressionElement) : "<unset>")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
super.done();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,16 @@
|
|||
package org.eclipse.cdt.dsf.ui.viewmodel;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
|
||||
import org.eclipse.cdt.dsf.internal.DsfPlugin;
|
||||
import org.eclipse.cdt.dsf.internal.LoggingUtils;
|
||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
|
||||
import org.eclipse.jface.viewers.TreePath;
|
||||
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.VMViewerUpdateTracing;
|
||||
/**
|
||||
* Helper class implementation of the {@link IChildrenCountUpdate} update object.
|
||||
*
|
||||
|
@ -54,6 +58,16 @@ public class VMChildrenCountUpdate extends VMViewerUpdate implements IChildrenCo
|
|||
@Override
|
||||
public void done() {
|
||||
assert isCanceled() || fCountRequestMonitor.getData() != null || !fCountRequestMonitor.isSuccess();
|
||||
|
||||
// trace our result
|
||||
if (VMViewerUpdateTracing.DEBUG_VMUPDATES && !isCanceled() && VMViewerUpdateTracing.matchesFilterRegex(this.getClass())) {
|
||||
final Integer data = fCountRequestMonitor.getData();
|
||||
DsfUIPlugin.debug(DsfPlugin.getDebugTime() + " " //$NON-NLS-1$
|
||||
+ LoggingUtils.toString(this) + " marked done; element = " //$NON-NLS-1$
|
||||
+ LoggingUtils.toString(getElement())
|
||||
+ "\n child count = " + (data != null ? data : "<unset>") ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
super.done();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,10 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.VMViewerUpdateTracing;
|
||||
import org.eclipse.cdt.dsf.internal.DsfPlugin;
|
||||
import org.eclipse.cdt.dsf.internal.LoggingUtils;
|
||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
|
@ -117,6 +121,20 @@ public class VMChildrenUpdate extends VMViewerUpdate implements IChildrenUpdate
|
|||
* do not check if any of the elements are null.
|
||||
*/
|
||||
rm.setData(fElements);
|
||||
|
||||
// trace our result
|
||||
if (VMViewerUpdateTracing.DEBUG_VMUPDATES && !isCanceled() && VMViewerUpdateTracing.matchesFilterRegex(this.getClass())) {
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append(DsfPlugin.getDebugTime() + " " + LoggingUtils.toString(this) + " marked done; element = " + LoggingUtils.toString(getElement())); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (fElements != null && fElements.size() > 0) {
|
||||
for (Object element : fElements) {
|
||||
str.append(" " + LoggingUtils.toString(element) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
str.deleteCharAt(str.length()-1); // remove trailing \n
|
||||
}
|
||||
DsfUIPlugin.debug(str.toString());
|
||||
}
|
||||
|
||||
super.done();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
package org.eclipse.cdt.dsf.ui.viewmodel;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.VMViewerUpdateTracing;
|
||||
import org.eclipse.cdt.dsf.internal.DsfPlugin;
|
||||
import org.eclipse.cdt.dsf.internal.LoggingUtils;
|
||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
|
@ -55,6 +59,17 @@ public class VMHasChildrenUpdate extends VMViewerUpdate implements IHasChildrenU
|
|||
@Override
|
||||
public void done() {
|
||||
assert isCanceled() || fHasElemsRequestMonitor.getData() != null || !fHasElemsRequestMonitor.isSuccess();
|
||||
|
||||
// trace our result
|
||||
if (VMViewerUpdateTracing.DEBUG_VMUPDATES && !isCanceled() && VMViewerUpdateTracing.matchesFilterRegex(this.getClass())) {
|
||||
final Boolean data = fHasElemsRequestMonitor.getData();
|
||||
DsfUIPlugin.debug(DsfPlugin.getDebugTime() + " " //$NON-NLS-1$
|
||||
+ LoggingUtils.toString(this) + " marked done; element = " //$NON-NLS-1$
|
||||
+ LoggingUtils.toString(getElement())
|
||||
+ "\n has children = " //$NON-NLS-1$
|
||||
+ (data != null ? data.toString() : "<unset>")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
super.done();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,15 @@ package org.eclipse.cdt.dsf.ui.viewmodel.properties;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.VMViewerUpdateTracing;
|
||||
import org.eclipse.cdt.dsf.internal.DsfPlugin;
|
||||
import org.eclipse.cdt.dsf.internal.LoggingUtils;
|
||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.VMViewerUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
|
||||
|
@ -89,6 +94,26 @@ public class VMPropertiesUpdate extends VMViewerUpdate implements IPropertiesUpd
|
|||
@SuppressWarnings("unchecked")
|
||||
DataRequestMonitor<Map<String,Object>> rm = (DataRequestMonitor<Map<String,Object>>)getRequestMonitor();
|
||||
rm.setData(fValues);
|
||||
|
||||
// trace our result
|
||||
if (VMViewerUpdateTracing.DEBUG_VMUPDATES && !isCanceled() && VMViewerUpdateTracing.matchesFilterRegex(this.getClass())) {
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append(DsfPlugin.getDebugTime() + " " + LoggingUtils.toString(this) + " marked done; element = " + LoggingUtils.toString(getElement())); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (fValues != null) {
|
||||
Iterator<String> keyIter = fValues.keySet().iterator();
|
||||
while (keyIter.hasNext()) {
|
||||
String prop = keyIter.next();
|
||||
Object val = fValues.get(prop);
|
||||
if (val instanceof String[]) {
|
||||
val = LoggingUtils.toString((String[])val);
|
||||
}
|
||||
str.append(" " + prop + "=" + val + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
str.deleteCharAt(str.length()-1); // remove trailing linefeed
|
||||
}
|
||||
DsfUIPlugin.debug(str.toString());
|
||||
}
|
||||
|
||||
super.done();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,5 +18,6 @@ Export-Package: org.eclipse.cdt.dsf.concurrent,
|
|||
org.eclipse.cdt.dsf.debug.service,
|
||||
org.eclipse.cdt.dsf.debug.service.command,
|
||||
org.eclipse.cdt.dsf.debug.sourcelookup,
|
||||
org.eclipse.cdt.dsf.internal;x-friends:="org.eclipse.cdt.dsf.ui",
|
||||
org.eclipse.cdt.dsf.service
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
|
|
|
@ -48,5 +48,25 @@ public class LoggingUtils {
|
|||
return className + "@" + id; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten out an array of strings into one string, in the form
|
||||
* "{s1, s2, s3, ...}"
|
||||
*
|
||||
* @param strings
|
||||
* the array of string
|
||||
* @return the flattened representation
|
||||
*/
|
||||
public static String toString(String[] strings) {
|
||||
StringBuilder str = new StringBuilder("{"); //$NON-NLS-1$
|
||||
for (String s : strings) {
|
||||
str.append(s + ", "); //$NON-NLS-1$
|
||||
}
|
||||
if (strings.length > 0) {
|
||||
str.delete(str.length()-2, Integer.MAX_VALUE); // remove the trailing comma and space
|
||||
}
|
||||
str.append("}"); //$NON-NLS-1$
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue