mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Added a status functionality to the CDebugElement class.
This commit is contained in:
parent
1f3480e46a
commit
bcc744554c
4 changed files with 75 additions and 13 deletions
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.debug.core.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the status of a debug element.
|
||||||
|
*
|
||||||
|
* @since May 2, 2003
|
||||||
|
*/
|
||||||
|
public interface ICDebugElementErrorStatus
|
||||||
|
{
|
||||||
|
public static final int OK = 0;
|
||||||
|
public static final int WARNING = 1;
|
||||||
|
public static final int ERROR = 2;
|
||||||
|
|
||||||
|
boolean isOK();
|
||||||
|
|
||||||
|
int getSeverity();
|
||||||
|
|
||||||
|
String getMessage();
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import org.eclipse.cdt.debug.core.CDebugModel;
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||||
|
import org.eclipse.cdt.debug.core.model.ICDebugElementErrorStatus;
|
||||||
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.ICDebugInternalConstants;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
@ -30,10 +31,14 @@ import org.eclipse.debug.core.model.IDebugTarget;
|
||||||
* @since Aug 1, 2002
|
* @since Aug 1, 2002
|
||||||
*/
|
*/
|
||||||
public class CDebugElement extends PlatformObject
|
public class CDebugElement extends PlatformObject
|
||||||
implements IDebugElement
|
implements IDebugElement,
|
||||||
|
ICDebugElementErrorStatus
|
||||||
{
|
{
|
||||||
private CDebugTarget fDebugTarget;
|
private CDebugTarget fDebugTarget;
|
||||||
|
|
||||||
|
private int fSeverity = ICDebugElementErrorStatus.OK;
|
||||||
|
private String fMessage = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CDebugElement.
|
* Constructor for CDebugElement.
|
||||||
*/
|
*/
|
||||||
|
@ -284,4 +289,42 @@ public class CDebugElement extends PlatformObject
|
||||||
return getCDISession();
|
return getCDISession();
|
||||||
return super.getAdapter(adapter);
|
return super.getAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setStatus( int severity, String message )
|
||||||
|
{
|
||||||
|
fSeverity = severity;
|
||||||
|
fMessage = message;
|
||||||
|
if ( fMessage != null )
|
||||||
|
fMessage.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void resetStatus()
|
||||||
|
{
|
||||||
|
fSeverity = ICDebugElementErrorStatus.OK;
|
||||||
|
fMessage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.model.ICDebugElementErrorStatus#isOK()
|
||||||
|
*/
|
||||||
|
public boolean isOK()
|
||||||
|
{
|
||||||
|
return ( fSeverity == ICDebugElementErrorStatus.OK );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.model.ICDebugElementErrorStatus#getSeverity()
|
||||||
|
*/
|
||||||
|
public int getSeverity()
|
||||||
|
{
|
||||||
|
return fSeverity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.model.ICDebugElementErrorStatus#getMessage()
|
||||||
|
*/
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
return fMessage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1173,6 +1173,7 @@ public class CDebugTarget extends CDebugElement
|
||||||
*/
|
*/
|
||||||
protected void cleanup()
|
protected void cleanup()
|
||||||
{
|
{
|
||||||
|
resetStatus();
|
||||||
removeAllThreads();
|
removeAllThreads();
|
||||||
getCDISession().getEventManager().removeEventListener( this );
|
getCDISession().getEventManager().removeEventListener( this );
|
||||||
DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener( this );
|
DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener( this );
|
||||||
|
@ -1401,6 +1402,7 @@ public class CDebugTarget extends CDebugElement
|
||||||
setSuspended( false );
|
setSuspended( false );
|
||||||
setCurrentStateId( IState.RUNNING );
|
setCurrentStateId( IState.RUNNING );
|
||||||
setCurrentStateInfo( null );
|
setCurrentStateInfo( null );
|
||||||
|
resetStatus();
|
||||||
resumeThreads( event );
|
resumeThreads( event );
|
||||||
int detail = DebugEvent.UNSPECIFIED;
|
int detail = DebugEvent.UNSPECIFIED;
|
||||||
switch( event.getType() )
|
switch( event.getType() )
|
||||||
|
|
|
@ -10,7 +10,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
|
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIEndSteppingRange;
|
import org.eclipse.cdt.debug.core.cdi.ICDIEndSteppingRange;
|
||||||
|
@ -28,6 +27,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
|
||||||
|
import org.eclipse.cdt.debug.core.model.ICDebugElementErrorStatus;
|
||||||
import org.eclipse.cdt.debug.core.model.IDummyStackFrame;
|
import org.eclipse.cdt.debug.core.model.IDummyStackFrame;
|
||||||
import org.eclipse.cdt.debug.core.model.IInstructionStep;
|
import org.eclipse.cdt.debug.core.model.IInstructionStep;
|
||||||
import org.eclipse.cdt.debug.core.model.IRestart;
|
import org.eclipse.cdt.debug.core.model.IRestart;
|
||||||
|
@ -36,12 +36,7 @@ import org.eclipse.cdt.debug.core.model.IRunToLine;
|
||||||
import org.eclipse.cdt.debug.core.model.IState;
|
import org.eclipse.cdt.debug.core.model.IState;
|
||||||
import org.eclipse.cdt.debug.core.model.ISwitchToFrame;
|
import org.eclipse.cdt.debug.core.model.ISwitchToFrame;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
|
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
|
||||||
import org.eclipse.cdt.debug.internal.core.CDebugUtils;
|
|
||||||
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.MultiStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.debug.core.DebugEvent;
|
import org.eclipse.debug.core.DebugEvent;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.debug.core.model.IBreakpoint;
|
import org.eclipse.debug.core.model.IBreakpoint;
|
||||||
|
@ -273,6 +268,7 @@ public class CThread extends CDebugElement
|
||||||
}
|
}
|
||||||
catch( CDIException e )
|
catch( CDIException e )
|
||||||
{
|
{
|
||||||
|
setStatus( ICDebugElementErrorStatus.WARNING, "Stack is not available: " + e.getMessage() );
|
||||||
targetRequestFailed( e.getMessage(), null );
|
targetRequestFailed( e.getMessage(), null );
|
||||||
}
|
}
|
||||||
return new ICDIStackFrame[0];
|
return new ICDIStackFrame[0];
|
||||||
|
@ -744,6 +740,7 @@ public class CThread extends CDebugElement
|
||||||
}
|
}
|
||||||
fStackFrames.clear();
|
fStackFrames.clear();
|
||||||
setLastStackDepth( 0 );
|
setLastStackDepth( 0 );
|
||||||
|
resetStatus();
|
||||||
setRefreshChildren( true );
|
setRefreshChildren( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1084,12 +1081,7 @@ public class CThread extends CDebugElement
|
||||||
}
|
}
|
||||||
catch( CDIException e )
|
catch( CDIException e )
|
||||||
{
|
{
|
||||||
MultiStatus status = new MultiStatus( CDebugCorePlugin.getUniqueIdentifier(),
|
setStatus( ICDebugElementErrorStatus.WARNING, "Stack is not available: " + e.getMessage() );
|
||||||
ICDebugInternalConstants.STATUS_CODE_ERROR,
|
|
||||||
"Stack is not available.",
|
|
||||||
null );
|
|
||||||
status.add( new Status( IStatus.ERROR, status.getPlugin(), status.getCode(), e.getMessage(), null ) );
|
|
||||||
CDebugUtils.error( status, getDebugTarget() );
|
|
||||||
}
|
}
|
||||||
return depth;
|
return depth;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue