1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 17:35:35 +02:00

Always set ourselves as the default thread before any operation.

This commit is contained in:
Alain Magloire 2002-08-26 05:19:57 +00:00
parent 8f16345f5e
commit de5d435726

View file

@ -1,3 +1,8 @@
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.CDIException;
@ -17,6 +22,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIStackListFramesInfo;
public class CThread extends CObject implements ICDIThread {
int id;
static StackFrame[] noStack = new StackFrame[0];
public CThread(CTarget target, int threadId) {
super(target);
@ -35,6 +41,7 @@ public class CThread extends CObject implements ICDIThread {
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#finish()
*/
public void finish() throws CDIException {
getCTarget().setCurrentThread(this);
getTarget().finish();
}
@ -42,36 +49,47 @@ public class CThread extends CObject implements ICDIThread {
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#getStackFrames()
*/
public ICDIStackFrame[] getStackFrames() throws CDIException {
MISession mi = getCTarget().getCSession().getMISession();
StackFrame[] stack = noStack;
CSession session = getCTarget().getCSession();
VariableManager mgr = (VariableManager)session.getVariableManager();
MISession mi = session.getMISession();
CommandFactory factory = mi.getCommandFactory();
MIStackListFrames frames = factory.createMIStackListFrames();
try {
getCTarget().setCurrentThread(this);
mi.postCommand(frames);
MIStackListFramesInfo info = frames.getMIStackListFramesInfo();
if (info == null) {
throw new CDIException("No answer");
}
MIFrame[] miFrames = info.getMIFrames();
StackFrame[] stack = new StackFrame[miFrames.length];
stack = new StackFrame[miFrames.length];
for (int i = 0; i < stack.length; i++) {
stack[i] = new StackFrame(this, miFrames[i]);
}
return stack;
} catch (MIException e) {
throw new CDIException(e.toString());
//throw new CDIException(e.toString());
System.out.println(e);
} catch (CDIException e) {
//throw e;
System.out.println(e);
}
return stack;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#setCurrentStackFrame(ICDIStackFrame)
*/
public void setCurrentStackFrame(StackFrame stackframe) throws CDIException {
getCTarget().setCurrentThread(this);
MISession mi = getCTarget().getCSession().getMISession();
CommandFactory factory = mi.getCommandFactory();
int frameNum = stackframe.getLevel();
MIStackSelectFrame frame = factory.createMIStackSelectFrame(frameNum);
try {
getCTarget().setCurrentThread(this);
mi.postCommand(frame);
MIInfo info = frame.getMIInfo();
if (info == null) {
@ -100,6 +118,7 @@ public class CThread extends CObject implements ICDIThread {
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#stepInto()
*/
public void stepInto() throws CDIException {
getCTarget().setCurrentThread(this);
getTarget().stepInto();
}
@ -107,6 +126,7 @@ public class CThread extends CObject implements ICDIThread {
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#stepIntoInstruction()
*/
public void stepIntoInstruction() throws CDIException {
getCTarget().setCurrentThread(this);
getTarget().stepIntoInstruction();
}
@ -114,6 +134,7 @@ public class CThread extends CObject implements ICDIThread {
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#stepOver()
*/
public void stepOver() throws CDIException {
getCTarget().setCurrentThread(this);
getTarget().stepOver();
}
@ -121,6 +142,7 @@ public class CThread extends CObject implements ICDIThread {
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#stepOverInstruction()
*/
public void stepOverInstruction() throws CDIException {
getCTarget().setCurrentThread(this);
getTarget().stepOverInstruction();
}
@ -128,6 +150,7 @@ public class CThread extends CObject implements ICDIThread {
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#stepReturn()
*/
public void stepReturn() throws CDIException {
getCTarget().setCurrentThread(this);
getTarget().stepReturn();
}
@ -135,6 +158,7 @@ public class CThread extends CObject implements ICDIThread {
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#suspend()
*/
public void suspend() throws CDIException {
getCTarget().setCurrentThread(this);
getTarget().suspend();
}