mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Implementation of error handling.
This commit is contained in:
parent
eb7350b546
commit
04ac19ff94
8 changed files with 108 additions and 53 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.debug.core;
|
package org.eclipse.cdt.debug.core;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
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.ICDIExpression;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||||
import org.eclipse.cdt.debug.internal.core.CDebugUtils;
|
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.CLineBreakpoint;
|
||||||
import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint;
|
import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint;
|
||||||
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
|
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
|
||||||
|
@ -115,22 +117,14 @@ public class CDebugModel
|
||||||
catch( CoreException e )
|
catch( CoreException e )
|
||||||
{
|
{
|
||||||
CDebugCorePlugin.log( e );
|
CDebugCorePlugin.log( e );
|
||||||
// throw DebugException
|
throw new DebugException( e.getStatus() );
|
||||||
}
|
}
|
||||||
|
|
||||||
ICDIConfiguration config = cdiTarget.getSession().getConfiguration();
|
ICDIConfiguration config = cdiTarget.getSession().getConfiguration();
|
||||||
|
|
||||||
if ( config.supportsBreakpoints() && stopInMain )
|
if ( config.supportsBreakpoints() && stopInMain )
|
||||||
{
|
{
|
||||||
ICDILocation location = cdiTarget.getSession().getBreakpointManager().createLocation( "", "main", 0 );
|
stopInMain( (CDebugTarget)target[0] );
|
||||||
try
|
|
||||||
{
|
|
||||||
((CDebugTarget)target[0]).setInternalTemporaryBreakpoint( location );
|
|
||||||
}
|
|
||||||
catch( DebugException e )
|
|
||||||
{
|
|
||||||
CDebugUtils.confirm( e.getStatus(), e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config.supportsResume() )
|
if ( config.supportsResume() )
|
||||||
|
@ -293,4 +287,31 @@ public class CDebugModel
|
||||||
}
|
}
|
||||||
return null;
|
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 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.debug.core.IStatusHandler;
|
||||||
*/
|
*/
|
||||||
public class CDebugUtils
|
public class CDebugUtils
|
||||||
{
|
{
|
||||||
public static boolean confirm( IStatus status, Object source )
|
public static boolean question( IStatus status, Object source )
|
||||||
{
|
{
|
||||||
Boolean result = new Boolean( false );
|
Boolean result = new Boolean( false );
|
||||||
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler( status );
|
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler( status );
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -242,6 +242,7 @@ 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()
|
protected void initializeState()
|
||||||
{
|
{
|
||||||
|
@ -252,7 +253,7 @@ public class CDebugTarget extends CDebugElement
|
||||||
}
|
}
|
||||||
catch( CDIException e )
|
catch( CDIException e )
|
||||||
{
|
{
|
||||||
internalError( e );
|
// ignore
|
||||||
}
|
}
|
||||||
for ( int i = 0; i < threads.length; ++i )
|
for ( int i = 0; i < threads.length; ++i )
|
||||||
createRunningThread( threads[i] );
|
createRunningThread( threads[i] );
|
||||||
|
|
|
@ -336,20 +336,20 @@
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.debug.core.statusHandlers">
|
point="org.eclipse.debug.core.statusHandlers">
|
||||||
<statusHandler
|
<statusHandler
|
||||||
code="10000"
|
|
||||||
plugin="org.eclipse.cdt.debug.core"
|
plugin="org.eclipse.cdt.debug.core"
|
||||||
class="org.eclipse.cdt.debug.internal.ui.ConfirmStatusHandler"
|
code="10000"
|
||||||
id="org.eclipse.cdt.debug.internal.ui.ConfirmStatusHandler">
|
class="org.eclipse.cdt.debug.internal.ui.QuestionStatusHandler"
|
||||||
|
id="org.eclipse.cdt.debug.internal.ui.QuestionStatusHandler">
|
||||||
</statusHandler>
|
</statusHandler>
|
||||||
<statusHandler
|
<statusHandler
|
||||||
code="10001"
|
|
||||||
plugin="org.eclipse.cdt.debug.core"
|
plugin="org.eclipse.cdt.debug.core"
|
||||||
|
code="10001"
|
||||||
class="org.eclipse.cdt.debug.internal.ui.InfoStatusHandler"
|
class="org.eclipse.cdt.debug.internal.ui.InfoStatusHandler"
|
||||||
id="org.eclipse.cdt.debug.internal.ui.InfoStatusHandler">
|
id="org.eclipse.cdt.debug.internal.ui.InfoStatusHandler">
|
||||||
</statusHandler>
|
</statusHandler>
|
||||||
<statusHandler
|
<statusHandler
|
||||||
code="10002"
|
|
||||||
plugin="org.eclipse.cdt.debug.core"
|
plugin="org.eclipse.cdt.debug.core"
|
||||||
|
code="10002"
|
||||||
class="org.eclipse.cdt.debug.internal.ui.ErrorStatusHandler"
|
class="org.eclipse.cdt.debug.internal.ui.ErrorStatusHandler"
|
||||||
id="org.eclipse.cdt.debug.internal.ui.ErrorStatusHandler">
|
id="org.eclipse.cdt.debug.internal.ui.ErrorStatusHandler">
|
||||||
</statusHandler>
|
</statusHandler>
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,13 +14,6 @@ package org.eclipse.cdt.debug.internal.ui;
|
||||||
*/
|
*/
|
||||||
public interface ICDebugUIInternalConstants
|
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.
|
* Memory view constants.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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] );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue