From 52945d770478dee85207eac126fbffbdc5679b1e Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Sat, 23 Jan 2010 00:59:09 +0000 Subject: [PATCH] [300586] - Error logged by DsfSuspendTrigger --- .../dsf/gdb/service/command/GDBControl.java | 3 +- .../concurrent/CountingRequestMonitor.java | 4 +- .../cdt/dsf/concurrent/DsfMultiStatus.java | 67 +++++++++++++++++++ 3 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/DsfMultiStatus.java diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java index 233a821fdc9..ec649773b4d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java @@ -22,6 +22,7 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; +import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.Sequence; import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent; @@ -419,7 +420,7 @@ public class GDBControl extends AbstractMIControl implements IGDBControl { IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true, null)) { // If the inferior finishes, let's terminate GDB - terminate(new RequestMonitor(getExecutor(), null)); + terminate(new RequestMonitor(ImmediateExecutor.getInstance(), null)); } } diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/CountingRequestMonitor.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/CountingRequestMonitor.java index 92185c41382..55c1349b2ae 100644 --- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/CountingRequestMonitor.java +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/CountingRequestMonitor.java @@ -115,8 +115,8 @@ public class CountingRequestMonitor extends RequestMonitor { @Override public synchronized void setStatus(IStatus status) { - if ((getStatus() instanceof MultiStatus)) { - ((MultiStatus)getStatus()).add(status); + if ((getStatus() instanceof DsfMultiStatus)) { + ((DsfMultiStatus)getStatus()).add(status); } }; } diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/DsfMultiStatus.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/DsfMultiStatus.java new file mode 100644 index 00000000000..adde79b0bee --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/DsfMultiStatus.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2008 Wind River Systems 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.concurrent; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; + +/** + * Multi-status that calculates the maximum error code for all children. + * + * @since 2.1 + */ +public class DsfMultiStatus extends MultiStatus { + + /** + * Creates and returns a new multi-status object with the given children. + * + * @param pluginId the unique identifier of the relevant plug-in + * @param code the plug-in-specific status code + * @param newChildren the list of children status objects + * @param message a human-readable message, localized to the + * current locale + * @param exception a low-level exception, or null if not + * applicable + */ + public DsfMultiStatus(String pluginId, int code, IStatus[] newChildren, String message, Throwable exception) { + super(pluginId, code, newChildren, message, exception); + } + + /** + * Creates and returns a new multi-status object with no children. + * + * @param pluginId the unique identifier of the relevant plug-in + * @param code the plug-in-specific status code + * @param message a human-readable message, localized to the + * current locale + * @param exception a low-level exception, or null if not + * applicable + */ + public DsfMultiStatus(String pluginId, int code, String message, Throwable exception) { + super(pluginId, code, message, exception); + } + + @Override + public int getCode() { + IStatus[] children = getChildren(); + if (children.length != 0) { + int maxCode = Integer.MIN_VALUE; + for (IStatus status : children) { + if (status.getCode() > maxCode) { + maxCode = status.getCode(); + } + } + return maxCode; + } else { + return super.getCode(); + } + } +}