diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index d233226d89f..3e7fe4418f3 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,8 @@ +2002-10-14 Mikhail Khodjaiants + * ISwitchToThread.java: New method to get the current thread. + * CDebugTarget.java: Implemented the 'getCurrentThread' method of the 'ISwitchToThread' interface. + * CDebugTarget.java: Fix in the 'setCurrentThread' method. + 2002-10-12 Alain Magloire * core/cdi/model/ICDIMemoryBlock (supportValueModification): diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ISwitchToThread.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ISwitchToThread.java index 606a76c2c18..6d069cbe245 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ISwitchToThread.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ISwitchToThread.java @@ -16,5 +16,6 @@ import org.eclipse.debug.core.model.IThread; */ public interface ISwitchToThread { + IThread getCurrentThread() throws DebugException; void setCurrentThread( IThread thread ) throws DebugException; } 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 1c2327bf8a7..f536dc08fc5 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 @@ -1798,6 +1798,7 @@ public class CDebugTarget extends CDebugElement try { getCDITarget().setCurrentThread( ((CThread)thread).getCDIThread() ); + ((CThread)thread).setCurrent( true ); } catch( CDIException e ) { @@ -1805,6 +1806,20 @@ public class CDebugTarget extends CDebugElement } } + /** + * @see org.eclipse.cdt.debug.core.ISwitchToThread#getCurrentThread() + */ + public IThread getCurrentThread() throws DebugException + { + IThread[] threads = getThreads(); + for ( int i = 0; i < threads.length; ++i ) + { + if ( ((CThread)threads[i]).isCurrent() ) + return threads[i]; + } + return null; + } + protected ISourceLocator getSourceLocator() { return getLaunch().getSourceLocator(); diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 698608d05e8..ecc3d13cea8 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,6 @@ +2002-10-14 Mikhail Khodjaiants + * CDebugUIPlugin.java: In the 'selectionChanged' method check if the thread of the new frame is current. If not make it current. + 2002-10-11 Mikhail Khodjaiants * SwitchToDisassemblyActionDelegate.java: Implementation of the 'Switch to disassembly mode' action. * plugin.properties: Action label and tooltip. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java index 56e4ae98bcb..b6753d776e9 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java @@ -30,6 +30,7 @@ import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.IDebugEventSetListener; +import org.eclipse.debug.core.model.IDebugElement; import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.debug.core.model.IThread; @@ -365,7 +366,10 @@ public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListen { try { - ((ISwitchToThread)((IThread)element).getDebugTarget()).setCurrentThread( (IThread)element ); + if ( !sameThread( (IDebugElement)element ) ) + { + ((ISwitchToThread)((IThread)element).getDebugTarget()).setCurrentThread( (IThread)element ); + } } catch( DebugException e ) { @@ -379,6 +383,10 @@ public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListen { try { + if ( !sameThread( (IDebugElement)element ) ) + { + ((ISwitchToThread)((IStackFrame)element).getDebugTarget()).setCurrentThread( ((IStackFrame)element).getThread() ); + } ((ISwitchToFrame)((IStackFrame)element).getThread()).switchToFrame( (IStackFrame)element ); } catch( DebugException e ) @@ -462,4 +470,20 @@ public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListen } } } + + private boolean sameThread( IDebugElement element ) throws DebugException + { + if ( element.getDebugTarget() instanceof ISwitchToThread ) + { + if ( element instanceof IThread ) + { + return ((IThread)element).equals( ((ISwitchToThread)element.getDebugTarget()).getCurrentThread() ); + } + if ( element instanceof IStackFrame ) + { + return ((IStackFrame)element).getThread().equals( ((ISwitchToThread)element.getDebugTarget()).getCurrentThread() ); + } + } + return false; + } }