From 014dc6df448f650d928cc2666081ebe7e1019926 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Tue, 24 May 2005 21:38:42 +0000 Subject: [PATCH] Bug 88558: run-to-line not thread oriented. The IRunTo* and IJumpTo* interfaces moved to ICStackFrame. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 9 + .../cdt/debug/core/model/ICDebugTarget.java | 4 - .../cdt/debug/core/model/ICStackFrame.java | 2 +- .../internal/core/model/CDebugTarget.java | 155 +----------------- .../internal/core/model/CStackFrame.java | 148 ++++++++++++++++- .../debug/internal/core/model/CThread.java | 16 +- 6 files changed, 172 insertions(+), 162 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index a6a6d0ce03e..5e6bb21d183 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,12 @@ +2005-05-24 Mikhail Khodjaiants + Bug 88558: run-to-line not thread oriented. + The IRunTo* and IJumpTo* interfaces moved to ICStackFrame. + * ICDebugTarget.java + * ICStackFrame.java + * CDebugTarget.java + * CStackFrame.java + * CThread.java + 2005-05-20 Mikhail Khodjaiants Bug 94139: User-defined register groups. Added API and group serialization. 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 0979a011f8d..b72334dcaea 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 @@ -20,10 +20,6 @@ import org.eclipse.debug.core.model.IRegisterGroup; public interface ICDebugTarget extends IDebugTarget, IExecFileInfo, IRestart, - IRunToLine, - IRunToAddress, - IJumpToLine, - IJumpToAddress, IResumeWithoutSignal, ICDebugElement, IBreakpointTarget, diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICStackFrame.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICStackFrame.java index 8506b14e558..1c8c88301e2 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICStackFrame.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICStackFrame.java @@ -18,7 +18,7 @@ import org.eclipse.debug.core.model.IValue; /** * C/C++ specific extension of IStackFrame. */ -public interface ICStackFrame extends IStackFrame, ICDebugElement { +public interface ICStackFrame extends IRunToLine, IRunToAddress, IJumpToLine, IJumpToAddress, IStackFrame, ICDebugElement { /** * Returns the address of this stack frame. 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 03d866096f3..a6d8666e53a 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.core.model; -import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -73,11 +72,7 @@ import org.eclipse.cdt.debug.core.model.IDebuggerProcessSupport; import org.eclipse.cdt.debug.core.model.IDisassembly; import org.eclipse.cdt.debug.core.model.IExecFileInfo; import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor; -import org.eclipse.cdt.debug.core.model.IJumpToAddress; -import org.eclipse.cdt.debug.core.model.IJumpToLine; import org.eclipse.cdt.debug.core.model.IRegisterDescriptor; -import org.eclipse.cdt.debug.core.model.IRunToAddress; -import org.eclipse.cdt.debug.core.model.IRunToLine; import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.ISourceLookupChangeListener; @@ -813,14 +808,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv return this; if ( adapter.equals( IExecFileInfo.class ) ) return this; - if ( adapter.equals( IRunToLine.class ) ) - return this; - if ( adapter.equals( IRunToAddress.class ) ) - return this; - if ( adapter.equals( IJumpToLine.class ) ) - return this; - if ( adapter.equals( IJumpToAddress.class ) ) - return this; if ( adapter.equals( IBreakpointTarget.class ) ) return this; if ( adapter.equals( CBreakpointManager.class ) ) @@ -1303,52 +1290,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv } } - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.IRunToLine#canRunToLine(java.lang.String, int) - */ - public boolean canRunToLine( String fileName, int lineNumber ) { - // check if supports run to line - return canResume(); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.IRunToLine#runToLine(java.lang.String, int, boolean) - */ - public void runToLine( String fileName, int lineNumber, boolean skipBreakpoints ) throws DebugException { - if ( !canRunToLine( fileName, lineNumber ) ) - return; - if ( skipBreakpoints ) { - getBreakpointManager().skipBreakpoints( true ); - } - ICDILocation location = getCDITarget().createLineLocation( fileName, lineNumber ); - try { - getCDITarget().stepUntil( location ); - } - catch( CDIException e ) { - if ( skipBreakpoints ) { - getBreakpointManager().skipBreakpoints( false ); - } - targetRequestFailed( e.getMessage(), e ); - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.IRunToLine#canRunToLine(org.eclipse.core.resources.IFile, int) - */ - public boolean canRunToLine( IFile file, int lineNumber ) { - // check if supports run to line - return canResume(); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.IRunToLine#runToLine(org.eclipse.core.resources.IFile, int, boolean) - */ - public void runToLine( IFile file, int lineNumber, boolean skipBreakpoints ) throws DebugException { - if ( !canRunToLine( file, lineNumber ) ) - return; - runToLine( file.getLocation().lastSegment(), lineNumber, skipBreakpoints ); - } - protected IThread getCurrentThread() throws DebugException { IThread[] threads = getThreads(); for( int i = 0; i < threads.length; ++i ) { @@ -1465,35 +1406,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv fGlobalVariableManager.dispose(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.IRunToAddress#canRunToAddress(org.eclipse.cdt.core.IAddress) - */ - public boolean canRunToAddress( IAddress address ) { - // for now - return canResume(); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.IRunToAddress#runToAddress(org.eclipse.cdt.core.IAddress, boolean) - */ - public void runToAddress( IAddress address, boolean skipBreakpoints ) throws DebugException { - if ( !canRunToAddress( address ) ) - return; - if ( skipBreakpoints ) { - getBreakpointManager().skipBreakpoints( true ); - } - ICDILocation location = getCDITarget().createAddressLocation( new BigInteger( address.toString() ) ); - try { - getCDITarget().stepUntil( location ); - } - catch( CDIException e ) { - if ( skipBreakpoints ) { - getBreakpointManager().skipBreakpoints( false ); - } - targetRequestFailed( e.getMessage(), e ); - } - } - /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.IResumeWithoutSignal#canResumeWithoutSignal() */ @@ -1518,69 +1430,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv } } - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.IJumpToLine#canJumpToLine(org.eclipse.core.resources.IFile, int) - */ - public boolean canJumpToLine( IFile file, int lineNumber ) { - // check if supports jump to line - return canResume(); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.IJumpToLine#jumpToLine(org.eclipse.core.resources.IFile, int) - */ - public void jumpToLine( IFile file, int lineNumber ) throws DebugException { - if ( !canJumpToLine( file, lineNumber ) ) - return; - jumpToLine( file.getLocation().lastSegment(), lineNumber ); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.IJumpToLine#canJumpToLine(java.lang.String, int) - */ - public boolean canJumpToLine( String fileName, int lineNumber ) { - // check if supports jump to line - return canResume(); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.IJumpToLine#jumpToLine(java.lang.String, int) - */ - public void jumpToLine( String fileName, int lineNumber ) throws DebugException { - if ( !canJumpToLine( fileName, lineNumber ) ) - return; - ICDILocation location = getCDITarget().createLineLocation( fileName, lineNumber ); - try { - getCDITarget().resume( location ); - } - catch( CDIException e ) { - targetRequestFailed( e.getMessage(), e ); - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.IJumpToAddress#canJumpToAddress(org.eclipse.cdt.core.IAddress) - */ - public boolean canJumpToAddress( IAddress address ) { - // check if supports jump to address - return canResume(); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.IJumpToAddress#jumpToAddress(org.eclipse.cdt.core.IAddress) - */ - public void jumpToAddress( IAddress address ) throws DebugException { - if ( !canJumpToAddress( address ) ) - return; - ICDILocation location = getCDITarget().createAddressLocation( new BigInteger( address.toString() ) ); - try { - getCDITarget().resume( location ); - } - catch( CDIException e ) { - targetRequestFailed( e.getMessage(), e ); - } - } - public CRegisterManager getRegisterManager() { return fRegisterManager; } @@ -1897,4 +1746,8 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv public void removeRegisterGroups( IRegisterGroup[] groups ) { getRegisterManager().removeRegisterGroups( groups ); } + + protected void skipBreakpoints( boolean enabled ) { + getBreakpointManager().skipBreakpoints( enabled ); + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java index 491a7170cca..f8bf84a0a33 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java @@ -10,6 +10,7 @@ ***********************************************************************/ package org.eclipse.cdt.debug.internal.core.model; +import java.math.BigInteger; import java.text.MessageFormat; import java.text.NumberFormat; import java.util.ArrayList; @@ -20,11 +21,13 @@ import java.util.List; import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IAddressFactory; import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.ICDILocation; import org.eclipse.cdt.debug.core.cdi.ICDILocator; 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.ICDIExpression; import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; +import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableDescriptor; import org.eclipse.cdt.debug.core.model.ICGlobalVariable; import org.eclipse.cdt.debug.core.model.ICStackFrame; @@ -36,6 +39,7 @@ import org.eclipse.cdt.debug.core.model.IRunToAddress; import org.eclipse.cdt.debug.core.model.IRunToLine; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.internal.core.CGlobalVariableManager; +import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlockRetrieval; @@ -460,16 +464,16 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart */ public Object getAdapter( Class adapter ) { if ( adapter == IRunToLine.class ) { - return getDebugTarget().getAdapter( adapter ); + return this; } if ( adapter == IRunToAddress.class ) { - return getDebugTarget().getAdapter( adapter ); + return this; } if ( adapter == IJumpToLine.class ) { - return getDebugTarget().getAdapter( adapter ); + return this; } if ( adapter == IJumpToAddress.class ) { - return getDebugTarget().getAdapter( adapter ); + return this; } if ( adapter == CStackFrame.class ) { return this; @@ -767,4 +771,140 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart private synchronized void setDisposed( boolean isDisposed ) { fIsDisposed = isDisposed; } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IRunToLine#canRunToLine(org.eclipse.core.resources.IFile, int) + */ + public boolean canRunToLine( IFile file, int lineNumber ) { + return getThread().canResume(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IRunToLine#runToLine(org.eclipse.core.resources.IFile, int, boolean) + */ + public void runToLine( IFile file, int lineNumber, boolean skipBreakpoints ) throws DebugException { + if ( !canRunToLine( file, lineNumber ) ) + return; + runToLine( file.getLocation().lastSegment(), lineNumber, skipBreakpoints ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IRunToLine#canRunToLine(java.lang.String, int) + */ + public boolean canRunToLine( String fileName, int lineNumber ) { + return getThread().canResume(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IRunToLine#runToLine(java.lang.String, int, boolean) + */ + public void runToLine( String fileName, int lineNumber, boolean skipBreakpoints ) throws DebugException { + if ( !canRunToLine( fileName, lineNumber ) ) + return; + if ( skipBreakpoints ) { + ((CDebugTarget)getDebugTarget()).skipBreakpoints( true ); + } + ICDILocation location = getCDITarget().createLineLocation( fileName, lineNumber ); + try { + getCDIThread().stepUntil( location ); + } + catch( CDIException e ) { + if ( skipBreakpoints ) { + ((CDebugTarget)getDebugTarget()).skipBreakpoints( false ); + } + targetRequestFailed( e.getMessage(), e ); + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IRunToAddress#canRunToAddress(org.eclipse.cdt.core.IAddress) + */ + public boolean canRunToAddress( IAddress address ) { + return getThread().canResume(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IRunToAddress#runToAddress(org.eclipse.cdt.core.IAddress, boolean) + */ + public void runToAddress( IAddress address, boolean skipBreakpoints ) throws DebugException { + if ( !canRunToAddress( address ) ) + return; + if ( skipBreakpoints ) { + ((CDebugTarget)getDebugTarget()).skipBreakpoints( true ); + } + ICDILocation location = getCDITarget().createAddressLocation( new BigInteger( address.toString() ) ); + try { + getCDIThread().stepUntil( location ); + } + catch( CDIException e ) { + if ( skipBreakpoints ) { + ((CDebugTarget)getDebugTarget()).skipBreakpoints( false ); + } + targetRequestFailed( e.getMessage(), e ); + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IJumpToLine#canJumpToLine(org.eclipse.core.resources.IFile, int) + */ + public boolean canJumpToLine( IFile file, int lineNumber ) { + return getThread().canResume(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IJumpToLine#jumpToLine(org.eclipse.core.resources.IFile, int) + */ + public void jumpToLine( IFile file, int lineNumber ) throws DebugException { + if ( !canJumpToLine( file, lineNumber ) ) + return; + jumpToLine( file.getLocation().lastSegment(), lineNumber ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IJumpToLine#canJumpToLine(java.lang.String, int) + */ + public boolean canJumpToLine( String fileName, int lineNumber ) { + return getThread().canResume(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IJumpToLine#jumpToLine(java.lang.String, int) + */ + public void jumpToLine( String fileName, int lineNumber ) throws DebugException { + if ( !canJumpToLine( fileName, lineNumber ) ) + return; + ICDILocation location = getCDITarget().createLineLocation( fileName, lineNumber ); + try { + getCDIThread().resume( location ); + } + catch( CDIException e ) { + targetRequestFailed( e.getMessage(), e ); + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IJumpToAddress#canJumpToAddress(org.eclipse.cdt.core.IAddress) + */ + public boolean canJumpToAddress( IAddress address ) { + return getThread().canResume(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.IJumpToAddress#jumpToAddress(org.eclipse.cdt.core.IAddress) + */ + public void jumpToAddress( IAddress address ) throws DebugException { + if ( !canJumpToAddress( address ) ) + return; + ICDILocation location = getCDITarget().createAddressLocation( new BigInteger( address.toString() ) ); + try { + getCDIThread().resume( location ); + } + catch( CDIException e ) { + targetRequestFailed( e.getMessage(), e ); + } + } + + private ICDIThread getCDIThread() { + return ((CThread)getThread()).getCDIThread(); + } } \ No newline at end of file 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 a4b7d5c26ce..46452c8bcd8 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 @@ -38,8 +38,11 @@ import org.eclipse.cdt.debug.core.model.ICDebugElementStatus; import org.eclipse.cdt.debug.core.model.ICStackFrame; import org.eclipse.cdt.debug.core.model.ICThread; import org.eclipse.cdt.debug.core.model.IDummyStackFrame; +import org.eclipse.cdt.debug.core.model.IJumpToAddress; +import org.eclipse.cdt.debug.core.model.IJumpToLine; import org.eclipse.cdt.debug.core.model.IRestart; import org.eclipse.cdt.debug.core.model.IResumeWithoutSignal; +import org.eclipse.cdt.debug.core.model.IRunToAddress; import org.eclipse.cdt.debug.core.model.IRunToLine; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.debug.core.DebugEvent; @@ -779,8 +782,17 @@ public class CThread extends CDebugElement implements ICThread, IRestart, IResum * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ public Object getAdapter( Class adapter ) { - if ( adapter.equals( IRunToLine.class ) ) - return this; + if ( adapter.equals( IRunToLine.class ) || + adapter.equals( IRunToAddress.class ) || + adapter.equals( IJumpToLine.class ) || + adapter.equals( IJumpToAddress.class ) ) { + try { + return (ICStackFrame)getTopStackFrame(); + } + catch( DebugException e ) { + // do nothing + } + } if ( adapter.equals( CDebugElementState.class ) ) return this; if ( adapter == ICStackFrame.class ) {