mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 08:55:25 +02:00
Pass the target state to threads on terminate, disconnect, resume, suspend and restart.
This commit is contained in:
parent
0fc818ad2c
commit
4761007499
5 changed files with 47 additions and 28 deletions
|
@ -1,3 +1,10 @@
|
|||
2004-10-21 Mikhail Khodjaiants
|
||||
Pass the target state to threads on terminate, disconnect, resume, suspend and restart.
|
||||
* CoreModelMessages.properties
|
||||
* CDebugElement.java
|
||||
* CDebugTarget.java
|
||||
* CThread.java
|
||||
|
||||
2004-10-19 Mikhail Khodjaiants
|
||||
Set the initial state of a thread according to the state of the underlying CDI thread.
|
||||
* CThread.java
|
||||
|
|
|
@ -52,10 +52,15 @@ abstract public class CDebugElement extends PlatformObject implements ICDebugEle
|
|||
private String fMessage = null;
|
||||
|
||||
/**
|
||||
* The state of this element.
|
||||
* The current state of this element.
|
||||
*/
|
||||
private CDebugElementState fState = CDebugElementState.UNDEFINED;
|
||||
|
||||
/**
|
||||
* The previous state of this element.
|
||||
*/
|
||||
private CDebugElementState fOldState = CDebugElementState.UNDEFINED;
|
||||
|
||||
/**
|
||||
* The current state info.
|
||||
*/
|
||||
|
@ -336,10 +341,15 @@ abstract public class CDebugElement extends PlatformObject implements ICDebugEle
|
|||
return fState;
|
||||
}
|
||||
|
||||
protected void setState( CDebugElementState state ) throws IllegalArgumentException {
|
||||
protected synchronized void setState( CDebugElementState state ) throws IllegalArgumentException {
|
||||
fOldState = fState;
|
||||
fState = state;
|
||||
}
|
||||
|
||||
protected synchronized void restoreState() {
|
||||
fState = fOldState;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.ICDebugElement#getCurrentStateInfo()
|
||||
*/
|
||||
|
|
|
@ -440,8 +440,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
if ( !canTerminate() ) {
|
||||
return;
|
||||
}
|
||||
final CDebugElementState oldState = getState();
|
||||
setState( CDebugElementState.TERMINATING );
|
||||
changeState( CDebugElementState.TERMINATING );
|
||||
DebugPlugin.getDefault().asyncExec( new Runnable() {
|
||||
|
||||
public void run() {
|
||||
|
@ -449,7 +448,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
getCDITarget().terminate();
|
||||
}
|
||||
catch( CDIException e ) {
|
||||
setState( oldState );
|
||||
restoreOldState();
|
||||
try {
|
||||
targetRequestFailed( e.getMessage(), e );
|
||||
}
|
||||
|
@ -500,8 +499,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
public void resume() throws DebugException {
|
||||
if ( !canResume() )
|
||||
return;
|
||||
final CDebugElementState oldState = getState();
|
||||
setState( CDebugElementState.RESUMING );
|
||||
changeState( CDebugElementState.RESUMING );
|
||||
DebugPlugin.getDefault().asyncExec( new Runnable() {
|
||||
|
||||
public void run() {
|
||||
|
@ -509,7 +507,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
getCDITarget().resume( false );
|
||||
}
|
||||
catch( CDIException e ) {
|
||||
setState( oldState );
|
||||
restoreOldState();
|
||||
try {
|
||||
targetRequestFailed( e.getMessage(), e );
|
||||
}
|
||||
|
@ -527,8 +525,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
public void suspend() throws DebugException {
|
||||
if ( !canSuspend() )
|
||||
return;
|
||||
final CDebugElementState oldState = getState();
|
||||
setState( CDebugElementState.SUSPENDING );
|
||||
changeState( CDebugElementState.SUSPENDING );
|
||||
DebugPlugin.getDefault().asyncExec( new Runnable() {
|
||||
|
||||
public void run() {
|
||||
|
@ -536,7 +533,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
getCDITarget().suspend();
|
||||
}
|
||||
catch( CDIException e ) {
|
||||
setState( oldState );
|
||||
restoreOldState();
|
||||
try {
|
||||
targetRequestFailed( e.getMessage(), e );
|
||||
}
|
||||
|
@ -731,11 +728,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
if ( isDisconnecting() ) {
|
||||
return;
|
||||
}
|
||||
if ( !supportsDisconnect() ) {
|
||||
notSupported( CoreModelMessages.getString( "CDebugTarget.0" ) ); //$NON-NLS-1$
|
||||
}
|
||||
final CDebugElementState oldState = getState();
|
||||
setState( CDebugElementState.DISCONNECTING );
|
||||
changeState( CDebugElementState.DISCONNECTING );
|
||||
DebugPlugin.getDefault().asyncExec( new Runnable() {
|
||||
|
||||
public void run() {
|
||||
|
@ -743,7 +736,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
getCDITarget().disconnect();
|
||||
}
|
||||
catch( CDIException e ) {
|
||||
setState( oldState );
|
||||
restoreOldState();
|
||||
try {
|
||||
targetRequestFailed( e.getMessage(), e );
|
||||
}
|
||||
|
@ -949,8 +942,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
if ( !canRestart() ) {
|
||||
return;
|
||||
}
|
||||
final CDebugElementState oldState = getState();
|
||||
setState( CDebugElementState.RESTARTING );
|
||||
changeState( CDebugElementState.RESTARTING );
|
||||
ICDILocation location = getCDITarget().createLocation( "", "main", 0 ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
setInternalTemporaryBreakpoint( location );
|
||||
DebugPlugin.getDefault().asyncExec( new Runnable() {
|
||||
|
@ -960,7 +952,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
getCDITarget().restart();
|
||||
}
|
||||
catch( CDIException e ) {
|
||||
setState( oldState );
|
||||
restoreOldState();
|
||||
try {
|
||||
targetRequestFailed( e.getMessage(), e );
|
||||
}
|
||||
|
@ -1540,8 +1532,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
public void resumeWithoutSignal() throws DebugException {
|
||||
if ( !canResume() )
|
||||
return;
|
||||
final CDebugElementState oldState = getState();
|
||||
setState( CDebugElementState.RESUMING );
|
||||
changeState( CDebugElementState.RESUMING );
|
||||
DebugPlugin.getDefault().asyncExec( new Runnable() {
|
||||
|
||||
public void run() {
|
||||
|
@ -1549,7 +1540,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
getCDITarget().resume( false );
|
||||
}
|
||||
catch( CDIException e ) {
|
||||
setState( oldState );
|
||||
restoreOldState();
|
||||
try {
|
||||
targetRequestFailed( e.getMessage(), e );
|
||||
}
|
||||
|
@ -1877,4 +1868,20 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
ms.add( new Status( IStatus.ERROR, CDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e ) );
|
||||
CDebugUtils.error( ms, this );
|
||||
}
|
||||
|
||||
private void changeState( CDebugElementState state ) {
|
||||
setState( state );
|
||||
Iterator it = getThreadList().iterator();
|
||||
while( it.hasNext() ) {
|
||||
((CThread)it.next()).setState( state );
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreOldState() {
|
||||
restoreState();
|
||||
Iterator it = getThreadList().iterator();
|
||||
while( it.hasNext() ) {
|
||||
((CThread)it.next()).restoreState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -910,10 +910,6 @@ public class CThread extends CDebugElement implements ICThread, IRestart, IResum
|
|||
}
|
||||
|
||||
protected void suspendByTarget( ICDISessionObject reason, ICDIThread suspensionThread ) {
|
||||
if ( !(getState().equals( CDebugElementState.RESUMED ) ||
|
||||
getState().equals( CDebugElementState.STEPPED ) ||
|
||||
getState().equals( CDebugElementState.SUSPENDING )) )
|
||||
return;
|
||||
setState( CDebugElementState.SUSPENDED );
|
||||
setCurrentStateInfo( null );
|
||||
if ( getCDIThread().equals( suspensionThread ) ) {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
CDebugTarget.Unable_to_get_globals_1=Unable to get globals. Reason:
|
||||
CArrayPartition.0=Type is not available.
|
||||
CArrayPartition.1=Qualified name is not available.
|
||||
CDebugTarget.0=Session does not support 'disconnect'.
|
||||
CDebugTarget.1=Execution is suspended because of error.
|
||||
CDebugTarget.2=Terminate failed.
|
||||
CDebugTarget.3=Resume failed.
|
||||
|
|
Loading…
Add table
Reference in a new issue