diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java index ba0479080f2..ff613b1cef7 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java @@ -6,6 +6,7 @@ package org.eclipse.cdt.debug.core; +import java.text.MessageFormat; import java.util.HashMap; import org.eclipse.cdt.debug.core.cdi.CDIException; @@ -14,6 +15,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDILocation; import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.internal.core.CDebugUtils; +import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants; import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint; import org.eclipse.cdt.debug.internal.core.model.CDebugTarget; @@ -115,22 +117,14 @@ public class CDebugModel catch( CoreException e ) { CDebugCorePlugin.log( e ); - // throw DebugException + throw new DebugException( e.getStatus() ); } ICDIConfiguration config = cdiTarget.getSession().getConfiguration(); if ( config.supportsBreakpoints() && stopInMain ) { - ICDILocation location = cdiTarget.getSession().getBreakpointManager().createLocation( "", "main", 0 ); - try - { - ((CDebugTarget)target[0]).setInternalTemporaryBreakpoint( location ); - } - catch( DebugException e ) - { - CDebugUtils.confirm( e.getStatus(), e ); - } + stopInMain( (CDebugTarget)target[0] ); } if ( config.supportsResume() ) @@ -293,4 +287,31 @@ public class CDebugModel } return null; } + + private static void stopInMain( CDebugTarget target ) throws DebugException + { + ICDILocation location = target.getCDISession().getBreakpointManager().createLocation( "", "xxxxmain", 0 ); + try + { + target.setInternalTemporaryBreakpoint( location ); + } + catch( DebugException e ) + { + String message = MessageFormat.format( "Unable to set temporary breakpoint in main.\nReason: {0}\nContinue?", new String[] { e.getStatus().getMessage() } ); + IStatus newStatus = new Status( IStatus.WARNING, + e.getStatus().getPlugin(), + ICDebugInternalConstants.STATUS_CODE_QUESTION, + message, + null ); + if ( !CDebugUtils.question( newStatus, target ) ) + { + target.terminate(); + throw new DebugException( new Status( IStatus.OK, + e.getStatus().getPlugin(), + e.getStatus().getCode(), + e.getStatus().getMessage(), + null ) ); + } + } + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugUtils.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugUtils.java index 256cdcbc6f3..c1fb2595e09 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugUtils.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugUtils.java @@ -18,7 +18,7 @@ import org.eclipse.debug.core.IStatusHandler; */ public class CDebugUtils { - public static boolean confirm( IStatus status, Object source ) + public static boolean question( IStatus status, Object source ) { Boolean result = new Boolean( false ); IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler( status ); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICDebugInternalConstants.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICDebugInternalConstants.java new file mode 100644 index 00000000000..f132127af8c --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICDebugInternalConstants.java @@ -0,0 +1,23 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.internal.core; + +/** + * + * Definitions of the internal constants for C/C++ Debug plug-in. + * + * @since: Sep 25, 2002 + */ +public class ICDebugInternalConstants +{ + /* + * Status handler codes. + */ + public static final int STATUS_CODE_QUESTION = 10000; + public static final int STATUS_CODE_INFO = 10001; + public static final int STATUS_CODE_ERROR = 10002; +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java index 44720fbbf97..b713ae3a36f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java @@ -241,7 +241,8 @@ public class CDebugTarget extends CDebugElement } /** - * Adds all of the pre-existing threads to this debug target. + * Adds all of the pre-existing threads to this debug target. + * */ protected void initializeState() { @@ -252,7 +253,7 @@ public class CDebugTarget extends CDebugElement } catch( CDIException e ) { - internalError( e ); + // ignore } for ( int i = 0; i < threads.length; ++i ) createRunningThread( threads[i] ); diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 6f235dcb4f3..1f986a1bbfd 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -336,20 +336,20 @@ + code="10000" + class="org.eclipse.cdt.debug.internal.ui.QuestionStatusHandler" + id="org.eclipse.cdt.debug.internal.ui.QuestionStatusHandler"> diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ConfirmStatusHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ConfirmStatusHandler.java deleted file mode 100644 index a9208e9f8cf..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ConfirmStatusHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - *(c) Copyright QNX Software Systems Ltd. 2002. - * All Rights Reserved. - * - */ -package org.eclipse.cdt.debug.internal.ui; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.debug.core.IStatusHandler; - -/** - * - * Enter type comment. - * - * @since Sep 25, 2002 - */ -public class ConfirmStatusHandler implements IStatusHandler -{ - - /* (non-Javadoc) - * @see org.eclipse.debug.core.IStatusHandler#handleStatus(IStatus, Object) - */ - public Object handleStatus( IStatus status, Object source ) throws CoreException - { - return null; - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugUIInternalConstants.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugUIInternalConstants.java index 782079d15c9..e3934ee48fd 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugUIInternalConstants.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugUIInternalConstants.java @@ -14,13 +14,6 @@ package org.eclipse.cdt.debug.internal.ui; */ public interface ICDebugUIInternalConstants { - /* - * Status handler codes. - */ - public static final int STATUS_CODE_CONFIRM = 10000; - public static final int STATUS_CODE_INFO = 10001; - public static final int STATUS_CODE_ERROR = 10002; - /* * Memory view constants. */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/QuestionStatusHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/QuestionStatusHandler.java new file mode 100644 index 00000000000..c14000f29ef --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/QuestionStatusHandler.java @@ -0,0 +1,45 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ +package org.eclipse.cdt.debug.internal.ui; + +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.debug.core.IStatusHandler; +import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.jface.dialogs.MessageDialog; + +/** + * + * Enter type comment. + * + * @since Sep 25, 2002 + */ +public class QuestionStatusHandler implements IStatusHandler +{ + + /* (non-Javadoc) + * @see org.eclipse.debug.core.IStatusHandler#handleStatus(IStatus, Object) + */ + public Object handleStatus( IStatus status, Object source ) throws CoreException + { + final boolean result[] = new boolean[1]; + if ( status != null && source != null && source instanceof IDebugTarget ) + { + final String title = ((IDebugTarget)source).getName(); + final String message = status.getMessage(); + CDebugUIPlugin.getStandardDisplay().syncExec( + new Runnable() + { + public void run() + { + result[0] = MessageDialog.openQuestion( CDebugUIPlugin.getActiveWorkbenchShell(), title, message ); + } + } ); + } + return new Boolean( result[0] ); + } +}