mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Fix for 221224: debugger mi target locking problems
Patch contributed by Alena Laskavaia <elaskavaia@qnx.com>
This commit is contained in:
parent
8d07be5f20
commit
da521c277c
7 changed files with 235 additions and 308 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
* Copyright (c) 2000, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Alena Laskavaia (QNX) - Bug 221224
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
@ -184,7 +185,7 @@ public class ExpressionManager extends Manager {
|
||||||
Target target = (Target)frame.getTarget();
|
Target target = (Target)frame.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
target.lockTarget();
|
synchronized(target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(frame.getThread(), false);
|
target.setCurrentThread(frame.getThread(), false);
|
||||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||||
|
@ -203,11 +204,8 @@ public class ExpressionManager extends Manager {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
target.setCurrentThread(currentThread, false);
|
target.setCurrentThread(currentThread, false);
|
||||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||||
} finally {
|
|
||||||
target.releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2007 QNX Software Systems and others.
|
* Copyright (c) 2000, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Giuseppe Montalto, STMicroelectronics - bug 174988
|
* Giuseppe Montalto, STMicroelectronics - bug 174988
|
||||||
|
* Alena Laskavaia (QNX) - Bug 221224
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
@ -255,7 +256,7 @@ public class RegisterManager extends Manager {
|
||||||
Target target = (Target)frame.getTarget();
|
Target target = (Target)frame.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
target.lockTarget();
|
synchronized(target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(frame.getThread(), false);
|
target.setCurrentThread(frame.getThread(), false);
|
||||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||||
|
@ -271,11 +272,8 @@ public class RegisterManager extends Manager {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
target.setCurrentThread(currentThread, false);
|
target.setCurrentThread(currentThread, false);
|
||||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||||
} finally {
|
|
||||||
target.releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,7 +282,7 @@ public class RegisterManager extends Manager {
|
||||||
Target target = (Target)frame.getTarget();
|
Target target = (Target)frame.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
target.lockTarget();
|
synchronized(target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(frame.getThread(), false);
|
target.setCurrentThread(frame.getThread(), false);
|
||||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||||
|
@ -301,11 +299,8 @@ public class RegisterManager extends Manager {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
target.setCurrentThread(currentThread, false);
|
target.setCurrentThread(currentThread, false);
|
||||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||||
} finally {
|
|
||||||
target.releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
* Copyright (c) 2000, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Alena Laskavaia (QNX) - Bug 221224
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
@ -424,17 +425,14 @@ public class SourceManager extends Manager {
|
||||||
Target target = (Target)frame.getTarget();
|
Target target = (Target)frame.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
target.lockTarget();
|
synchronized(target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(frame.getThread(), false);
|
target.setCurrentThread(frame.getThread(), false);
|
||||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||||
return getDetailTypeName(target, variable);
|
return getDetailTypeName(target, variable);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
target.setCurrentThread(currentThread, false);
|
target.setCurrentThread(currentThread, false);
|
||||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||||
} finally {
|
|
||||||
target.releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,17 +463,14 @@ public class SourceManager extends Manager {
|
||||||
Target target = (Target)frame.getTarget();
|
Target target = (Target)frame.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
target.lockTarget();
|
synchronized(target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(frame.getThread(), false);
|
target.setCurrentThread(frame.getThread(), false);
|
||||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||||
return getTypeName(target, variable);
|
return getTypeName(target, variable);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
target.setCurrentThread(currentThread, false);
|
target.setCurrentThread(currentThread, false);
|
||||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||||
} finally {
|
|
||||||
target.releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2007 QNX Software Systems and others.
|
* Copyright (c) 2000, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Alena Laskavaia (QNX) - Bug 197986
|
* Alena Laskavaia (QNX) - Bug 197986, Bug 221224
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ public class VariableManager extends Manager {
|
||||||
Target target = (Target)frame.getTarget();
|
Target target = (Target)frame.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
target.lockTarget();
|
synchronized(target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(frame.getThread(), false);
|
target.setCurrentThread(frame.getThread(), false);
|
||||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||||
|
@ -194,14 +194,11 @@ public class VariableManager extends Manager {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
MISession miSession = target.getMISession();
|
MISession miSession = target.getMISession();
|
||||||
RxThread rxThread = miSession.getRxThread();
|
RxThread rxThread = miSession.getRxThread();
|
||||||
rxThread.setEnableConsole(true);
|
rxThread.setEnableConsole(true);
|
||||||
target.setCurrentThread(currentThread, false);
|
target.setCurrentThread(currentThread, false);
|
||||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||||
} finally {
|
|
||||||
target.releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -374,7 +371,7 @@ public class VariableManager extends Manager {
|
||||||
Target target = (Target)argDesc.getTarget();
|
Target target = (Target)argDesc.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
target.lockTarget();
|
synchronized(target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(stack.getThread(), false);
|
target.setCurrentThread(stack.getThread(), false);
|
||||||
((Thread)stack.getThread()).setCurrentStackFrame(stack, false);
|
((Thread)stack.getThread()).setCurrentStackFrame(stack, false);
|
||||||
|
@ -394,11 +391,8 @@ public class VariableManager extends Manager {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
target.setCurrentThread(currentThread, false);
|
target.setCurrentThread(currentThread, false);
|
||||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||||
} finally {
|
|
||||||
target.releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,7 +404,7 @@ public class VariableManager extends Manager {
|
||||||
Target target = (Target)frame.getTarget();
|
Target target = (Target)frame.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
target.lockTarget();
|
synchronized(target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(frame.getThread(), false);
|
target.setCurrentThread(frame.getThread(), false);
|
||||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||||
|
@ -440,11 +434,8 @@ public class VariableManager extends Manager {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
target.setCurrentThread(currentThread, false);
|
target.setCurrentThread(currentThread, false);
|
||||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||||
} finally {
|
|
||||||
target.releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (ICDIArgumentDescriptor[]) argObjects.toArray(new ICDIArgumentDescriptor[0]);
|
return (ICDIArgumentDescriptor[]) argObjects.toArray(new ICDIArgumentDescriptor[0]);
|
||||||
|
@ -506,7 +497,7 @@ public class VariableManager extends Manager {
|
||||||
Target target = (Target)frame.getTarget();
|
Target target = (Target)frame.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
target.lockTarget();
|
synchronized(target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(frame.getThread(), false);
|
target.setCurrentThread(frame.getThread(), false);
|
||||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||||
|
@ -530,11 +521,8 @@ public class VariableManager extends Manager {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
target.setCurrentThread(currentThread, false);
|
target.setCurrentThread(currentThread, false);
|
||||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||||
} finally {
|
|
||||||
target.releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (ICDILocalVariableDescriptor[]) varObjects.toArray(new ICDILocalVariableDescriptor[0]);
|
return (ICDILocalVariableDescriptor[]) varObjects.toArray(new ICDILocalVariableDescriptor[0]);
|
||||||
|
@ -552,7 +540,7 @@ public class VariableManager extends Manager {
|
||||||
Target target = (Target)varDesc.getTarget();
|
Target target = (Target)varDesc.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
target.lockTarget();
|
synchronized(target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(stack.getThread(), false);
|
target.setCurrentThread(stack.getThread(), false);
|
||||||
((Thread)stack.getThread()).setCurrentStackFrame(stack, false);
|
((Thread)stack.getThread()).setCurrentStackFrame(stack, false);
|
||||||
|
@ -572,11 +560,8 @@ public class VariableManager extends Manager {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
target.setCurrentThread(currentThread, false);
|
target.setCurrentThread(currentThread, false);
|
||||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||||
} finally {
|
|
||||||
target.releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2007 QNX Software Systems and others.
|
* Copyright (c) 2000, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Ken Ryall (Nokia) - 175532 support the address to source location API
|
* Ken Ryall (Nokia) - 175532 support the address to source location API
|
||||||
|
* Alena Laskavaia (QNX) - Bug 221224
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi.model;
|
package org.eclipse.cdt.debug.mi.core.cdi.model;
|
||||||
|
|
||||||
|
@ -100,45 +101,6 @@ import org.eclipse.cdt.debug.mi.core.output.MIThreadSelectInfo;
|
||||||
*/
|
*/
|
||||||
public class Target extends SessionObject implements ICDITarget, ICDIBreakpointManagement2, ICDIAddressToSource, ICDIMemorySpaceManagement {
|
public class Target extends SessionObject implements ICDITarget, ICDIBreakpointManagement2, ICDIAddressToSource, ICDIMemorySpaceManagement {
|
||||||
|
|
||||||
public class Lock {
|
|
||||||
|
|
||||||
java.lang.Thread heldBy;
|
|
||||||
int count;
|
|
||||||
|
|
||||||
public Lock() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void aquire() {
|
|
||||||
if (heldBy == null || heldBy == java.lang.Thread.currentThread()) {
|
|
||||||
heldBy = java.lang.Thread.currentThread();
|
|
||||||
count++;
|
|
||||||
} else {
|
|
||||||
while (true) {
|
|
||||||
try {
|
|
||||||
wait();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
if (heldBy == null) {
|
|
||||||
heldBy = java.lang.Thread.currentThread();
|
|
||||||
count++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void release() {
|
|
||||||
if (heldBy == null || heldBy != java.lang.Thread.currentThread()) {
|
|
||||||
throw new IllegalStateException("Thread does not own lock");
|
|
||||||
}
|
|
||||||
if(--count == 0) {
|
|
||||||
heldBy = null;
|
|
||||||
notifyAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MISession miSession;
|
MISession miSession;
|
||||||
ICDITargetConfiguration fConfiguration;
|
ICDITargetConfiguration fConfiguration;
|
||||||
Thread[] noThreads = new Thread[0];
|
Thread[] noThreads = new Thread[0];
|
||||||
|
@ -147,7 +109,7 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
|
||||||
String fEndian = null;
|
String fEndian = null;
|
||||||
boolean suspended = true;
|
boolean suspended = true;
|
||||||
boolean deferBreakpoints = true;
|
boolean deferBreakpoints = true;
|
||||||
Lock lock = new Lock();
|
final private Object lock = new Object();
|
||||||
|
|
||||||
final static String CODE_MEMORY_SPACE = "code"; //$NON-NLS-1$
|
final static String CODE_MEMORY_SPACE = "code"; //$NON-NLS-1$
|
||||||
final static String DATA_MEMORY_SPACE = "data"; //$NON-NLS-1$
|
final static String DATA_MEMORY_SPACE = "data"; //$NON-NLS-1$
|
||||||
|
@ -158,13 +120,37 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
|
||||||
currentThreads = noThreads;
|
currentThreads = noThreads;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lockTarget() {
|
/**
|
||||||
lock.aquire();
|
* Return lock object for target. Replacement for <code>lockTarget</code> and
|
||||||
|
* <code>releaseTarget</code> methods.
|
||||||
|
* <p>
|
||||||
|
* Use as synchronization object:
|
||||||
|
* </p>
|
||||||
|
* new code:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* synchronized (target.getLock()) {
|
||||||
|
* ...
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* old code:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* target.lockTarget();
|
||||||
|
* try {
|
||||||
|
* ...
|
||||||
|
* } finally {
|
||||||
|
* target.releaseTarget();
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public Object getLock() {
|
||||||
|
return lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void releaseTarget() {
|
|
||||||
lock.release();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MISession getMISession() {
|
public MISession getMISession() {
|
||||||
return miSession;
|
return miSession;
|
||||||
|
@ -271,15 +257,14 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
|
||||||
// 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();
|
synchronized (lock) {
|
||||||
try {
|
try {
|
||||||
// get the new Threads.
|
// get the new Threads.
|
||||||
currentThreadId = newThreadId;
|
currentThreadId = newThreadId;
|
||||||
currentThreads = getCThreads();
|
currentThreads = getCThreads();
|
||||||
} catch (CDIException e) {
|
} catch (CDIException e) {
|
||||||
currentThreads = noThreads;
|
currentThreads = noThreads;
|
||||||
} finally {
|
}
|
||||||
releaseTarget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fire CreatedEvent for new threads.
|
// Fire CreatedEvent for new threads.
|
||||||
|
@ -338,10 +323,10 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
|
||||||
*/
|
*/
|
||||||
public Thread[] getCThreads() throws CDIException {
|
public Thread[] getCThreads() throws CDIException {
|
||||||
Thread[] cthreads = noThreads;
|
Thread[] cthreads = noThreads;
|
||||||
try {
|
synchronized (lock) {
|
||||||
lockTarget();
|
|
||||||
RxThread rxThread = miSession.getRxThread();
|
RxThread rxThread = miSession.getRxThread();
|
||||||
rxThread.setEnableConsole(false);
|
rxThread.setEnableConsole(false);
|
||||||
|
try {
|
||||||
CommandFactory factory = miSession.getCommandFactory();
|
CommandFactory factory = miSession.getCommandFactory();
|
||||||
CLIInfoThreads tids = factory.createCLIInfoThreads();
|
CLIInfoThreads tids = factory.createCLIInfoThreads();
|
||||||
// HACK/FIXME: gdb/mi thread-list-ids does not
|
// HACK/FIXME: gdb/mi thread-list-ids does not
|
||||||
|
@ -386,9 +371,8 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
|
||||||
// Do not throw anything in this case.
|
// Do not throw anything in this case.
|
||||||
throw new CDIException(e.getMessage());
|
throw new CDIException(e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
RxThread rxThread = miSession.getRxThread();
|
|
||||||
rxThread.setEnableConsole(true);
|
rxThread.setEnableConsole(true);
|
||||||
releaseTarget();
|
}
|
||||||
}
|
}
|
||||||
return cthreads;
|
return cthreads;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2007 QNX Software Systems and others.
|
* Copyright (c) 2000, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Alena Laskavaia (QNX) - Bug 221224
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi.model;
|
package org.eclipse.cdt.debug.mi.core.cdi.model;
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
currentFrames = new ArrayList();
|
currentFrames = new ArrayList();
|
||||||
Target target = (Target)getTarget();
|
Target target = (Target)getTarget();
|
||||||
ICDIThread currentThread = target.getCurrentThread();
|
ICDIThread currentThread = target.getCurrentThread();
|
||||||
target.lockTarget();
|
synchronized (target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(this, false);
|
target.setCurrentThread(this, false);
|
||||||
MISession mi = target.getMISession();
|
MISession mi = target.getMISession();
|
||||||
|
@ -131,10 +132,7 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
//throw e;
|
//throw e;
|
||||||
//System.out.println(e);
|
//System.out.println(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
target.setCurrentThread(currentThread, false);
|
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.
|
||||||
|
@ -157,7 +155,7 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
if (stackdepth == 0) {
|
if (stackdepth == 0) {
|
||||||
Target target = (Target)getTarget();
|
Target target = (Target)getTarget();
|
||||||
ICDIThread currentThread = target.getCurrentThread();
|
ICDIThread currentThread = target.getCurrentThread();
|
||||||
target.lockTarget();
|
synchronized (target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(this, false);
|
target.setCurrentThread(this, false);
|
||||||
MISession mi = target.getMISession();
|
MISession mi = target.getMISession();
|
||||||
|
@ -189,13 +187,7 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
target.setCurrentThread(currentThread, false);
|
target.setCurrentThread(currentThread, false);
|
||||||
} catch (MI2CDIException e) {
|
|
||||||
target.releaseTarget();
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
target.releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +202,7 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
currentFrames = new ArrayList();
|
currentFrames = new ArrayList();
|
||||||
Target target = (Target) getTarget();
|
Target target = (Target) getTarget();
|
||||||
ICDIThread currentThread = target.getCurrentThread();
|
ICDIThread currentThread = target.getCurrentThread();
|
||||||
target.lockTarget();
|
synchronized (target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(this, false);
|
target.setCurrentThread(this, false);
|
||||||
int depth = getStackFrameCount();
|
int depth = getStackFrameCount();
|
||||||
|
@ -243,10 +235,7 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
//throw e;
|
//throw e;
|
||||||
//System.out.println(e);
|
//System.out.println(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
target.setCurrentThread(currentThread, false);
|
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
|
||||||
|
@ -294,7 +283,7 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
int miLevel = getStackFrameCount() - frameLevel;
|
int miLevel = getStackFrameCount() - frameLevel;
|
||||||
MIStackSelectFrame frame = factory.createMIStackSelectFrame(miLevel);
|
MIStackSelectFrame frame = factory.createMIStackSelectFrame(miLevel);
|
||||||
// Set ourself as the current thread first.
|
// Set ourself as the current thread first.
|
||||||
target.lockTarget();
|
synchronized (target.getLock()) {
|
||||||
try {
|
try {
|
||||||
target.setCurrentThread(this, doUpdate);
|
target.setCurrentThread(this, doUpdate);
|
||||||
mi.postCommand(frame);
|
mi.postCommand(frame);
|
||||||
|
@ -319,8 +308,7 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
}
|
||||||
target.releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,12 +323,10 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteStep#stepInto(int)
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteStep#stepInto(int)
|
||||||
*/
|
*/
|
||||||
public void stepInto(int count) throws CDIException {
|
public void stepInto(int count) throws CDIException {
|
||||||
((Target)getTarget()).lockTarget();
|
Target target = (Target)getTarget();
|
||||||
try {
|
synchronized(target.getLock()) {
|
||||||
((Target)getTarget()).setCurrentThread(this);
|
target.setCurrentThread(this);
|
||||||
getTarget().stepInto(count);
|
target.stepInto(count);
|
||||||
} finally {
|
|
||||||
((Target)getTarget()).releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,12 +341,10 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteStep#stepIntoInstruction(int)
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteStep#stepIntoInstruction(int)
|
||||||
*/
|
*/
|
||||||
public void stepIntoInstruction(int count) throws CDIException {
|
public void stepIntoInstruction(int count) throws CDIException {
|
||||||
((Target)getTarget()).lockTarget();
|
Target target = (Target)getTarget();
|
||||||
try {
|
synchronized(target.getLock()) {
|
||||||
((Target)getTarget()).setCurrentThread(this);
|
target.setCurrentThread(this);
|
||||||
getTarget().stepIntoInstruction(count);
|
target.stepIntoInstruction(count);
|
||||||
} finally {
|
|
||||||
((Target)getTarget()).releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,12 +359,10 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteStep#stepOver(int)
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteStep#stepOver(int)
|
||||||
*/
|
*/
|
||||||
public void stepOver(int count) throws CDIException {
|
public void stepOver(int count) throws CDIException {
|
||||||
((Target)getTarget()).lockTarget();
|
Target target = (Target)getTarget();
|
||||||
try {
|
synchronized(target.getLock()) {
|
||||||
((Target)getTarget()).setCurrentThread(this);
|
target.setCurrentThread(this);
|
||||||
getTarget().stepOver(count);
|
target.stepOver(count);
|
||||||
} finally {
|
|
||||||
((Target)getTarget()).releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,12 +377,10 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteStep#stepOverInstruction(int)
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteStep#stepOverInstruction(int)
|
||||||
*/
|
*/
|
||||||
public void stepOverInstruction(int count) throws CDIException {
|
public void stepOverInstruction(int count) throws CDIException {
|
||||||
((Target)getTarget()).lockTarget();
|
Target target = (Target)getTarget();
|
||||||
try {
|
synchronized(target.getLock()) {
|
||||||
((Target)getTarget()).setCurrentThread(this);
|
target.setCurrentThread(this);
|
||||||
getTarget().stepOverInstruction(count);
|
target.stepOverInstruction(count);
|
||||||
} finally {
|
|
||||||
((Target)getTarget()).releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,12 +402,10 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteStep#stepUntil(org.eclipse.cdt.debug.core.cdi.ICDILocation)
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteStep#stepUntil(org.eclipse.cdt.debug.core.cdi.ICDILocation)
|
||||||
*/
|
*/
|
||||||
public void stepUntil(ICDILocation location) throws CDIException {
|
public void stepUntil(ICDILocation location) throws CDIException {
|
||||||
((Target)getTarget()).lockTarget();
|
Target target = (Target)getTarget();
|
||||||
try {
|
synchronized(target.getLock()) {
|
||||||
((Target)getTarget()).setCurrentThread(this);
|
target.setCurrentThread(this);
|
||||||
getTarget().stepUntil(location);
|
target.stepUntil(location);
|
||||||
} finally {
|
|
||||||
((Target)getTarget()).releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,24 +435,20 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void resume(boolean passSignal) throws CDIException {
|
public void resume(boolean passSignal) throws CDIException {
|
||||||
((Target)getTarget()).lockTarget();
|
Target target = (Target)getTarget();
|
||||||
try {
|
synchronized(target.getLock()) {
|
||||||
((Target)getTarget()).setCurrentThread(this);
|
target.setCurrentThread(this);
|
||||||
getTarget().resume(passSignal);
|
target.resume(passSignal);
|
||||||
} finally {
|
|
||||||
((Target)getTarget()).releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteResume#resume(org.eclipse.cdt.debug.core.cdi.ICDILocation)
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteResume#resume(org.eclipse.cdt.debug.core.cdi.ICDILocation)
|
||||||
*/
|
*/
|
||||||
public void resume(ICDILocation location) throws CDIException {
|
public void resume(ICDILocation location) throws CDIException {
|
||||||
((Target)getTarget()).lockTarget();
|
Target target = (Target)getTarget();
|
||||||
try {
|
synchronized(target.getLock()) {
|
||||||
((Target)getTarget()).setCurrentThread(this);
|
target.setCurrentThread(this);
|
||||||
getTarget().resume(location);
|
target.resume(location);
|
||||||
} finally {
|
|
||||||
((Target)getTarget()).releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,12 +456,10 @@ public class Thread extends CObject implements ICDIThread {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteResume#resume(org.eclipse.cdt.debug.core.cdi.model.ICDISignal)
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteResume#resume(org.eclipse.cdt.debug.core.cdi.model.ICDISignal)
|
||||||
*/
|
*/
|
||||||
public void resume(ICDISignal signal) throws CDIException {
|
public void resume(ICDISignal signal) throws CDIException {
|
||||||
((Target)getTarget()).lockTarget();
|
Target target = (Target)getTarget();
|
||||||
try {
|
synchronized(target.getLock()) {
|
||||||
((Target)getTarget()).setCurrentThread(this);
|
target.setCurrentThread(this);
|
||||||
getTarget().resume(signal);
|
target.resume(signal);
|
||||||
} finally {
|
|
||||||
((Target)getTarget()).releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
* Copyright (c) 2000, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Alena Laskavaia (QNX) - Bug 221224
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi.model;
|
package org.eclipse.cdt.debug.mi.core.cdi.model;
|
||||||
|
|
||||||
|
@ -240,7 +241,7 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
StackFrame frame = (StackFrame)getStackFrame();
|
StackFrame frame = (StackFrame)getStackFrame();
|
||||||
Thread thread = (Thread)getThread();
|
Thread thread = (Thread)getThread();
|
||||||
target.lockTarget();
|
synchronized(target.getLock()) {
|
||||||
try {
|
try {
|
||||||
if (frame != null) {
|
if (frame != null) {
|
||||||
target.setCurrentThread(frame.getThread(), false);
|
target.setCurrentThread(frame.getThread(), false);
|
||||||
|
@ -261,15 +262,12 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
if (frame != null) {
|
if (frame != null) {
|
||||||
target.setCurrentThread(currentThread, false);
|
target.setCurrentThread(currentThread, false);
|
||||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||||
} else if (thread != null) {
|
} else if (thread != null) {
|
||||||
target.setCurrentThread(currentThread, false);
|
target.setCurrentThread(currentThread, false);
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
target.releaseTarget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue