From 2f1ea39182e71d86ec07915de0dd72aa9b46cfd3 Mon Sep 17 00:00:00 2001 From: Thomas Fletcher Date: Thu, 17 Aug 2006 19:55:50 +0000 Subject: [PATCH] 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 --- .../cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 f508a6e67ed..ed7c84c9323 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 @@ -256,6 +256,7 @@ public class Target extends SessionObject implements ICDITarget { // If we use "info threads" in getCThreads() this // 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. @@ -264,6 +265,7 @@ public class Target extends SessionObject implements ICDITarget { } catch (CDIException e) { currentThreads = noThreads; } + releaseTarget(); // Fire CreatedEvent for new threads. // 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 { Thread[] cthreads = noThreads; try { + lockTarget(); RxThread rxThread = miSession.getRxThread(); rxThread.setEnableConsole(false); CommandFactory factory = miSession.getCommandFactory(); @@ -362,7 +365,7 @@ public class Target extends SessionObject implements ICDITarget { // FIX: When attaching there is no thread selected // We will choose the first one as a workaround. if (currentThreadId == 0 && cthreads.length > 0) { - currentThreadId = cthreads[0].getId(); + setCurrentThread(cthreads[0], false); } } catch (MIException e) { // Do not throw anything in this case. @@ -370,6 +373,7 @@ public class Target extends SessionObject implements ICDITarget { } finally { RxThread rxThread = miSession.getRxThread(); rxThread.setEnableConsole(true); + releaseTarget(); } return cthreads; }