From fbc9d83a6517ede4eeca27064b85f67cfe87503a Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Wed, 16 Jun 2004 20:17:55 +0000 Subject: [PATCH] Added support for the "Skip Breakpoints" and "Skip breakpoints during a "Run To Line" operation. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 7 +++++ .../cdt/debug/core/model/IRunToAddress.java | 2 +- .../cdt/debug/core/model/IRunToLine.java | 4 +-- .../internal/core/CBreakpointManager.java | 27 +++++++++++++++++-- .../internal/core/model/CDebugTarget.java | 21 ++++++++++++--- debug/org.eclipse.cdt.debug.ui/ChangeLog | 4 +++ .../internal/ui/actions/RunToLineAdapter.java | 12 ++++++--- 7 files changed, 64 insertions(+), 13 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 20a3d71518c..158adda1a9a 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,10 @@ +2004-06-16 Mikhail Khodjaiants + Added support for the "Skip Breakpoints" and "Skip breakpoints during a "Run To Line" operation. + * IRunToAddress.java + * IRunToLine.java + * CBreakpointManager.java + * CDebugTarget.java + 2004-06-12 Mikhail Khodjaiants "CUpdateManager" extends "Observable" to support "Auto-Refresh" toggle actions. * CRegisterManager.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToAddress.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToAddress.java index d58753c998e..040fa5260bc 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToAddress.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToAddress.java @@ -29,5 +29,5 @@ public interface IRunToAddress { * * @exception DebugException on failure. Reasons include: */ - public void runToAddress( long address ) throws DebugException; + public void runToAddress( long address, boolean skipBreakpoints ) throws DebugException; } \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToLine.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToLine.java index b50e12182be..ce57fcbd86f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToLine.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToLine.java @@ -30,7 +30,7 @@ public interface IRunToLine { * * @exception DebugException on failure. Reasons include: */ - public void runToLine( IFile file, int lineNumber ) throws DebugException; + public void runToLine( IFile file, int lineNumber, boolean skipBreakpoints ) throws DebugException; /** * Returns whether this operation is currently available for this file and line number. @@ -44,5 +44,5 @@ public interface IRunToLine { * * @exception DebugException on failure. Reasons include: */ - public void runToLine( String fileName, int lineNumber ) throws DebugException; + public void runToLine( String fileName, int lineNumber, boolean skipBreakpoints ) throws DebugException; } \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java index e33316d434d..cac0344e256 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java @@ -125,6 +125,8 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent private CDebugTarget fDebugTarget; private BreakpointMap fMap; + + private boolean fSkipBreakpoint= false; public CBreakpointManager( CDebugTarget target ) { super(); @@ -353,6 +355,14 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent doHandleLocationBreakpointCreatedEvent( (ICDILocationBreakpoint)cdiBreakpoint ); else if ( cdiBreakpoint instanceof ICDIWatchpoint ) doHandleWatchpointCreatedEvent( (ICDIWatchpoint)cdiBreakpoint ); + if ( !cdiBreakpoint.isTemporary() && !DebugPlugin.getDefault().getBreakpointManager().isEnabled() ) { + try { + cdiBreakpoint.setEnabled( false ); + } + catch( CDIException e ) { + DebugPlugin.log( e ); + } + } } protected void doHandleLocationBreakpointCreatedEvent( ICDILocationBreakpoint cdiBreakpoint ) { @@ -396,7 +406,7 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent if ( breakpoint != null ) { Map map = new HashMap( 3 ); try { - if ( DebugPlugin.getDefault().getBreakpointManager().isEnabled() ) { + if ( !fSkipBreakpoint && DebugPlugin.getDefault().getBreakpointManager().isEnabled() ) { map.put( IBreakpoint.ENABLED, new Boolean( cdiBreakpoint.isEnabled() ) ); } else { @@ -631,19 +641,32 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent * @see org.eclipse.debug.core.IBreakpointManagerListener#breakpointManagerEnablementChanged(boolean) */ public void breakpointManagerEnablementChanged( boolean enabled ) { + doSkipBreakpoints( !enabled ); + } + + public void skipBreakpoints( boolean enabled ) { + if ( fSkipBreakpoint != enabled && (DebugPlugin.getDefault().getBreakpointManager().isEnabled() || !enabled) ) { + fSkipBreakpoint = enabled; + doSkipBreakpoints( enabled ); + } + } + + private void doSkipBreakpoints( boolean enabled ) { ICBreakpoint[] cBreakpoints = getBreakpointMap().getAllCBreakpoints(); for ( int i = 0; i < cBreakpoints.length; ++i ) { try { if ( cBreakpoints[i].isEnabled() ) { ICDIBreakpoint cdiBreakpoint = getBreakpointMap().getCDIBreakpoint( cBreakpoints[i] ); if ( cdiBreakpoint != null ) { - cdiBreakpoint.setEnabled( enabled ); + cdiBreakpoint.setEnabled( !enabled ); } } } catch( CoreException e ) { + DebugPlugin.log( e.getStatus() ); } catch( CDIException e ) { + DebugPlugin.log( e ); } } } 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 9733b0f65bc..e17647bee33 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 @@ -1325,6 +1325,7 @@ public class CDebugTarget extends CDebugElement // Reset the registers that have errors. getRegisterManager().targetSuspended(); setSuspensionThread(); + getBreakpointManager().skipBreakpoints( false ); List newThreads = refreshThreads(); if ( event.getSource() instanceof ICDITarget ) { @@ -1856,10 +1857,13 @@ public class CDebugTarget extends CDebugElement /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.IRunToLine#runToLine(IResource, int) */ - public void runToLine( String fileName, int lineNumber ) throws DebugException + public void runToLine( String fileName, int lineNumber, boolean skipBreakpoints ) throws DebugException { if ( !canRunToLine( fileName, lineNumber ) ) return; + if ( skipBreakpoints ) { + getBreakpointManager().skipBreakpoints( true ); + } ICDILocation location = getCDISession().getBreakpointManager().createLocation( fileName, null, lineNumber ); try { @@ -1867,6 +1871,9 @@ public class CDebugTarget extends CDebugElement } catch( CDIException e ) { + if ( skipBreakpoints ) { + getBreakpointManager().skipBreakpoints( false ); + } targetRequestFailed( e.getMessage(), e ); } } @@ -1883,11 +1890,11 @@ public class CDebugTarget extends CDebugElement /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.IRunToLine#runToLine(IResource, int) */ - public void runToLine( IFile file, int lineNumber ) throws DebugException + public void runToLine( IFile file, int lineNumber, boolean skipBreakpoints ) throws DebugException { if ( !canRunToLine( file, lineNumber ) ) return; - runToLine( file.getLocation().lastSegment(), lineNumber ); + runToLine( file.getLocation().lastSegment(), lineNumber, skipBreakpoints ); } /* (non-Javadoc) @@ -2111,10 +2118,13 @@ public class CDebugTarget extends CDebugElement /** * @see org.eclipse.cdt.debug.core.model.IRunToAddress#runToLine(long) */ - public void runToAddress( long address ) throws DebugException + public void runToAddress( long address, boolean skipBreakpoints ) throws DebugException { if ( !canRunToAddress( address ) ) return; + if ( skipBreakpoints ) { + getBreakpointManager().skipBreakpoints( true ); + } ICDILocation location = getCDISession().getBreakpointManager().createLocation( address ); try { @@ -2122,6 +2132,9 @@ public class CDebugTarget extends CDebugElement } catch( CDIException e ) { + if ( skipBreakpoints ) { + getBreakpointManager().skipBreakpoints( false ); + } targetRequestFailed( e.getMessage(), e ); } } diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 5e2ad7c7a0f..eb13831dda7 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,7 @@ +2004-06-16 Mikhail Khodjaiants + Added support for the "Skip Breakpoints" and "Skip breakpoints during a "Run To Line" operation. + * RunToLineAdapter.java + 2004-06-16 Mikhail Khodjaiants Removed the "Add Address Breakpoint" and "Add Watchpoint" global actions. * plugin.properties diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java index dd00243bbf9..895cec7a25d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java @@ -23,6 +23,8 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.model.IDebugElement; import org.eclipse.debug.core.model.ISuspendResume; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.actions.IRunToLineTarget; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextSelection; @@ -65,8 +67,9 @@ public class RunToLineAdapter implements IRunToLineTarget { int lineNumber = textSelection.getStartLine() + 1; if ( target instanceof IAdaptable ) { IRunToLine runToLine = (IRunToLine)((IAdaptable)target).getAdapter( IRunToLine.class ); - if ( runToLine != null && runToLine.canRunToLine( fileName, lineNumber ) ) - runToLine.runToLine( fileName, lineNumber ); + if ( runToLine != null && runToLine.canRunToLine( fileName, lineNumber ) ) { + runToLine.runToLine( fileName, lineNumber, DebugUIPlugin.getDefault().getPluginPreferences().getBoolean( IDebugUIConstants.PREF_SKIP_BREAKPOINTS_DURING_RUN_TO_LINE ) ); + } } return; } @@ -83,8 +86,9 @@ public class RunToLineAdapter implements IRunToLineTarget { long address = ((DisassemblyEditorInput)input).getAddress( lineNumber ); if ( target instanceof IAdaptable ) { IRunToAddress runToAddress = (IRunToAddress)((IAdaptable)target).getAdapter( IRunToAddress.class ); - if ( runToAddress != null && runToAddress.canRunToAddress( address ) ) - runToAddress.runToAddress( address ); + if ( runToAddress != null && runToAddress.canRunToAddress( address ) ) { + runToAddress.runToAddress( address, DebugUIPlugin.getDefault().getPluginPreferences().getBoolean( IDebugUIConstants.PREF_SKIP_BREAKPOINTS_DURING_RUN_TO_LINE ) ); + } } return; }