diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java index df0f2fa8cc1..c6f28fd1d62 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java @@ -203,9 +203,12 @@ public class ExpressionManager extends Manager { } catch (MIException e) { throw new MI2CDIException(e); } finally { - target.setCurrentThread(currentThread, false); - currentThread.setCurrentStackFrame(currentFrame, false); - target.releaseTarget(); + try { + target.setCurrentThread(currentThread, false); + currentThread.setCurrentStackFrame(currentFrame, false); + } finally { + target.releaseTarget(); + } } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java index 1b28c47c66c..d57a9eb276f 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java @@ -430,9 +430,12 @@ public class SourceManager extends Manager { ((Thread)frame.getThread()).setCurrentStackFrame(frame, false); return getDetailTypeName(target, variable); } finally { - target.setCurrentThread(currentThread, false); - currentThread.setCurrentStackFrame(currentFrame, false); - target.releaseTarget(); + try { + target.setCurrentThread(currentThread, false); + currentThread.setCurrentStackFrame(currentFrame, false); + } finally { + target.releaseTarget(); + } } } public String getDetailTypeName(Target target, String typename) throws CDIException { @@ -468,9 +471,12 @@ public class SourceManager extends Manager { ((Thread)frame.getThread()).setCurrentStackFrame(frame, false); return getTypeName(target, variable); } finally { - target.setCurrentThread(currentThread, false); - currentThread.setCurrentStackFrame(currentFrame, false); - target.releaseTarget(); + try { + target.setCurrentThread(currentThread, false); + currentThread.setCurrentStackFrame(currentFrame, false); + } finally { + target.releaseTarget(); + } } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java index 43ea841bc7a..779d59f162e 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java @@ -192,12 +192,15 @@ public class VariableManager extends Manager { } catch (MIException e) { throw new MI2CDIException(e); } finally { - MISession miSession = target.getMISession(); - RxThread rxThread = miSession.getRxThread(); - rxThread.setEnableConsole(true); - target.setCurrentThread(currentThread, false); - currentThread.setCurrentStackFrame(currentFrame, false); - target.releaseTarget(); + try { + MISession miSession = target.getMISession(); + RxThread rxThread = miSession.getRxThread(); + rxThread.setEnableConsole(true); + target.setCurrentThread(currentThread, false); + currentThread.setCurrentStackFrame(currentFrame, false); + } finally { + target.releaseTarget(); + } } } else { throw new CDIException(CdiResources.getString("cdi.VariableManager.Unknown_type")); //$NON-NLS-1$ @@ -389,9 +392,12 @@ public class VariableManager extends Manager { } catch (MIException e) { throw new MI2CDIException(e); } finally { - target.setCurrentThread(currentThread, false); - currentThread.setCurrentStackFrame(currentFrame, false); - target.releaseTarget(); + try { + target.setCurrentThread(currentThread, false); + currentThread.setCurrentStackFrame(currentFrame, false); + } finally { + target.releaseTarget(); + } } } return argument; @@ -432,9 +438,12 @@ public class VariableManager extends Manager { } catch (MIException e) { throw new MI2CDIException(e); } finally { - target.setCurrentThread(currentThread, false); - currentThread.setCurrentStackFrame(currentFrame, false); - target.releaseTarget(); + try { + target.setCurrentThread(currentThread, false); + currentThread.setCurrentStackFrame(currentFrame, false); + } finally { + target.releaseTarget(); + } } return (ICDIArgumentDescriptor[]) argObjects.toArray(new ICDIArgumentDescriptor[0]); } @@ -519,9 +528,12 @@ public class VariableManager extends Manager { } catch (MIException e) { throw new MI2CDIException(e); } finally { - target.setCurrentThread(currentThread, false); - currentThread.setCurrentStackFrame(currentFrame, false); - target.releaseTarget(); + try { + target.setCurrentThread(currentThread, false); + currentThread.setCurrentStackFrame(currentFrame, false); + } finally { + target.releaseTarget(); + } } return (ICDILocalVariableDescriptor[]) varObjects.toArray(new ICDILocalVariableDescriptor[0]); } @@ -558,9 +570,12 @@ public class VariableManager extends Manager { } catch (MIException e) { throw new MI2CDIException(e); } finally { - target.setCurrentThread(currentThread, false); - currentThread.setCurrentStackFrame(currentFrame, false); - target.releaseTarget(); + try { + target.setCurrentThread(currentThread, false); + currentThread.setCurrentStackFrame(currentFrame, false); + } finally { + target.releaseTarget(); + } } } return local; diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java index 9a4d90b438f..3e16afc7987 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java @@ -272,15 +272,15 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM // will be overwritten. However if we use -stack-list-threads // it does not provide to the current thread lockTarget(); - currentThreadId = newThreadId; - - // get the new Threads. try { + // get the new Threads. + currentThreadId = newThreadId; currentThreads = getCThreads(); } catch (CDIException e) { currentThreads = noThreads; + } finally { + releaseTarget(); } - releaseTarget(); // Fire CreatedEvent for new threads. // Replace the new threads with the old thread object diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java index bb7221997e6..d031b9c5ec9 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java @@ -131,8 +131,11 @@ public class Thread extends CObject implements ICDIThread { //throw e; //System.out.println(e); } finally { - target.setCurrentThread(currentThread, false); - target.releaseTarget(); + try { + target.setCurrentThread(currentThread, false); + } finally { + target.releaseTarget(); + } } // assign the currentFrame if it was not done yet. if (currentFrame == null) { @@ -187,12 +190,13 @@ public class Thread extends CObject implements ICDIThread { throw new MI2CDIException(e); } finally { try { - target.setCurrentThread(currentThread, false); + target.setCurrentThread(currentThread, false); } catch (MI2CDIException e) { target.releaseTarget(); throw e; + } finally { + target.releaseTarget(); } - target.releaseTarget(); } } return stackdepth; @@ -239,8 +243,11 @@ public class Thread extends CObject implements ICDIThread { //throw e; //System.out.println(e); } finally { - target.setCurrentThread(currentThread, false); - target.releaseTarget(); + try { + target.setCurrentThread(currentThread, false); + } finally { + target.releaseTarget(); + } } // take time to assign the currentFrame, if it is in the set if (currentFrame == null) {