diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 01b62f78a49..28338f6c069 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,9 @@ +2003-01-21 Mikhail Khodjaiants + Retry to set breakpoints if shared library's symbols are loaded. + * CDebugTarget.java + * CThread.java + * CSharedLibraryManager.java + 2003-01-20 Mikhail Khodjaiants Fix for the 'Show breakpoints supported by selected target' action. * CDebugTarget.java 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 51c5ff9f57f..d8b455a6d96 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 @@ -67,6 +67,7 @@ public class CSharedLibraryManager implements ICSharedLibraryManager CSharedLibrary library = find( cdiLibrary ); if ( library != null ) { + ((CDebugTarget)getDebugTarget()).setRetryBreakpoints( true ); library.fireChangeEvent( DebugEvent.STATE ); } } 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 64811618103..55ca4db91aa 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 @@ -236,6 +236,12 @@ 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; + /** * Constructor for CDebugTarget. * @param target @@ -257,7 +263,7 @@ public class CDebugTarget extends CDebugElement setName( name ); setProcesses( debuggeeProcess, debuggerProcess ); setCDITarget( cdiTarget ); - setBreakpoints( new HashMap( 5 ) ); + initializeBreakpoints( new HashMap( 5 ) ); setExecFile( file ); setConfiguration( cdiTarget.getSession().getConfiguration() ); fSupportsTerminate = allowsTerminate & getConfiguration().supportsTerminate(); @@ -279,7 +285,7 @@ public class CDebugTarget extends CDebugElement { initializeState(); setSourceSearchPath(); - initializeBreakpoints(); + setBreakpoints(); initializeRegisters(); initializeMemoryManager(); getLaunch().addDebugTarget( this ); @@ -310,17 +316,21 @@ public class CDebugTarget extends CDebugElement * the breakpoint manager. * */ - protected void initializeBreakpoints() + protected void setBreakpoints() { - IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); - manager.addBreakpointListener( this ); - IBreakpoint[] bps = (IBreakpoint[])manager.getBreakpoints( CDebugModel.getPluginIdentifier() ); - for ( int i = 0; i < bps.length; i++ ) + if ( getRetryBreakpoints() ) { - if ( bps[i] instanceof ICBreakpoint ) + IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); + manager.addBreakpointListener( this ); + IBreakpoint[] bps = (IBreakpoint[])manager.getBreakpoints( CDebugModel.getPluginIdentifier() ); + for ( int i = 0; i < bps.length; i++ ) { - breakpointAdded( (ICBreakpoint)bps[i] ); + if ( bps[i] instanceof ICBreakpoint && findCDIBreakpoint( bps[i] ) == null ) + { + breakpointAdded( (ICBreakpoint)bps[i] ); + } } + setRetryBreakpoints( false ); } } @@ -528,6 +538,7 @@ public class CDebugTarget extends CDebugElement { if ( !isSuspended() ) return; + setBreakpoints(); try { getCDITarget().resume(); @@ -887,6 +898,8 @@ public class CDebugTarget extends CDebugElement if ( source instanceof ICDISharedLibrary ) { getSharedLibraryManager().sharedLibraryLoaded( (ICDISharedLibrary)source ); + if ( ((ICDISharedLibrary)source).areSymbolsLoaded() ) + setRetryBreakpoints( true ); } } else if ( event instanceof ICDISuspendedEvent ) @@ -1575,7 +1588,7 @@ public class CDebugTarget extends CDebugElement * * @param breakpoints breakpoints map */ - private void setBreakpoints( HashMap breakpoints ) + private void initializeBreakpoints( HashMap breakpoints ) { fBreakpoints = breakpoints; } @@ -1834,6 +1847,7 @@ public class CDebugTarget extends CDebugElement { if ( !canRunToLine( resource, lineNumber ) ) return; + setBreakpoints(); ICDILocation location = getCDISession().getBreakpointManager().createLocation( resource.getLocation().lastSegment(), null, lineNumber ); try { @@ -2139,6 +2153,7 @@ public class CDebugTarget extends CDebugElement { if ( !canRunToAddress( address ) ) return; + setBreakpoints(); ICDILocation location = getCDISession().getBreakpointManager().createLocation( address ); try { @@ -2149,4 +2164,14 @@ public class CDebugTarget extends CDebugElement targetRequestFailed( e.toString(), e ); } } + + private boolean getRetryBreakpoints() + { + return fSetBreakpoints; + } + + public void setRetryBreakpoints( boolean retry ) + { + fSetBreakpoints = retry; + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CThread.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CThread.java index dd3f3b137c3..a39f941ab53 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CThread.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CThread.java @@ -585,6 +585,7 @@ public class CThread extends CDebugElement { if ( !canStepInto() ) return; + ((CDebugTarget)getDebugTarget()).setBreakpoints(); try { if ( getRealSourceMode() == ISourceMode.MODE_SOURCE ) @@ -609,6 +610,7 @@ public class CThread extends CDebugElement { if ( !canStepOver() ) return; + ((CDebugTarget)getDebugTarget()).setBreakpoints(); try { if ( getRealSourceMode() == ISourceMode.MODE_SOURCE ) @@ -633,6 +635,7 @@ public class CThread extends CDebugElement { if ( !canStepReturn() ) return; + ((CDebugTarget)getDebugTarget()).setBreakpoints(); try { getCDIThread().stepReturn(); @@ -834,6 +837,7 @@ public class CThread extends CDebugElement { if ( !canStepIntoInstruction() ) return; + ((CDebugTarget)getDebugTarget()).setBreakpoints(); try { getCDIThread().stepIntoInstruction(); @@ -851,6 +855,7 @@ public class CThread extends CDebugElement { if ( !canStepOverInstruction() ) return; + ((CDebugTarget)getDebugTarget()).setBreakpoints(); try { getCDIThread().stepOverInstruction();