diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 9c0856e0f8b..2644028e558 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,12 @@ +2004-05-13 Mikhail Khodjaiants + Support for the instruction stepping mode. + * ICDebugTarget.java + * ISteppingModeTarget.java: new + * ITargetProperties.java: new + * IInstructionstep.java: deleted + * CDebugTarget.java + * CThread.java + 2004-05-06 Mikhail Khodjaiants Implementation of mixed disassembly mode. * IAsmSourceLine.java: new 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 a73ca4df8db..2af2d2f6096 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 @@ -29,7 +29,9 @@ public interface ICDebugTarget extends IDebugTarget, IState, ISwitchToThread, ICDebugElement, - IBreakpointTarget { + IBreakpointTarget, + ISteppingModeTarget, + ITargetProperties { /** * Returns the shared libraries loaded in this debug target. An diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IInstructionStep.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IInstructionStep.java deleted file mode 100644 index 7011dc47c14..00000000000 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IInstructionStep.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - *(c) Copyright QNX Software Systems Ltd. 2002. - * All Rights Reserved. - * - */ - -package org.eclipse.cdt.debug.core.model; -import org.eclipse.debug.core.DebugException; - -/** - * Provides the ability to step into and over machine instruction - * at the current execution location. - * - */ -public interface IInstructionStep -{ - /** - * Returns whether this element can currently perform a step - * into the instruction. - * - * @return whether this element can currently perform a step - * into the instruction - */ - boolean canStepIntoInstruction(); - - /** - * Returns whether this element can currently perform a step - * over the instruction (nexti command). - * - * @return whether this element can currently perform a step - * over the instruction - */ - boolean canStepOverInstruction(); - - /** - * Steps into the current instruction. - * - * @exception DebugException on failure. Reasons include: - */ - void stepIntoInstruction() throws DebugException; - - /** - * Steps over the current instruction. - * - * @exception DebugException on failure. Reasons include: - */ - void stepOverInstruction() throws DebugException; -} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ISteppingModeTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ISteppingModeTarget.java new file mode 100644 index 00000000000..a8a2bbe70a4 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ISteppingModeTarget.java @@ -0,0 +1,40 @@ +/********************************************************************** + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.debug.core.model; + +/** + * Support for the instruction stepping mode for a debug target. + */ +public interface ISteppingModeTarget { + + /** + * Returns whether this debug target supports instruction stepping. + * + * @return whether this debug target supports instruction stepping + */ + boolean supportsInstructionStepping(); + + /** + * Sets whether the instruction stepping are enabled in this debug target. + * + * @param enabled whether the instruction stepping are enabled in this debug target + */ + void enableInstructionStepping( boolean enabled ); + + /** + * Returns whether the instruction stepping are currently enabled in this + * debug target. + * + * @return whether the instruction stepping are currently enabled in this + * debug target + */ + boolean isInstructionSteppingEnabled(); +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ITargetProperties.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ITargetProperties.java new file mode 100644 index 00000000000..f8e1979e263 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ITargetProperties.java @@ -0,0 +1,37 @@ +/********************************************************************** + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.debug.core.model; + +import org.eclipse.core.runtime.Preferences; + +/** + * Provides access to the properties of a debug target. + */ +public interface ITargetProperties { + + public static final String PREF_INSTRUCTION_STEPPING_MODE = "instruction_stepping_mode"; //$NON-NLS-1$ + + /** + * Adds a property change listener to this target. + * Has no affect if the identical listener is already registered. + * + * @param listener a property change listener + */ + void addPropertyChangeListener( Preferences.IPropertyChangeListener listener ); + + /** + * Removes the given listener from this target. + * Has no affect if the listener is not registered. + * + * @param listener a property change listener + */ + void removePropertyChangeListener( Preferences.IPropertyChangeListener listener ); +} 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 b20cfb1ee19..9de31243f24 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 @@ -91,7 +91,9 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.Preferences.IPropertyChangeListener; import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; @@ -278,7 +280,12 @@ public class CDebugTarget extends CDebugElement private Boolean fIsLittleEndian = null; private RunningInfo fRunningInfo = null; - + + /** + * The target's preference set. + */ + private Preferences fPreferences = null; + /** * Constructor for CDebugTarget. * @param target @@ -300,6 +307,7 @@ public class CDebugTarget extends CDebugElement setName( name ); setProcess( debuggeeProcess ); setCDITarget( cdiTarget ); + initializePreferences(); setExecFile( file ); setConfiguration( cdiTarget.getSession().getConfiguration() ); setThreadList( new ArrayList( 5 ) ); @@ -1249,6 +1257,7 @@ public class CDebugTarget extends CDebugElement disposeSourceManager(); disposeBreakpointManager(); removeAllExpressions(); + disposePreferences(); } /** @@ -2470,4 +2479,50 @@ public class CDebugTarget extends CDebugElement public boolean isTargetBreakpoint( ICBreakpoint breakpoint ) { return ( getBreakpointManager() != null ) ? getBreakpointManager().isTargetBreakpoint( breakpoint ) : false; } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ISteppingModeTarget#enableInstructionStepping(boolean) + */ + public void enableInstructionStepping( boolean enabled ) { + fPreferences.setValue( PREF_INSTRUCTION_STEPPING_MODE, enabled ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ISteppingModeTarget#isInstructionSteppingEnabled() + */ + public boolean isInstructionSteppingEnabled() { + return fPreferences.getBoolean( PREF_INSTRUCTION_STEPPING_MODE ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ISteppingModeTarget#supportsInstructionStepping() + */ + public boolean supportsInstructionStepping() { + return getConfiguration().supportsInstructionStepping(); + } + + private void initializePreferences() { + fPreferences = new Preferences(); + fPreferences.setDefault( PREF_INSTRUCTION_STEPPING_MODE, false ); + } + + private void disposePreferences() { + fPreferences = null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ITargetProperties#addPropertyChangeListener(org.eclipse.core.runtime.Preferences.IPropertyChangeListener) + */ + public void addPropertyChangeListener( IPropertyChangeListener listener ) { + if ( fPreferences!= null ) + fPreferences.addPropertyChangeListener( listener ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.ITargetProperties#removePropertyChangeListener(org.eclipse.core.runtime.Preferences.IPropertyChangeListener) + */ + public void removePropertyChangeListener( IPropertyChangeListener listener ) { + if ( fPreferences!= null ) + fPreferences.removePropertyChangeListener( listener ); + } } 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 07ed8041fb2..c9cf92de468 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 @@ -11,6 +11,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration; @@ -31,7 +32,6 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; import org.eclipse.cdt.debug.core.model.ICDebugElementErrorStatus; import org.eclipse.cdt.debug.core.model.IDummyStackFrame; -import org.eclipse.cdt.debug.core.model.IInstructionStep; import org.eclipse.cdt.debug.core.model.IRestart; import org.eclipse.cdt.debug.core.model.IResumeWithoutSignal; import org.eclipse.cdt.debug.core.model.IRunToLine; @@ -45,7 +45,6 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.debug.core.model.IThread; -import org.eclipse.cdt.debug.core.CDebugCorePlugin; /** * @@ -57,7 +56,6 @@ public class CThread extends CDebugElement implements IThread, IState, IRestart, - IInstructionStep, IResumeWithoutSignal, ISwitchToFrame, ICDIEventListener @@ -608,69 +606,62 @@ public class CThread extends CDebugElement /* (non-Javadoc) * @see org.eclipse.debug.core.model.IStep#stepInto() */ - public void stepInto() throws DebugException - { + public void stepInto() throws DebugException { if ( !canStepInto() ) return; - try - { - if ( getRealSourceMode() == ISourceMode.MODE_SOURCE ) - { + try { + if ( !isInstructionsteppingEnabled() ) { getCDIThread().stepInto(); } - else - { + else { getCDIThread().stepIntoInstruction(); } - } - catch( CDIException e ) - { + } + catch( CDIException e ) { targetRequestFailed( e.getMessage(), e ); } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.debug.core.model.IStep#stepOver() */ - public void stepOver() throws DebugException - { + public void stepOver() throws DebugException { if ( !canStepOver() ) return; - try - { - if ( getRealSourceMode() == ISourceMode.MODE_SOURCE ) - { + try { + if ( !isInstructionsteppingEnabled() ) { getCDIThread().stepOver(); } - else - { + else { getCDIThread().stepOverInstruction(); } - } - catch( CDIException e ) - { + } + catch( CDIException e ) { targetRequestFailed( e.getMessage(), e ); } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.debug.core.model.IStep#stepReturn() */ - public void stepReturn() throws DebugException - { + public void stepReturn() throws DebugException { if ( !canStepReturn() ) return; - try - { + try { getCDIThread().stepReturn(); - } - catch( CDIException e ) - { + } + catch( CDIException e ) { targetRequestFailed( e.getMessage(), e ); } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.debug.core.model.ITerminate#canTerminate() */ public boolean canTerminate() @@ -838,56 +829,6 @@ public class CThread extends CDebugElement fCurrentStateInfo = info; } - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.IInstructionStep#canStepIntoInstruction() - */ - public boolean canStepIntoInstruction() - { - return canStepInto(); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.IInstructionStep#canStepOverInstruction() - */ - public boolean canStepOverInstruction() - { - return canStepOver(); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.IInstructionStep#stepIntoInstruction() - */ - public void stepIntoInstruction() throws DebugException - { - if ( !canStepIntoInstruction() ) - return; - try - { - getCDIThread().stepIntoInstruction(); - } - catch( CDIException e ) - { - targetRequestFailed( e.getMessage(), e ); - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.IInstructionStep#stepOverInstruction() - */ - public void stepOverInstruction() throws DebugException - { - if ( !canStepOverInstruction() ) - return; - try - { - getCDIThread().stepOverInstruction(); - } - catch( CDIException e ) - { - targetRequestFailed( e.getMessage(), e ); - } - } - private void handleSuspendedEvent( ICDISuspendedEvent event ) { setRunning( false ); @@ -1220,4 +1161,8 @@ public class CThread extends CDebugElement setCurrentStateId( state ); setCurrentStateInfo( null ); } + + private boolean isInstructionsteppingEnabled() { + return ((CDebugTarget)getDebugTarget()).isInstructionSteppingEnabled(); + } }