From 5c5930d219eca2cd7d2777003624f2b38d715098 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Tue, 13 Aug 2002 05:26:09 +0000 Subject: [PATCH] working on the implementation. --- .../cdt/debug/core/cdi/CDIException.java | 19 +-- .../debug/core/cdi/ICDIExpressionManager.java | 11 +- .../cdt/debug/core/cdi/ICDISession.java | 7 - ...atedEvent.java => ICDIDestroyedEvent.java} | 2 +- .../core/cdi/event/ICDISuspendedEvent.java | 1 + .../debug/core/cdi/model/ICDIExpression.java | 20 +-- .../cdt/debug/core/cdi/model/ICDIObject.java | 17 +- .../cdt/debug/core/cdi/model/ICDITarget.java | 22 +-- .../debug/core/cdi/model/ICDIVariable.java | 8 - .../cdt/debug/internal/core/CDebugTarget.java | 14 +- .../debug/internal/core/CLocalVariable.java | 2 +- .../cdt/debug/internal/core/CStackFrame.java | 5 +- .../cdt/debug/internal/core/CThread.java | 12 +- .../cdt/debug/mi/core/GDBDebugger.java | 9 +- .../eclipse/cdt/debug/mi/core/MIProcess.java | 11 +- .../eclipse/cdt/debug/mi/core/RxThread.java | 32 +++- .../cdt/debug/mi/core/cdi/Argument.java | 28 +--- .../debug/mi/core/cdi/BreakpointManager.java | 33 ++-- .../cdt/debug/mi/core/cdi/CObject.java | 33 ++++ .../cdt/debug/mi/core/cdi/CSession.java | 30 ++-- .../cdt/debug/mi/core/cdi/CTarget.java | 156 ++++++++---------- .../cdt/debug/mi/core/cdi/CThread.java | 117 +++++++++++++ .../debug/mi/core/cdi/EndSteppingRange.java | 18 ++ .../cdt/debug/mi/core/cdi/EventAdapter.java | 13 +- .../cdt/debug/mi/core/cdi/EventManager.java | 4 +- .../cdt/debug/mi/core/cdi/Expression.java | 36 ++-- .../debug/mi/core/cdi/ExpressionManager.java | 14 +- .../cdt/debug/mi/core/cdi/ResumedEvent.java | 32 ++++ .../cdt/debug/mi/core/cdi/StackFrame.java | 51 ++---- .../cdt/debug/mi/core/cdi/SteppingEvent.java | 39 +++++ .../cdt/debug/mi/core/cdi/SuspendedEvent.java | 65 +++++--- .../eclipse/cdt/debug/mi/core/cdi/Value.java | 25 +-- .../cdt/debug/mi/core/cdi/Variable.java | 26 +-- .../debug/mi/core/command/CommandFactory.java | 4 + .../command/MIDataEvaluateExpression.java | 4 + .../mi/core/command/MIStackListFrames.java | 4 + .../mi/core/event/MIBreakpointEvent.java | 2 +- .../debug/mi/core/event/MIRunningEvent.java | 34 ++++ .../cdt/debug/mi/core/event/MIStepEvent.java | 2 +- .../mi/core/output/MIStackListFramesInfo.java | 2 +- 40 files changed, 585 insertions(+), 379 deletions(-) rename debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/event/{ICDITerminatedEvent.java => ICDIDestroyedEvent.java} (84%) create mode 100644 debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CObject.java create mode 100644 debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CThread.java create mode 100644 debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EndSteppingRange.java create mode 100644 debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ResumedEvent.java create mode 100644 debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SteppingEvent.java create mode 100644 debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/CDIException.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/CDIException.java index 95a63f2c8fd..27fd6cf6804 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/CDIException.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/CDIException.java @@ -6,22 +6,19 @@ package org.eclipse.cdt.debug.core.cdi; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; - /** * * Represents a failure in the CDI model operations. * * @since Jul 9, 2002 */ -public class CDIException extends CoreException -{ - /* (non-Javadoc) - * @see org.eclipse.core.runtime.CoreException#CoreException(IStatus) - */ - public CDIException( IStatus status ) - { - super( status ); +public class CDIException extends Exception { + + public CDIException() { + super(); + } + + public CDIException(String s) { + super(s); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDIExpressionManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDIExpressionManager.java index e58a31b5b12..1728add1882 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDIExpressionManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDIExpressionManager.java @@ -16,15 +16,6 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression; */ public interface ICDIExpressionManager extends ICDISessionObject { - /** - * Adds the given expression to the collection of registered - * expressions. This has no effect if the given expression is - * already registered. - * - * @param expression - the expression to add - * @throws CDIException on failure. Reasons include: - */ - void addExpression( ICDIExpression expression ) throws CDIException; /** * Removes the given array of expressions from the expression @@ -50,7 +41,7 @@ public interface ICDIExpressionManager extends ICDISessionObject * @return ICDIExpression an expression specified by the given identifier * @throws CDIException on failure. Reasons include: */ - ICDIExpression getExpression( String expressionId ) throws CDIException; + ICDIExpression createExpression( String expressionId ) throws CDIException; /** * Returns a collection of all registered expressions, possibly empty. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDISession.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDISession.java index 7686ac04213..b9f5c47db9e 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDISession.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDISession.java @@ -96,13 +96,6 @@ public interface ICDISession */ ICDIRuntimeOptions getRuntimeOptions(); - /** - * Returns whether this element is terminated. - * - * @return whether this element is terminated - */ - boolean isTerminated(); - /** * Causes this element to terminate, generating a KIND_TERMINATE event. * diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/event/ICDITerminatedEvent.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/event/ICDIDestroyedEvent.java similarity index 84% rename from debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/event/ICDITerminatedEvent.java rename to debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/event/ICDIDestroyedEvent.java index 767e36ed222..910c9a76bdd 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/event/ICDITerminatedEvent.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/event/ICDIDestroyedEvent.java @@ -16,6 +16,6 @@ package org.eclipse.cdt.debug.core.cdi.event; * * @since Jul 10, 2002 */ -public interface ICDITerminatedEvent extends ICDIEvent +public interface ICDIDestroyedEvent extends ICDIEvent { } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/event/ICDISuspendedEvent.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/event/ICDISuspendedEvent.java index 2097be7d7c4..76e9c6bd9a7 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/event/ICDISuspendedEvent.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/event/ICDISuspendedEvent.java @@ -42,4 +42,5 @@ public interface ICDISuspendedEvent extends ICDIEvent * @return the current stack frame */ ICDIStackFrame getStackFrame(); + } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIExpression.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIExpression.java index 4906779d81e..8c4c1238262 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIExpression.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIExpression.java @@ -6,7 +6,7 @@ package org.eclipse.cdt.debug.core.cdi.model; -import org.eclipse.cdt.debug.core.cdi.CDIException; + /** * An expression is a snippet of code that can be evaluated to @@ -14,21 +14,5 @@ import org.eclipse.cdt.debug.core.cdi.CDIException; * * @since Jul 9, 2002 */ -public interface ICDIExpression extends ICDIObject -{ - /** - * Returns this expression's snippet of code. - * - * @return the expression - */ - String getExpressionText(); - - /** - * Returns the current value of this expression or null - * if this expression does not currently have a value. - * - * @return the current value of this expression - * @throws CDIException if this method fails. Reasons include: - */ - ICDIValue getValue() throws CDIException; +public interface ICDIExpression extends ICDIVariable { } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIObject.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIObject.java index aab381815f5..ab74cf66ee5 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIObject.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIObject.java @@ -13,25 +13,10 @@ package org.eclipse.cdt.debug.core.cdi.model; */ public interface ICDIObject { - /** - * Returns the identifier of this object. - * - * @return the identifier of this object - */ - String getId(); - /** * Returns the target this object is contained in. * * @return the target this object is contained in */ - ICDITarget getCDITarget(); - - /** - * Returns the parent of this object or null if this - * object is a top level object. - * - * @return the parent of this object - */ - ICDIObject getParent(); + ICDITarget getTarget(); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDITarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDITarget.java index a96eb1f8312..00ae0b6aa0c 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDITarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDITarget.java @@ -29,28 +29,12 @@ public interface ICDITarget extends ICDIObject ICDISession getSession(); /** - * Gets the output stream of the target process. + * Gets the target process. * * @return the output stream connected to the normal input of the * target process. */ - OutputStream getOutputStream(); - - /** - * Gets the input stream of the target process. - * - * @return the input stream connected to the normal output of the - * target process. - */ - InputStream getInputStream(); - - /** - * Gets the error stream of the target process. - * - * @return the input stream connected to the error stream of the - * target process. - */ - InputStream getErrorStream(); + Process getProcess(); /** * Returns the shared libraries loaded in this target. @@ -79,7 +63,7 @@ public interface ICDITarget extends ICDIObject * @return the thread associated with the given id * @throws CDIException if this method fails. Reasons include: */ - ICDIThread getThread( String id ) throws CDIException; + ICDIThread getCurrentThread() throws CDIException; /** * Returns a memory block that starts at the specified memory diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIVariable.java index c1195a448e9..247a929ec7d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIVariable.java @@ -41,14 +41,6 @@ public interface ICDIVariable extends ICDIObject */ ICDIValue getValue() throws CDIException; - /** - * Returns whether this variable's value has changed since the last suspend event. - * - * @return whether this variable's value has changed since the last suspend event - * @throws CDIException if this method fails. Reasons include: - */ - boolean hasValueChanged() throws CDIException; - /** * Attempts to set the value of this variable to the value of * the given expression. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugTarget.java index 01cba828218..b6468e9d3a3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugTarget.java @@ -32,7 +32,7 @@ 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.ICDISteppingEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent; -import org.eclipse.cdt.debug.core.cdi.event.ICDITerminatedEvent; +import org.eclipse.cdt.debug.core.cdi.event.ICDIDestroyedEvent; import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; @@ -628,7 +628,7 @@ public class CDebugTarget extends CDebugElement public void handleDebugEvent( ICDIEvent event ) { ICDIObject source = event.getSource(); - if ( source.getCDITarget().equals( this ) ) + if ( source.getTarget().equals( this ) ) { if ( event instanceof ICDICreatedEvent ) { @@ -658,15 +658,15 @@ public class CDebugTarget extends CDebugElement handleExitedEvent( (ICDIExitedEvent)event ); } } - else if ( event instanceof ICDITerminatedEvent ) + else if ( event instanceof ICDIDestroyedEvent ) { if ( source instanceof ICDITarget ) { - handleTerminatedEvent( (ICDITerminatedEvent)event ); + handleTerminatedEvent( (ICDIDestroyedEvent)event ); } else if ( source instanceof ICDIThread ) { - handleThreadTerminatedEvent( (ICDITerminatedEvent)event ); + handleThreadTerminatedEvent( (ICDIDestroyedEvent)event ); } } else if ( event instanceof ICDIDisconnectedEvent ) @@ -998,7 +998,7 @@ public class CDebugTarget extends CDebugElement fireChangeEvent( DebugEvent.STATE ); } - private void handleTerminatedEvent( ICDITerminatedEvent event ) + private void handleTerminatedEvent( ICDIDestroyedEvent event ) { setCurrentStateId( IState.TERMINATED ); setCurrentStateInfo( null ); @@ -1045,7 +1045,7 @@ public class CDebugTarget extends CDebugElement } } - private void handleThreadTerminatedEvent( ICDITerminatedEvent event ) + private void handleThreadTerminatedEvent( ICDIDestroyedEvent event ) { ICDIThread cdiThread = (ICDIThread)event.getSource(); CThread thread = findThread( cdiThread ); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CLocalVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CLocalVariable.java index 9681831b0aa..36a775fe5b8 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CLocalVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CLocalVariable.java @@ -132,7 +132,7 @@ public class CLocalVariable extends CModificationVariable public void handleDebugEvent( ICDIEvent event ) { ICDIObject source = event.getSource(); - if ( source.getCDITarget().equals( getCDITarget() ) ) + if ( source.getTarget().equals( getCDITarget() ) ) { if ( event instanceof ICDIChangedEvent ) { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CStackFrame.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CStackFrame.java index 15e7a91de0e..5f6a42b46e4 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CStackFrame.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CStackFrame.java @@ -475,8 +475,9 @@ public class CStackFrame extends CDebugElement */ protected static boolean equalFrame( ICDIStackFrame frameOne, ICDIStackFrame frameTwo ) { - return ( frameOne.getParent().equals( frameTwo.getParent() ) && - frameOne.getLocation().equals( frameTwo.getLocation() ) ); + //return ( frameOne.getParent().equals( frameTwo.getParent() ) && + // frameOne.getLocation().equals( frameTwo.getLocation() ) ); + return (frameOne.getLocation().equals(frameTwo.getLocation())); } protected boolean exists() throws DebugException diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CThread.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CThread.java index 9cd16f27f90..70836c3331b 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CThread.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CThread.java @@ -27,7 +27,7 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener; import org.eclipse.cdt.debug.core.cdi.event.ICDIResumedEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDISteppingEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent; -import org.eclipse.cdt.debug.core.cdi.event.ICDITerminatedEvent; +import org.eclipse.cdt.debug.core.cdi.event.ICDIDestroyedEvent; import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; @@ -359,7 +359,7 @@ public class CThread extends CDebugElement */ public String getName() throws DebugException { - return "Thread " + getCDIThread().getId(); + return "Thread " + getCDIThread().toString(); } /* (non-Javadoc) @@ -376,7 +376,7 @@ public class CThread extends CDebugElement public void handleDebugEvent( ICDIEvent event ) { ICDIObject source = event.getSource(); - if ( source.getCDITarget().equals( getCDITarget() ) ) + if ( source.getTarget().equals( getCDITarget() ) ) { if ( event instanceof ICDISuspendedEvent ) { @@ -392,11 +392,11 @@ public class CThread extends CDebugElement handleResumedEvent( (ICDIResumedEvent)event ); } } - else if ( event instanceof ICDITerminatedEvent ) + else if ( event instanceof ICDIDestroyedEvent ) { if ( source instanceof ICDIThread ) { - handleTerminatedEvent( (ICDITerminatedEvent)event ); + handleTerminatedEvent( (ICDIDestroyedEvent)event ); } } else if ( event instanceof ICDIDisconnectedEvent ) @@ -864,7 +864,7 @@ public class CThread extends CDebugElement fireSuspendEvent( DebugEvent.UNSPECIFIED ); } - private void handleTerminatedEvent( ICDITerminatedEvent event ) + private void handleTerminatedEvent( ICDIDestroyedEvent event ) { setCurrentStateId( IState.TERMINATED ); setCurrentStateInfo( null ); 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 7aa0568b3cb..6b05259025b 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 @@ -20,7 +20,8 @@ public class GDBDebugger implements ICDebugger { return MIPlugin.getDefault().createCSession(exe.getLocation().toOSString()); } catch (IOException e) { - throw new CDIException(new Status(0, MIPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, "error", e)); + //throw new CDIException(new Status(0, MIPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, "error", e)); + throw new CDIException("Error initializing"); } } @@ -29,7 +30,8 @@ public class GDBDebugger implements ICDebugger { return MIPlugin.getDefault().createCSession(exe.getLocation().toOSString(), pid); } catch (IOException e) { - throw new CDIException(new Status(0, MIPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, "error", e)); + //throw new CDIException(new Status(0, MIPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, "error", e)); + throw new CDIException("Error initializing"); } } @@ -38,7 +40,8 @@ public class GDBDebugger implements ICDebugger { return MIPlugin.getDefault().createCSession(exe.getLocation().toOSString(), corefile.getLocation().toOSString()); } catch (IOException e) { - throw new CDIException(new Status(0, MIPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, "error", e)); + //throw new CDIException(new Status(0, MIPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, "error", e)); + throw new CDIException("Error initializing"); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcess.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcess.java index f559ed0db5c..1f5bec21797 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcess.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcess.java @@ -22,7 +22,8 @@ public class MIProcess extends Process { public final static int SUSPENDED = 1; public final static int RUNNING = 2; - public final static int TERMINATED = 3; + public final static int STEPPING = 3; + public final static int TERMINATED = 4; int state = 0; MISession session; @@ -130,6 +131,10 @@ public class MIProcess extends Process { return state == RUNNING; } + public synchronized boolean isStepping() { + return state == STEPPING; + } + public synchronized boolean isTerminated() { return state == TERMINATED; } @@ -142,6 +147,10 @@ public class MIProcess extends Process { state = RUNNING; } + public synchronized void setStepping() { + state = STEPPING; + } + public synchronized void setTerminated() { state = TERMINATED; notifyAll(); 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 7c89415bc1d..e24a60f6637 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,12 +12,18 @@ 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.MIExecNext; +import org.eclipse.cdt.debug.mi.core.command.MIExecNextInstruction; +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; import org.eclipse.cdt.debug.mi.core.event.EventThread; import org.eclipse.cdt.debug.mi.core.event.MIBreakpointEvent; import org.eclipse.cdt.debug.mi.core.event.MIEvent; import org.eclipse.cdt.debug.mi.core.event.MIExitEvent; import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent; import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent; +import org.eclipse.cdt.debug.mi.core.event.MIRunningEvent; import org.eclipse.cdt.debug.mi.core.event.MISignalEvent; import org.eclipse.cdt.debug.mi.core.event.MIStepEvent; import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent; @@ -102,16 +108,33 @@ public class RxThread extends Thread { // Notify any command waiting for a ResultRecord. MIResultRecord rr = response.getMIResultRecord(); if (rr != null) { + int id = rr.geToken(); + Command cmd = rxQueue.removeCommand(id); + // Check if the state changed. String state = rr.getResultClass(); if ("running".equals(state)) { - session.getMIProcess().setRunning(); + MIEvent[] events = new MIEvent[1]; + // Check the type of command + // if it was a step instruction set state stepping + if (cmd instanceof MIExecNext || + cmd instanceof MIExecNextInstruction || + cmd instanceof MIExecStep || + cmd instanceof MIExecStepInstruction || + cmd instanceof MIExecUntil) { + session.getMIProcess().setStepping(); + events[0] = new MIRunningEvent(true); + } else { + session.getMIProcess().setRunning(); + events[0] = new MIRunningEvent(); + } + Thread eventTread = new EventThread(session, events); + eventTread.start(); } else if ("exit".equals(state)) { session.getMIProcess().setTerminated(); } - int id = rr.geToken(); - Command cmd = rxQueue.removeCommand(id); + // Notify the waiting command. if (cmd != null) { synchronized (cmd) { cmd.setMIOutput(response); @@ -292,6 +315,9 @@ public class RxThread extends Thread { } else if ("exited-normally".equals(reason)) { session.getMIProcess().setTerminated(); event = new MIInferiorExitEvent(); + } else if ("exited-signalled".equals(reason)) { + session.getMIProcess().setTerminated(); + event = new MIInferiorExitEvent(); } return event; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Argument.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Argument.java index 5c59cf12b55..34408cfc016 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Argument.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Argument.java @@ -15,11 +15,12 @@ import org.eclipse.cdt.debug.mi.core.output.MIArg; * To enable and disable the creation of type comments go to * Window>Preferences>Java>Code Generation. */ -public class Argument implements ICDIArgument { +public class Argument extends CObject implements ICDIArgument { MIArg arg; - public Argument(MIArg a) { + public Argument(CTarget target, MIArg a) { + super(target); arg = a; } @@ -34,7 +35,7 @@ public class Argument implements ICDIArgument { * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getValue() */ public ICDIValue getValue() throws CDIException { - return new Value(arg.getValue()); + return new Value(getCTarget(), arg.getValue()); } /** @@ -56,27 +57,6 @@ public class Argument implements ICDIArgument { public void setValue(String expression) throws CDIException { } - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getCDITarget() - */ - public ICDITarget getCDITarget() { - return null; - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getId() - */ - public String getId() { - return null; - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getParent() - */ - public ICDIObject getParent() { - return null; - } - /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getTypeName() */ 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 812c90231df..147c4fa3856 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 @@ -65,7 +65,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa && breakList.contains(breakpoints[i])) { numbers[i] = ((Breakpoint)breakpoints[i]).getMIBreakPoint().getNumber(); } else { - //throw new CDIException(); + throw new CDIException("Not a CDT breakpoint"); } } CSession s = getCSession(); @@ -75,10 +75,10 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa s.getMISession().postCommand(breakDelete); MIInfo info = breakDelete.getMIInfo(); if (info == null) { - //throw new CDIException(); + throw new CDIException("Timedout"); } } catch (MIException e) { - // throw new CDIException(e); + throw new CDIException(e.toString()); } for (int i = 0; i < breakpoints.length; i++) { breakList.remove(breakpoints[i]); @@ -90,7 +90,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa if (breakpoint instanceof Breakpoint && breakList.contains(breakpoint)) { number = ((Breakpoint)breakpoint).getMIBreakPoint().getNumber(); } else { - //throw new CDIException(); + throw new CDIException("Not a CDT breakpoint"); } CSession s = getCSession(); CommandFactory factory = s.getMISession().getCommandFactory(); @@ -99,10 +99,10 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa s.getMISession().postCommand(breakEnable); MIInfo info = breakEnable.getMIInfo(); if (info == null) { - //throw new CDIException(); + throw new CDIException("Timedout"); } } catch (MIException e) { - // throw new CDIException(e); + throw new CDIException(e.toString()); } ((Breakpoint)breakpoint).getMIBreakPoint().setEnabled(true); } @@ -112,7 +112,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa if (breakpoint instanceof Breakpoint && breakList.contains(breakpoint)) { number = ((Breakpoint)breakpoint).getMIBreakPoint().getNumber(); } else { - // throw new CDIException(); + throw new CDIException("Not a CDT breakpoint"); } CSession s = getCSession(); CommandFactory factory = s.getMISession().getCommandFactory(); @@ -121,10 +121,10 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa s.getMISession().postCommand(breakDisable); MIInfo info = breakDisable.getMIInfo(); if (info == null) { - //throw new CDIException(); + throw new CDIException("Timeout"); } } catch (MIException e) { - // throw new CDIException(e); + throw new CDIException(e.toString()); } ((Breakpoint)breakpoint).getMIBreakPoint().setEnabled(false); } @@ -141,8 +141,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa */ public ICDICatchpoint setCatchpoint(int type, ICDICatchEvent event, String expression, ICDICondition condition) throws CDIException { - // throw new CDIException(); - return null; + throw new CDIException("Not Supported"); } /** @@ -184,14 +183,14 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa s.getMISession().postCommand(breakInsert); MIBreakInsertInfo info = breakInsert.getMIBreakInsertInfo(); if (info == null) { - //throw new CDIException(); + throw new CDIException("Timedout"); } points = info.getBreakPoints(); if (points == null || points.length == 0) { - //throw new CDIException(); + throw new CDIException("Error parsing"); } } catch (MIException e) { - // throw new CDIException(e); + throw new CDIException(e.toString()); } Breakpoint bkpt= new Breakpoint(this, points[0]); @@ -215,14 +214,14 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa s.getMISession().postCommand(breakWatch); MIBreakWatchInfo info = breakWatch.getMIBreakWatchInfo(); if (info == null) { - //throw new CDIException(); + throw new CDIException("Timedout"); } points = info.getBreakPoints(); if (points == null || points.length == 0) { - //throw new CDIException(); + throw new CDIException("Parsing Error"); } } catch (MIException e) { - // throw new CDIException(e); + throw new CDIException(e.toString()); } Breakpoint bkpt= new Breakpoint(this, points[0]); diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CObject.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CObject.java new file mode 100644 index 00000000000..ae46f10d5f6 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CObject.java @@ -0,0 +1,33 @@ +package org.eclipse.cdt.debug.mi.core.cdi; + +import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; +import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; + +/** + * @author alain + * + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. + */ +public class CObject implements ICDIObject { + + CTarget target; + + public CObject(CTarget t) { + target = t; + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getTarget() + */ + public ICDITarget getTarget() { + return target; + } + + public CTarget getCTarget() { + return target; + } + +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CSession.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CSession.java index d535636a121..2e06132c413 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CSession.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CSession.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager; import org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager; import org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions; import org.eclipse.cdt.debug.core.cdi.ICDISession; +import org.eclipse.cdt.debug.core.cdi.ICDISessionObject; import org.eclipse.cdt.debug.core.cdi.ICDISignalManager; import org.eclipse.cdt.debug.core.cdi.ICDISourceManager; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; @@ -24,7 +25,7 @@ import org.eclipse.cdt.debug.mi.core.MISession; /** * @see org.eclipse.cdt.debug.core.cdi.ICDISession */ -public class CSession implements ICDISession { +public class CSession implements ICDISession, ICDISessionObject { Properties props; MISession session; @@ -52,6 +53,14 @@ public class CSession implements ICDISession { return session; } + ICDITarget getTarget() { + return ctarget; + } + + CTarget getCTarget() { + return ctarget; + } + /** * @see org.eclipse.cdt.debug.core.cdi.ICDISession#getAttribute(String) */ @@ -108,17 +117,6 @@ public class CSession implements ICDISession { return new ICDITarget[]{ctarget}; } - public ICDITarget getCTarget() { - return ctarget; - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.ICDISession#isTerminated() - */ - public boolean isTerminated() { - return session.isTerminated(); - } - /** * @see org.eclipse.cdt.debug.core.cdi.ICDISession#setAttribute(String, String) */ @@ -146,4 +144,12 @@ public class CSession implements ICDISession { public ICDIRuntimeOptions getRuntimeOptions() { return new RuntimeOptions(); } + + /** + * @see org.eclipse.cdt.debug.core.cdi.ICDISessionObject#getSession() + */ + public ICDISession getSession() { + return this; + } + } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CTarget.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CTarget.java index 4454f58e2c7..c7ac2080fc8 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CTarget.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CTarget.java @@ -9,6 +9,7 @@ import java.io.InputStream; import java.io.OutputStream; import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.ICDISession; import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression; import org.eclipse.cdt.debug.core.cdi.model.ICDIGlobalVariable; import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock; @@ -21,6 +22,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MISession; 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; import org.eclipse.cdt.debug.mi.core.command.MIExecFinish; import org.eclipse.cdt.debug.mi.core.command.MIExecInterrupt; @@ -30,6 +32,7 @@ import org.eclipse.cdt.debug.mi.core.command.MIExecRun; 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.MITargetDetach; +import org.eclipse.cdt.debug.mi.core.output.MIDataEvaluateExpressionInfo; import org.eclipse.cdt.debug.mi.core.output.MIInfo; /** @@ -40,60 +43,51 @@ import org.eclipse.cdt.debug.mi.core.output.MIInfo; * To enable and disable the creation of type comments go to * Window>Preferences>Java>Code Generation. */ -public class CTarget extends SessionObject implements ICDITarget { +public class CTarget implements ICDITarget { - public CTarget(CSession session) { - super(session); + CSession session; + + public CTarget(CSession s) { + session = s; } + CSession getCSession() { + return session; + } + /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#disconnect() */ public void disconnect() throws CDIException { - MISession mi = getCSession().getMISession(); + MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MITargetDetach detach = factory.createMITargetDetach(); try { mi.postCommand(detach); MIInfo info = detach.getMIInfo(); if (info == null) { - // throw new CDIException(); + throw new CDIException("Timedout"); } } catch (MIException e) { - //throw new CDIException(e); + throw new CDIException(e.toString()); } } - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#evaluateExpression(ICDIExpression) - */ - public void evaluateExpression(ICDIExpression expression) - throws CDIException { - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#evaluateExpression(String) - */ - public ICDIExpression evaluateExpression(String expressionText) - throws CDIException { - return null; - } - /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#finish() */ public void finish() throws CDIException { - MISession mi = getCSession().getMISession(); + MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecFinish finish = factory.createMIExecFinish(); try { mi.postCommand(finish); MIInfo info = finish.getMIInfo(); if (info == null) { - // throw new CDIException(); + throw new CDIException("Timedout"); } } catch (MIException e) { - //throw new CDIException(e); + throw new CDIException(e.toString()); } } @@ -106,24 +100,10 @@ public class CTarget extends SessionObject implements ICDITarget { } /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getErrorStream() + * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getProcess() */ - public InputStream getErrorStream() { - return getCSession().getMISession().getMIProcess().getErrorStream(); - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getInputStream() - */ - public InputStream getInputStream() { - return getCSession().getMISession().getMIProcess().getInputStream(); - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getOutputStream() - */ - public OutputStream getOutputStream() { - return getCSession().getMISession().getMIProcess().getOutputStream(); + public Process getProcess() { + return session.getMISession().getMIProcess(); } /** @@ -150,7 +130,7 @@ public class CTarget extends SessionObject implements ICDITarget { /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getThread(String) */ - public ICDIThread getThread(String id) throws CDIException { + public ICDIThread getCurrentThread() throws CDIException { return null; } @@ -158,7 +138,7 @@ public class CTarget extends SessionObject implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getThreads() */ public ICDIThread[] getThreads() throws CDIException { - return null; + return new ICDIThread[0]; } /** @@ -172,38 +152,38 @@ public class CTarget extends SessionObject implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#isStepping() */ public boolean isStepping() { - return getCSession().getMISession().getMIProcess().isRunning(); + return session.getMISession().getMIProcess().isRunning(); } /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#isSuspended() */ public boolean isSuspended() { - return getCSession().getMISession().getMIProcess().isSuspended(); + return session.getMISession().getMIProcess().isSuspended(); } /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#isTerminated() */ public boolean isTerminated() { - return getCSession().getMISession().getMIProcess().isTerminated(); + return session.getMISession().getMIProcess().isTerminated(); } /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#restart() */ public void restart() throws CDIException { - MISession mi = getCSession().getMISession(); + MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecRun run = factory.createMIExecRun(new String[0]); try { mi.postCommand(run); MIInfo info = run.getMIInfo(); if (info == null) { - // throw new CDIException(); + throw new CDIException("Timedout"); } } catch (MIException e) { - //throw new CDIException(e); + throw new CDIException(e.toString()); } } @@ -211,7 +191,7 @@ public class CTarget extends SessionObject implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#resume() */ public void resume() throws CDIException { - MISession mi = getCSession().getMISession(); + MISession mi = session.getMISession(); if (mi.getMIProcess().isSuspended()) { CommandFactory factory = mi.getCommandFactory(); MIExecContinue cont = factory.createMIExecContinue(); @@ -219,10 +199,10 @@ public class CTarget extends SessionObject implements ICDITarget { mi.postCommand(cont); MIInfo info = cont.getMIInfo(); if (info == null) { - // throw new CDIException(); + throw new CDIException("Timedout"); } } catch (MIException e) { - //throw new CDIException(e); + throw new CDIException(e.toString()); } } else { restart(); @@ -233,17 +213,17 @@ public class CTarget extends SessionObject implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#stepInto() */ public void stepInto() throws CDIException { - MISession mi = getCSession().getMISession(); + MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecStep step = factory.createMIExecStep(); try { mi.postCommand(step); MIInfo info = step.getMIInfo(); if (info == null) { - // throw new CDIException(); + throw new CDIException("Timedout"); } } catch (MIException e) { - //throw new CDIException(e); + throw new CDIException(e.toString()); } } @@ -251,17 +231,17 @@ public class CTarget extends SessionObject implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#stepIntoInstruction() */ public void stepIntoInstruction() throws CDIException { - MISession mi = getCSession().getMISession(); + MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecStepInstruction stepi = factory.createMIExecStepInstruction(); try { mi.postCommand(stepi); MIInfo info = stepi.getMIInfo(); if (info == null) { - // throw new CDIException(); + throw new CDIException("Timedout"); } } catch (MIException e) { - //throw new CDIException(e); + throw new CDIException(e.toString()); } } @@ -269,17 +249,17 @@ public class CTarget extends SessionObject implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#stepOver() */ public void stepOver() throws CDIException { - MISession mi = getCSession().getMISession(); + MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecNext next = factory.createMIExecNext(); try { mi.postCommand(next); MIInfo info = next.getMIInfo(); if (info == null) { - // throw new CDIException(); + throw new CDIException("Timedout"); } } catch (MIException e) { - //throw new CDIException(e); + throw new CDIException(e.toString()); } } @@ -287,17 +267,17 @@ public class CTarget extends SessionObject implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#stepOverInstruction() */ public void stepOverInstruction() throws CDIException { - MISession mi = getCSession().getMISession(); + MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecNextInstruction nexti = factory.createMIExecNextInstruction(); try { mi.postCommand(nexti); MIInfo info = nexti.getMIInfo(); if (info == null) { - // throw new CDIException(); + throw new CDIException("Timedout"); } } catch (MIException e) { - //throw new CDIException(e); + throw new CDIException(e.toString()); } } @@ -305,17 +285,17 @@ public class CTarget extends SessionObject implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#suspend() */ public void suspend() throws CDIException { - MISession mi = getCSession().getMISession(); + MISession mi = session.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecInterrupt interrupt = factory.createMIExecInterrupt(); try { mi.postCommand(interrupt); MIInfo info = interrupt.getMIInfo(); if (info == null) { - // throw new CDIException(); + throw new CDIException("Timedout"); } } catch (MIException e) { - //throw new CDIException(e); + throw new CDIException(e.toString()); } } @@ -323,36 +303,37 @@ public class CTarget extends SessionObject implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#terminate() */ public void terminate() throws CDIException { - getCSession().getMISession().getMIProcess().destroy(); + session.getMISession().getMIProcess().destroy(); } /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getCDITarget() + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getTarget() */ - public ICDITarget getCDITarget() { + public ICDITarget getTarget() { return this; } - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getId() - */ - public String getId() { - return null; - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getParent() - */ - public ICDIObject getParent() { - return null; - } /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#evaluateExpressionToString(String) */ public String evaluateExpressionToString(String expressionText) throws CDIException { - return null; + MISession mi = session.getMISession(); + CommandFactory factory = mi.getCommandFactory(); + MIDataEvaluateExpression evaluate = + factory.createMIDataEvaluateExpression(expressionText); + try { + mi.postCommand(evaluate); + MIDataEvaluateExpressionInfo info = + evaluate.getMIDataEvaluateExpressionInfo(); + if (info == null) { + throw new CDIException("Timedout"); + } + return info.getExpression(); + } catch (MIException e) { + throw new CDIException(e.toString()); + } } /** @@ -363,4 +344,11 @@ public class CTarget extends SessionObject implements ICDITarget { return null; } + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getSession() + */ + public ICDISession getSession() { + return session; + } + } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CThread.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CThread.java new file mode 100644 index 00000000000..1050c0f7d55 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CThread.java @@ -0,0 +1,117 @@ +package org.eclipse.cdt.debug.mi.core.cdi; + +import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; +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.command.CommandFactory; +import org.eclipse.cdt.debug.mi.core.command.MIStackListFrames; +import org.eclipse.cdt.debug.mi.core.output.MIFrame; +import org.eclipse.cdt.debug.mi.core.output.MIStackListFramesInfo; + +/** + * @author alain + * + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. + */ +public class CThread extends CObject implements ICDIThread { + + String id = ""; + + public CThread(CTarget target, String threadId) { + super(target); + id = threadId; + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#finish() + */ + public void finish() throws CDIException { + getTarget().finish(); + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#getStackFrames() + */ + public ICDIStackFrame[] getStackFrames() throws CDIException { + MISession mi = getCTarget().getCSession().getMISession(); + CommandFactory factory = mi.getCommandFactory(); + MIStackListFrames frames = factory.createMIStackListFrames(); + try { + mi.postCommand(frames); + MIStackListFramesInfo info = frames.getMIStackListFramesInfo(); + if (info == null) { + throw new CDIException("Timedout"); + } + MIFrame[] miFrames = info.getMIFrames(); + ICDIStackFrame[] stack = new ICDIStackFrame[miFrames.length]; + for (int i = 0; i < stack.length; i++) { + stack[i] = new StackFrame(getCTarget(), miFrames[i]); + } + return stack; + } catch (MIException e) { + throw new CDIException(e.toString()); + } + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#isStepping() + */ + public boolean isStepping() { + return getTarget().isStepping(); + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#isSuspended() + */ + public boolean isSuspended() { + return getTarget().isSuspended(); + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#resume() + */ + public void resume() throws CDIException { + getTarget().resume(); + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#stepInto() + */ + public void stepInto() throws CDIException { + getTarget().stepInto(); + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#stepIntoInstruction() + */ + public void stepIntoInstruction() throws CDIException { + getTarget().stepIntoInstruction(); + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#stepOver() + */ + public void stepOver() throws CDIException { + getTarget().stepOver(); + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#stepOverInstruction() + */ + public void stepOverInstruction() throws CDIException { + getTarget().stepOverInstruction(); + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#suspend() + */ + public void suspend() throws CDIException { + getTarget().suspend(); + } + +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EndSteppingRange.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EndSteppingRange.java new file mode 100644 index 00000000000..0de41586292 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EndSteppingRange.java @@ -0,0 +1,18 @@ +package org.eclipse.cdt.debug.mi.core.cdi; + +import org.eclipse.cdt.debug.core.cdi.ICDIEndSteppingRange; + +/** + * @author alain + * + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. + */ +public class EndSteppingRange extends SessionObject implements ICDIEndSteppingRange { + + public EndSteppingRange(CSession session) { + super(session); + } +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventAdapter.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventAdapter.java index 7660066a98e..d7a120cf941 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventAdapter.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventAdapter.java @@ -7,6 +7,7 @@ import org.eclipse.cdt.debug.mi.core.event.MIExitEvent; import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent; import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent; import org.eclipse.cdt.debug.mi.core.event.MILocationReachedEvent; +import org.eclipse.cdt.debug.mi.core.event.MIRunningEvent; import org.eclipse.cdt.debug.mi.core.event.MISignalEvent; import org.eclipse.cdt.debug.mi.core.event.MIStepEvent; import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent; @@ -21,16 +22,24 @@ import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent; */ public class EventAdapter { - public static ICDIEvent getCEvent(final CSession session, final MIEvent miEvent) { + public static ICDIEvent getCDIEvent(CSession session, MIEvent miEvent) { if (miEvent instanceof MIBreakpointEvent) { - return new SuspendedEvent(session, (MIBreakpointEvent)miEvent); + return new SuspendedEvent(session, miEvent); } else if (miEvent instanceof MIInferiorExitEvent) { } else if (miEvent instanceof MIExitEvent) { } else if (miEvent instanceof MIFunctionFinishedEvent) { } else if (miEvent instanceof MILocationReachedEvent) { } else if (miEvent instanceof MISignalEvent) { } else if (miEvent instanceof MIStepEvent) { + return new SuspendedEvent(session, miEvent); } else if (miEvent instanceof MIWatchpointEvent) { + } else if (miEvent instanceof MIRunningEvent) { + MIRunningEvent running = (MIRunningEvent)miEvent; + if (running.isStepping()) { + return new SteppingEvent(session, miEvent); + } else { + return new ResumedEvent(session, miEvent); + } } return null; } 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 76e1434beb4..e79bd797c5c 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 @@ -12,6 +12,7 @@ import java.util.Observable; import java.util.Observer; import org.eclipse.cdt.debug.core.cdi.ICDIEventManager; +import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener; import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.event.MIEvent; @@ -36,7 +37,8 @@ public class EventManager extends SessionObject implements ICDIEventManager { public void update(Observable o, Object args) { MIEvent[] events = (MIEvent[])args; for (int i = 0; i < events.length; i++) { - // listener.handleDebugEvent(new CEventAdapter(events[i])); + ICDIEvent cdiEvent = EventAdapter.getCDIEvent(getCSession(), events[i]); + listener.handleDebugEvent(cdiEvent); } } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Expression.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Expression.java index 79ab5cb8232..0cdf94b71ad 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Expression.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Expression.java @@ -14,41 +14,43 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; * To enable and disable the creation of type comments go to * Window>Preferences>Java>Code Generation. */ -public class Expression implements ICDIExpression { +public class Expression extends CObject implements ICDIExpression { + + public Expression(CTarget target) { + super(target); + } /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIExpression#getExpressionText() + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getName() */ - public String getExpressionText() { + public String getName() throws CDIException { return null; } /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIExpression#getValue() + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getTypeName() + */ + public String getTypeName() throws CDIException { + return null; + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getValue() */ public ICDIValue getValue() throws CDIException { return null; } /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getCDITarget() + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(ICDIValue) */ - public ICDITarget getCDITarget() { - return null; + public void setValue(ICDIValue value) throws CDIException { } /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getId() + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(String) */ - public String getId() { - return null; - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getParent() - */ - public ICDIObject getParent() { - return null; + public void setValue(String expression) throws CDIException { } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java index 71e53a9743f..f3f8fb10f5d 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java @@ -24,12 +24,6 @@ public class ExpressionManager extends SessionObject implements ICDIExpressionMa super(session); } - /** - * @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#addExpression(ICDIExpression) - */ - public void addExpression(ICDIExpression expression) throws CDIException { - } - /** * @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#getExpression(String) */ @@ -58,4 +52,12 @@ public class ExpressionManager extends SessionObject implements ICDIExpressionMa throws CDIException { } + /** + * @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createExpression(String) + */ + public ICDIExpression createExpression(String expressionId) + throws CDIException { + return null; + } + } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ResumedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ResumedEvent.java new file mode 100644 index 00000000000..c056f556cc8 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ResumedEvent.java @@ -0,0 +1,32 @@ +package org.eclipse.cdt.debug.mi.core.cdi; + +import org.eclipse.cdt.debug.core.cdi.event.ICDIResumedEvent; +import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; +import org.eclipse.cdt.debug.mi.core.event.MIEvent; + +/** + * @author alain + * + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. + */ +public class ResumedEvent implements ICDIResumedEvent { + + CSession session; + MIEvent event; + + public ResumedEvent(CSession s, MIEvent e) { + session = s; + event = e; + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource() + */ + public ICDIObject getSource() { + return session.getTarget(); + } + +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/StackFrame.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/StackFrame.java index 052dfea9275..8262818ce0d 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/StackFrame.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/StackFrame.java @@ -23,13 +23,12 @@ import org.eclipse.cdt.debug.mi.core.output.MIStackListLocalsInfo; * To enable and disable the creation of type comments go to * Window>Preferences>Java>Code Generation. */ -public class StackFrame implements ICDIStackFrame { +public class StackFrame extends CObject implements ICDIStackFrame { - CSession session; MIFrame frame; - public StackFrame(CSession s, MIFrame f) { - session = s; + public StackFrame(CTarget target, MIFrame f) { + super(target); frame = f; } @@ -37,12 +36,15 @@ public class StackFrame implements ICDIStackFrame { * @see org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame#getArguments() */ public ICDIArgument[] getArguments() throws CDIException { - MIArg[] args = frame.getArgs(); - ICDIArgument[] cargs = new ICDIArgument[args.length]; - for (int i = 0; i < cargs.length; i++) { - cargs[i] = new Argument(args[i]); + if (frame != null) { + MIArg[] args = frame.getArgs(); + ICDIArgument[] cargs = new ICDIArgument[args.length]; + for (int i = 0; i < cargs.length; i++) { + cargs[i] = new Argument(getCTarget(), args[i]); + } + return cargs; } - return cargs; + return new ICDIArgument[0]; } /** @@ -51,7 +53,7 @@ public class StackFrame implements ICDIStackFrame { public ICDIVariable[] getLocalVariables() throws CDIException { MIArg[] args = null; ICDIVariable[] variables = null; - MISession mi = session.getMISession(); + MISession mi = getCTarget().getCSession().getMISession(); CommandFactory factory = mi.getCommandFactory(); MIStackListLocals locals = factory.createMIStackListLocals(true); try { @@ -68,7 +70,7 @@ public class StackFrame implements ICDIStackFrame { if (args != null) { variables = new ICDIVariable[args.length]; for (int i = 0; i < variables.length; i++) { - variables[i] = new Variable(args[i]); + variables[i] = new Variable(getCTarget(), args[i]); } } else { variables = new ICDIVariable[0]; @@ -80,28 +82,11 @@ public class StackFrame implements ICDIStackFrame { * @see org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame#getLocation() */ public ICDILocation getLocation() { - return new Location(frame.getFile(), frame.getFunction(), - frame.getLine(), frame.getAddress()); + if (frame != null) { + return new Location(frame.getFile(), frame.getFunction(), + frame.getLine(), frame.getAddress()); + } + return new Location("", "", 0, 0); } - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getCDITarget() - */ - public ICDITarget getCDITarget() { - return session.getCTarget(); - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getId() - */ - public String getId() { - return null; - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getParent() - */ - public ICDIObject getParent() { - return null; - } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SteppingEvent.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SteppingEvent.java new file mode 100644 index 00000000000..efac7ee6cf8 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SteppingEvent.java @@ -0,0 +1,39 @@ +package org.eclipse.cdt.debug.mi.core.cdi; + +import org.eclipse.cdt.debug.core.cdi.event.ICDISteppingEvent; +import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; +import org.eclipse.cdt.debug.mi.core.event.MIEvent; + +/** + * @author alain + * + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. + */ +public class SteppingEvent implements ICDISteppingEvent { + + CSession session; + MIEvent event; + + public SteppingEvent(CSession s, MIEvent e) { + session = s; + event = e; + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.event.ICDISteppingEvent#getType() + */ + public int getType() { + return 0; + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource() + */ + public ICDIObject getSource() { + return session.getTarget(); + } + +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SuspendedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SuspendedEvent.java index 104e22622f6..0010dc4b00d 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SuspendedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SuspendedEvent.java @@ -1,52 +1,73 @@ package org.eclipse.cdt.debug.mi.core.cdi; -import org.eclipse.cdt.debug.core.cdi.ICDILocation; +import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint; +import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager; import org.eclipse.cdt.debug.core.cdi.ICDISessionObject; -import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent; -import org.eclipse.cdt.debug.core.cdi.model.ICDIArgument; import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; 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.ICDIVariable; import org.eclipse.cdt.debug.mi.core.event.MIBreakpointEvent; import org.eclipse.cdt.debug.mi.core.event.MIEvent; -import org.eclipse.cdt.debug.mi.core.event.MIExitEvent; -import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent; -import org.eclipse.cdt.debug.mi.core.event.MILocationReachedEvent; -import org.eclipse.cdt.debug.mi.core.event.MISignalEvent; import org.eclipse.cdt.debug.mi.core.event.MIStepEvent; -import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent; +import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint; /** - * @author alain * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. */ public class SuspendedEvent implements ICDISuspendedEvent { - MIBreakpointEvent event; + MIEvent event; CSession session; - public SuspendedEvent(CSession s, MIBreakpointEvent e) { + public SuspendedEvent(CSession s, MIEvent e) { session = s; event = e; } + public ICDISessionObject getReason() { - return new SessionObject(session); - } - - public ICDIStackFrame getStackFrame() { - return new StackFrame(session, event.getMIFrame()); + if (event instanceof MIBreakpointEvent) { + MIBreakpointEvent breakEvent = (MIBreakpointEvent)event; + int number = breakEvent.getNumber(); + ICDIBreakpointManager mgr = session.getBreakpointManager(); + try { + ICDIBreakpoint[] bkpts= mgr.getBreakpoints(); + for (int i = 0; i < bkpts.length; i++) { + if (bkpts[i] instanceof Breakpoint) { + Breakpoint point = (Breakpoint)bkpts[i]; + MIBreakPoint miBreak = point.getMIBreakPoint(); + if (miBreak.getNumber() == number) { + return point; + } + } + } + } catch (CDIException e) { + } + } else if (event instanceof MIStepEvent) { + return new EndSteppingRange(session); + } + return session; } + /** * @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource() */ public ICDIObject getSource() { + return new CThread(session.getCTarget(), ""); + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent#getStackFrame() + */ + public ICDIStackFrame getStackFrame() { + if (event instanceof MIBreakpointEvent) { + MIBreakpointEvent breakEvent = (MIBreakpointEvent)event; + return new StackFrame(session.getCTarget(), breakEvent.getMIFrame()); + } else if (event instanceof MIStepEvent) { + MIStepEvent stepEvent = (MIStepEvent)event; + return new StackFrame(session.getCTarget(), stepEvent.getMIFrame()); + } return null; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Value.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Value.java index 41d489fecf8..65b256949cc 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Value.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Value.java @@ -14,11 +14,12 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; * To enable and disable the creation of type comments go to * Window>Preferences>Java>Code Generation. */ -public class Value implements ICDIValue { +public class Value extends CObject implements ICDIValue { String val = ""; - public Value(String s) { + public Value(CTarget target, String s) { + super(target); val = s; } @@ -43,24 +44,4 @@ public class Value implements ICDIValue { return new ICDIVariable[0]; } - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getCDITarget() - */ - public ICDITarget getCDITarget() { - return null; - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getId() - */ - public String getId() { - return null; - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getParent() - */ - public ICDIObject getParent() { - return null; - } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Variable.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Variable.java index acf8eef2946..7fb1038c18e 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Variable.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Variable.java @@ -15,11 +15,12 @@ import org.eclipse.cdt.debug.mi.core.output.MIArg; * To enable and disable the creation of type comments go to * Window>Preferences>Java>Code Generation. */ -public class Variable implements ICDIVariable { +public class Variable extends CObject implements ICDIVariable { MIArg arg; - public Variable(MIArg a) { + public Variable(CTarget target, MIArg a) { + super(target); arg = a; } /** @@ -62,25 +63,4 @@ public class Variable implements ICDIVariable { public void setValue(String expression) throws CDIException { } - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getCDITarget() - */ - public ICDITarget getCDITarget() { - return null; - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getId() - */ - public String getId() { - return null; - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getParent() - */ - public ICDIObject getParent() { - return null; - } - } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java index 6cb29f2fd01..61c52d08f36 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java @@ -178,6 +178,10 @@ public class CommandFactory { return new MIStackListArguments(showValue, lowFrame, highFrame); } + public MIStackListFrames createMIStackListFrames() { + return new MIStackListFrames(); + } + public MIStackListFrames createMIStackListFrames(int lowFrame, int highFrame) { return new MIStackListFrames(lowFrame, highFrame); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIDataEvaluateExpression.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIDataEvaluateExpression.java index 3370145a704..ef622092ef5 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIDataEvaluateExpression.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIDataEvaluateExpression.java @@ -26,6 +26,10 @@ public class MIDataEvaluateExpression extends MICommand super("-data-evaluate-expression", new String[]{expr}); } + public MIDataEvaluateExpressionInfo getMIDataEvaluateExpressionInfo() throws MIException { + return (MIDataEvaluateExpressionInfo)getMIInfo(); + } + public MIInfo getMIInfo() throws MIException { MIInfo info = null; MIOutput out = getMIOutput(); diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIStackListFrames.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIStackListFrames.java index f5dbf2a424a..86efe1b7ef6 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIStackListFrames.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIStackListFrames.java @@ -51,6 +51,10 @@ public class MIStackListFrames extends MICommand Integer.toString(high)}); } + public MIStackListFramesInfo getMIStackListFramesInfo() throws MIException { + return (MIStackListFramesInfo)getMIInfo(); + } + public MIInfo getMIInfo() throws MIException { MIInfo info = null; MIOutput out = getMIOutput(); diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIBreakpointEvent.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIBreakpointEvent.java index 3dd6f25131f..8432dc33447 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIBreakpointEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIBreakpointEvent.java @@ -31,7 +31,7 @@ public class MIBreakpointEvent extends MIEvent { parse(); } - public int getBreakNumber() { + public int getNumber() { return bkptno; } 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 new file mode 100644 index 00000000000..5304c6fee54 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java @@ -0,0 +1,34 @@ +package org.eclipse.cdt.debug.mi.core.event; + +import org.eclipse.cdt.debug.mi.core.output.MIConst; +import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; +import org.eclipse.cdt.debug.mi.core.output.MIFrame; +import org.eclipse.cdt.debug.mi.core.output.MIResult; +import org.eclipse.cdt.debug.mi.core.output.MIResultRecord; +import org.eclipse.cdt.debug.mi.core.output.MITuple; +import org.eclipse.cdt.debug.mi.core.output.MIValue; + +/** + * + * ^running + */ +public class MIRunningEvent extends MIEvent { + + boolean isStep; + + public MIRunningEvent() { + this(false); + } + + public MIRunningEvent(boolean step) { + isStep = step; + } + + public boolean isStepping() { + return isStep; + } + + public String toString() { + return "Running"; + } +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIStepEvent.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIStepEvent.java index 9383b9d9524..ca7490700af 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIStepEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIStepEvent.java @@ -34,7 +34,7 @@ public class MIStepEvent extends MIEvent { return threadId; } - public MIFrame getFrame() { + public MIFrame getMIFrame() { return frame; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIStackListFramesInfo.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIStackListFramesInfo.java index 2b89607ee22..aee3fb433be 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIStackListFramesInfo.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIStackListFramesInfo.java @@ -19,7 +19,7 @@ public class MIStackListFramesInfo extends MIInfo { super(out); } - public MIFrame[] getFrames() { + public MIFrame[] getMIFrames() { if (frames == null) { parse(); }