diff --git a/dsf/org.eclipse.cdt.dsf.ui/.options b/dsf/org.eclipse.cdt.dsf.ui/.options index cda9510d97c..6c5f5781b8c 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/.options +++ b/dsf/org.eclipse.cdt.dsf.ui/.options @@ -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 = diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/viewmodel/VMViewerUpdateTracing.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/viewmodel/VMViewerUpdateTracing.java new file mode 100644 index 00000000000..66bf66858b8 --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/viewmodel/VMViewerUpdateTracing.java @@ -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; + } + } +} + diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/VMExpressionUpdate.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/VMExpressionUpdate.java index 9764fd135eb..0c617253829 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/VMExpressionUpdate.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/VMExpressionUpdate.java @@ -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) : "")); //$NON-NLS-1$ + } + super.done(); } } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/VMChildrenCountUpdate.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/VMChildrenCountUpdate.java index 9286770aef5..55f7d0c67b4 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/VMChildrenCountUpdate.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/VMChildrenCountUpdate.java @@ -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 : "") ); //$NON-NLS-1$ //$NON-NLS-2$ + } + super.done(); } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/VMChildrenUpdate.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/VMChildrenUpdate.java index eb4c04334f4..73b2b01e115 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/VMChildrenUpdate.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/VMChildrenUpdate.java @@ -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(); } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/VMHasChildrenUpdate.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/VMHasChildrenUpdate.java index 84e1e22b09d..f3ba2c8b528 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/VMHasChildrenUpdate.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/VMHasChildrenUpdate.java @@ -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() : "")); //$NON-NLS-1$ + } + super.done(); } } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/properties/VMPropertiesUpdate.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/properties/VMPropertiesUpdate.java index ce9e031031d..a645c34d6fc 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/properties/VMPropertiesUpdate.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/properties/VMPropertiesUpdate.java @@ -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> rm = (DataRequestMonitor>)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 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(); } diff --git a/dsf/org.eclipse.cdt.dsf/META-INF/MANIFEST.MF b/dsf/org.eclipse.cdt.dsf/META-INF/MANIFEST.MF index 86d1d312f04..e7777aabc36 100644 --- a/dsf/org.eclipse.cdt.dsf/META-INF/MANIFEST.MF +++ b/dsf/org.eclipse.cdt.dsf/META-INF/MANIFEST.MF @@ -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 diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/internal/LoggingUtils.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/internal/LoggingUtils.java index 5a162200b7f..94a033fb02c 100644 --- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/internal/LoggingUtils.java +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/internal/LoggingUtils.java @@ -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(); + } + }