From eb88fc52b3ea850a942e749b8eb3a764674d8417 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Wed, 26 Feb 2020 21:05:46 +0100 Subject: Bug 563154 - Add tracing to DebugCommandService Change-Id: I9549ebac8e45d70f3141e45a20887ec5a15fbb55 Signed-off-by: Andrey Loskutov --- org.eclipse.debug.ui/.options | 1 + .../ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java | 13 +++++++++---- .../ui/commands/actions/DebugCommandService.java | 17 +++++++++++++++-- .../ui/commands/actions/UpdateActionsRequest.java | 9 +++++++++ 4 files changed, 34 insertions(+), 6 deletions(-) (limited to 'org.eclipse.debug.ui') diff --git a/org.eclipse.debug.ui/.options b/org.eclipse.debug.ui/.options index 1b586a599..24f7c7e4c 100644 --- a/org.eclipse.debug.ui/.options +++ b/org.eclipse.debug.ui/.options @@ -11,3 +11,4 @@ org.eclipse.debug.ui/debug/viewers/stateSaveRestore = false org.eclipse.debug.ui/debug/viewers/presentationId = org.eclipse.debug.ui/debug/breadcrumb = false org.eclipse.debug.ui/debug/memory/dynamicLoading = false +org.eclipse.debug.ui/debug/commandservice = false diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java index 08680061c..4095e260a 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java @@ -142,6 +142,7 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener, public static boolean DEBUG_STATE_SAVE_RESTORE = false; public static String DEBUG_PRESENTATION_ID = null; public static boolean DEBUG_DYNAMIC_LOADING = false; + public static boolean DEBUG_COMMAND_SERVICE = false; static final String DEBUG_FLAG = "org.eclipse.debug.ui/debug"; //$NON-NLS-1$ static final String DEBUG_BREAKPOINT_DELTAS_FLAG = "org.eclipse.debug.ui/debug/viewers/breakpointDeltas"; //$NON-NLS-1$ @@ -155,6 +156,7 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener, static final String DEBUG_STATE_SAVE_RESTORE_FLAG = "org.eclipse.debug.ui/debug/viewers/stateSaveRestore"; //$NON-NLS-1$ static final String DEBUG_PRESENTATION_ID_FLAG ="org.eclipse.debug.ui/debug/viewers/presentationId"; //$NON-NLS-1$ static final String DEBUG_DYNAMIC_LOADING_FLAG = "org.eclipse.debug.ui/debug/memory/dynamicLoading"; //$NON-NLS-1$ + static final String DEBUG_COMMAND_SERVICE_FLAG = "org.eclipse.debug.ui/debug/commandservice"; //$NON-NLS-1$ /** * The {@link DebugTrace} object to print to OSGi tracing * @since 3.8 @@ -260,16 +262,18 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener, } /** - * Prints the given message to System.out and to the OSGi tracing (if started) - * @param option the option or null - * @param message the message to print or null + * Prints the given message to System.out or to the OSGi tracing (if started) + * + * @param option the option or null + * @param message the message to print or null * @param throwable the {@link Throwable} or null * @since 3.8 */ public static void trace(String option, String message, Throwable throwable) { - System.out.println(message); if(fgDebugTrace != null) { fgDebugTrace.trace(option, message, throwable); + } else { + System.out.println(message); } } @@ -595,6 +599,7 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener, DEBUG_DELTAS = DEBUG && options.getBooleanOption(DEBUG_DELTAS_FLAG, false); DEBUG_STATE_SAVE_RESTORE = DEBUG && options.getBooleanOption(DEBUG_STATE_SAVE_RESTORE_FLAG, false); DEBUG_DYNAMIC_LOADING = DEBUG && options.getBooleanOption(DEBUG_DYNAMIC_LOADING_FLAG, false); + DEBUG_COMMAND_SERVICE = DEBUG && options.getBooleanOption(DEBUG_COMMAND_SERVICE_FLAG, false); if(DEBUG) { DEBUG_PRESENTATION_ID = options.getOption(DEBUG_PRESENTATION_ID_FLAG, IInternalDebugCoreConstants.EMPTY_STRING); if(IInternalDebugCoreConstants.EMPTY_STRING.equals(DEBUG_PRESENTATION_ID)) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java index 8bfeda65f..96afac9b8 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java @@ -23,6 +23,7 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.commands.IDebugCommandHandler; import org.eclipse.debug.core.commands.IDebugCommandRequest; +import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.contexts.DebugContextEvent; import org.eclipse.debug.ui.contexts.IDebugContextListener; @@ -48,12 +49,12 @@ public class DebugCommandService implements IDebugContextListener { /** * Window this service is for. */ - private IWorkbenchWindow fWindow = null; + private IWorkbenchWindow fWindow; /** * The context service for this command service. */ - private IDebugContextService fContextService = null; + private IDebugContextService fContextService; /** * Service per window @@ -186,6 +187,9 @@ public class DebugCommandService implements IDebugContextListener { IDebugCommandHandler handler = getHandler(element, handlerType); if (handler != null) { UpdateActionsRequest request = new UpdateActionsRequest(elements, actions); + if (DebugUIPlugin.DEBUG_COMMAND_SERVICE) { + DebugUIPlugin.trace(request + " to " + handler); //$NON-NLS-1$ + } handler.canExecute(request); return; } @@ -195,6 +199,9 @@ public class DebugCommandService implements IDebugContextListener { ActionsUpdater updater = new ActionsUpdater(actions, map.size()); for (Entry> entry : map.entrySet()) { UpdateHandlerRequest request = new UpdateHandlerRequest(entry.getValue().toArray(), updater); + if (DebugUIPlugin.DEBUG_COMMAND_SERVICE) { + DebugUIPlugin.trace(request + " to " + entry.getKey()); //$NON-NLS-1$ + } entry.getKey().canExecute(request); } return; @@ -291,6 +298,12 @@ public class DebugCommandService implements IDebugContextListener { if (handlerType != null) { boolean hasMultipleWindowServices = hasMultipleWindowServices(); if (!hasMultipleWindowServices) { + if (DebugUIPlugin.DEBUG_COMMAND_SERVICE) { + Job[] jobs = Job.getJobManager().find(handlerType); + for (Job job : jobs) { + DebugUIPlugin.trace("WOULD cancel " + job); //$NON-NLS-1$ + } + } Job.getJobManager().cancel(handlerType); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/UpdateActionsRequest.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/UpdateActionsRequest.java index b40a9aede..701099563 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/UpdateActionsRequest.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/UpdateActionsRequest.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.debug.internal.ui.commands.actions; +import java.util.Arrays; + import org.eclipse.debug.core.commands.IEnabledStateRequest; import org.eclipse.debug.internal.core.commands.DebugCommandRequest; @@ -47,4 +49,11 @@ public class UpdateActionsRequest extends DebugCommandRequest implements IEnable } } + @Override + public String toString() { + return getClass().getSimpleName() + " on " + fActions.length //$NON-NLS-1$ + + " actions from " //$NON-NLS-1$ + + Arrays.toString(getElements()); + } + } -- cgit v1.2.3