From 15070bcc55c24e52bf90530ab125e8ecfbd5ff12 Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Sun, 27 Jul 2008 18:05:39 +0000 Subject: [PATCH] Hacked threadId for non multi-thread applications. --- .../src/org/eclipse/dd/mi/service/MIRunControl.java | 10 ++++++---- .../dd/mi/service/command/AbstractMIControl.java | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/MIRunControl.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/MIRunControl.java index d82ed1354a2..38d81a9ddea 100644 --- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/MIRunControl.java +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/MIRunControl.java @@ -303,7 +303,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl private StateChangeReason fStateChangeReason; private IExecutionDMContext fStateChangeTriggeringContext; - private static final int DEFAULT_THREAD_ID = 1; + private static final int FAKE_THREAD_ID = 0; public MIRunControl(DsfSession session) { super(session); @@ -655,9 +655,11 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl private IExecutionDMContext[] makeExecutionDMCs(IContainerDMContext containerCtx, MIThreadListIdsInfo info) { if (info.getThreadIds().length == 0) { - //Main thread always exist even if it is not reported by GDB. - //So create thread-id= 0 when no thread is reported - return new IMIExecutionDMContext[]{createMIExecutionContext(containerCtx, DEFAULT_THREAD_ID)}; + // Main thread always exist even if it is not reported by GDB. + // So create thread-id = 0 when no thread is reported. + // This hack is necessary to prevent AbstractMIControl from issuing a thread-select + // because it doesn't work if the application was not compiled with pthread. + return new IMIExecutionDMContext[]{new MIExecutionDMC(getSession().getId(), containerCtx, FAKE_THREAD_ID)}; } else { IExecutionDMContext[] executionDmcs = new IMIExecutionDMContext[info.getThreadIds().length]; for (int i = 0; i < info.getThreadIds().length; i++) { diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/AbstractMIControl.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/AbstractMIControl.java index 483f1049ab8..1fc81db595f 100644 --- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/AbstractMIControl.java +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/AbstractMIControl.java @@ -259,7 +259,7 @@ public abstract class AbstractMIControl extends AbstractDsfService if (runControl != null && execDmc != null && runControl.isSuspended(execDmc)) { // Before the command is sent, Check the Thread Id and send it to // the queue only if the id has been changed. - if (targetThread != -1 && targetThread != fCurrentThreadId) { + if (targetThread > 0 && targetThread != fCurrentThreadId) { fCurrentThreadId = targetThread; resetCurrentStackLevel(); CommandHandle cmdHandle = new CommandHandle(new MIThreadSelect(execDmc), null);