diff options
28 files changed, 704 insertions, 784 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 0969f846756..7e58cee14fe 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,13 +1,45 @@ +2003-11-10 Mikhail Khodjaiants + Ensure that all breakpoint creation and modification operations are running in the UI thread. + * CBreakpointManager.java + +2003-11-10 Mikhail Khodjaiants + Added synchronization to some of the 'CBreakpoint' methods. + * CBreakpoint.java + 2003-11-07 Mikhail Khodjaiants Fix for PR 46358: NPE in the "setCurrentThread" method of "CDebugTarget". 'setCurrentThread': check if the old current thread is not null. * CDebugTarget.java 2003-11-07 Mikhail Khodjaiants + Use the corresponding methods of 'ICBreakpoint' to set breakpoint properties. + * CBreakpointManager.java + +2003-11-07 Mikhail Khodjaiants Fix for PR 46303: Exception when selecting Debug... menu. Check if the string passed to the 'getCommonSourceLocationsFromMemento' method is not empty. * SourceUtils.java +2003-11-05 Mikhail Khodjaiants + 'getCDIBreakpointFile' returns wrong file for address breakpoints. + * CBreakpointManager.java + +2003-11-05 Mikhail Khodjaiants + Changed the handling of the breakpoint created event to reflect the CDI changes for deferred + breakpoints support. + * CBreakpointManager.java + * CSharedLibraryManager.java + * CDebugTarget.java + +2003-11-05 Mikhail Khodjaiants + Moved all breakpoint-related functionality to the new class - 'CBreakpointManager'. + * CBreakpointManager.java + +2003-11-05 Mikhail Khodjaiants + The argument type of the 'getBreakpointAddress' method of 'ICBreakpointManager' is changed from + 'ICBreakpoint' to 'ICBreakpointManager'. + * ICBreakpointMaanger.java + 2003-10-30 Mikhail Khodjaiants * CSourceManager.java: implements adapters for 'ISourceMode' and 'IPersistableSourceLocator'. @@ -62,6 +94,15 @@ if the initialization of one fails. * CSourceLocator.java +2003-10-17 Alain Magloire + + ICDIBreakpointManager new method + setLocationBreakpoint(...., deferred); + The new boolean "deferred" indicate if yes or not the breakpoint + should be on the deferred list if the setting fails. + + * ICDIBreakpointManager.java + 2003-10-17 Mikhail Khodjaiants Core support of the 'Search for duplicate source files' option. * ICSourceLocation.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpointManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpointManager.java index 9287c047204..3133b541413 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpointManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpointManager.java @@ -5,8 +5,8 @@ */ package org.eclipse.cdt.debug.core; +import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.debug.core.model.IBreakpoint; /** * Enter type comment. @@ -15,5 +15,5 @@ import org.eclipse.debug.core.model.IBreakpoint; */ public interface ICBreakpointManager extends IAdaptable { - long getBreakpointAddress( IBreakpoint breakpoint ); + long getBreakpointAddress( ICBreakpoint breakpoint ); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDIBreakpointManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDIBreakpointManager.java index 5bda4b7b231..6a573c913d3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDIBreakpointManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDIBreakpointManager.java @@ -77,6 +77,29 @@ public interface ICDIBreakpointManager extends ICDIManager { * @param condition - the condition or <code>null</code> * @param threadId - the thread identifier if this is * a thread-specific breakpoint or <code>null</code> + * @param deferred - when set to <code>true</code>, if the breakpoint fails + * to be set, it is put a deferred list and the debugger will retry to set + * it when a new Shared library is loaded. + * @return a breakpoint + * @throws CDIException on failure. Reasons include: + */ + ICDILocationBreakpoint setLocationBreakpoint( + int type, + ICDILocation location, + ICDICondition condition, + String threadId, boolean deferred) + throws CDIException; + + /** + * Equivalent to : + * setLocationBreakpoint(type, location, condition, threadID, false); + * The breakpoint is not deferred. + * + * @param type - a combination of TEMPORARY and HARDWARE or REGULAR + * @param location - the location + * @param condition - the condition or <code>null</code> + * @param threadId - the thread identifier if this is + * a thread-specific breakpoint or <code>null</code> * @return a breakpoint * @throws CDIException on failure. Reasons include: */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugTarget.java index ba63b674684..e64a882d8ed 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugTarget.java @@ -5,7 +5,6 @@ */ package org.eclipse.cdt.debug.core.model; -import org.eclipse.cdt.debug.core.ICBreakpointManager; import org.eclipse.debug.core.model.IDebugTarget; /** @@ -25,7 +24,6 @@ public interface ICDebugTarget extends IDebugTarget, IJumpToAddress, IResumeWithoutSignal, IState, - ISwitchToThread, - ICBreakpointManager + ISwitchToThread { } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSharedLibraryManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSharedLibraryManager.java index 509c335ade5..d78d7a20bf3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSharedLibraryManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSharedLibraryManager.java @@ -51,7 +51,7 @@ public class CSharedLibraryManager extends CUpdateManager implements ICSharedLib fSharedLibraries.add( library ); library.fireCreationEvent(); if ( library.areSymbolsLoaded() ) - ((CDebugTarget)getDebugTarget()).setDeferredBreakpoints(); + setBreakpoints(); } /* (non-Javadoc) @@ -77,7 +77,7 @@ public class CSharedLibraryManager extends CUpdateManager implements ICSharedLib if ( library != null ) { library.fireChangeEvent( DebugEvent.STATE ); - ((CDebugTarget)getDebugTarget()).setDeferredBreakpoints(); + setBreakpoints(); } } @@ -181,4 +181,9 @@ public class CSharedLibraryManager extends CUpdateManager implements ICSharedLib } } } + + private void setBreakpoints() + { + ((CDebugTarget)getDebugTarget()).setBreakpoints(); + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java index a2650912a73..017db08b048 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java @@ -6,10 +6,8 @@ package org.eclipse.cdt.debug.internal.core.model; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.StringTokenizer; import org.eclipse.cdt.core.CCorePlugin; @@ -28,8 +26,6 @@ import org.eclipse.cdt.debug.core.ICSharedLibraryManager; import org.eclipse.cdt.debug.core.ICSignalManager; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit; -import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager; -import org.eclipse.cdt.debug.core.cdi.ICDICondition; import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration; import org.eclipse.cdt.debug.core.cdi.ICDIEndSteppingRange; import org.eclipse.cdt.debug.core.cdi.ICDIErrorInfo; @@ -51,22 +47,17 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDIRestartedEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDIResumedEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; -import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary; import org.eclipse.cdt.debug.core.cdi.model.ICDISignal; 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.ICDIWatchpoint; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.model.ICDebugElementErrorStatus; import org.eclipse.cdt.debug.core.model.ICDebugTarget; import org.eclipse.cdt.debug.core.model.ICDebugTargetType; import org.eclipse.cdt.debug.core.model.ICExpressionEvaluator; -import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; -import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; -import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.IDebuggerProcessSupport; import org.eclipse.cdt.debug.core.model.IExecFileInfo; import org.eclipse.cdt.debug.core.model.IGlobalVariable; @@ -77,18 +68,16 @@ import org.eclipse.cdt.debug.core.model.IRunToLine; import org.eclipse.cdt.debug.core.model.IState; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode; +import org.eclipse.cdt.debug.internal.core.CBreakpointManager; import org.eclipse.cdt.debug.internal.core.CMemoryManager; import org.eclipse.cdt.debug.internal.core.CRegisterManager; import org.eclipse.cdt.debug.internal.core.CSharedLibraryManager; import org.eclipse.cdt.debug.internal.core.CSignalManager; import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants; -import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint; import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager; import org.eclipse.cdt.debug.internal.core.sourcelookup.DisassemblyManager; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarkerDelta; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; @@ -236,11 +225,6 @@ public class CDebugTarget extends CDebugElement private int fSuspendCount = 0; /** - * Collection of breakpoints added to this target. Values are of type <code>ICBreakpoint</code>. - */ - private HashMap fBreakpoints; - - /** * A memory manager for this target. */ private CMemoryManager fMemoryManager; @@ -266,6 +250,11 @@ public class CDebugTarget extends CDebugElement private CRegisterManager fRegisterManager; /** + * A breakpoint manager for this target. + */ + private CBreakpointManager fBreakpointManager; + + /** * Whether the debugger process is default. */ private boolean fIsDebuggerProcessDefault = false; @@ -275,12 +264,6 @@ public class CDebugTarget extends CDebugElement */ private IFile fExecFile; - /** - * If is set to 'true' the debugger will try to set breakpoints on - * the next resume or step call. - */ - private boolean fSetBreakpoints = true; - private RunningInfo fRunningInfo = null; /** @@ -304,7 +287,6 @@ public class CDebugTarget extends CDebugElement setName( name ); setProcesses( debuggeeProcess, debuggerProcess ); setCDITarget( cdiTarget ); - initializeBreakpointMap( new HashMap( 5 ) ); setExecFile( file ); setConfiguration( cdiTarget.getSession().getConfiguration() ); fSupportsTerminate = allowsTerminate & getConfiguration().supportsTerminate(); @@ -314,6 +296,7 @@ public class CDebugTarget extends CDebugElement setSharedLibraryManager( new CSharedLibraryManager( this ) ); setSignalManager( new CSignalManager( this ) ); setRegisterManager( new CRegisterManager( this ) ); + setBreakpointManager( new CBreakpointManager( this ) ); initialize(); DebugPlugin.getDefault().getLaunchManager().addLaunchListener( this ); DebugPlugin.getDefault().getExpressionManager().addExpressionListener( this ); @@ -365,66 +348,30 @@ public class CDebugTarget extends CDebugElement * the breakpoint manager. * */ - protected void setBreakpoints() + public void setBreakpoints() { - if ( getRetryBreakpoints() ) + IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); + IBreakpoint[] bps = (IBreakpoint[])manager.getBreakpoints( CDebugModel.getPluginIdentifier() ); + for ( int i = 0; i < bps.length; i++ ) { - IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); - IBreakpoint[] bps = (IBreakpoint[])manager.getBreakpoints( CDebugModel.getPluginIdentifier() ); - for ( int i = 0; i < bps.length; i++ ) + if ( bps[i] instanceof ICBreakpoint && + getBreakpointManager().isTargetBreakpoint( (ICBreakpoint)bps[i] ) && + !getBreakpointManager().isCDIRegistered( (ICBreakpoint)bps[i] ) ) { - if ( bps[i] instanceof ICBreakpoint && isTargetBreakpoint( bps[i] ) && findCDIBreakpoint( bps[i] ) == null ) + if ( bps[i] instanceof ICAddressBreakpoint ) { - if ( bps[i] instanceof ICAddressBreakpoint ) + // disable address breakpoints to prevent the debugger to insert them prematurely + try + { + bps[i].setEnabled( false ); + } + catch( CoreException e ) { - // disable address breakpoints to prevent the debugger to insert them prematurely - try - { - bps[i].setEnabled( false ); - } - catch( CoreException e ) - { - } } - breakpointAdded( (ICBreakpoint)bps[i] ); - } - } - setRetryBreakpoints( false ); - } - } - - private boolean isTargetBreakpoint( IBreakpoint bp ) - { - IResource resource = bp.getMarker().getResource(); - if ( bp instanceof ICLineBreakpoint ) - { - if ( getSourceLocator() instanceof IAdaptable ) - { - ICSourceLocator sl = (ICSourceLocator)((IAdaptable)getSourceLocator()).getAdapter( ICSourceLocator.class ); - if ( sl != null ) - return sl.contains( resource ); - } - } - else - { - IProject project = resource.getProject(); - if ( project != null && project.exists() ) - { - if ( getSourceLocator() instanceof IAdaptable ) - { - ICSourceLocator sl = (ICSourceLocator)((IAdaptable)getSourceLocator()).getAdapter( ICSourceLocator.class ); - if ( sl != null ) - return sl.contains( project ); - } - else - { - if ( project.equals( getExecFile().getProject() ) ) - return true; - return CDebugUtils.isReferencedProject( getExecFile().getProject(), project ); } + breakpointAdded( (ICBreakpoint)bps[i] ); } } - return true; } protected void initializeRegisters() @@ -519,13 +466,7 @@ public class CDebugTarget extends CDebugElement { if ( !getConfiguration().supportsBreakpoints() ) return false; - return ( findCDIBreakpoint( breakpoint ) != null ); - } - - private boolean supportsAddressBreakpoint( ICAddressBreakpoint breakpoint ) - { - return ( getExecFile() != null && - getExecFile().getLocation().toOSString().equals( breakpoint.getMarker().getResource().getLocation().toOSString() ) ); + return ( breakpoint instanceof ICBreakpoint && getBreakpointManager().isCDIRegistered( (ICBreakpoint)breakpoint ) ); } /* (non-Javadoc) @@ -746,29 +687,17 @@ public class CDebugTarget extends CDebugElement */ public void breakpointAdded( IBreakpoint breakpoint ) { - if ( !isTargetBreakpoint( breakpoint ) || !isAvailable() ) + if ( !(breakpoint instanceof ICBreakpoint) || + !getBreakpointManager().isTargetBreakpoint( (ICBreakpoint)breakpoint ) || + !isAvailable() ) + return; + if ( breakpoint instanceof ICAddressBreakpoint && !getBreakpointManager().supportsAddressBreakpoint( (ICAddressBreakpoint)breakpoint ) ) return; if ( getConfiguration().supportsBreakpoints() ) { try { - if ( breakpoint instanceof ICFunctionBreakpoint ) - { - setFunctionBreakpoint( (ICFunctionBreakpoint)breakpoint ); - } - else if ( breakpoint instanceof ICAddressBreakpoint ) - { - if ( supportsAddressBreakpoint( (ICAddressBreakpoint)breakpoint ) ) - setAddressBreakpoint( (ICAddressBreakpoint)breakpoint ); - } - else if ( breakpoint instanceof ICLineBreakpoint ) - { - setLineBreakpoint( (ICLineBreakpoint)breakpoint ); - } - else if ( breakpoint instanceof ICWatchpoint ) - { - setWatchpoint( (ICWatchpoint)breakpoint ); - } + getBreakpointManager().setBreakpoint( (ICBreakpoint)breakpoint ); } catch( DebugException e ) { @@ -782,12 +711,13 @@ public class CDebugTarget extends CDebugElement */ public void breakpointRemoved( IBreakpoint breakpoint, IMarkerDelta delta ) { - if ( !isTargetBreakpoint( breakpoint ) || !isAvailable() ) + if ( !(breakpoint instanceof ICBreakpoint) || + !getBreakpointManager().isTargetBreakpoint( (ICBreakpoint)breakpoint ) || + !isAvailable() ) return; try { - if ( breakpoint instanceof CBreakpoint ) - removeBreakpoint( (CBreakpoint)breakpoint ); + getBreakpointManager().removeBreakpoint( (ICBreakpoint)breakpoint ); } catch( DebugException e ) { @@ -799,12 +729,14 @@ public class CDebugTarget extends CDebugElement */ public void breakpointChanged( IBreakpoint breakpoint, IMarkerDelta delta ) { - if ( !isTargetBreakpoint( breakpoint ) || !isAvailable() ) + if ( !(breakpoint instanceof ICBreakpoint) || + !getBreakpointManager().isTargetBreakpoint( (ICBreakpoint)breakpoint ) || + !isAvailable() || + delta == null ) return; try { - if ( breakpoint instanceof CBreakpoint && delta != null ) - changeBreakpointProperties( (CBreakpoint)breakpoint, delta ); + getBreakpointManager().changeBreakpointProperties( (ICBreakpoint)breakpoint, delta ); } catch( DebugException e ) { @@ -985,7 +917,7 @@ public class CDebugTarget extends CDebugElement if ( adapter.equals( IJumpToAddress.class ) ) return this; if ( adapter.equals( ICBreakpointManager.class ) ) - return this; + return getBreakpointManager(); if ( adapter.equals( DisassemblyManager.class ) ) return getDisassemblyManager(); if ( adapter.equals( ICSharedLibraryManager.class ) ) @@ -1018,30 +950,11 @@ public class CDebugTarget extends CDebugElement if ( source instanceof ICDISharedLibrary ) { getSharedLibraryManager().sharedLibraryLoaded( (ICDISharedLibrary)source ); - if ( ((ICDISharedLibrary)source).areSymbolsLoaded() ) - setRetryBreakpoints( true ); - } - if ( source instanceof ICDILocationBreakpoint ) - { - handleLocationBreakpointCreatedEvent( (ICDILocationBreakpoint)source ); - } - if ( source instanceof ICDIWatchpoint ) - { - handleWatchpointCreatedEvent( (ICDIWatchpoint)source ); } } else if ( event instanceof ICDISuspendedEvent ) { - boolean pass = true; -/* - if ( source instanceof ICDITarget && - ((ICDISuspendedEvent)event).getReason() instanceof ICDISharedLibraryEvent && - applyDeferredBreakpoints() ) - { - pass = handleInternalSuspendedEvent( (ICDISuspendedEvent)event ); - } -*/ - if ( pass && (source instanceof ICDITarget || source instanceof ICDIThread) ) + if ( source instanceof ICDITarget || source instanceof ICDIThread ) { handleSuspendedEvent( (ICDISuspendedEvent)event ); } @@ -1070,10 +983,6 @@ public class CDebugTarget extends CDebugElement { getSharedLibraryManager().sharedLibraryUnloaded( (ICDISharedLibrary)source ); } - if ( source instanceof ICDIBreakpoint ) - { - handleBreakpointDestroyedEvent( (ICDIBreakpoint)source ); - } } else if ( event instanceof ICDIDisconnectedEvent ) { @@ -1096,10 +1005,6 @@ public class CDebugTarget extends CDebugElement { getSignalManager().signalChanged( (ICDISignal)source ); } - if ( source instanceof ICDIBreakpoint ) - { - handleBreakpointChangedEvent( (ICDIBreakpoint)source ); - } } else if ( event instanceof ICDIRestartedEvent ) { @@ -1250,15 +1155,8 @@ public class CDebugTarget extends CDebugElement disposeRegisterManager(); disposeDisassemblyManager(); disposeSourceManager(); + disposeBreakpointManager(); removeAllExpressions(); - try - { - removeAllBreakpoints(); - } - catch( DebugException e ) - { - CDebugCorePlugin.log( e ); - } } /** @@ -1295,96 +1193,6 @@ public class CDebugTarget extends CDebugElement } /** - * Removes all breakpoints from this target. - * - */ - protected void removeAllBreakpoints() throws DebugException - { - ICDIBreakpoint[] cdiBreakpoints = (ICDIBreakpoint[])getBreakpoints().values().toArray( new ICDIBreakpoint[0] ); - ICDIBreakpointManager bm = getCDISession().getBreakpointManager(); - if ( cdiBreakpoints.length > 0 ) - { - try - { - bm.deleteBreakpoints( cdiBreakpoints ); - } - catch( CDIException e ) - { - logError( e ); - } - try - { - Iterator it = getBreakpoints().keySet().iterator(); - while( it.hasNext() ) - { - ((CBreakpoint)it.next()).decrementInstallCount(); - } - getBreakpoints().clear(); - } - catch( CoreException ce ) - { - logError( ce ); - } - } - } - - protected void removeBreakpoint( CBreakpoint breakpoint ) throws DebugException - { - ICDIBreakpoint cdiBreakpoint = findCDIBreakpoint( breakpoint ); - if ( cdiBreakpoint == null ) - return; - ICDIBreakpointManager bm = getCDISession().getBreakpointManager(); - try - { - bm.deleteBreakpoints( new ICDIBreakpoint[] { cdiBreakpoint } ); - getBreakpoints().remove( breakpoint ); - breakpoint.decrementInstallCount(); - } - catch( CoreException ce ) - { - requestFailed( "Operation failed. Reason: ", ce ); - } - catch( CDIException e ) - { - requestFailed( "Operation failed. Reason: ", e ); - } - } - - protected void changeBreakpointProperties( CBreakpoint breakpoint, IMarkerDelta delta ) throws DebugException - { - ICDIBreakpoint cdiBreakpoint = findCDIBreakpoint( breakpoint ); - if ( cdiBreakpoint == null ) - return; - ICDIBreakpointManager bm = getCDISession().getBreakpointManager(); - try - { - boolean enabled = breakpoint.isEnabled(); - boolean oldEnabled = delta.getAttribute( IBreakpoint.ENABLED, true ); - int ignoreCount = breakpoint.getIgnoreCount(); - int oldIgnoreCount = delta.getAttribute( ICBreakpoint.IGNORE_COUNT, 0 ); - String condition = breakpoint.getCondition(); - String oldCondition = delta.getAttribute( ICBreakpoint.CONDITION, "" ); - if ( enabled != oldEnabled ) - { - cdiBreakpoint.setEnabled( enabled ); - } - if ( ignoreCount != oldIgnoreCount || !condition.equals( oldCondition ) ) - { - ICDICondition cdiCondition = bm.createCondition( ignoreCount, condition ); - cdiBreakpoint.setCondition( cdiCondition ); - } - } - catch( CoreException ce ) - { - requestFailed( "Operation failed. Reason: ", ce ); - } - catch( CDIException e ) - { - requestFailed( "Operation failed. Reason: ", e ); - } - } - - /** * Creates, adds and returns a thread for the given underlying * CDI thread. A creation event is fired for the thread. * Returns <code>null</code> if during the creation of the thread @@ -1618,16 +1426,19 @@ public class CDebugTarget extends CDebugElement private void handleWatchpointScope( ICDIWatchpointScope ws ) { - CBreakpoint watchpoint = (CBreakpoint)findBreakpoint( ws.getWatchpoint() ); - try - { - removeBreakpoint( watchpoint ); - } - catch( DebugException e ) + ICBreakpoint watchpoint = getBreakpointManager().getBreakpoint( ws.getWatchpoint() ); + if ( watchpoint != null ) { - CDebugCorePlugin.log( e ); + try + { + getBreakpointManager().removeBreakpoint( watchpoint ); + } + catch( DebugException e ) + { + CDebugCorePlugin.log( e ); + } + fireSuspendEvent( DebugEvent.BREAKPOINT ); } - fireSuspendEvent( DebugEvent.BREAKPOINT ); } private void handleSuspendedBySignal( ICDISignalReceived signal ) @@ -1718,177 +1529,6 @@ public class CDebugTarget extends CDebugElement } } - private void handleLocationBreakpointCreatedEvent( final ICDILocationBreakpoint breakpoint ) - { - Runnable runnable = new Runnable() - { - public void run() - { - doHandleLocationBreakpointCreatedEvent( breakpoint ); - } - }; - CDebugCorePlugin.getDefault().asyncExec( runnable ); - } - - protected void doHandleLocationBreakpointCreatedEvent( final ICDILocationBreakpoint cdiBreakpoint ) - { - if ( cdiBreakpoint.isTemporary() || getBreakpoints().containsValue( cdiBreakpoint ) ) - return; - try - { - if ( cdiBreakpoint.getLocation().getFile() != null && cdiBreakpoint.getLocation().getFile().length() > 0 ) - { - if ( getSourceLocator() instanceof IAdaptable && ((IAdaptable)getSourceLocator()).getAdapter( ICSourceLocator.class ) != null ) - { - Object sourceElement = ((ICSourceLocator)((IAdaptable)getSourceLocator()).getAdapter( ICSourceLocator.class )).findSourceElement( cdiBreakpoint.getLocation().getFile() ); - if ( sourceElement != null && sourceElement instanceof IFile ) - { - createLineBreakpoint( (IFile)sourceElement, cdiBreakpoint ); - } - else if ( cdiBreakpoint.getLocation().getAddress() > 0 ) - { - createAddressBreakpoint( cdiBreakpoint ); - } - } - } - else if ( cdiBreakpoint.getLocation().getAddress() > 0 ) - { - createAddressBreakpoint( cdiBreakpoint ); - } - } - catch( CDIException e ) - { - } - catch( CoreException e ) - { - } - } - - private void createLineBreakpoint( IFile file, ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException - { - ICLineBreakpoint breakpoint = CDebugModel.createLineBreakpoint( file, - cdiBreakpoint.getLocation().getLineNumber(), - cdiBreakpoint.isEnabled(), - cdiBreakpoint.getCondition().getIgnoreCount(), - cdiBreakpoint.getCondition().getExpression(), - false ); - getBreakpoints().put( breakpoint, cdiBreakpoint ); - ((CBreakpoint)breakpoint).register( true ); - } - - private void createAddressBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException - { - ICAddressBreakpoint breakpoint = CDebugModel.createAddressBreakpoint( getExecFile(), - cdiBreakpoint.getLocation().getAddress(), - cdiBreakpoint.isEnabled(), - cdiBreakpoint.getCondition().getIgnoreCount(), - cdiBreakpoint.getCondition().getExpression(), - false ); - getBreakpoints().put( breakpoint, cdiBreakpoint ); - ((CBreakpoint)breakpoint).register( true ); - } - - private void handleWatchpointCreatedEvent( final ICDIWatchpoint watchpoint ) - { - Runnable runnable = new Runnable() - { - public void run() - { - doHandleWatchpointCreatedEvent( watchpoint ); - } - - }; - CDebugCorePlugin.getDefault().asyncExec( runnable ); - } - - protected void doHandleWatchpointCreatedEvent( ICDIWatchpoint cdiWatchpoint ) - { - if ( getBreakpoints().containsValue( cdiWatchpoint ) ) - return; - try - { - ICWatchpoint watchpoint = CDebugModel.createWatchpoint( getExecFile().getProject(), - cdiWatchpoint.isWriteType(), - cdiWatchpoint.isReadType(), - cdiWatchpoint.getWatchExpression(), - cdiWatchpoint.isEnabled(), - cdiWatchpoint.getCondition().getIgnoreCount(), - cdiWatchpoint.getCondition().getExpression(), - false ); - getBreakpoints().put( watchpoint, cdiWatchpoint ); - ((CBreakpoint)watchpoint).register( true ); - } - catch( CDIException e ) - { - } - catch( CoreException e ) - { - } - } - - private void handleBreakpointDestroyedEvent( final ICDIBreakpoint breakpoint ) - { - Runnable runnable = new Runnable() - { - public void run() - { - doHandleBreakpointDestroyedEvent( breakpoint ); - } - - }; - CDebugCorePlugin.getDefault().asyncExec( runnable ); - } - - protected void doHandleBreakpointDestroyedEvent( ICDIBreakpoint cdiBreakpoint ) - { - IBreakpoint breakpoint = findBreakpoint( cdiBreakpoint ); - if ( breakpoint != null ) - { - try - { - DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true ); - } - catch( CoreException e ) - { - } - } - } - - private void handleBreakpointChangedEvent( final ICDIBreakpoint breakpoint ) - { - Runnable runnable = new Runnable() - { - public void run() - { - doHandleBreakpointChangedEvent( breakpoint ); - } - - }; - CDebugCorePlugin.getDefault().asyncExec( runnable ); - } - - protected void doHandleBreakpointChangedEvent( ICDIBreakpoint cdiBreakpoint ) - { - IBreakpoint breakpoint = findBreakpoint( cdiBreakpoint ); - if ( breakpoint instanceof ICBreakpoint ) - { - try - { - Map attributes = breakpoint.getMarker().getAttributes(); - attributes.put( ICBreakpoint.ENABLED, new Boolean( cdiBreakpoint.isEnabled() ) ); - attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( cdiBreakpoint.getCondition().getIgnoreCount() ) ); - attributes.put( ICBreakpoint.CONDITION, cdiBreakpoint.getCondition().getExpression() ); - breakpoint.getMarker().setAttributes( attributes ); - } - catch( CDIException e ) - { - } - catch( CoreException e ) - { - } - } - } - /** * Finds and returns the model thread for the associated CDI thread, * or <code>null</code> if not found. @@ -2000,26 +1640,6 @@ public class CDebugTarget extends CDebugElement } /** - * Returns the map of breakpoints installed in this debug target. - * - * @return map of installed breakpoints - */ - protected HashMap getBreakpoints() - { - return fBreakpoints; - } - - /** - * Sets the map of breakpoints installed in this debug target. - * - * @param breakpoints breakpoints map - */ - private void initializeBreakpointMap( HashMap breakpoints ) - { - fBreakpoints = breakpoints; - } - - /** * Returns the debug configuration of this target. * * @return the debug configuration of this target @@ -2039,187 +1659,6 @@ public class CDebugTarget extends CDebugElement fConfig = config; } - private void setLineBreakpoint( ICLineBreakpoint breakpoint ) throws DebugException - { - try - { - ICDIBreakpoint cdiBreakpoint = (ICDIBreakpoint)getBreakpoints().get( breakpoint ); - if ( cdiBreakpoint == null ) - { - cdiBreakpoint = setLineBreakpoint0( breakpoint ); - } - ((CBreakpoint)breakpoint).incrementInstallCount(); - if ( !breakpoint.isEnabled() ) - { - cdiBreakpoint.setEnabled( false ); - } - setBreakpointCondition( breakpoint ); - } - catch( CoreException ce ) - { - requestFailed( "Operation failed. Reason: ", ce ); - } - catch( CDIException e ) - { - requestFailed( "Operation failed. Reason: ", e ); - } - } - - private synchronized ICDIBreakpoint setLineBreakpoint0( ICLineBreakpoint breakpoint ) throws CDIException, CoreException - { - ICDIBreakpointManager bm = getCDISession().getBreakpointManager(); - ICDILocation location = bm.createLocation( breakpoint.getMarker().getResource().getLocation().lastSegment(), null, breakpoint.getLineNumber() ); - ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null ); - getBreakpoints().put( breakpoint, cdiBreakpoint ); - return cdiBreakpoint; - } - - private void setAddressBreakpoint( ICAddressBreakpoint breakpoint ) throws DebugException - { - try - { - ICDIBreakpoint cdiBreakpoint = (ICDIBreakpoint)getBreakpoints().get( breakpoint ); - if ( cdiBreakpoint == null ) - { - cdiBreakpoint = setAddressBreakpoint0( breakpoint ); - } - ((CBreakpoint)breakpoint).incrementInstallCount(); - if ( !breakpoint.isEnabled() ) - { - cdiBreakpoint.setEnabled( false ); - } - setBreakpointCondition( breakpoint ); - } - catch( CoreException ce ) - { - requestFailed( "Operation failed. Reason: ", ce ); - } - catch( CDIException e ) - { - requestFailed( "Operation failed. Reason: ", e ); - } - catch( NumberFormatException e ) - { - requestFailed( "Operation failed. Reason: ", e ); - } - } - - private synchronized ICDIBreakpoint setAddressBreakpoint0( ICAddressBreakpoint breakpoint ) throws CDIException, CoreException - { - ICDIBreakpointManager bm = getCDISession().getBreakpointManager(); - ICDILocation location = bm.createLocation( Long.parseLong( breakpoint.getAddress() ) ); - ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null ); - getBreakpoints().put( breakpoint, cdiBreakpoint ); - return cdiBreakpoint; - } - - private void setFunctionBreakpoint( ICFunctionBreakpoint breakpoint ) throws DebugException - { - try - { - ICDIBreakpoint cdiBreakpoint = (ICDIBreakpoint)getBreakpoints().get( breakpoint ); - if ( cdiBreakpoint == null ) - { - cdiBreakpoint = setFunctionBreakpoint0( breakpoint ); - } - ((CBreakpoint)breakpoint).incrementInstallCount(); - if ( !breakpoint.isEnabled() ) - { - cdiBreakpoint.setEnabled( false ); - } - setBreakpointCondition( breakpoint ); - } - catch( CoreException ce ) - { - requestFailed( "Operation failed. Reason: ", ce ); - } - catch( CDIException e ) - { - requestFailed( "Operation failed. Reason: ", e ); - } - catch( NumberFormatException e ) - { - requestFailed( "Operation failed. Reason: ", e ); - } - } - - private synchronized ICDIBreakpoint setFunctionBreakpoint0( ICFunctionBreakpoint breakpoint ) throws CDIException, CoreException - { - ICDIBreakpointManager bm = getCDISession().getBreakpointManager(); - String function = breakpoint.getFunction(); - String fileName = ( function != null && function.indexOf( "::" ) == -1 ) ? breakpoint.getFileName() : null; - ICDILocation location = bm.createLocation( fileName, function, -1 ); - ICDIBreakpoint cdiBreakpoint = bm.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null ); - getBreakpoints().put( breakpoint, cdiBreakpoint ); - return cdiBreakpoint; - } - - private void setWatchpoint( ICWatchpoint watchpoint ) throws DebugException - { - try - { - ICDIWatchpoint cdiWatchpoint = (ICDIWatchpoint)getBreakpoints().get( watchpoint ); - if ( cdiWatchpoint == null ) - { - cdiWatchpoint = setWatchpoint0( watchpoint ); - } - ((CBreakpoint)watchpoint).incrementInstallCount(); - if ( !watchpoint.isEnabled() ) - { - cdiWatchpoint.setEnabled( false ); - } - } - catch( CoreException ce ) - { - requestFailed( "Operation failed. Reason: ", ce ); - } - catch( CDIException e ) - { - requestFailed( "Operation failed. Reason: ", e ); - } - } - - private synchronized ICDIWatchpoint setWatchpoint0( ICWatchpoint watchpoint ) throws CDIException, CoreException - { - ICDIBreakpointManager bm = getCDISession().getBreakpointManager(); - int accessType = 0; - accessType |= ( watchpoint.isWriteType() ) ? ICDIWatchpoint.WRITE : 0; - accessType |= ( watchpoint.isReadType() ) ? ICDIWatchpoint.READ : 0; - String expression = watchpoint.getExpression(); - ICDIWatchpoint cdiWatchpoint = bm.setWatchpoint( ICDIBreakpoint.REGULAR, accessType, expression, null ); - getBreakpoints().put( watchpoint, cdiWatchpoint ); - return cdiWatchpoint; - } - - private void setBreakpointCondition( ICBreakpoint breakpoint ) throws CoreException, CDIException - { - ICDIBreakpoint cdiBreakpoint = findCDIBreakpoint( breakpoint ); - if ( cdiBreakpoint == null ) - return; - ICDIBreakpointManager bm = getCDISession().getBreakpointManager(); - ICDICondition condition = bm.createCondition( breakpoint.getIgnoreCount(), breakpoint.getCondition() ); - cdiBreakpoint.setCondition( condition ); - } - - private ICDIBreakpoint findCDIBreakpoint( IBreakpoint breakpoint ) - { - return (ICDIBreakpoint)getBreakpoints().get( breakpoint ); - } - - private IBreakpoint findBreakpoint( ICDIBreakpoint cdiBreakpoint ) - { - if ( cdiBreakpoint == null ) - return null; - Iterator it = getBreakpoints().keySet().iterator(); - while( it.hasNext() ) - { - IBreakpoint breakpoint = (IBreakpoint)it.next(); - if ( cdiBreakpoint.equals( getBreakpoints().get( breakpoint ) ) ) - return breakpoint; - } - return null; - } - protected boolean supportsExpressionEvaluation() { return getConfiguration().supportsExpressionEvaluation(); @@ -2349,15 +1788,14 @@ public class CDebugTarget extends CDebugElement public void setCurrentThread( IThread thread ) throws DebugException { if ( !isSuspended() || !isAvailable() || thread == null || !(thread instanceof CThread) ) - { return; - } try { CThread oldThread = (CThread)getCurrentThread(); - if ( !oldThread.equals( thread ) ) + if ( !thread.equals( oldThread ) ) { - oldThread.setCurrent( false ); + if ( oldThread != null ) + oldThread.setCurrent( false ); getCDITarget().setCurrentThread( ((CThread)thread).getCDIThread() ); ((CThread)thread).setCurrent( true ); } @@ -2428,7 +1866,7 @@ public class CDebugTarget extends CDebugElement return fMemoryManager; } - private void disposeMemoryManager() + protected void disposeMemoryManager() { getMemoryManager().dispose(); } @@ -2590,29 +2028,6 @@ public class CDebugTarget extends CDebugElement fDisassemblyManager.dispose(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.ICBreakpointManager#getBreakpointAddress(IBreakpoint) - */ - public long getBreakpointAddress( IBreakpoint breakpoint ) - { - ICDIBreakpoint cdiBreakpoint = findCDIBreakpoint( breakpoint ); - if ( cdiBreakpoint != null && cdiBreakpoint instanceof ICDILocationBreakpoint ) - { - try - { - ICDILocation location = ((ICDILocationBreakpoint)cdiBreakpoint).getLocation(); - if ( location != null ) - { - return location.getAddress(); - } - } - catch( CDIException e ) - { - } - } - return 0; - } - /** * @see org.eclipse.cdt.debug.core.model.IRunToAddress#canRunToAddress(long) */ @@ -2640,22 +2055,6 @@ public class CDebugTarget extends CDebugElement } } - private boolean getRetryBreakpoints() - { - return fSetBreakpoints; - } - - protected void setRetryBreakpoints( boolean retry ) - { - fSetBreakpoints = retry; - } - - public void setDeferredBreakpoints() - { - setRetryBreakpoints( true ); - setBreakpoints(); - } - /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.IResumeWithoutSignal#canResumeWithoutSignal() */ @@ -2791,15 +2190,7 @@ public class CDebugTarget extends CDebugElement { ICDIBreakpoint cdiBreakpoint = ((ICDIBreakpointHit)info).getBreakpoint(); if ( cdiBreakpoint != null ) - { - IBreakpoint breakpoint = findBreakpoint( cdiBreakpoint ); - if ( breakpoint instanceof ICLineBreakpoint ) - { - IResource resource = ((ICLineBreakpoint)breakpoint).getMarker().getResource(); - if ( resource instanceof IFile ) - return (IFile)resource; - } - } + return getBreakpointManager().getCDIBreakpointFile( cdiBreakpoint ); } return null; } @@ -2830,18 +2221,19 @@ public class CDebugTarget extends CDebugElement setRunningInfo( info ); } -/* - private boolean applyDeferredBreakpoints() + protected CBreakpointManager getBreakpointManager() { - boolean result = false; - try - { - result = getLaunch().getLaunchConfiguration().getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_DEFERRED_BREAKPOINTS, false ); - } - catch( CoreException e ) - { - } - return result; + return fBreakpointManager; + } + + protected void setBreakpointManager( CBreakpointManager manager ) + { + fBreakpointManager = manager; + } + + protected void disposeBreakpointManager() + { + if ( getBreakpointManager() != null ) + getBreakpointManager().dispose(); } -*/ } diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index 8a22c707a6f..08ba339971e 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -1,3 +1,53 @@ +2003-11-06 Alain Magloire + + * src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java: + Small fix for the defferred breakpoint support. + +2003-11-06 Alain Magloire + + Patch from Ashish Karkare: + A CDT 1.2 patch that enables setting of + serial line speed in the launch configuration when debugging remote targets. + + * src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java + New attribute definition DEV_SPEED. + + * src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java + Extracts serial speed value and passes it to createCSession(). + + +2003-10-29 Alain Magloire + + Deal with PR 45533 + + Make a preferenc for Timeout and use it when launching + the ICDebugger session, when way wait for for gdb + to say "ready" by returning the prompt. + + * src/org/eclipse/cdt/debug/mi/core/MISession.java + * src/org/eclipse/cdt/debug/mi/core/MIPlugin.java + * src/org/eclipse/cdt/debug/mi/core/IMIConstants.java + +2003-10-17 Alain Magloire + + Put the framework to deal with deferred breakpoint. + + * src/org/eclipse/cdt/debug/mi/core/cdi/event/ResumeEvent.java + Deal with MIRunningEvent.RETURN. + * src/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java + Check if MIBreakpoint is null first. + * src/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java + Check if MIWathchpoint is null first. + * src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java + Implement Deferred Breakpoint + * src/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java + Implement Deferred Breakpoint + * src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java + Enable deferredBreakpoint. + * src/org/eclipse/cdt/debug/mi/core/CygwinDebugger.java + Enable deferredBreakpoint. + + 2003-10-07 Mikhail Khodjaiants All methods of 'IRuntimeOptions' should throw CDI exceptions in case of failure. diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java index 19cacfa0f46..53f86a78e10 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java @@ -33,11 +33,21 @@ public class CygwinGDBDebugger extends GDBDebugger { protected void initializeLibraries(ILaunchConfiguration config, Session session) throws CDIException { try { - ICDISharedLibraryManager mgr = session.getSharedLibraryManager(); - if (mgr instanceof SharedLibraryManager) { + ICDISharedLibraryManager manager = session.getSharedLibraryManager(); + if (manager instanceof SharedLibraryManager) { + SharedLibraryManager mgr = (SharedLibraryManager)manager; boolean stopOnSolibEvents = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, false); try { - ((SharedLibraryManager)mgr).setStopOnSolibEvents(stopOnSolibEvents); + mgr.setStopOnSolibEvents(stopOnSolibEvents); + // By default, we provide with the capability of deferred breakpoints + // And we set setStopOnSolib events for them(but they should not see the dll events ). + // + // If the user explicitly set stopOnSolibEvents well it probably + // means that they wanted to see those events so do no do deferred breakpoints. + if (!stopOnSolibEvents) { + mgr.setStopOnSolibEvents(true); + mgr.setDeferredBreakpoint(true); + } } catch (CDIException e) { // Ignore this error // it seems to be a real problem on many gdb platform @@ -45,11 +55,11 @@ public class CygwinGDBDebugger extends GDBDebugger { } List p = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST); if (p.size() > 0) { - String[] oldPaths = mgr.getSharedLibraryPaths(); + String[] oldPaths = manager.getSharedLibraryPaths(); String[] paths = new String[oldPaths.length + p.size()]; System.arraycopy((String[])p.toArray(new String[p.size()]), 0, paths, 0, p.size()); System.arraycopy(oldPaths, 0, paths, p.size(), oldPaths.length); - mgr.setSharedLibraryPaths(paths); + manager.setSharedLibraryPaths(paths); } } catch (CoreException e) { throw new CDIException("Error initializing shared library options: " + e.getMessage()); @@ -77,6 +87,7 @@ public class CygwinGDBDebugger extends GDBDebugger { // We ignore this exception, for example // on GNU/Linux the new-console is an error. } + initializeLibraries(config, session); return session; } @@ -88,6 +99,7 @@ public class CygwinGDBDebugger extends GDBDebugger { Session session = (Session) super.createAttachSession(config, exe, pid); session.getMISession().setCommandFactory(commandFactory); + initializeLibraries(config, session); return session; } @@ -99,6 +111,7 @@ public class CygwinGDBDebugger extends GDBDebugger { Session session = (Session) super.createCoreSession(config, exe, corefile); session.getMISession().setCommandFactory(commandFactory); + initializeLibraries(config, session); return session; } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java index 0ddf8889e20..5cede42edc8 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java @@ -24,13 +24,24 @@ public class GDBDebugger implements ICDebugger { protected void initializeLibraries(ILaunchConfiguration config, Session session) throws CDIException { try { - ICDISharedLibraryManager mgr = session.getSharedLibraryManager(); - if (mgr instanceof SharedLibraryManager) { + ICDISharedLibraryManager manager = session.getSharedLibraryManager(); + if (manager instanceof SharedLibraryManager) { + SharedLibraryManager mgr = (SharedLibraryManager)manager; boolean autolib = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, false); boolean stopOnSolibEvents = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, false); try { - ((SharedLibraryManager)mgr).setAutoLoadSymbols(autolib); - ((SharedLibraryManager)mgr).setStopOnSolibEvents(stopOnSolibEvents); + mgr.setAutoLoadSymbols(autolib); + mgr.setStopOnSolibEvents(stopOnSolibEvents); + // The idea is that if the user set autolib, by default + // we provide with the capability of deferred breakpoints + // And we set setStopOnSolib events for them(but they should not see those things. + // + // If the user explicitly set stopOnSolibEvents well it probably + // means that they wanted to see those events so do no do deferred breakpoints. + if (autolib && !stopOnSolibEvents) { + mgr.setDeferredBreakpoint(true); + mgr.setStopOnSolibEvents(true); + } } catch (CDIException e) { // Ignore this error // it seems to be a real problem on many gdb platform @@ -38,11 +49,11 @@ public class GDBDebugger implements ICDebugger { } List p = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST); if (p.size() > 0) { - String[] oldPaths = mgr.getSharedLibraryPaths(); + String[] oldPaths = manager.getSharedLibraryPaths(); String[] paths = new String[oldPaths.length + p.size()]; System.arraycopy((String[])p.toArray(new String[p.size()]), 0, paths, 0, p.size()); System.arraycopy(oldPaths, 0, paths, p.size(), oldPaths.length); - mgr.setSharedLibraryPaths(paths); + manager.setSharedLibraryPaths(paths); } } catch (CoreException e) { throw new CDIException("Error initializing shared library options: " + e.getMessage()); diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java index 2d13e85defb..7ab4bd63bbc 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java @@ -22,9 +22,14 @@ import org.eclipse.cdt.debug.core.cdi.ICDISession; import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager; import org.eclipse.cdt.debug.mi.core.cdi.Session; import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager; +import org.eclipse.cdt.debug.mi.core.command.CommandFactory; +import org.eclipse.cdt.debug.mi.core.command.MIGDBSet; +import org.eclipse.cdt.debug.mi.core.command.MITargetSelect; +import org.eclipse.cdt.debug.mi.core.output.MIInfo; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Preferences; import org.eclipse.debug.core.ILaunchConfiguration; public class GDBServerDebugger implements ICDebugger { @@ -54,17 +59,40 @@ public class GDBServerDebugger implements ICDebugger { try { String gdb = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); File cwd = exe.getProject().getLocation().toFile(); - String remote; + String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit"); + Session session = null; if (config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false)) { - remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, "invalid"); + String remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, "invalid"); remote += ":"; remote += config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, "invalid"); + String[] args = new String[] {"remote", remote}; + session = (Session)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), 0, args, cwd, gdbinit); } else { - remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "invalid"); + MIPlugin plugin = MIPlugin.getDefault(); + Preferences prefs = plugin.getPluginPreferences(); + int launchTimeout = prefs.getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT); + + String remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "invalid"); + String remoteBaud = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "invalid"); + session = (Session)MIPlugin.getDefault().createCSession(gdb, (File)null, cwd, gdbinit); + MISession miSession = session.getMISession(); + CommandFactory factory = miSession.getCommandFactory(); + MIGDBSet setRemoteBaud = factory.createMIGDBSet(new String[]{"remotebaud", remoteBaud}); + // Set serial line parameters + miSession.postCommand(setRemoteBaud, launchTimeout); + MIInfo info = setRemoteBaud.getMIInfo(); + if (info == null) { + session.terminate(); + throw new MIException ("Can not set Baud"); + } + MITargetSelect select = factory.createMITargetSelect(new String[] {"remote", remote}); + miSession.postCommand(select, launchTimeout); + select.getMIInfo(); + if (info == null) { + session.terminate(); + throw new MIException ("No answer"); + } } - String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit"); - String[] args = new String[] {"remote", remote}; - Session session = (Session)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), 0, args, cwd, gdbinit); initializeLibraries(config, session); return session; } catch (IOException e) { diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java index 23280a68452..7c6f976a631 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IGDBServerMILaunchConfigurationConstants.java @@ -21,4 +21,5 @@ public interface IGDBServerMILaunchConfigurationConstants extends IMILaunchConfi public static final String ATTR_HOST = MIPlugin.getUniqueIdentifier() + ".HOST"; //$NON-NLS-1$ public static final String ATTR_PORT = MIPlugin.getUniqueIdentifier() + ".PORT"; //$NON-NLS-1$ public static final String ATTR_DEV = MIPlugin.getUniqueIdentifier() + ".DEV"; //$NON-NLS-1$ + public static final String ATTR_DEV_SPEED = MIPlugin.getUniqueIdentifier() + ".DEV_SPEED"; //$NON-NLS-1$ } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IMIConstants.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IMIConstants.java index 5f672d4e89b..46c559832d0 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IMIConstants.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/IMIConstants.java @@ -22,6 +22,16 @@ public interface IMIConstants * Preference key for default MI request timeout value. */ public static final String PREF_REQUEST_TIMEOUT = PLUGIN_ID + ".PREF_REQUEST_TIMEOUT"; //$NON-NLS-1$ + + /** + * Preference key for default MI launch request timeout value. + */ + public static final String PREF_REQUEST_LAUNCH_TIMEOUT = PLUGIN_ID + ".PREF_REQUEST_LAUNCH_TIMEOUT"; //$NON-NLS-1$ + + /** + * The default MI request timeout when no preference is set. + */ + public static final int DEF_REQUEST_LAUNCH_TIMEOUT = 30000; /** * The default MI request timeout when no preference is set. diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java index 425f28af4eb..0fc77d809e5 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java @@ -71,8 +71,8 @@ public class MIPlugin extends Plugin { * @throws MIException * @return MISession */ - public MISession createMISession(Process process, PTY pty, int timeout, int type) throws MIException { - return new MISession(process, pty, timeout, type); + public MISession createMISession(Process process, PTY pty, int timeout, int type, int launchTimeout) throws MIException { + return new MISession(process, pty, timeout, type, launchTimeout); } /** @@ -87,7 +87,8 @@ public class MIPlugin extends Plugin { MIPlugin plugin = getDefault(); Preferences prefs = plugin.getPluginPreferences(); int timeout = prefs.getInt(IMIConstants.PREF_REQUEST_TIMEOUT); - return createMISession(process, pty, timeout, type); + int launchTimeout = prefs.getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT); + return createMISession(process, pty, timeout, type, launchTimeout); } /** @@ -344,10 +345,15 @@ public class MIPlugin extends Plugin { syncStartup.start(); synchronized (pgdb) { - int timeout = getAdjustedTimeout(program); + MIPlugin plugin = getDefault(); + Preferences prefs = plugin.getPluginPreferences(); + int launchTimeout = prefs.getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT); + if (launchTimeout <= 0) { + launchTimeout = getAdjustedTimeout(program); + } while (syncStartup.isAlive()) { try { - pgdb.wait(timeout); + pgdb.wait(launchTimeout); break; } catch (InterruptedException e) { } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java index f2261add0b2..67cb613ab26 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java @@ -89,7 +89,7 @@ public class MISession extends Observable { * @param timeout time in milliseconds to wait for command response. * @param type the type of debugin session. */ - public MISession(Process process, PTY pty, int timeout, int type) throws MIException { + public MISession(Process process, PTY pty, int timeout, int type, int launchTimeout) throws MIException { gdbProcess = process; inChannel = process.getInputStream(); @@ -142,15 +142,15 @@ public class MISession extends Observable { // Like confirmation and screen size. MIGDBSet confirm = new MIGDBSet(new String[]{"confirm", "off"}); - postCommand(confirm); + postCommand(confirm, launchTimeout); confirm.getMIInfo(); MIGDBSet width = new MIGDBSet(new String[]{"width", "0"}); - postCommand(width); + postCommand(width, launchTimeout); confirm.getMIInfo(); MIGDBSet height = new MIGDBSet(new String[]{"height", "0"}); - postCommand(height); + postCommand(height, launchTimeout); confirm.getMIInfo(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/RxThread.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/RxThread.java index 7445f0e3f58..93bac3fb00f 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/RxThread.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/RxThread.java @@ -12,9 +12,11 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.cdt.debug.mi.core.command.Command; +import org.eclipse.cdt.debug.mi.core.command.MIExecContinue; import org.eclipse.cdt.debug.mi.core.command.MIExecFinish; import org.eclipse.cdt.debug.mi.core.command.MIExecNext; import org.eclipse.cdt.debug.mi.core.command.MIExecNextInstruction; +import org.eclipse.cdt.debug.mi.core.command.MIExecReturn; import org.eclipse.cdt.debug.mi.core.command.MIExecStep; import org.eclipse.cdt.debug.mi.core.command.MIExecStepInstruction; import org.eclipse.cdt.debug.mi.core.command.MIExecUntil; @@ -146,6 +148,10 @@ public class RxThread extends Thread { type = MIRunningEvent.UNTIL; } else if (cmd instanceof MIExecFinish) { type = MIRunningEvent.FINISH; + } else if (cmd instanceof MIExecReturn) { + type = MIRunningEvent.RETURN; + } else if (cmd instanceof MIExecContinue) { + type = MIRunningEvent.CONTINUE; } else { type = MIRunningEvent.CONTINUE; } @@ -199,6 +205,7 @@ public class RxThread extends Thread { void processMIOOBRecord(MIOOBRecord oob, List list) { if (oob instanceof MIAsyncRecord) { processMIOOBRecord((MIAsyncRecord) oob, list); + oobList.clear(); } else if (oob instanceof MIStreamRecord) { processMIOOBRecord((MIStreamRecord) oob); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java index 4693d476542..a641d53793f 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java @@ -14,6 +14,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager; import org.eclipse.cdt.debug.core.cdi.ICDICatchEvent; import org.eclipse.cdt.debug.core.cdi.ICDICondition; import org.eclipse.cdt.debug.core.cdi.ICDILocation; +import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDICatchpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint; @@ -24,6 +25,7 @@ import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint; import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.cdi.model.Watchpoint; +import org.eclipse.cdt.debug.mi.core.command.Command; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIBreakAfter; import org.eclipse.cdt.debug.mi.core.command.MIBreakCondition; @@ -49,12 +51,14 @@ import org.eclipse.cdt.debug.mi.core.output.MIInfo; public class BreakpointManager extends SessionObject implements ICDIBreakpointManager { List breakList; + List deferredList; boolean allowInterrupt; boolean autoupdate; public BreakpointManager(Session session) { super(session); breakList = Collections.synchronizedList(new ArrayList()); + deferredList = Collections.synchronizedList(new ArrayList()); allowInterrupt = true; autoupdate = false; } @@ -107,7 +111,11 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa // Disable events. if (ctarget.isRunning()) { EventManager mgr = (EventManager)session.getEventManager(); - int lastToken = ctarget.getLastExecutionToken(); + Command cmd = ctarget.getLastExecutionCommand(); + int lastToken = 0; + if (cmd != null) { + lastToken = cmd.getToken(); + } mgr.disableEventToken(lastToken); ctarget.suspend(); shouldRestart = true; @@ -260,6 +268,8 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa // Fire ChangedEvent bp.setMIBreakpoint(newMIBreakpoints[i]); eventList.add(new MIBreakpointChangedEvent(no)); + } else { + eventList.add(new MIBreakpointCreatedEvent(no)); } } else { // add the new breakpoint and fire CreatedEvent @@ -313,6 +323,14 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa deleteBreakpoints(new ICDIBreakpoint[] { breakpoint }); } + public void deleteFromDeferredList(Breakpoint bkpt) { + deferredList.remove(bkpt); + } + + public void addToBreakpointList(Breakpoint bkpt) { + breakList.add(bkpt); + } + /** * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#deleteBreakpoints(ICDIBreakpoint[]) */ @@ -359,6 +377,10 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa return (ICDIBreakpoint[]) breakList.toArray(new ICDIBreakpoint[0]); } + public ICDIBreakpoint[] getDeferredBreakpoints() throws CDIException { + return (ICDIBreakpoint[]) deferredList.toArray(new ICDIBreakpoint[0]); + } + /** * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#setCatchpoint(int, ICDICatchEvent, String, ICDICondition, boolean) */ @@ -372,18 +394,58 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa */ public ICDILocationBreakpoint setLocationBreakpoint(int type, ICDILocation location, ICDICondition condition, String threadId) throws CDIException { + return setLocationBreakpoint(type, location, condition, threadId, false); + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#setLocationBreakpoint(int, ICDILocation, ICDICondition, boolean, String) + */ + public ICDILocationBreakpoint setLocationBreakpoint(int type, ICDILocation location, + ICDICondition condition, String threadId, boolean deferred) throws CDIException { + + Breakpoint bkpt = new Breakpoint(this, type, location, condition, threadId); + try { + setLocationBreakpoint(bkpt); + breakList.add(bkpt); + + // Fire a created Event. + Session session = (Session)getSession(); + MISession mi = session.getMISession(); + mi.fireEvent(new MIBreakpointCreatedEvent(bkpt.getMIBreakpoint().getNumber())); + } catch (CDIException e) { + if (!deferred) { + throw e; + } else { + Session session = (Session)getSession(); + ICDISharedLibraryManager sharedMgr = session.getSharedLibraryManager(); + if (sharedMgr instanceof SharedLibraryManager) { + SharedLibraryManager mgr = (SharedLibraryManager)sharedMgr; + if (mgr.isDeferredBreakpoint()) { + deferredList.add(bkpt); + } else { + throw e; + } + } + } + } + return bkpt; + } - boolean hardware = (type == ICDIBreakpoint.HARDWARE); - boolean temporary = (type == ICDIBreakpoint.TEMPORARY); + MIBreakInsert createMIBreakInsert(Breakpoint bkpt) throws CDIException { + boolean hardware = bkpt.isHardware(); + boolean temporary = bkpt.isTemporary(); String exprCond = null; int ignoreCount = 0; StringBuffer line = new StringBuffer(); - if (condition != null) { + + if (bkpt.getCondition() != null) { + ICDICondition condition = bkpt.getCondition(); exprCond = condition.getExpression(); ignoreCount = condition.getIgnoreCount(); } - if (location != null) { + if (bkpt.getLocation() != null) { + ICDILocation location = bkpt.getLocation(); String file = location.getFile(); String function = location.getFunction(); if (file != null && file.length() > 0) { @@ -401,13 +463,15 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa line.append('*').append(location.getAddress()); } } + Session session = (Session)getSession(); + CommandFactory factory = session.getMISession().getCommandFactory(); + return factory.createMIBreakInsert(temporary, hardware, exprCond, ignoreCount, line.toString()); + } + public void setLocationBreakpoint (Breakpoint bkpt) throws CDIException { Session session = (Session)getSession(); boolean state = suspendInferior(session.getCurrentTarget()); - CommandFactory factory = session.getMISession().getCommandFactory(); - MIBreakInsert breakInsert = - factory.createMIBreakInsert( temporary, hardware, exprCond, - ignoreCount, line.toString()); + MIBreakInsert breakInsert = createMIBreakInsert(bkpt); MIBreakpoint[] points = null; try { session.getMISession().postCommand(breakInsert); @@ -424,13 +488,8 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa } finally { resumeInferior(session.getCurrentTarget(), state); } - Breakpoint bkpt = new Breakpoint(this, points[0]); - breakList.add(bkpt); - // Fire a created Event. - MISession mi = session.getMISession(); - mi.fireEvent(new MIBreakpointCreatedEvent(bkpt.getMIBreakpoint().getNumber())); - return bkpt; + bkpt.setMIBreakpoint(points[0]); } /** diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java index cb3597df71d..3d9eb00ccd8 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java @@ -23,7 +23,12 @@ import org.eclipse.cdt.debug.core.cdi.ICDISourceManager; import org.eclipse.cdt.debug.core.cdi.ICDIVariableManager; import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener; +import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; +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.ICDIThread; +import org.eclipse.cdt.debug.mi.core.MIException; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.event.ChangedEvent; import org.eclipse.cdt.debug.mi.core.cdi.event.CreatedEvent; import org.eclipse.cdt.debug.mi.core.cdi.event.DestroyedEvent; @@ -32,8 +37,17 @@ import org.eclipse.cdt.debug.mi.core.cdi.event.ExitedEvent; import org.eclipse.cdt.debug.mi.core.cdi.event.MemoryChangedEvent; import org.eclipse.cdt.debug.mi.core.cdi.event.ResumedEvent; import org.eclipse.cdt.debug.mi.core.cdi.event.SuspendedEvent; +import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint; import org.eclipse.cdt.debug.mi.core.cdi.model.MemoryBlock; import org.eclipse.cdt.debug.mi.core.cdi.model.Target; +import org.eclipse.cdt.debug.mi.core.cdi.model.Thread; +import org.eclipse.cdt.debug.mi.core.command.Command; +import org.eclipse.cdt.debug.mi.core.command.CommandFactory; +import org.eclipse.cdt.debug.mi.core.command.MIExecContinue; +import org.eclipse.cdt.debug.mi.core.command.MIExecFinish; +import org.eclipse.cdt.debug.mi.core.command.MIStackInfoDepth; +import org.eclipse.cdt.debug.mi.core.command.MIStackSelectFrame; +import org.eclipse.cdt.debug.mi.core.command.MIThreadSelect; import org.eclipse.cdt.debug.mi.core.event.MIBreakpointChangedEvent; import org.eclipse.cdt.debug.mi.core.event.MIBreakpointCreatedEvent; import org.eclipse.cdt.debug.mi.core.event.MIBreakpointDeletedEvent; @@ -52,6 +66,7 @@ import org.eclipse.cdt.debug.mi.core.event.MIRegisterCreatedEvent; import org.eclipse.cdt.debug.mi.core.event.MIRunningEvent; import org.eclipse.cdt.debug.mi.core.event.MISharedLibChangedEvent; import org.eclipse.cdt.debug.mi.core.event.MISharedLibCreatedEvent; +import org.eclipse.cdt.debug.mi.core.event.MISharedLibEvent; import org.eclipse.cdt.debug.mi.core.event.MISharedLibUnloadedEvent; import org.eclipse.cdt.debug.mi.core.event.MISignalChangedEvent; import org.eclipse.cdt.debug.mi.core.event.MIStoppedEvent; @@ -60,6 +75,8 @@ import org.eclipse.cdt.debug.mi.core.event.MIThreadExitEvent; import org.eclipse.cdt.debug.mi.core.event.MIVarChangedEvent; import org.eclipse.cdt.debug.mi.core.event.MIVarCreatedEvent; import org.eclipse.cdt.debug.mi.core.event.MIVarDeletedEvent; +import org.eclipse.cdt.debug.mi.core.output.MIInfo; +import org.eclipse.cdt.debug.mi.core.output.MIStackInfoDepthInfo; /** */ @@ -67,6 +84,8 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs List list = Collections.synchronizedList(new ArrayList(1)); List tokenList = new ArrayList(1); + MIRunningEvent lastRunningEvent; + Command lastUserCommand = null; /** * Process the event from MI, do any state work on the CDI, @@ -80,10 +99,12 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs if (ignoreEventToken(miEvent.getToken())) { // Ignore the event if it is on the ignore list. } else if (miEvent instanceof MIStoppedEvent) { - processSuspendedEvent((MIStoppedEvent)miEvent); - cdiList.add(new SuspendedEvent(session, miEvent)); + if (processSuspendedEvent((MIStoppedEvent)miEvent)) { + cdiList.add(new SuspendedEvent(session, miEvent)); + } } else if (miEvent instanceof MIRunningEvent) { - cdiList.add(new ResumedEvent(session, (MIRunningEvent)miEvent)); + if (processRunningEvent((MIRunningEvent)miEvent)) + cdiList.add(new ResumedEvent(session, (MIRunningEvent)miEvent)); } else if (miEvent instanceof MIChangedEvent) { if (miEvent instanceof MIVarChangedEvent) { cdiList.add(new ChangedEvent(session, (MIVarChangedEvent)miEvent)); @@ -238,24 +259,36 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs * Alse the variable and the memory needs to be updated and events * fired for changes. */ - void processSuspendedEvent(MIStoppedEvent stopped) { + boolean processSuspendedEvent(MIStoppedEvent stopped) { Session session = (Session)getSession(); ICDITarget currentTarget = session.getCurrentTarget(); - // Set the current thread. + + if (processSharedLibEvent(stopped)) { + // Event was consumed by the shared lib processing bailout + return false; + } + int threadId = threadId = stopped.getThreadId(); if (currentTarget instanceof Target) { - ((Target)currentTarget).updateState(threadId); + Target cTarget = (Target)currentTarget; + cTarget.updateState(threadId); + try { + cTarget.getCurrentThread().getCurrentStackFrame(); + } catch (CDIException e1) { + //e1.printStackTrace(); + } } + // Update the managers. // For the Variable/Expression Managers call only the updateManager. ICDIVariableManager varMgr = session.getVariableManager(); ICDIExpressionManager expMgr = session.getExpressionManager(); ICDIRegisterManager regMgr = session.getRegisterManager(); ICDIMemoryManager memMgr = session.getMemoryManager(); - ICDISharedLibraryManager libMgr = session.getSharedLibraryManager(); ICDIBreakpointManager bpMgr = session.getBreakpointManager(); ICDISignalManager sigMgr = session.getSignalManager(); ICDISourceManager srcMgr = session.getSourceManager(); + ICDISharedLibraryManager libMgr = session.getSharedLibraryManager(); try { if (varMgr.isAutoUpdate()) { varMgr.update(); @@ -269,29 +302,190 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs if (memMgr.isAutoUpdate()) { memMgr.update(); } - if (libMgr.isAutoUpdate()) { - libMgr.update(); - } if (bpMgr.isAutoUpdate()) { bpMgr.update(); } if (sigMgr.isAutoUpdate()) { sigMgr.update(); } + if (libMgr.isAutoUpdate()) { + libMgr.update(); + } if (srcMgr.isAutoUpdate()) { srcMgr.update(); } } catch (CDIException e) { //System.out.println(e); } + return true; + } + + /** + * If the deferredBreakpoint processing is set + * catch the shared-lib-event go to the last known + * stackframe and try to finish. + * Save the last user command and issue it again. + * @param stopped + * @return + */ + boolean processSharedLibEvent(MIStoppedEvent stopped) { + Session session = (Session)getSession(); + MISession mi = session.getMISession(); + + ICDITarget currentTarget = session.getCurrentTarget(); + ICDISharedLibraryManager libMgr = session.getSharedLibraryManager(); + SharedLibraryManager mgr = null; + + if (libMgr instanceof SharedLibraryManager) { + mgr = (SharedLibraryManager)libMgr; + } + + if (mgr !=null && mgr.isDeferredBreakpoint()) { + if (stopped instanceof MISharedLibEvent) { + // Check if we have a new library loaded + List eventList = null; + try { + eventList = mgr.updateState(); + } catch (CDIException e3) { + eventList = Collections.EMPTY_LIST; + } + // A new Libraries loaded, try to set the breakpoints. + if (eventList.size() > 0) { + ICDIBreakpointManager manager = session.getBreakpointManager(); + if (manager instanceof BreakpointManager) { + BreakpointManager bpMgr = (BreakpointManager)manager; + ICDIBreakpoint bpoints[] = null; + try { + bpoints = bpMgr.getDeferredBreakpoints(); + } catch (CDIException e) { + bpoints = new ICDIBreakpoint[0]; + } + for (int i = 0; i < bpoints.length; i++) { + if (bpoints[i] instanceof Breakpoint) { + Breakpoint bkpt = (Breakpoint)bpoints[i]; + try { + bpMgr.setLocationBreakpoint(bkpt); + bpMgr.deleteFromDeferredList(bkpt); + bpMgr.addToBreakpointList(bkpt); + eventList.add(new MIBreakpointCreatedEvent(bkpt.getMIBreakpoint().getNumber())); + } catch (CDIException e) { + } + } + } + } + MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]); + mi.fireEvents(events); + } + CommandFactory factory = mi.getCommandFactory(); + int type = (lastRunningEvent == null) ? MIRunningEvent.CONTINUE : lastRunningEvent.getType(); + if (lastUserCommand == null) { + switch (type) { + case MIRunningEvent.NEXT: + lastUserCommand = factory.createMIExecNext(); + break; + case MIRunningEvent.NEXTI: + lastUserCommand = factory.createMIExecNextInstruction(); + break; + case MIRunningEvent.STEP: + lastUserCommand = factory.createMIExecStep(); + break; + case MIRunningEvent.STEPI: + lastUserCommand = factory.createMIExecStepInstruction(); + break; + case MIRunningEvent.FINISH: + lastUserCommand = factory.createMIExecFinish(); + break; + case MIRunningEvent.RETURN: + lastUserCommand = factory.createMIExecReturn(); + break; + case MIRunningEvent.CONTINUE: { + MIExecContinue cont = factory.createMIExecContinue(); + try { + mi.postCommand(cont); + MIInfo info = cont.getMIInfo(); + if (info == null) { + // throw new CDIException("Target is not responding"); + } + } catch (MIException e) { + // throw new MI2CDIException(e); + } + return true; // for the continue bailout early no need to the stuff below + } + } + } + + int miLevel = 0; + int tid = 0; + ICDIThread currentThread = null; + try { + currentThread = currentTarget.getCurrentThread(); + } catch (CDIException e1) { + } + if (currentThread instanceof Thread) { + tid = ((Thread)currentThread).getId(); + } + ICDIStackFrame frame = null; + try { + frame = currentThread.getCurrentStackFrame(); + } catch (CDIException e2) { + } + int count = 0; + try { + MIStackInfoDepth depth = factory.createMIStackInfoDepth(); + mi.postCommand(depth); + MIStackInfoDepthInfo info = depth.getMIStackInfoDepthInfo(); + if (info == null) { + //throw new CDIException("No answer"); + } + count = info.getDepth(); + } catch (MIException e) { + //throw new MI2CDIException(e); + //System.out.println(e); + } + if (frame != null) { + // Fortunately the ICDIStackFrame store the level + // in ascending level the higher the stack the higher the level + // GDB does the opposite the highest stack is 0. + // This allow us to do some calculation, in figure out the + // level of the old stack. The -1 is because gdb level is zero-based + miLevel = count - frame.getLevel() - 1; + } + if (tid > 0) { + MIThreadSelect selectThread = factory.createMIThreadSelect(tid); + try { + mi.postCommand(selectThread); + } catch (MIException e) { + } + } + if (miLevel >= 0) { + MIStackSelectFrame selectFrame = factory.createMIStackSelectFrame(miLevel); + MIExecFinish finish = factory.createMIExecFinish(); + try { + mi.postCommand(selectFrame); + mi.postCommand(finish); + } catch (MIException e) { + } + } + return true; + } else if (lastUserCommand != null) { + Command cmd = lastUserCommand; + lastUserCommand = null; + try { + mi.postCommand(cmd); + } catch (MIException e) { + } + return true; + } + } + return false; } /** * Do any processing of before a running event. */ - void processRunningEvent() { - //Target target = getCSession().getCTarget(); - //target.clearState(); + boolean processRunningEvent(MIRunningEvent running) { + lastRunningEvent = running; + return true; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java index 5318dd6f363..532200c8ca3 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java @@ -7,6 +7,7 @@ package org.eclipse.cdt.debug.mi.core.cdi; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.eclipse.cdt.debug.core.cdi.CDIException; @@ -41,6 +42,7 @@ public class SharedLibraryManager extends SessionObject implements ICDISharedLib List sharedList; boolean autoupdate; + boolean isDeferred; public SharedLibraryManager (Session session) { super(session); @@ -71,13 +73,21 @@ public class SharedLibraryManager extends SessionObject implements ICDISharedLib */ public void update() throws CDIException { Session session = (Session)getSession(); + MISession mi = session.getMISession(); + List eventList = updateState(); + MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]); + mi.fireEvents(events); + } + + public List updateState() throws CDIException { + Session session = (Session)getSession(); ICDIConfiguration conf = session.getConfiguration(); if (!conf.supportsSharedLibrary()) { - return; // Bail out early; + return Collections.EMPTY_LIST; // Bail out early; } MIShared[] miLibs = getMIShareds(); - List eventList = new ArrayList(miLibs.length); + ArrayList eventList = new ArrayList(miLibs.length); for (int i = 0; i < miLibs.length; i++) { ICDISharedLibrary sharedlib = getSharedLibrary(miLibs[i].getName()); if (sharedlib != null) { @@ -107,9 +117,7 @@ public class SharedLibraryManager extends SessionObject implements ICDISharedLib eventList.add(new MISharedLibUnloadedEvent(oldlibs[i].getFileName())); } } - MISession mi = session.getMISession(); - MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]); - mi.fireEvents(events); + return eventList; } public boolean hasSharedLibChanged(ICDISharedLibrary lib, MIShared miLib) { @@ -133,6 +141,14 @@ public class SharedLibraryManager extends SessionObject implements ICDISharedLib return null; } + public void setDeferredBreakpoint (boolean set) { + isDeferred = set; + } + + public boolean isDeferredBreakpoint() { + return isDeferred; + } + /** * @see org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager#setSharedLibraryPaths(String[]) */ diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/event/ResumedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/event/ResumedEvent.java index a962213b301..60d6cbe0419 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/event/ResumedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/event/ResumedEvent.java @@ -58,13 +58,11 @@ public class ResumedEvent implements ICDIResumedEvent { cdiType = ICDIResumedEvent.STEP_INTO_INSTRUCTION; break; + case MIRunningEvent.RETURN: case MIRunningEvent.FINISH: cdiType = ICDIResumedEvent.STEP_RETURN; break; - //MIRunningEvent.UNTIL: - //cdiType = ICDIResumedEvent.STEP_UNTIL; - //break; } return cdiType; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java index f4ae937862d..9eb28458d57 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java @@ -7,6 +7,7 @@ package org.eclipse.cdt.debug.mi.core.cdi.model; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDICondition; import org.eclipse.cdt.debug.core.cdi.ICDILocation; +import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint; import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager; import org.eclipse.cdt.debug.mi.core.cdi.Condition; @@ -21,6 +22,17 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint { ICDICondition condition; MIBreakpoint miBreakpoint; BreakpointManager mgr; + int type; + String tid; + + public Breakpoint(BreakpointManager m, int kind, ICDILocation loc, ICDICondition cond, String threadId) { + super(m.getSession().getCurrentTarget()); + mgr = m; + type = kind; + location = loc; + condition = cond; + tid = threadId; + } public Breakpoint(BreakpointManager m, MIBreakpoint miBreak) { super(m.getSession().getCurrentTarget()); @@ -39,13 +51,17 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint { condition = null; } + public boolean isDeferred() { + return (miBreakpoint == null); + } + /** * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#getCondition() */ public ICDICondition getCondition() throws CDIException { if (condition == null) { - condition = new Condition(miBreakpoint.getIgnoreCount(), - miBreakpoint.getCondition()); + if (miBreakpoint != null) + condition = new Condition(miBreakpoint.getIgnoreCount(), miBreakpoint.getCondition()); } return condition; } @@ -54,28 +70,36 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint { * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#getThreadId() */ public String getThreadId() throws CDIException { - return miBreakpoint.getThreadId(); + if (miBreakpoint != null) + return miBreakpoint.getThreadId(); + return tid; } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#isEnabled() */ public boolean isEnabled() throws CDIException { - return miBreakpoint.isEnabled(); + if (miBreakpoint != null) + return miBreakpoint.isEnabled(); + return false; } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#isHardware() */ public boolean isHardware() { - return miBreakpoint.isHardware(); + if (miBreakpoint != null) + return miBreakpoint.isHardware(); + return (type == ICDIBreakpoint.HARDWARE); } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#isTemporary() */ public boolean isTemporary() { - return miBreakpoint.isTemporary(); + if (miBreakpoint != null) + return miBreakpoint.isTemporary(); + return (type == ICDIBreakpoint.TEMPORARY); } /** @@ -104,11 +128,16 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint { */ public ICDILocation getLocation() throws CDIException { if (location == null) { - location = new Location (miBreakpoint.getFile(), + if (miBreakpoint != null) + location = new Location (miBreakpoint.getFile(), miBreakpoint.getFunction(), miBreakpoint.getLine(), miBreakpoint.getAddress()); } return location; } + + public void setLocation(ICDILocation loc) { + location = loc; + } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java index 60a7e4945bd..be5872b325c 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java @@ -58,7 +58,7 @@ public class StackFrame extends CObject implements ICDIStackFrame { level = l; } - MIFrame getMIFrame() { + public MIFrame getMIFrame() { return frame; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java index f68ed19d824..cb8538311de 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException; import org.eclipse.cdt.debug.mi.core.cdi.RegisterManager; import org.eclipse.cdt.debug.mi.core.cdi.Session; import org.eclipse.cdt.debug.mi.core.cdi.VariableManager; +import org.eclipse.cdt.debug.mi.core.command.Command; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIDataEvaluateExpression; import org.eclipse.cdt.debug.mi.core.command.MIExecContinue; @@ -52,7 +53,7 @@ public class Target implements ICDITarget { Thread[] noThreads = new Thread[0]; Thread[] currentThreads; int currentThreadId; - int lastExecutionToken; + Command lastExecutionCommand; public Target(Session s) { session = s; @@ -63,8 +64,8 @@ public class Target implements ICDITarget { return session; } - public int getLastExecutionToken() { - return lastExecutionToken; + public Command getLastExecutionCommand() { + return lastExecutionCommand; } /** @@ -308,6 +309,7 @@ public class Target implements ICDITarget { MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecRun run = factory.createMIExecRun(new String[0]); + lastExecutionCommand = run; try { mi.postCommand(run); MIInfo info = run.getMIInfo(); @@ -317,7 +319,6 @@ public class Target implements ICDITarget { } catch (MIException e) { throw new MI2CDIException(e); } - lastExecutionToken = run.getToken(); } /** @@ -330,6 +331,7 @@ public class Target implements ICDITarget { } else if (mi.getMIInferior().isSuspended()) { CommandFactory factory = mi.getCommandFactory(); MIExecContinue cont = factory.createMIExecContinue(); + lastExecutionCommand = cont; try { mi.postCommand(cont); MIInfo info = cont.getMIInfo(); @@ -339,7 +341,6 @@ public class Target implements ICDITarget { } catch (MIException e) { throw new MI2CDIException(e); } - lastExecutionToken = cont.getToken(); } else if (mi.getMIInferior().isTerminated()) { restart(); } else { @@ -354,6 +355,7 @@ public class Target implements ICDITarget { MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecStep step = factory.createMIExecStep(); + lastExecutionCommand = step; try { mi.postCommand(step); MIInfo info = step.getMIInfo(); @@ -363,7 +365,6 @@ public class Target implements ICDITarget { } catch (MIException e) { throw new MI2CDIException(e); } - lastExecutionToken = step.getToken(); } /** @@ -373,6 +374,7 @@ public class Target implements ICDITarget { MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecStepInstruction stepi = factory.createMIExecStepInstruction(); + lastExecutionCommand = stepi; try { mi.postCommand(stepi); MIInfo info = stepi.getMIInfo(); @@ -382,7 +384,6 @@ public class Target implements ICDITarget { } catch (MIException e) { throw new MI2CDIException(e); } - lastExecutionToken = stepi.getToken(); } /** @@ -392,6 +393,7 @@ public class Target implements ICDITarget { MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecNext next = factory.createMIExecNext(); + lastExecutionCommand = next; try { mi.postCommand(next); MIInfo info = next.getMIInfo(); @@ -401,7 +403,6 @@ public class Target implements ICDITarget { } catch (MIException e) { throw new MI2CDIException(e); } - lastExecutionToken = next.getToken(); } /** @@ -411,6 +412,7 @@ public class Target implements ICDITarget { MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecNextInstruction nexti = factory.createMIExecNextInstruction(); + lastExecutionCommand = nexti; try { mi.postCommand(nexti); MIInfo info = nexti.getMIInfo(); @@ -420,7 +422,6 @@ public class Target implements ICDITarget { } catch (MIException e) { throw new MI2CDIException(e); } - lastExecutionToken = nexti.getToken(); } /** @@ -447,6 +448,7 @@ public class Target implements ICDITarget { MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecFinish finish = factory.createMIExecFinish(); + lastExecutionCommand = finish; try { mi.postCommand(finish); MIInfo info = finish.getMIInfo(); @@ -456,7 +458,6 @@ public class Target implements ICDITarget { } catch (MIException e) { throw new MI2CDIException(e); } - lastExecutionToken = finish.getToken(); } /** @@ -465,6 +466,7 @@ public class Target implements ICDITarget { MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecReturn ret = factory.createMIExecReturn(); + lastExecutionCommand = ret; try { mi.postCommand(ret); MIInfo info = ret.getMIInfo(); @@ -474,15 +476,12 @@ public class Target implements ICDITarget { } catch (MIException e) { throw new MI2CDIException(e); } - lastExecutionToken = ret.getToken(); } /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#suspend() */ public void suspend() throws CDIException { - // Send the interrupt an sync for 10 seconds. - // for an answer. The waiting time is arbitrary. MISession mi = session.getMISession(); try { mi.getMIInferior().interrupt(); @@ -529,6 +528,7 @@ public class Target implements ICDITarget { loc = "*" + location.getAddress(); } MIExecUntil until = factory.createMIExecUntil(loc); + lastExecutionCommand = until; try { mi.postCommand(until); MIInfo info = until.getMIInfo(); @@ -538,7 +538,6 @@ public class Target implements ICDITarget { } catch (MIException e) { throw new MI2CDIException(e); } - lastExecutionToken = until.getToken(); } @@ -557,6 +556,7 @@ public class Target implements ICDITarget { loc = "*" + location.getAddress(); } MIJump jump = factory.createMIJump(loc); + lastExecutionCommand = jump; try { mi.postCommand(jump); MIInfo info = jump.getMIInfo(); @@ -566,7 +566,6 @@ public class Target implements ICDITarget { } catch (MIException e) { throw new MI2CDIException(e); } - lastExecutionToken = jump.getToken(); } /** diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java index 20ad608bf8a..ecd3ba20c18 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java @@ -40,7 +40,7 @@ public class Thread extends CObject implements ICDIThread { id = threadId; } - int getId() { + public int getId() { return id; } @@ -53,6 +53,13 @@ public class Thread extends CObject implements ICDIThread { return Integer.toString(id); } + public void updateState() { + try { + getCurrentStackFrame(); + } catch (CDIException e) { + } + } + public ICDIStackFrame getCurrentStackFrame() throws CDIException { if (currentFrame == null) { ICDIStackFrame[] frames = getStackFrames(0, 0); diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java index c47ce15d4b0..7ab814166de 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java @@ -6,6 +6,7 @@ package org.eclipse.cdt.debug.mi.core.cdi.model; import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.ICDICondition; import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint; import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager; import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint; @@ -14,6 +15,15 @@ import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint; */ public class Watchpoint extends Breakpoint implements ICDIWatchpoint { + int watchType; + String what; + + public Watchpoint(BreakpointManager m, String expression, int type, int wType, ICDICondition cond) { + super(m, type, null, cond, ""); + watchType = wType; + what = expression; + } + public Watchpoint(BreakpointManager m, MIBreakpoint miBreak) { super(m, miBreak); } @@ -22,21 +32,30 @@ public class Watchpoint extends Breakpoint implements ICDIWatchpoint { * @see org.eclipse.cdt.debug.core.cdi.ICDIWatchpoint#getWatchExpression() */ public String getWatchExpression() throws CDIException { - return getMIBreakpoint().getWhat(); + MIBreakpoint miPoint = getMIBreakpoint(); + if (miPoint != null) + return getMIBreakpoint().getWhat(); + return what; } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIWatchpoint#isReadType() */ public boolean isReadType() { - return getMIBreakpoint().isReadWatchpoint() || getMIBreakpoint().isAccessWatchpoint(); + MIBreakpoint miPoint = getMIBreakpoint(); + if (miPoint != null) + return getMIBreakpoint().isReadWatchpoint() || getMIBreakpoint().isAccessWatchpoint(); + return ((watchType & ICDIWatchpoint.READ) == ICDIWatchpoint.READ); } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIWatchpoint#isWriteType() */ public boolean isWriteType() { - return getMIBreakpoint().isAccessWatchpoint() || getMIBreakpoint().isWriteWatchpoint(); + MIBreakpoint miPoint = getMIBreakpoint(); + if (miPoint != null) + return getMIBreakpoint().isAccessWatchpoint() || getMIBreakpoint().isWriteWatchpoint(); + return ((watchType & ICDIWatchpoint.WRITE) == ICDIWatchpoint.WRITE); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java index 442a0275be9..d5b5167d810 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java @@ -20,6 +20,7 @@ public class MIRunningEvent extends MIEvent { public static final int STEPI = 4; public static final int FINISH = 5; public static final int UNTIL = 6; + public static final int RETURN = 7; int type; diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIBreakpoint.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIBreakpoint.java index ac8d674add1..3da45ea10c6 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIBreakpoint.java @@ -72,6 +72,10 @@ public class MIBreakpoint { return number; } + public void setNumber(int num) { + number = num; + } + public String getType() { return type; } @@ -84,7 +88,7 @@ public class MIBreakpoint { return isWpt; } - public void setWatcpoint(boolean w) { + public void setWatchpoint(boolean w) { isWpt = w; } diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index dd27a359f85..ce919b617c9 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,8 @@ +2003-11-05 Mikhail Khodjaiants
+ The argument type of the 'getBreakpointAddress' of 'ICBreakpointManager' is changed from
+ 'ICBreakpoint' to 'ICBreakpointManager'.
+ * DisassemblyMarkerAnnotationModel.java
+
2003-11-03 Mikhail Khodjaiants
Fix for PR 45957: Memory view: last column does not show updates.
* MemoryPresentation.java
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java index 0c715b2b635..d6bf7f6f494 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyMarkerAnnotationModel.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import org.eclipse.cdt.debug.core.ICBreakpointManager; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; +import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage; import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint; @@ -240,16 +241,19 @@ public class DisassemblyMarkerAnnotationModel extends AbstractMarkerAnnotationMo private Position createPositionFromLineBreakpoint( IMarker marker ) { - if ( fStorage == null ) - return null; - IDebugTarget target = fStorage.getDebugTarget(); - if ( target != null && target.getAdapter( ICBreakpointManager.class ) != null ) + if ( fStorage != null ) { - ICBreakpointManager bm = (ICBreakpointManager)target.getAdapter( ICBreakpointManager.class ); - long address = bm.getBreakpointAddress( DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker ) ); - if ( address != 0 ) - { - return createPositionFromAddress( address ); + IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker ); + if ( breakpoint instanceof ICBreakpoint ) + { + IDebugTarget target = fStorage.getDebugTarget(); + if ( target != null && target.getAdapter( ICBreakpointManager.class ) != null ) + { + ICBreakpointManager bm = (ICBreakpointManager)target.getAdapter( ICBreakpointManager.class ); + long address = bm.getBreakpointAddress( (ICBreakpoint)breakpoint ); + if ( address != 0 ) + return createPositionFromAddress( address ); + } } } return null; |