diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index 41cbcbc3dc0..be7308cea99 100644 --- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF @@ -40,7 +40,7 @@ Export-Package: org.eclipse.cdt.core, org.eclipse.cdt.core.templateengine, org.eclipse.cdt.core.templateengine.process, org.eclipse.cdt.core.templateengine.process.processes, - org.eclipse.cdt.internal.core;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.debug.core,org.eclipse.cdt.dsf", + org.eclipse.cdt.internal.core;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.debug.core", org.eclipse.cdt.internal.core.browser;x-friends:="org.eclipse.cdt.ui", org.eclipse.cdt.internal.core.cdtvariables;x-internal:=true, org.eclipse.cdt.internal.core.dom;x-friends:="org.eclipse.cdt.ui", 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 new file mode 100644 index 00000000000..5b65c993514 --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/internal/LoggingUtils.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2009 Freescale Semiconductor, Inc. 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.internal; + +/** + * Some general purpose functions that can be useful for logging/tracing + * activities. This is a duplicate of LoggingUtils in + * org.eclipse.cdt.internal.core. The idea is for core parts of DSF (ones that + * don't have debug in package name) to have very limited dependencies on other + * plugins. + * + * @since 5.2 + */ +public class LoggingUtils { + /** + * Return a string that uniquely identifies a Java object reference, in the form "classname@id", where + * 'classname' is the simple (unqualified) name of the object's class, and 'id' is the hash code. If the + * object is of an anonymous class, classname will be "". + * + * Why not just use obj.toString()? That method is often overriden, and so cannot be relied on for a + * representation that uniquely identifies the object in the VM space. + * + * @param obj + * the object reference to stringify + * @return the stringified representation of the object reference + */ + public static String toString(Object obj) { + if (obj == null) { + return "null"; //$NON-NLS-1$ + } + String className = obj.getClass().getSimpleName(); + if (className == null) { + className = ""; //$NON-NLS-1$ + } + + String id = Integer.toHexString(System.identityHashCode(obj)); + + return className + "@" + id; //$NON-NLS-1$ + } + + +} diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/service/DsfSession.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/service/DsfSession.java index e5368198c26..919ffb59243 100644 --- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/service/DsfSession.java +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/service/DsfSession.java @@ -30,7 +30,7 @@ import org.eclipse.cdt.dsf.concurrent.DsfExecutor; import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.ThreadSafe; import org.eclipse.cdt.dsf.internal.DsfPlugin; -import org.eclipse.cdt.internal.core.LoggingUtils; +import org.eclipse.cdt.dsf.internal.LoggingUtils; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; @@ -63,7 +63,7 @@ public class DsfSession * * @since 2.1 */ - protected static final boolean DEBUG_SESSION; + private static final boolean DEBUG_SESSION; /** * Has the "debug/session/listeners" tracing option been turned on? Requires @@ -71,7 +71,7 @@ public class DsfSession * * @since 2.1 */ - protected static final boolean DEBUG_SESSION_LISTENERS; + private static final boolean DEBUG_SESSION_LISTENERS; /** * Has the "debug/session/dispatches" tracing option been turned on? Requires @@ -79,7 +79,7 @@ public class DsfSession * * @since 2.1 */ - protected static final boolean DEBUG_SESSION_DISPATCHES; + private static final boolean DEBUG_SESSION_DISPATCHES; static { DEBUG_SESSION = DsfPlugin.DEBUG && "true".equals( //$NON-NLS-1$ @@ -286,7 +286,8 @@ public class DsfSession assert !fListeners.containsKey(entry); if (DEBUG_SESSION_LISTENERS) { String msg = new Formatter().format( - "%s added as a service listener to %s (id=%s)", //$NON-NLS-1$ + "%s %s added as a service listener to %s (id=%s)", //$NON-NLS-1$ + DsfPlugin.getDebugTime(), LoggingUtils.toString(listener), LoggingUtils.toString(this), getId() @@ -305,7 +306,8 @@ public class DsfSession assert fListeners.containsKey(entry); if (DEBUG_SESSION_LISTENERS) { String msg = new Formatter().format( - "%s removed as a service listener to %s (id=%s)", //$NON-NLS-1$ + "%s %s removed as a service listener to %s (id=%s)", //$NON-NLS-1$ + DsfPlugin.getDebugTime(), LoggingUtils.toString(listener), LoggingUtils.toString(this), getId() @@ -429,7 +431,7 @@ public class DsfSession for (Method method : entry.getValue()) { try { if (DEBUG_SESSION_DISPATCHES) { - DsfPlugin.debug("Listener " + LoggingUtils.toString(entry.getKey().fListener) + " invoked with event " + LoggingUtils.toString(event)); //$NON-NLS-1$ //$NON-NLS-2$ + DsfPlugin.debug(DsfPlugin.getDebugTime() + " Listener " + LoggingUtils.toString(entry.getKey().fListener) + " invoked with event " + LoggingUtils.toString(event)); //$NON-NLS-1$ //$NON-NLS-2$ } method.invoke(entry.getKey().fListener, new Object[] { event } ); }