1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Implementation of error handling.

This commit is contained in:
Mikhail Khodjaiants 2002-09-25 19:42:09 +00:00
parent eb7350b546
commit 04ac19ff94
8 changed files with 108 additions and 53 deletions

View file

@ -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 ) );
}
}
}
}

View file

@ -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 );

View file

@ -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;
}

View file

@ -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] );

View file

@ -336,20 +336,20 @@
<extension
point="org.eclipse.debug.core.statusHandlers">
<statusHandler
code="10000"
plugin="org.eclipse.cdt.debug.core"
class="org.eclipse.cdt.debug.internal.ui.ConfirmStatusHandler"
id="org.eclipse.cdt.debug.internal.ui.ConfirmStatusHandler">
code="10000"
class="org.eclipse.cdt.debug.internal.ui.QuestionStatusHandler"
id="org.eclipse.cdt.debug.internal.ui.QuestionStatusHandler">
</statusHandler>
<statusHandler
code="10001"
plugin="org.eclipse.cdt.debug.core"
code="10001"
class="org.eclipse.cdt.debug.internal.ui.InfoStatusHandler"
id="org.eclipse.cdt.debug.internal.ui.InfoStatusHandler">
</statusHandler>
<statusHandler
code="10002"
plugin="org.eclipse.cdt.debug.core"
code="10002"
class="org.eclipse.cdt.debug.internal.ui.ErrorStatusHandler"
id="org.eclipse.cdt.debug.internal.ui.ErrorStatusHandler">
</statusHandler>

View file

@ -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;
}
}

View file

@ -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.
*/

View file

@ -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] );
}
}