mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Alena Laskavaia (QNX) - Bug 221224
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||
|
||||
|
@ -184,7 +185,7 @@ public class ExpressionManager extends Manager {
|
|||
Target target = (Target)frame.getTarget();
|
||||
Thread currentThread = (Thread)target.getCurrentThread();
|
||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||
target.lockTarget();
|
||||
synchronized(target.getLock()) {
|
||||
try {
|
||||
target.setCurrentThread(frame.getThread(), false);
|
||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||
|
@ -203,12 +204,9 @@ public class ExpressionManager extends Manager {
|
|||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
} finally {
|
||||
try {
|
||||
target.setCurrentThread(currentThread, 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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Giuseppe Montalto, STMicroelectronics - bug 174988
|
||||
* Alena Laskavaia (QNX) - Bug 221224
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||
|
||||
|
@ -255,7 +256,7 @@ public class RegisterManager extends Manager {
|
|||
Target target = (Target)frame.getTarget();
|
||||
Thread currentThread = (Thread)target.getCurrentThread();
|
||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||
target.lockTarget();
|
||||
synchronized(target.getLock()) {
|
||||
try {
|
||||
target.setCurrentThread(frame.getThread(), false);
|
||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||
|
@ -271,12 +272,9 @@ public class RegisterManager extends Manager {
|
|||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
} finally {
|
||||
try {
|
||||
target.setCurrentThread(currentThread, false);
|
||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||
} finally {
|
||||
target.releaseTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -284,7 +282,7 @@ public class RegisterManager extends Manager {
|
|||
Target target = (Target)frame.getTarget();
|
||||
Thread currentThread = (Thread)target.getCurrentThread();
|
||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||
target.lockTarget();
|
||||
synchronized(target.getLock()) {
|
||||
try {
|
||||
target.setCurrentThread(frame.getThread(), false);
|
||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||
|
@ -301,12 +299,9 @@ public class RegisterManager extends Manager {
|
|||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
} finally {
|
||||
try {
|
||||
target.setCurrentThread(currentThread, 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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Alena Laskavaia (QNX) - Bug 221224
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||
|
||||
|
@ -424,18 +425,15 @@ public class SourceManager extends Manager {
|
|||
Target target = (Target)frame.getTarget();
|
||||
Thread currentThread = (Thread)target.getCurrentThread();
|
||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||
target.lockTarget();
|
||||
synchronized(target.getLock()) {
|
||||
try {
|
||||
target.setCurrentThread(frame.getThread(), false);
|
||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||
return getDetailTypeName(target, variable);
|
||||
} finally {
|
||||
try {
|
||||
target.setCurrentThread(currentThread, false);
|
||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||
} finally {
|
||||
target.releaseTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public String getDetailTypeName(Target target, String typename) throws CDIException {
|
||||
|
@ -465,18 +463,15 @@ public class SourceManager extends Manager {
|
|||
Target target = (Target)frame.getTarget();
|
||||
Thread currentThread = (Thread)target.getCurrentThread();
|
||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||
target.lockTarget();
|
||||
synchronized(target.getLock()) {
|
||||
try {
|
||||
target.setCurrentThread(frame.getThread(), false);
|
||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||
return getTypeName(target, variable);
|
||||
} finally {
|
||||
try {
|
||||
target.setCurrentThread(currentThread, 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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* 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;
|
||||
|
||||
|
@ -177,7 +177,7 @@ public class VariableManager extends Manager {
|
|||
Target target = (Target)frame.getTarget();
|
||||
Thread currentThread = (Thread)target.getCurrentThread();
|
||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||
target.lockTarget();
|
||||
synchronized(target.getLock()) {
|
||||
try {
|
||||
target.setCurrentThread(frame.getThread(), false);
|
||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||
|
@ -194,15 +194,12 @@ public class VariableManager extends Manager {
|
|||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
} finally {
|
||||
try {
|
||||
MISession miSession = target.getMISession();
|
||||
RxThread rxThread = miSession.getRxThread();
|
||||
rxThread.setEnableConsole(true);
|
||||
target.setCurrentThread(currentThread, false);
|
||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||
} finally {
|
||||
target.releaseTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new CDIException(CdiResources.getString("cdi.VariableManager.Unknown_type")); //$NON-NLS-1$
|
||||
|
@ -374,7 +371,7 @@ public class VariableManager extends Manager {
|
|||
Target target = (Target)argDesc.getTarget();
|
||||
Thread currentThread = (Thread)target.getCurrentThread();
|
||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||
target.lockTarget();
|
||||
synchronized(target.getLock()) {
|
||||
try {
|
||||
target.setCurrentThread(stack.getThread(), false);
|
||||
((Thread)stack.getThread()).setCurrentStackFrame(stack, false);
|
||||
|
@ -394,12 +391,9 @@ public class VariableManager extends Manager {
|
|||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
} finally {
|
||||
try {
|
||||
target.setCurrentThread(currentThread, false);
|
||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||
} finally {
|
||||
target.releaseTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return argument;
|
||||
|
@ -410,7 +404,7 @@ public class VariableManager extends Manager {
|
|||
Target target = (Target)frame.getTarget();
|
||||
Thread currentThread = (Thread)target.getCurrentThread();
|
||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||
target.lockTarget();
|
||||
synchronized(target.getLock()) {
|
||||
try {
|
||||
target.setCurrentThread(frame.getThread(), false);
|
||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||
|
@ -440,12 +434,9 @@ public class VariableManager extends Manager {
|
|||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
} finally {
|
||||
try {
|
||||
target.setCurrentThread(currentThread, false);
|
||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||
} finally {
|
||||
target.releaseTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
return (ICDIArgumentDescriptor[]) argObjects.toArray(new ICDIArgumentDescriptor[0]);
|
||||
}
|
||||
|
@ -506,7 +497,7 @@ public class VariableManager extends Manager {
|
|||
Target target = (Target)frame.getTarget();
|
||||
Thread currentThread = (Thread)target.getCurrentThread();
|
||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||
target.lockTarget();
|
||||
synchronized(target.getLock()) {
|
||||
try {
|
||||
target.setCurrentThread(frame.getThread(), false);
|
||||
((Thread)frame.getThread()).setCurrentStackFrame(frame, false);
|
||||
|
@ -530,12 +521,9 @@ public class VariableManager extends Manager {
|
|||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
} finally {
|
||||
try {
|
||||
target.setCurrentThread(currentThread, false);
|
||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||
} finally {
|
||||
target.releaseTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
return (ICDILocalVariableDescriptor[]) varObjects.toArray(new ICDILocalVariableDescriptor[0]);
|
||||
}
|
||||
|
@ -552,7 +540,7 @@ public class VariableManager extends Manager {
|
|||
Target target = (Target)varDesc.getTarget();
|
||||
Thread currentThread = (Thread)target.getCurrentThread();
|
||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||
target.lockTarget();
|
||||
synchronized(target.getLock()) {
|
||||
try {
|
||||
target.setCurrentThread(stack.getThread(), false);
|
||||
((Thread)stack.getThread()).setCurrentStackFrame(stack, false);
|
||||
|
@ -572,12 +560,9 @@ public class VariableManager extends Manager {
|
|||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
} finally {
|
||||
try {
|
||||
target.setCurrentThread(currentThread, false);
|
||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||
} finally {
|
||||
target.releaseTarget();
|
||||
}
|
||||
target.setCurrentThread(currentThread, false);
|
||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return local;
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* 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;
|
||||
|
||||
|
@ -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 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;
|
||||
ICDITargetConfiguration fConfiguration;
|
||||
Thread[] noThreads = new Thread[0];
|
||||
|
@ -147,7 +109,7 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
|
|||
String fEndian = null;
|
||||
boolean suspended = 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 DATA_MEMORY_SPACE = "data"; //$NON-NLS-1$
|
||||
|
@ -158,13 +120,37 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
|
|||
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() {
|
||||
return miSession;
|
||||
|
@ -271,15 +257,14 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
|
|||
// 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();
|
||||
try {
|
||||
// get the new Threads.
|
||||
currentThreadId = newThreadId;
|
||||
currentThreads = getCThreads();
|
||||
} catch (CDIException e) {
|
||||
currentThreads = noThreads;
|
||||
} finally {
|
||||
releaseTarget();
|
||||
synchronized (lock) {
|
||||
try {
|
||||
// get the new Threads.
|
||||
currentThreadId = newThreadId;
|
||||
currentThreads = getCThreads();
|
||||
} catch (CDIException e) {
|
||||
currentThreads = noThreads;
|
||||
}
|
||||
}
|
||||
|
||||
// Fire CreatedEvent for new threads.
|
||||
|
@ -338,57 +323,56 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
|
|||
*/
|
||||
public Thread[] getCThreads() throws CDIException {
|
||||
Thread[] cthreads = noThreads;
|
||||
try {
|
||||
lockTarget();
|
||||
synchronized (lock) {
|
||||
RxThread rxThread = miSession.getRxThread();
|
||||
rxThread.setEnableConsole(false);
|
||||
CommandFactory factory = miSession.getCommandFactory();
|
||||
CLIInfoThreads tids = factory.createCLIInfoThreads();
|
||||
// HACK/FIXME: gdb/mi thread-list-ids does not
|
||||
// show any newly create thread, we workaround by
|
||||
// issuing "info threads" instead.
|
||||
// MIThreadListIds tids = factory.createMIThreadListIds();
|
||||
// MIThreadListIdsInfo info = tids.getMIThreadListIdsInfo();
|
||||
miSession.postCommand(tids);
|
||||
CLIInfoThreadsInfo info = tids.getMIInfoThreadsInfo();
|
||||
int[] ids;
|
||||
String[] names;
|
||||
if (info == null) {
|
||||
ids = new int[0];
|
||||
names = new String[0];
|
||||
} else {
|
||||
ids = info.getThreadIds();
|
||||
names = info.getThreadNames();
|
||||
currentThreadId = info.getCurrentThread();
|
||||
}
|
||||
if (ids != null && ids.length > 0) {
|
||||
cthreads = new Thread[ids.length];
|
||||
// Ok that means it is a multiThreaded.
|
||||
if (names != null && names.length == ids.length) {
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
cthreads[i] = new Thread(this, ids[i], names[i]);
|
||||
try {
|
||||
CommandFactory factory = miSession.getCommandFactory();
|
||||
CLIInfoThreads tids = factory.createCLIInfoThreads();
|
||||
// HACK/FIXME: gdb/mi thread-list-ids does not
|
||||
// show any newly create thread, we workaround by
|
||||
// issuing "info threads" instead.
|
||||
// MIThreadListIds tids = factory.createMIThreadListIds();
|
||||
// MIThreadListIdsInfo info = tids.getMIThreadListIdsInfo();
|
||||
miSession.postCommand(tids);
|
||||
CLIInfoThreadsInfo info = tids.getMIInfoThreadsInfo();
|
||||
int[] ids;
|
||||
String[] names;
|
||||
if (info == null) {
|
||||
ids = new int[0];
|
||||
names = new String[0];
|
||||
} else {
|
||||
ids = info.getThreadIds();
|
||||
names = info.getThreadNames();
|
||||
currentThreadId = info.getCurrentThread();
|
||||
}
|
||||
if (ids != null && ids.length > 0) {
|
||||
cthreads = new Thread[ids.length];
|
||||
// Ok that means it is a multiThreaded.
|
||||
if (names != null && names.length == ids.length) {
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
cthreads[i] = new Thread(this, ids[i], names[i]);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
cthreads[i] = new Thread(this, ids[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
cthreads[i] = new Thread(this, ids[i]);
|
||||
}
|
||||
// Provide a dummy.
|
||||
cthreads = new Thread[]{new Thread(this, 0)};
|
||||
}
|
||||
} else {
|
||||
// Provide a dummy.
|
||||
cthreads = new Thread[]{new Thread(this, 0)};
|
||||
// FIX: When attaching there is no thread selected
|
||||
// We will choose the first one as a workaround.
|
||||
if (currentThreadId == 0 && cthreads.length > 0) {
|
||||
setCurrentThread(cthreads[0], false);
|
||||
}
|
||||
} catch (MIException e) {
|
||||
// Do not throw anything in this case.
|
||||
throw new CDIException(e.getMessage());
|
||||
} finally {
|
||||
rxThread.setEnableConsole(true);
|
||||
}
|
||||
// FIX: When attaching there is no thread selected
|
||||
// We will choose the first one as a workaround.
|
||||
if (currentThreadId == 0 && cthreads.length > 0) {
|
||||
setCurrentThread(cthreads[0], false);
|
||||
}
|
||||
} catch (MIException e) {
|
||||
// Do not throw anything in this case.
|
||||
throw new CDIException(e.getMessage());
|
||||
} finally {
|
||||
RxThread rxThread = miSession.getRxThread();
|
||||
rxThread.setEnableConsole(true);
|
||||
releaseTarget();
|
||||
}
|
||||
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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Alena Laskavaia (QNX) - Bug 221224
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.mi.core.cdi.model;
|
||||
|
||||
|
@ -109,32 +110,29 @@ public class Thread extends CObject implements ICDIThread {
|
|||
currentFrames = new ArrayList();
|
||||
Target target = (Target)getTarget();
|
||||
ICDIThread currentThread = target.getCurrentThread();
|
||||
target.lockTarget();
|
||||
try {
|
||||
target.setCurrentThread(this, false);
|
||||
MISession mi = target.getMISession();
|
||||
CommandFactory factory = mi.getCommandFactory();
|
||||
MIStackListFrames frames = factory.createMIStackListFrames();
|
||||
mi.postCommand(frames);
|
||||
MIStackListFramesInfo info = frames.getMIStackListFramesInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
|
||||
}
|
||||
MIFrame[] miFrames = info.getMIFrames();
|
||||
for (int i = 0; i < miFrames.length; i++) {
|
||||
currentFrames.add(new StackFrame(this, miFrames[i], depth - miFrames[i].getLevel()));
|
||||
}
|
||||
} catch (MIException e) {
|
||||
//throw new CDIException(e.getMessage());
|
||||
//System.out.println(e);
|
||||
} catch (CDIException e) {
|
||||
//throw e;
|
||||
//System.out.println(e);
|
||||
} finally {
|
||||
synchronized (target.getLock()) {
|
||||
try {
|
||||
target.setCurrentThread(currentThread, false);
|
||||
target.setCurrentThread(this, false);
|
||||
MISession mi = target.getMISession();
|
||||
CommandFactory factory = mi.getCommandFactory();
|
||||
MIStackListFrames frames = factory.createMIStackListFrames();
|
||||
mi.postCommand(frames);
|
||||
MIStackListFramesInfo info = frames.getMIStackListFramesInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
|
||||
}
|
||||
MIFrame[] miFrames = info.getMIFrames();
|
||||
for (int i = 0; i < miFrames.length; i++) {
|
||||
currentFrames.add(new StackFrame(this, miFrames[i], depth - miFrames[i].getLevel()));
|
||||
}
|
||||
} catch (MIException e) {
|
||||
//throw new CDIException(e.getMessage());
|
||||
//System.out.println(e);
|
||||
} catch (CDIException e) {
|
||||
//throw e;
|
||||
//System.out.println(e);
|
||||
} finally {
|
||||
target.releaseTarget();
|
||||
target.setCurrentThread(currentThread, false);
|
||||
}
|
||||
}
|
||||
// assign the currentFrame if it was not done yet.
|
||||
|
@ -157,45 +155,39 @@ public class Thread extends CObject implements ICDIThread {
|
|||
if (stackdepth == 0) {
|
||||
Target target = (Target)getTarget();
|
||||
ICDIThread currentThread = target.getCurrentThread();
|
||||
target.lockTarget();
|
||||
try {
|
||||
target.setCurrentThread(this, false);
|
||||
MISession mi = target.getMISession();
|
||||
CommandFactory factory = mi.getCommandFactory();
|
||||
MIStackInfoDepth depth = factory.createMIStackInfoDepth();
|
||||
mi.postCommand(depth);
|
||||
MIStackInfoDepthInfo info = null;
|
||||
synchronized (target.getLock()) {
|
||||
try {
|
||||
// Catch the first exception gdb can recover the second time.
|
||||
info = depth.getMIStackInfoDepthInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
|
||||
}
|
||||
stackdepth = info.getDepth();
|
||||
} catch (MIException e) {
|
||||
// First try fails, retry. gdb patches up the corrupt frame
|
||||
// so retry should give us a frame count that is safe.
|
||||
depth = factory.createMIStackInfoDepth();
|
||||
target.setCurrentThread(this, false);
|
||||
MISession mi = target.getMISession();
|
||||
CommandFactory factory = mi.getCommandFactory();
|
||||
MIStackInfoDepth depth = factory.createMIStackInfoDepth();
|
||||
mi.postCommand(depth);
|
||||
info = depth.getMIStackInfoDepthInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
|
||||
MIStackInfoDepthInfo info = null;
|
||||
try {
|
||||
// Catch the first exception gdb can recover the second time.
|
||||
info = depth.getMIStackInfoDepthInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
|
||||
}
|
||||
stackdepth = info.getDepth();
|
||||
} catch (MIException e) {
|
||||
// First try fails, retry. gdb patches up the corrupt frame
|
||||
// so retry should give us a frame count that is safe.
|
||||
depth = factory.createMIStackInfoDepth();
|
||||
mi.postCommand(depth);
|
||||
info = depth.getMIStackInfoDepthInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
|
||||
}
|
||||
stackdepth = info.getDepth();
|
||||
if (stackdepth > 0) {
|
||||
stackdepth--;
|
||||
}
|
||||
}
|
||||
stackdepth = info.getDepth();
|
||||
if (stackdepth > 0) {
|
||||
stackdepth--;
|
||||
}
|
||||
}
|
||||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
} finally {
|
||||
try {
|
||||
target.setCurrentThread(currentThread, false);
|
||||
} catch (MI2CDIException e) {
|
||||
target.releaseTarget();
|
||||
throw e;
|
||||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
} finally {
|
||||
target.releaseTarget();
|
||||
target.setCurrentThread(currentThread, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +202,7 @@ public class Thread extends CObject implements ICDIThread {
|
|||
currentFrames = new ArrayList();
|
||||
Target target = (Target) getTarget();
|
||||
ICDIThread currentThread = target.getCurrentThread();
|
||||
target.lockTarget();
|
||||
synchronized (target.getLock()) {
|
||||
try {
|
||||
target.setCurrentThread(this, false);
|
||||
int depth = getStackFrameCount();
|
||||
|
@ -243,11 +235,8 @@ public class Thread extends CObject implements ICDIThread {
|
|||
//throw e;
|
||||
//System.out.println(e);
|
||||
} finally {
|
||||
try {
|
||||
target.setCurrentThread(currentThread, false);
|
||||
} finally {
|
||||
target.releaseTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
// take time to assign the currentFrame, if it is in the set
|
||||
if (currentFrame == null) {
|
||||
|
@ -294,34 +283,33 @@ public class Thread extends CObject implements ICDIThread {
|
|||
int miLevel = getStackFrameCount() - frameLevel;
|
||||
MIStackSelectFrame frame = factory.createMIStackSelectFrame(miLevel);
|
||||
// Set ourself as the current thread first.
|
||||
target.lockTarget();
|
||||
try {
|
||||
target.setCurrentThread(this, doUpdate);
|
||||
mi.postCommand(frame);
|
||||
MIInfo info = frame.getMIInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
|
||||
}
|
||||
currentFrame = stackframe;
|
||||
// Resetting stackframe may change the value of
|
||||
// some variables like registers. Call an update()
|
||||
// To generate changeEvents.
|
||||
if (doUpdate) {
|
||||
Session session = (Session) target.getSession();
|
||||
RegisterManager regMgr = session.getRegisterManager();
|
||||
if (regMgr.isAutoUpdate()) {
|
||||
regMgr.update(target);
|
||||
synchronized (target.getLock()) {
|
||||
try {
|
||||
target.setCurrentThread(this, doUpdate);
|
||||
mi.postCommand(frame);
|
||||
MIInfo info = frame.getMIInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
|
||||
}
|
||||
VariableManager varMgr = session.getVariableManager();
|
||||
if (varMgr.isAutoUpdate()) {
|
||||
varMgr.update(target);
|
||||
currentFrame = stackframe;
|
||||
// Resetting stackframe may change the value of
|
||||
// some variables like registers. Call an update()
|
||||
// To generate changeEvents.
|
||||
if (doUpdate) {
|
||||
Session session = (Session) target.getSession();
|
||||
RegisterManager regMgr = session.getRegisterManager();
|
||||
if (regMgr.isAutoUpdate()) {
|
||||
regMgr.update(target);
|
||||
}
|
||||
VariableManager varMgr = session.getVariableManager();
|
||||
if (varMgr.isAutoUpdate()) {
|
||||
varMgr.update(target);
|
||||
}
|
||||
}
|
||||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
}
|
||||
} catch (MIException 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)
|
||||
*/
|
||||
public void stepInto(int count) throws CDIException {
|
||||
((Target)getTarget()).lockTarget();
|
||||
try {
|
||||
((Target)getTarget()).setCurrentThread(this);
|
||||
getTarget().stepInto(count);
|
||||
} finally {
|
||||
((Target)getTarget()).releaseTarget();
|
||||
Target target = (Target)getTarget();
|
||||
synchronized(target.getLock()) {
|
||||
target.setCurrentThread(this);
|
||||
target.stepInto(count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,12 +341,10 @@ public class Thread extends CObject implements ICDIThread {
|
|||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteStep#stepIntoInstruction(int)
|
||||
*/
|
||||
public void stepIntoInstruction(int count) throws CDIException {
|
||||
((Target)getTarget()).lockTarget();
|
||||
try {
|
||||
((Target)getTarget()).setCurrentThread(this);
|
||||
getTarget().stepIntoInstruction(count);
|
||||
} finally {
|
||||
((Target)getTarget()).releaseTarget();
|
||||
Target target = (Target)getTarget();
|
||||
synchronized(target.getLock()) {
|
||||
target.setCurrentThread(this);
|
||||
target.stepIntoInstruction(count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,12 +359,10 @@ public class Thread extends CObject implements ICDIThread {
|
|||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteStep#stepOver(int)
|
||||
*/
|
||||
public void stepOver(int count) throws CDIException {
|
||||
((Target)getTarget()).lockTarget();
|
||||
try {
|
||||
((Target)getTarget()).setCurrentThread(this);
|
||||
getTarget().stepOver(count);
|
||||
} finally {
|
||||
((Target)getTarget()).releaseTarget();
|
||||
Target target = (Target)getTarget();
|
||||
synchronized(target.getLock()) {
|
||||
target.setCurrentThread(this);
|
||||
target.stepOver(count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,12 +377,10 @@ public class Thread extends CObject implements ICDIThread {
|
|||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteStep#stepOverInstruction(int)
|
||||
*/
|
||||
public void stepOverInstruction(int count) throws CDIException {
|
||||
((Target)getTarget()).lockTarget();
|
||||
try {
|
||||
((Target)getTarget()).setCurrentThread(this);
|
||||
getTarget().stepOverInstruction(count);
|
||||
} finally {
|
||||
((Target)getTarget()).releaseTarget();
|
||||
Target target = (Target)getTarget();
|
||||
synchronized(target.getLock()) {
|
||||
target.setCurrentThread(this);
|
||||
target.stepOverInstruction(count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
*/
|
||||
public void stepUntil(ICDILocation location) throws CDIException {
|
||||
((Target)getTarget()).lockTarget();
|
||||
try {
|
||||
((Target)getTarget()).setCurrentThread(this);
|
||||
getTarget().stepUntil(location);
|
||||
} finally {
|
||||
((Target)getTarget()).releaseTarget();
|
||||
Target target = (Target)getTarget();
|
||||
synchronized(target.getLock()) {
|
||||
target.setCurrentThread(this);
|
||||
target.stepUntil(location);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,24 +435,20 @@ public class Thread extends CObject implements ICDIThread {
|
|||
*/
|
||||
|
||||
public void resume(boolean passSignal) throws CDIException {
|
||||
((Target)getTarget()).lockTarget();
|
||||
try {
|
||||
((Target)getTarget()).setCurrentThread(this);
|
||||
getTarget().resume(passSignal);
|
||||
} finally {
|
||||
((Target)getTarget()).releaseTarget();
|
||||
Target target = (Target)getTarget();
|
||||
synchronized(target.getLock()) {
|
||||
target.setCurrentThread(this);
|
||||
target.resume(passSignal);
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteResume#resume(org.eclipse.cdt.debug.core.cdi.ICDILocation)
|
||||
*/
|
||||
public void resume(ICDILocation location) throws CDIException {
|
||||
((Target)getTarget()).lockTarget();
|
||||
try {
|
||||
((Target)getTarget()).setCurrentThread(this);
|
||||
getTarget().resume(location);
|
||||
} finally {
|
||||
((Target)getTarget()).releaseTarget();
|
||||
Target target = (Target)getTarget();
|
||||
synchronized(target.getLock()) {
|
||||
target.setCurrentThread(this);
|
||||
target.resume(location);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
*/
|
||||
public void resume(ICDISignal signal) throws CDIException {
|
||||
((Target)getTarget()).lockTarget();
|
||||
try {
|
||||
((Target)getTarget()).setCurrentThread(this);
|
||||
getTarget().resume(signal);
|
||||
} finally {
|
||||
((Target)getTarget()).releaseTarget();
|
||||
Target target = (Target)getTarget();
|
||||
synchronized(target.getLock()) {
|
||||
target.setCurrentThread(this);
|
||||
target.resume(signal);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Alena Laskavaia (QNX) - Bug 221224
|
||||
*******************************************************************************/
|
||||
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 frame = (StackFrame)getStackFrame();
|
||||
Thread thread = (Thread)getThread();
|
||||
target.lockTarget();
|
||||
synchronized(target.getLock()) {
|
||||
try {
|
||||
if (frame != null) {
|
||||
target.setCurrentThread(frame.getThread(), false);
|
||||
|
@ -261,17 +262,14 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable
|
|||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (frame != null) {
|
||||
target.setCurrentThread(currentThread, false);
|
||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||
} else if (thread != null) {
|
||||
target.setCurrentThread(currentThread, false);
|
||||
}
|
||||
} finally {
|
||||
target.releaseTarget();
|
||||
if (frame != null) {
|
||||
target.setCurrentThread(currentThread, false);
|
||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||
} else if (thread != null) {
|
||||
target.setCurrentThread(currentThread, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeof != null) {
|
||||
|
|
Loading…
Add table
Reference in a new issue