mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Implementation of termination policy.
This commit is contained in:
parent
f0901784b6
commit
579f75531e
5 changed files with 122 additions and 21 deletions
|
@ -1,3 +1,10 @@
|
|||
2003-05-01 Mikhail Khodjaiants
|
||||
Implementation of termination policy.
|
||||
* ICDIConfiguration.java: new "terminateSessionOnExit" method added.
|
||||
* SessionManager.java: terminates the launch when all targets are terminated or disconnected.
|
||||
* CDebugCorePlugin.java: provides an access to the current session managers.
|
||||
* CDebugTarget.java
|
||||
|
||||
2003-04-25 Mikhail Khodjaiants
|
||||
Fix for bug 36909
|
||||
* DisassemblyManager.java: check if the address of a stack frame is not 0;
|
||||
|
|
|
@ -9,6 +9,7 @@ package org.eclipse.cdt.debug.core;
|
|||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.core.DebugConfiguration;
|
||||
import org.eclipse.cdt.debug.internal.core.SessionManager;
|
||||
import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
|
@ -41,6 +42,8 @@ public class CDebugCorePlugin extends Plugin
|
|||
|
||||
private IAsyncExecutor fAsyncExecutor = null;
|
||||
|
||||
private SessionManager fSessionManager = null;
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
|
@ -169,6 +172,7 @@ public class CDebugCorePlugin extends Plugin
|
|||
*/
|
||||
public void shutdown() throws CoreException
|
||||
{
|
||||
setSessionManager( null );
|
||||
resetBreakpointsInstallCount();
|
||||
super.shutdown();
|
||||
}
|
||||
|
@ -180,6 +184,7 @@ public class CDebugCorePlugin extends Plugin
|
|||
{
|
||||
super.startup();
|
||||
resetBreakpointsInstallCount();
|
||||
setSessionManager( new SessionManager() );
|
||||
}
|
||||
|
||||
protected void resetBreakpointsInstallCount()
|
||||
|
@ -212,4 +217,16 @@ public class CDebugCorePlugin extends Plugin
|
|||
if ( fAsyncExecutor != null )
|
||||
fAsyncExecutor.asyncExec( runnable );
|
||||
}
|
||||
|
||||
protected SessionManager getSessionManager()
|
||||
{
|
||||
return fSessionManager;
|
||||
}
|
||||
|
||||
protected void setSessionManager( SessionManager sm )
|
||||
{
|
||||
if ( fSessionManager != null )
|
||||
fSessionManager.dispose();
|
||||
fSessionManager = sm;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,4 +109,11 @@ public interface ICDIConfiguration {
|
|||
* @return whether this session supports expression evaluation
|
||||
*/
|
||||
boolean supportsExpressionEvaluation();
|
||||
|
||||
/**
|
||||
* Returns whether the session should be terminated when the inferior exits.
|
||||
*
|
||||
* @return whether the session be terminated when the inferior exits
|
||||
*/
|
||||
boolean terminateSessionOnExit();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.core;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.IDebugEventSetListener;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
|
||||
/**
|
||||
* Default implementation of the session manager.
|
||||
* Terminates session when the last target is terminated;
|
||||
*
|
||||
* @since Apr 28, 2003
|
||||
*/
|
||||
public class SessionManager implements IDebugEventSetListener
|
||||
{
|
||||
public SessionManager()
|
||||
{
|
||||
DebugPlugin.getDefault().addDebugEventListener( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
||||
*/
|
||||
public Object getAdapter( Class adapter )
|
||||
{
|
||||
if ( SessionManager.class.equals( adapter ) )
|
||||
return this;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
DebugPlugin.getDefault().removeDebugEventListener( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
|
||||
*/
|
||||
public void handleDebugEvents( DebugEvent[] events )
|
||||
{
|
||||
for ( int i = 0; i < events.length; i++ )
|
||||
{
|
||||
DebugEvent event = events[i];
|
||||
if ( event.getKind() == DebugEvent.TERMINATE )
|
||||
{
|
||||
Object element = event.getSource();
|
||||
if ( element instanceof IDebugTarget && ((IDebugTarget)element).getAdapter( ICDITarget.class ) != null )
|
||||
{
|
||||
handleTerminateEvent( ((IDebugTarget)element).getLaunch(), ((ICDITarget)((IDebugTarget)element).getAdapter( ICDITarget.class )).getSession() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleTerminateEvent( ILaunch launch, ICDISession session )
|
||||
{
|
||||
IDebugTarget[] targets = launch.getDebugTargets();
|
||||
boolean terminate = true;
|
||||
for ( int i = 0; i < targets.length; ++i )
|
||||
{
|
||||
if ( !targets[i].isTerminated() && !targets[i].isDisconnected() )
|
||||
terminate = false;
|
||||
}
|
||||
if ( terminate )
|
||||
{
|
||||
try
|
||||
{
|
||||
session.terminate();
|
||||
}
|
||||
catch( CDIException e )
|
||||
{
|
||||
CDebugCorePlugin.log( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -526,7 +526,7 @@ public class CDebugTarget extends CDebugElement
|
|||
try
|
||||
{
|
||||
setTerminating( true );
|
||||
getCDISession().terminate();
|
||||
getCDITarget().terminate();
|
||||
}
|
||||
catch( CDIException e )
|
||||
{
|
||||
|
@ -780,7 +780,7 @@ public class CDebugTarget extends CDebugElement
|
|||
*/
|
||||
public boolean canDisconnect()
|
||||
{
|
||||
return supportsDisconnect() && !isDisconnected() && isSuspended();
|
||||
return supportsDisconnect() && isAvailable();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -1161,19 +1161,8 @@ public class CDebugTarget extends CDebugElement
|
|||
if ( !isDisconnected() )
|
||||
{
|
||||
setDisconnected( true );
|
||||
try
|
||||
{
|
||||
getCDISession().terminate();
|
||||
}
|
||||
catch( CDIException e )
|
||||
{
|
||||
logError( e );
|
||||
}
|
||||
fireChangeEvent( DebugEvent.STATE );
|
||||
/*
|
||||
cleanup();
|
||||
fireTerminateEvent();
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1500,14 +1489,8 @@ public class CDebugTarget extends CDebugElement
|
|||
setCurrentStateId( IState.EXITED );
|
||||
setCurrentStateInfo( event.getReason() );
|
||||
fireChangeEvent( DebugEvent.CONTENT );
|
||||
try
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
CDebugCorePlugin.log( e.getStatus() );
|
||||
}
|
||||
if ( getConfiguration().terminateSessionOnExit() )
|
||||
terminated();
|
||||
}
|
||||
|
||||
private void handleTerminatedEvent( ICDIDestroyedEvent event )
|
||||
|
|
Loading…
Add table
Reference in a new issue