1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Bug 215553 - patch for Alena - ensure the target is released in exception scenarios.

This commit is contained in:
Doug Schaefer 2008-01-28 19:56:26 +00:00
parent 0d547afec5
commit d1561de41d
5 changed files with 68 additions and 37 deletions

View file

@ -203,9 +203,12 @@ public class ExpressionManager extends Manager {
} catch (MIException e) { } catch (MIException e) {
throw new MI2CDIException(e); throw new MI2CDIException(e);
} finally { } finally {
target.setCurrentThread(currentThread, false); try {
currentThread.setCurrentStackFrame(currentFrame, false); target.setCurrentThread(currentThread, false);
target.releaseTarget(); currentThread.setCurrentStackFrame(currentFrame, false);
} finally {
target.releaseTarget();
}
} }
} }

View file

@ -430,9 +430,12 @@ public class SourceManager extends Manager {
((Thread)frame.getThread()).setCurrentStackFrame(frame, false); ((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
return getDetailTypeName(target, variable); return getDetailTypeName(target, variable);
} finally { } finally {
target.setCurrentThread(currentThread, false); try {
currentThread.setCurrentStackFrame(currentFrame, false); target.setCurrentThread(currentThread, false);
target.releaseTarget(); currentThread.setCurrentStackFrame(currentFrame, false);
} finally {
target.releaseTarget();
}
} }
} }
public String getDetailTypeName(Target target, String typename) throws CDIException { public String getDetailTypeName(Target target, String typename) throws CDIException {
@ -468,9 +471,12 @@ public class SourceManager extends Manager {
((Thread)frame.getThread()).setCurrentStackFrame(frame, false); ((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
return getTypeName(target, variable); return getTypeName(target, variable);
} finally { } finally {
target.setCurrentThread(currentThread, false); try {
currentThread.setCurrentStackFrame(currentFrame, false); target.setCurrentThread(currentThread, false);
target.releaseTarget(); currentThread.setCurrentStackFrame(currentFrame, false);
} finally {
target.releaseTarget();
}
} }
} }

View file

@ -192,12 +192,15 @@ public class VariableManager extends Manager {
} catch (MIException e) { } catch (MIException e) {
throw new MI2CDIException(e); throw new MI2CDIException(e);
} finally { } finally {
MISession miSession = target.getMISession(); try {
RxThread rxThread = miSession.getRxThread(); MISession miSession = target.getMISession();
rxThread.setEnableConsole(true); RxThread rxThread = miSession.getRxThread();
target.setCurrentThread(currentThread, false); rxThread.setEnableConsole(true);
currentThread.setCurrentStackFrame(currentFrame, false); target.setCurrentThread(currentThread, false);
target.releaseTarget(); currentThread.setCurrentStackFrame(currentFrame, false);
} finally {
target.releaseTarget();
}
} }
} else { } else {
throw new CDIException(CdiResources.getString("cdi.VariableManager.Unknown_type")); //$NON-NLS-1$ throw new CDIException(CdiResources.getString("cdi.VariableManager.Unknown_type")); //$NON-NLS-1$
@ -389,9 +392,12 @@ public class VariableManager extends Manager {
} catch (MIException e) { } catch (MIException e) {
throw new MI2CDIException(e); throw new MI2CDIException(e);
} finally { } finally {
target.setCurrentThread(currentThread, false); try {
currentThread.setCurrentStackFrame(currentFrame, false); target.setCurrentThread(currentThread, false);
target.releaseTarget(); currentThread.setCurrentStackFrame(currentFrame, false);
} finally {
target.releaseTarget();
}
} }
} }
return argument; return argument;
@ -432,9 +438,12 @@ public class VariableManager extends Manager {
} catch (MIException e) { } catch (MIException e) {
throw new MI2CDIException(e); throw new MI2CDIException(e);
} finally { } finally {
target.setCurrentThread(currentThread, false); try {
currentThread.setCurrentStackFrame(currentFrame, false); target.setCurrentThread(currentThread, false);
target.releaseTarget(); currentThread.setCurrentStackFrame(currentFrame, false);
} finally {
target.releaseTarget();
}
} }
return (ICDIArgumentDescriptor[]) argObjects.toArray(new ICDIArgumentDescriptor[0]); return (ICDIArgumentDescriptor[]) argObjects.toArray(new ICDIArgumentDescriptor[0]);
} }
@ -519,9 +528,12 @@ public class VariableManager extends Manager {
} catch (MIException e) { } catch (MIException e) {
throw new MI2CDIException(e); throw new MI2CDIException(e);
} finally { } finally {
target.setCurrentThread(currentThread, false); try {
currentThread.setCurrentStackFrame(currentFrame, false); target.setCurrentThread(currentThread, false);
target.releaseTarget(); currentThread.setCurrentStackFrame(currentFrame, false);
} finally {
target.releaseTarget();
}
} }
return (ICDILocalVariableDescriptor[]) varObjects.toArray(new ICDILocalVariableDescriptor[0]); return (ICDILocalVariableDescriptor[]) varObjects.toArray(new ICDILocalVariableDescriptor[0]);
} }
@ -558,9 +570,12 @@ public class VariableManager extends Manager {
} catch (MIException e) { } catch (MIException e) {
throw new MI2CDIException(e); throw new MI2CDIException(e);
} finally { } finally {
target.setCurrentThread(currentThread, false); try {
currentThread.setCurrentStackFrame(currentFrame, false); target.setCurrentThread(currentThread, false);
target.releaseTarget(); currentThread.setCurrentStackFrame(currentFrame, false);
} finally {
target.releaseTarget();
}
} }
} }
return local; return local;

