1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 23:05:47 +02:00

Minor additional locking to enhance the safety of the currentThreadID

and to ensure that we are always setting the stack frame initially, even
in the case where it is being arbitrarily selected.
PR 151253
This commit is contained in:
Thomas Fletcher 2006-08-17 19:55:50 +00:00
parent b4286a0d6e
commit 2f1ea39182

View file

@ -256,6 +256,7 @@ public class Target extends SessionObject implements ICDITarget {
// If we use "info threads" in getCThreads() this // If we use "info threads" in getCThreads() this
// 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();
currentThreadId = newThreadId; currentThreadId = newThreadId;
// get the new Threads. // get the new Threads.
@ -264,6 +265,7 @@ public class Target extends SessionObject implements ICDITarget {
} catch (CDIException e) { } catch (CDIException e) {
currentThreads = noThreads; currentThreads = noThreads;
} }
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
@ -322,6 +324,7 @@ public class Target extends SessionObject implements ICDITarget {
public Thread[] getCThreads() throws CDIException { public Thread[] getCThreads() throws CDIException {
Thread[] cthreads = noThreads; Thread[] cthreads = noThreads;
try { try {
lockTarget();
RxThread rxThread = miSession.getRxThread(); RxThread rxThread = miSession.getRxThread();
rxThread.setEnableConsole(false); rxThread.setEnableConsole(false);
CommandFactory factory = miSession.getCommandFactory(); CommandFactory factory = miSession.getCommandFactory();
@ -362,7 +365,7 @@ public class Target extends SessionObject implements ICDITarget {
// FIX: When attaching there is no thread selected // FIX: When attaching there is no thread selected
// We will choose the first one as a workaround. // We will choose the first one as a workaround.
if (currentThreadId == 0 && cthreads.length > 0) { if (currentThreadId == 0 && cthreads.length > 0) {
currentThreadId = cthreads[0].getId(); setCurrentThread(cthreads[0], false);
} }
} catch (MIException e) { } catch (MIException e) {
// Do not throw anything in this case. // Do not throw anything in this case.
@ -370,6 +373,7 @@ public class Target extends SessionObject implements ICDITarget {
} finally { } finally {
RxThread rxThread = miSession.getRxThread(); RxThread rxThread = miSession.getRxThread();
rxThread.setEnableConsole(true); rxThread.setEnableConsole(true);
releaseTarget();
} }
return cthreads; return cthreads;
} }