View file

@ -272,15 +272,15 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
// will be overwritten. However if we use -stack-list-threads // will be overwritten. However if we use -stack-list-threads
// it does not provide to the current thread // it does not provide to the current thread
lockTarget(); lockTarget();
currentThreadId = newThreadId;
// get the new Threads.
try { try {
// get the new Threads.
currentThreadId = newThreadId;
currentThreads = getCThreads(); currentThreads = getCThreads();
} catch (CDIException e) { } catch (CDIException e) {
currentThreads = noThreads; currentThreads = noThreads;
} finally {
releaseTarget();
} }
releaseTarget();
// Fire CreatedEvent for new threads. // Fire CreatedEvent for new threads.
// Replace the new threads with the old thread object // Replace the new threads with the old thread object

View file

@ -131,8 +131,11 @@ public class Thread extends CObject implements ICDIThread {
//throw e; //throw e;
//System.out.println(e); //System.out.println(e);
} finally { } finally {
target.setCurrentThread(currentThread, false); try {
target.releaseTarget(); target.setCurrentThread(currentThread, false);
} finally {
target.releaseTarget();
}
} }
// assign the currentFrame if it was not done yet. // assign the currentFrame if it was not done yet.
if (currentFrame == null) { if (currentFrame == null) {
@ -187,12 +190,13 @@ public class Thread extends CObject implements ICDIThread {
throw new MI2CDIException(e); throw new MI2CDIException(e);
} finally { } finally {
try { try {
target.setCurrentThread(currentThread, false); target.setCurrentThread(currentThread, false);
} catch (MI2CDIException e) { } catch (MI2CDIException e) {
target.releaseTarget(); target.releaseTarget();
throw e; throw e;
} finally {
target.releaseTarget();
} }
target.releaseTarget();
} }
} }
return stackdepth; return stackdepth;
@ -239,8 +243,11 @@ public class Thread extends CObject implements ICDIThread {
//throw e; //throw e;
//System.out.println(e); //System.out.println(e);
} finally { } finally {
target.setCurrentThread(currentThread, false); try {
target.releaseTarget(); target.setCurrentThread(currentThread, false);
} finally {
target.releaseTarget();
}
} }
// take time to assign the currentFrame, if it is in the set // take time to assign the currentFrame, if it is in the set
if (currentFrame == null) { if (currentFrame == null) {