mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
The use of MI Variable Objects for the CDI bridge implementation.
This commit is contained in:
parent
893ef39e38
commit
501c326a4b
16 changed files with 659 additions and 270 deletions
|
@ -12,7 +12,7 @@ import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager;
|
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIDebugConfiguration;
|
import org.eclipse.cdt.debug.core.cdi.ICDIDebugConfiguration;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIEventManager;
|
import org.eclipse.cdt.debug.core.cdi.ICDIEventManager;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIVariableManager;
|
import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager;
|
import org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions;
|
import org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||||
|
@ -31,7 +31,8 @@ public class CSession implements ICDISession, ICDISessionObject {
|
||||||
MISession session;
|
MISession session;
|
||||||
BreakpointManager breakpointManager;
|
BreakpointManager breakpointManager;
|
||||||
EventManager eventManager;
|
EventManager eventManager;
|
||||||
VariableManager expressionManager;
|
ExpressionManager expressionManager;
|
||||||
|
VariableManager variableManager;
|
||||||
MemoryManager memoryManager;
|
MemoryManager memoryManager;
|
||||||
SignalManager signalManager;
|
SignalManager signalManager;
|
||||||
SourceManager sourceManager;
|
SourceManager sourceManager;
|
||||||
|
@ -43,7 +44,8 @@ public class CSession implements ICDISession, ICDISessionObject {
|
||||||
breakpointManager = new BreakpointManager(this);
|
breakpointManager = new BreakpointManager(this);
|
||||||
eventManager = new EventManager(this);
|
eventManager = new EventManager(this);
|
||||||
s.addObserver(eventManager);
|
s.addObserver(eventManager);
|
||||||
expressionManager = new VariableManager(this);
|
expressionManager = new ExpressionManager(this);
|
||||||
|
variableManager = new VariableManager(this);
|
||||||
memoryManager = new MemoryManager(this);
|
memoryManager = new MemoryManager(this);
|
||||||
signalManager = new SignalManager(this);
|
signalManager = new SignalManager(this);
|
||||||
sourceManager = new SourceManager(this);
|
sourceManager = new SourceManager(this);
|
||||||
|
@ -54,10 +56,6 @@ public class CSession implements ICDISession, ICDISessionObject {
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICDITarget getTarget() {
|
|
||||||
return ctarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
CTarget getCTarget() {
|
CTarget getCTarget() {
|
||||||
return ctarget;
|
return ctarget;
|
||||||
}
|
}
|
||||||
|
@ -86,10 +84,16 @@ public class CSession implements ICDISession, ICDISessionObject {
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDISession#getVariableManager()
|
* @see org.eclipse.cdt.debug.core.cdi.ICDISession#getVariableManager()
|
||||||
*/
|
*/
|
||||||
public ICDIVariableManager getVariableManager() {
|
public ICDIExpressionManager getExpressionManager() {
|
||||||
return expressionManager;
|
return expressionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public VariableManager getVariableManager() {
|
||||||
|
return variableManager;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDISession#getMemoryManager()
|
* @see org.eclipse.cdt.debug.core.cdi.ICDISession#getMemoryManager()
|
||||||
*/
|
*/
|
||||||
|
@ -118,6 +122,23 @@ public class CSession implements ICDISession, ICDISessionObject {
|
||||||
return new ICDITarget[]{ctarget};
|
return new ICDITarget[]{ctarget};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICDISession#getCurrentTarget()
|
||||||
|
*/
|
||||||
|
public ICDITarget getCurrentTarget() {
|
||||||
|
return ctarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void setCurrentTarget(ICDITarget target) throws CDIException {
|
||||||
|
if (target instanceof CTarget) {
|
||||||
|
ctarget = (CTarget)target;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new CDIException("Unkown target");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDISession#setAttribute(String, String)
|
* @see org.eclipse.cdt.debug.core.cdi.ICDISession#setAttribute(String, String)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,9 +9,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIVariableManager;
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
|
import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIGlobalVariable;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIGlobalVariable;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterGroup;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterGroup;
|
||||||
|
@ -19,6 +18,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
|
||||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||||
|
@ -33,9 +33,11 @@ import org.eclipse.cdt.debug.mi.core.command.MIExecStep;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIExecStepInstruction;
|
import org.eclipse.cdt.debug.mi.core.command.MIExecStepInstruction;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MITargetDetach;
|
import org.eclipse.cdt.debug.mi.core.command.MITargetDetach;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIThreadListIds;
|
import org.eclipse.cdt.debug.mi.core.command.MIThreadListIds;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIThreadSelect;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIDataEvaluateExpressionInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIDataEvaluateExpressionInfo;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIThreadListIdsInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIThreadListIdsInfo;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIThreadSelectInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -49,7 +51,7 @@ public class CTarget implements ICDITarget {
|
||||||
public CTarget(CSession s) {
|
public CTarget(CSession s) {
|
||||||
session = s;
|
session = s;
|
||||||
threadList = new ArrayList(1);
|
threadList = new ArrayList(1);
|
||||||
dummyThread = new CThread(this, 0);
|
dummyThread = new CThread(this, 1);
|
||||||
currentThread = dummyThread;
|
currentThread = dummyThread;
|
||||||
threadList.add(dummyThread);
|
threadList.add(dummyThread);
|
||||||
}
|
}
|
||||||
|
@ -67,13 +69,20 @@ public class CTarget implements ICDITarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrentThread(int id) {
|
void setCurrentThread(int id) {
|
||||||
for (int i = 0; i < threadList.size(); i++) {
|
CThread cthread = null;
|
||||||
CThread cthread = (CThread)threadList.get(i);
|
if (containsCThread(id)) {
|
||||||
if (cthread.getId() == id) {
|
for (int i = 0; i < threadList.size(); i++) {
|
||||||
currentThread = cthread;
|
CThread thread = (CThread)threadList.get(i);
|
||||||
return ;
|
if (thread.getId() == id) {
|
||||||
|
cthread = thread;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
cthread = new CThread(this, id);
|
||||||
|
addCThread(cthread);
|
||||||
}
|
}
|
||||||
|
currentThread = cthread;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean containsCThread(int id) {
|
boolean containsCThread(int id) {
|
||||||
|
@ -101,7 +110,7 @@ public class CTarget implements ICDITarget {
|
||||||
mi.postCommand(detach);
|
mi.postCommand(detach);
|
||||||
MIInfo info = detach.getMIInfo();
|
MIInfo info = detach.getMIInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new CDIException("Timedout");
|
throw new CDIException("No answer");
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
throw new CDIException(e.toString());
|
||||||
|
@ -119,7 +128,7 @@ public class CTarget implements ICDITarget {
|
||||||
mi.postCommand(finish);
|
mi.postCommand(finish);
|
||||||
MIInfo info = finish.getMIInfo();
|
MIInfo info = finish.getMIInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new CDIException("Timedout");
|
throw new CDIException("No answer");
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
throw new CDIException(e.toString());
|
||||||
|
@ -163,12 +172,30 @@ public class CTarget implements ICDITarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getCurrentThread()
|
|
||||||
*/
|
*/
|
||||||
public ICDIThread getCurrentThread() throws CDIException {
|
public CThread getCurrentThread() throws CDIException {
|
||||||
return currentThread;
|
return currentThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void setCurrentThread(CThread cthread) throws CDIException {
|
||||||
|
session.setCurrentTarget(this);
|
||||||
|
int id = cthread.getId();
|
||||||
|
session.setCurrentTarget(this);
|
||||||
|
MISession mi = session.getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIThreadSelect select = factory.createMIThreadSelect(id);
|
||||||
|
try {
|
||||||
|
mi.postCommand(select);
|
||||||
|
MIThreadSelectInfo info = select.getMIThreadSelectInfo();
|
||||||
|
int newId = info.getNewThreadId();
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new CDIException(e.toString());
|
||||||
|
}
|
||||||
|
setCurrentThread(id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getThreads()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getThreads()
|
||||||
*/
|
*/
|
||||||
|
@ -182,7 +209,7 @@ public class CTarget implements ICDITarget {
|
||||||
int[] ids = info.getThreadIds();
|
int[] ids = info.getThreadIds();
|
||||||
if (ids != null && ids.length > 0) {
|
if (ids != null && ids.length > 0) {
|
||||||
// Ok that means it is a multiThreaded, remove the dummy Thread
|
// Ok that means it is a multiThreaded, remove the dummy Thread
|
||||||
removeCThread(dummyThread);
|
//removeCThread(dummyThread);
|
||||||
for (int i = 0; i < ids.length; i++) {
|
for (int i = 0; i < ids.length; i++) {
|
||||||
if (! containsCThread(ids[i])) {
|
if (! containsCThread(ids[i])) {
|
||||||
addCThread(new CThread(this, ids[i]));
|
addCThread(new CThread(this, ids[i]));
|
||||||
|
@ -227,7 +254,7 @@ public class CTarget implements ICDITarget {
|
||||||
mi.postCommand(run);
|
mi.postCommand(run);
|
||||||
MIInfo info = run.getMIInfo();
|
MIInfo info = run.getMIInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new CDIException("Timedout");
|
throw new CDIException("No answer");
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
throw new CDIException(e.toString());
|
||||||
|
@ -248,7 +275,7 @@ public class CTarget implements ICDITarget {
|
||||||
mi.postCommand(cont);
|
mi.postCommand(cont);
|
||||||
MIInfo info = cont.getMIInfo();
|
MIInfo info = cont.getMIInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new CDIException("Timedout");
|
throw new CDIException("No answer");
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
throw new CDIException(e.toString());
|
||||||
|
@ -272,7 +299,7 @@ public class CTarget implements ICDITarget {
|
||||||
mi.postCommand(step);
|
mi.postCommand(step);
|
||||||
MIInfo info = step.getMIInfo();
|
MIInfo info = step.getMIInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new CDIException("Timedout");
|
throw new CDIException("No answer");
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
throw new CDIException(e.toString());
|
||||||
|
@ -290,7 +317,7 @@ public class CTarget implements ICDITarget {
|
||||||
mi.postCommand(stepi);
|
mi.postCommand(stepi);
|
||||||
MIInfo info = stepi.getMIInfo();
|
MIInfo info = stepi.getMIInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new CDIException("Timedout");
|
throw new CDIException("No answer");
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
throw new CDIException(e.toString());
|
||||||
|
@ -308,7 +335,7 @@ public class CTarget implements ICDITarget {
|
||||||
mi.postCommand(next);
|
mi.postCommand(next);
|
||||||
MIInfo info = next.getMIInfo();
|
MIInfo info = next.getMIInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new CDIException("Timedout");
|
throw new CDIException("No answer");
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
throw new CDIException(e.toString());
|
||||||
|
@ -326,7 +353,7 @@ public class CTarget implements ICDITarget {
|
||||||
mi.postCommand(nexti);
|
mi.postCommand(nexti);
|
||||||
MIInfo info = nexti.getMIInfo();
|
MIInfo info = nexti.getMIInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new CDIException("Timedout");
|
throw new CDIException("No answer");
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
throw new CDIException(e.toString());
|
||||||
|
@ -344,7 +371,7 @@ public class CTarget implements ICDITarget {
|
||||||
mi.postCommand(interrupt);
|
mi.postCommand(interrupt);
|
||||||
MIInfo info = interrupt.getMIInfo();
|
MIInfo info = interrupt.getMIInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new CDIException("Timedout");
|
throw new CDIException("No answer");
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
throw new CDIException(e.toString());
|
||||||
|
@ -380,7 +407,7 @@ public class CTarget implements ICDITarget {
|
||||||
MIDataEvaluateExpressionInfo info =
|
MIDataEvaluateExpressionInfo info =
|
||||||
evaluate.getMIDataEvaluateExpressionInfo();
|
evaluate.getMIDataEvaluateExpressionInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new CDIException("Timedout");
|
throw new CDIException("No answer");
|
||||||
}
|
}
|
||||||
return info.getExpression();
|
return info.getExpression();
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
|
@ -393,11 +420,9 @@ public class CTarget implements ICDITarget {
|
||||||
*/
|
*/
|
||||||
public ICDIValue evaluateExpressionToValue(String expressionText)
|
public ICDIValue evaluateExpressionToValue(String expressionText)
|
||||||
throws CDIException {
|
throws CDIException {
|
||||||
ICDIVariableManager mgr = session.getVariableManager();
|
VariableManager mgr = session.getVariableManager();
|
||||||
ICDIExpression cexp = mgr.createExpression(expressionText);
|
ICDIVariable var = mgr.createVariable(expressionText);
|
||||||
ICDIValue value = cexp.getValue();
|
return var.getValue();
|
||||||
mgr.removeExpression(cexp);
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -406,5 +431,5 @@ public class CTarget implements ICDITarget {
|
||||||
public ICDISession getSession() {
|
public ICDISession getSession() {
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,20 +7,17 @@ import org.eclipse.cdt.debug.mi.core.MIException;
|
||||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIStackListFrames;
|
import org.eclipse.cdt.debug.mi.core.command.MIStackListFrames;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIStackSelectFrame;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIFrame;
|
import org.eclipse.cdt.debug.mi.core.output.MIFrame;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIStackListFramesInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIStackListFramesInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author alain
|
|
||||||
*
|
|
||||||
* To change this generated comment edit the template variable "typecomment":
|
|
||||||
* Window>Preferences>Java>Templates.
|
|
||||||
* To enable and disable the creation of type comments go to
|
|
||||||
* Window>Preferences>Java>Code Generation.
|
|
||||||
*/
|
*/
|
||||||
public class CThread extends CObject implements ICDIThread {
|
public class CThread extends CObject implements ICDIThread {
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
|
StackFrame currentStackFrame;
|
||||||
|
|
||||||
public CThread(CTarget target, int threadId) {
|
public CThread(CTarget target, int threadId) {
|
||||||
super(target);
|
super(target);
|
||||||
|
@ -53,12 +50,15 @@ public class CThread extends CObject implements ICDIThread {
|
||||||
mi.postCommand(frames);
|
mi.postCommand(frames);
|
||||||
MIStackListFramesInfo info = frames.getMIStackListFramesInfo();
|
MIStackListFramesInfo info = frames.getMIStackListFramesInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new CDIException("Timedout");
|
throw new CDIException("No answer");
|
||||||
}
|
}
|
||||||
MIFrame[] miFrames = info.getMIFrames();
|
MIFrame[] miFrames = info.getMIFrames();
|
||||||
ICDIStackFrame[] stack = new ICDIStackFrame[miFrames.length];
|
StackFrame[] stack = new StackFrame[miFrames.length];
|
||||||
for (int i = 0; i < stack.length; i++) {
|
for (int i = 0; i < stack.length; i++) {
|
||||||
stack[i] = new StackFrame(getCTarget(), miFrames[i]);
|
stack[i] = new StackFrame(this, miFrames[i]);
|
||||||
|
if (i == 0) {
|
||||||
|
currentStackFrame = stack[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
|
@ -66,6 +66,33 @@ public class CThread extends CObject implements ICDIThread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 {
|
||||||
|
mi.postCommand(frame);
|
||||||
|
MIInfo info = frame.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
throw new CDIException("No answer");
|
||||||
|
}
|
||||||
|
currentStackFrame = (StackFrame)stackframe;
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new CDIException(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public StackFrame getCurrentStackFrame() throws CDIException {
|
||||||
|
return currentStackFrame;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#isSuspended()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#isSuspended()
|
||||||
*/
|
*/
|
||||||
|
@ -115,4 +142,15 @@ public class CThread extends CObject implements ICDIThread {
|
||||||
getTarget().suspend();
|
getTarget().suspend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#equals(ICDIThread)
|
||||||
|
*/
|
||||||
|
public boolean equals(ICDIThread thread) {
|
||||||
|
if (thread instanceof CThread) {
|
||||||
|
CThread cthread = (CThread) thread;
|
||||||
|
return id == cthread.getId();
|
||||||
|
}
|
||||||
|
return super.equals(thread);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author alain
|
||||||
|
*
|
||||||
|
* To change this generated comment edit the template variable "typecomment":
|
||||||
|
* Window>Preferences>Java>Templates.
|
||||||
|
* To enable and disable the creation of type comments go to
|
||||||
|
* Window>Preferences>Java>Code Generation.
|
||||||
|
*/
|
||||||
|
public class ChangedEvent implements ICDIChangedEvent {
|
||||||
|
|
||||||
|
CSession session;
|
||||||
|
MIEvent event;
|
||||||
|
|
||||||
|
public ChangedEvent(CSession s, MIEvent e) {
|
||||||
|
session = s;
|
||||||
|
event = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource()
|
||||||
|
*/
|
||||||
|
public ICDIObject getSource() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -80,6 +80,10 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fire the event;
|
// Fire the event;
|
||||||
|
fireEvent(cdiEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fireEvent(ICDIEvent cdiEvent) {
|
||||||
if (cdiEvent != null) {
|
if (cdiEvent != null) {
|
||||||
ICDIEventListener[] listeners =
|
ICDIEventListener[] listeners =
|
||||||
(ICDIEventListener[])list.toArray(new ICDIEventListener[0]);
|
(ICDIEventListener[])list.toArray(new ICDIEventListener[0]);
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class ExitedEvent implements ICDIExitedEvent {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource()
|
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource()
|
||||||
*/
|
*/
|
||||||
public ICDIObject getSource() {
|
public ICDIObject getSource() {
|
||||||
return session.getTarget();
|
return session.getCurrentTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,91 +1,13 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
|
import org.eclipse.cdt.debug.mi.core.output.MIVar;
|
||||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
|
||||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
|
||||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIVarAssign;
|
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIVarEvaluateExpression;
|
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIChild;
|
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIVarEvaluateExpressionInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author alain
|
|
||||||
*
|
|
||||||
* To change this generated comment edit the template variable "typecomment":
|
|
||||||
* Window>Preferences>Java>Templates.
|
|
||||||
* To enable and disable the creation of type comments go to
|
|
||||||
* Window>Preferences>Java>Code Generation.
|
|
||||||
*/
|
*/
|
||||||
public class Expression extends CObject implements ICDIExpression {
|
public class Expression extends Variable implements ICDIExpression {
|
||||||
|
|
||||||
MIChild child;
|
public Expression(StackFrame stackframe, String name, MIVar var) {
|
||||||
String exp;
|
super(stackframe, name, var);
|
||||||
|
|
||||||
public Expression(CTarget target, String e, MIChild c) {
|
|
||||||
super(target);
|
|
||||||
exp = e;
|
|
||||||
child = c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String getVarName() {
|
|
||||||
return child.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getName()
|
|
||||||
*/
|
|
||||||
public String getName() throws CDIException {
|
|
||||||
return exp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getTypeName()
|
|
||||||
*/
|
|
||||||
public String getTypeName() throws CDIException {
|
|
||||||
return child.getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getValue()
|
|
||||||
*/
|
|
||||||
public ICDIValue getValue() throws CDIException {
|
|
||||||
Value cvalue;
|
|
||||||
MISession mi = getCTarget().getCSession().getMISession();
|
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
|
||||||
MIVarEvaluateExpression var = factory.createMIVarEvaluateExpression(getVarName());
|
|
||||||
try {
|
|
||||||
mi.postCommand(var);
|
|
||||||
MIVarEvaluateExpressionInfo info = var.getMIVarEvaluateExpressionInfo();
|
|
||||||
String value = info.getValue();
|
|
||||||
cvalue = new Value(getCTarget(), value);
|
|
||||||
} catch (MIException e) {
|
|
||||||
throw new CDIException(e.toString());
|
|
||||||
}
|
|
||||||
return cvalue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(ICDIValue)
|
|
||||||
*/
|
|
||||||
public void setValue(ICDIValue value) throws CDIException {
|
|
||||||
setValue(value.getValueString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(String)
|
|
||||||
*/
|
|
||||||
public void setValue(String expression) throws CDIException {
|
|
||||||
MISession mi = getCTarget().getCSession().getMISession();
|
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
|
||||||
MIVarAssign var = factory.createMIVarAssign(getVarName(), expression);
|
|
||||||
try {
|
|
||||||
mi.postCommand(var);
|
|
||||||
} catch (MIException e) {
|
|
||||||
throw new CDIException(e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author alain
|
||||||
|
*
|
||||||
|
* To change this generated comment edit the template variable "typecomment":
|
||||||
|
* Window>Preferences>Java>Templates.
|
||||||
|
* To enable and disable the creation of type comments go to
|
||||||
|
* Window>Preferences>Java>Code Generation.
|
||||||
|
*/
|
||||||
|
public class ExpressionManager extends SessionObject implements ICDIExpressionManager {
|
||||||
|
|
||||||
|
public ExpressionManager(CSession session) {
|
||||||
|
super(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createCondition(int, String)
|
||||||
|
*/
|
||||||
|
public ICDICondition createCondition(int ignoreCount, String expression) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createExpression(String)
|
||||||
|
*/
|
||||||
|
public ICDIExpression createExpression(String name) throws CDIException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#getExpressions()
|
||||||
|
*/
|
||||||
|
public ICDIExpression[] getExpressions() throws CDIException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeExpression(ICDIExpression)
|
||||||
|
*/
|
||||||
|
public void removeExpression(ICDIExpression expression)
|
||||||
|
throws CDIException {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeExpressions(ICDIExpression[])
|
||||||
|
*/
|
||||||
|
public void removeExpressions(ICDIExpression[] expressions)
|
||||||
|
throws CDIException {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -71,4 +71,18 @@ public class Location implements ICDILocation {
|
||||||
public int getLineNumber() {
|
public int getLineNumber() {
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICDILocation#equals(ICDILocation)
|
||||||
|
*/
|
||||||
|
public boolean equals(ICDILocation location) {
|
||||||
|
if (location instanceof Location) {
|
||||||
|
Location loc = (Location)location;
|
||||||
|
return addr == loc.getAddress() &&
|
||||||
|
file.equals(loc.getFile()) &&
|
||||||
|
function.equals(loc.getFunction()) &&
|
||||||
|
line == loc.getLineNumber();
|
||||||
|
}
|
||||||
|
return super.equals(location);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIVar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class Register extends Variable implements ICDIRegister {
|
||||||
|
|
||||||
|
public Register(StackFrame frame, String name, MIVar var) {
|
||||||
|
super(frame, name, var);
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ public class ResumedEvent implements ICDIResumedEvent {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource()
|
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource()
|
||||||
*/
|
*/
|
||||||
public ICDIObject getSource() {
|
public ICDIObject getSource() {
|
||||||
return session.getTarget();
|
return session.getCurrentTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,43 +20,61 @@ import org.eclipse.cdt.debug.mi.core.output.MIStackListLocalsInfo;
|
||||||
public class StackFrame extends CObject implements ICDIStackFrame {
|
public class StackFrame extends CObject implements ICDIStackFrame {
|
||||||
|
|
||||||
MIFrame frame;
|
MIFrame frame;
|
||||||
|
CThread cthread;
|
||||||
|
|
||||||
public StackFrame(CTarget target, MIFrame f) {
|
public StackFrame(CThread thread, MIFrame f) {
|
||||||
super(target);
|
super(thread.getCTarget());
|
||||||
|
cthread = thread;
|
||||||
frame = f;
|
frame = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MIFrame getMIFrame() {
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
CThread getCThread() {
|
||||||
|
return cthread;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame#getArguments()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame#getArguments()
|
||||||
*/
|
*/
|
||||||
public ICDIArgument[] getArguments() throws CDIException {
|
public ICDIArgument[] getArguments() throws CDIException {
|
||||||
MIArg[] args = null;
|
|
||||||
ICDIArgument[] cdiArgs = null;
|
ICDIArgument[] cdiArgs = null;
|
||||||
if (frame != null) {
|
if (frame != null) {
|
||||||
MISession mi = getCTarget().getCSession().getMISession();
|
CSession session = getCTarget().getCSession();
|
||||||
|
VariableManager mgr = (VariableManager)session.getVariableManager();
|
||||||
|
mgr.update();
|
||||||
|
MISession mi = session.getMISession();
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
int level = frame.getLevel();
|
int level = frame.getLevel();
|
||||||
MIStackListArguments listArgs =
|
MIStackListArguments listArgs =
|
||||||
factory.createMIStackListArguments(true, level, level);
|
factory.createMIStackListArguments(false, level, level);
|
||||||
try {
|
try {
|
||||||
|
MIArg[] args = null;
|
||||||
mi.postCommand(listArgs);
|
mi.postCommand(listArgs);
|
||||||
MIStackListArgumentsInfo info = listArgs.getMIStackListArgumentsInfo();
|
MIStackListArgumentsInfo info =
|
||||||
|
listArgs.getMIStackListArgumentsInfo();
|
||||||
|
if (info == null) {
|
||||||
|
throw new CDIException("No answer");
|
||||||
|
}
|
||||||
MIFrame[] miFrames = info.getMIFrames();
|
MIFrame[] miFrames = info.getMIFrames();
|
||||||
if (miFrames != null && miFrames.length == 1) {
|
if (miFrames != null && miFrames.length == 1) {
|
||||||
args = miFrames[0].getArgs();
|
args = miFrames[0].getArgs();
|
||||||
}
|
}
|
||||||
|
if (args != null) {
|
||||||
|
cdiArgs = new ICDIArgument[args.length];
|
||||||
|
for (int i = 0; i < cdiArgs.length; i++) {
|
||||||
|
cdiArgs[i] =
|
||||||
|
mgr.createArgument(this, args[i].getName());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cdiArgs = new ICDIArgument[0];
|
||||||
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
//throw new CDIException(e);
|
throw new CDIException(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args != null) {
|
|
||||||
cdiArgs = new ICDIArgument[args.length];
|
|
||||||
for (int i = 0; i < cdiArgs.length; i++) {
|
|
||||||
cdiArgs[i] = new Argument(getCTarget(), args[i]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cdiArgs = new ICDIArgument[0];
|
|
||||||
}
|
|
||||||
return cdiArgs;
|
return cdiArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,31 +82,33 @@ public class StackFrame extends CObject implements ICDIStackFrame {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame#getLocalVariables()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame#getLocalVariables()
|
||||||
*/
|
*/
|
||||||
public ICDIVariable[] getLocalVariables() throws CDIException {
|
public ICDIVariable[] getLocalVariables() throws CDIException {
|
||||||
MIArg[] args = null;
|
CSession session = getCTarget().getCSession();
|
||||||
ICDIVariable[] variables = null;
|
VariableManager mgr = (VariableManager)session.getVariableManager();
|
||||||
MISession mi = getCTarget().getCSession().getMISession();
|
mgr.update();
|
||||||
|
MISession mi = session.getMISession();
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
MIStackListLocals locals = factory.createMIStackListLocals(true);
|
MIStackListLocals locals = factory.createMIStackListLocals(false);
|
||||||
try {
|
try {
|
||||||
|
MIArg[] args = null;
|
||||||
|
ICDIVariable[] variables = null;
|
||||||
mi.postCommand(locals);
|
mi.postCommand(locals);
|
||||||
MIStackListLocalsInfo info = locals.getMIStackListLocalsInfo();
|
MIStackListLocalsInfo info = locals.getMIStackListLocalsInfo();
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
// throw new CDIException();
|
throw new CDIException("No answer");
|
||||||
}
|
}
|
||||||
args = info.getLocals();
|
args = info.getLocals();
|
||||||
|
if (args != null) {
|
||||||
} catch (MIException e) {
|
variables = new ICDIVariable[args.length];
|
||||||
//throw new CDIException(e);
|
for (int i = 0; i < variables.length; i++) {
|
||||||
}
|
variables[i] = mgr.createVariable(this, args[i].getName());
|
||||||
if (args != null) {
|
}
|
||||||
variables = new ICDIVariable[args.length];
|
} else {
|
||||||
for (int i = 0; i < variables.length; i++) {
|
variables = new ICDIVariable[0];
|
||||||
variables[i] = new Variable(getCTarget(), args[i]);
|
|
||||||
}
|
}
|
||||||
} else {
|
return variables;
|
||||||
variables = new ICDIVariable[0];
|
} catch (MIException e) {
|
||||||
|
throw new CDIException(e.toString());
|
||||||
}
|
}
|
||||||
return variables;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,4 +131,20 @@ public class StackFrame extends CObject implements ICDIStackFrame {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame#equals(ICDIStackFrame)
|
||||||
|
*/
|
||||||
|
public boolean equals(ICDIStackFrame stackframe) {
|
||||||
|
if (stackframe instanceof StackFrame) {
|
||||||
|
StackFrame stack = (StackFrame)stackframe;
|
||||||
|
return cthread != null &&
|
||||||
|
cthread.equals(stack.getCThread()) &&
|
||||||
|
frame != null &&
|
||||||
|
frame.getLevel() == stack.getMIFrame().getLevel() &&
|
||||||
|
frame.getFile().equals(stack.getMIFrame().getFile()) &&
|
||||||
|
frame.getFunction().equals(stack.getMIFrame().getFunction());
|
||||||
|
}
|
||||||
|
return super.equals(stackframe);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,25 +29,17 @@ public class SuspendedEvent implements ICDISuspendedEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICDISessionObject getReason() {
|
public ICDISessionObject getReason() {
|
||||||
if (event instanceof MIBreakpointEvent
|
if (event instanceof MIBreakpointEvent || event instanceof MIWatchpointEvent) {
|
||||||
|| event instanceof MIWatchpointEvent) {
|
MIBreakpointEvent breakEvent = (MIBreakpointEvent)event;
|
||||||
MIBreakpointEvent breakEvent = (MIBreakpointEvent) event;
|
|
||||||
int number = breakEvent.getNumber();
|
int number = breakEvent.getNumber();
|
||||||
ICDIBreakpointManager mgr = session.getBreakpointManager();
|
BreakpointManager mgr = (BreakpointManager)session.getBreakpointManager();
|
||||||
// Ask the breakpoint manager the array of ICDIBreakpoint(s)
|
// Ask the breakpointManager for the breakpoint
|
||||||
// We need to return the same object as the reason.
|
// We need to return the same object as the reason.
|
||||||
try {
|
Breakpoint point = mgr.getBreakpoint(number);
|
||||||
ICDIBreakpoint[] bkpts = mgr.getBreakpoints();
|
if (point != null) {
|
||||||
for (int i = 0; i < bkpts.length; i++) {
|
return point;
|
||||||
if (bkpts[i] instanceof Breakpoint) {
|
} else {
|
||||||
Breakpoint point = (Breakpoint) bkpts[i];
|
// FIXME: Create a new breakpoint.
|
||||||
MIBreakPoint miBreak = point.getMIBreakPoint();
|
|
||||||
if (miBreak.getNumber() == number) {
|
|
||||||
return point;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (CDIException e) {
|
|
||||||
}
|
}
|
||||||
} else if (event instanceof MISteppingRangeEvent) {
|
} else if (event instanceof MISteppingRangeEvent) {
|
||||||
return new EndSteppingRange(session);
|
return new EndSteppingRange(session);
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIVarEvaluateExpression;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIVarListChildren;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIVar;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIVarEvaluateExpressionInfo;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIVarListChildrenInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author alain
|
* @author alain
|
||||||
|
@ -16,32 +22,71 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
|
||||||
*/
|
*/
|
||||||
public class Value extends CObject implements ICDIValue {
|
public class Value extends CObject implements ICDIValue {
|
||||||
|
|
||||||
String val = "";
|
Variable variable;
|
||||||
|
|
||||||
public Value(CTarget target, String s) {
|
public Value(Variable v) {
|
||||||
super(target);
|
super(v.getCTarget());
|
||||||
val = s;
|
variable = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getTypeName()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getTypeName()
|
||||||
*/
|
*/
|
||||||
public String getTypeName() throws CDIException {
|
public String getTypeName() throws CDIException {
|
||||||
return "";
|
return variable.getTypeName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getValueString()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getValueString()
|
||||||
*/
|
*/
|
||||||
public String getValueString() throws CDIException {
|
public String getValueString() throws CDIException {
|
||||||
return val;
|
String result = "";
|
||||||
|
StackFrame stack = variable.getStackFrame();
|
||||||
|
stack.getCThread().setCurrentStackFrame(stack);
|
||||||
|
MISession mi = getCTarget().getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIVarEvaluateExpression var =
|
||||||
|
factory.createMIVarEvaluateExpression(variable.getMIVar().getVarName());
|
||||||
|
try {
|
||||||
|
mi.postCommand(var);
|
||||||
|
MIVarEvaluateExpressionInfo info = var.getMIVarEvaluateExpressionInfo();
|
||||||
|
if (info == null) {
|
||||||
|
throw new CDIException("No answer");
|
||||||
|
}
|
||||||
|
result = info.getValue();
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new CDIException(e.toString());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getVariables()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getVariables()
|
||||||
*/
|
*/
|
||||||
public ICDIVariable[] getVariables() throws CDIException {
|
public ICDIVariable[] getVariables() throws CDIException {
|
||||||
return new ICDIVariable[0];
|
StackFrame stack = variable.getStackFrame();
|
||||||
|
stack.getCThread().setCurrentStackFrame(stack);
|
||||||
|
Variable[] variables = null;
|
||||||
|
MISession mi = getCTarget().getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIVarListChildren var =
|
||||||
|
factory.createMIVarListChildren(variable.getMIVar().getVarName());
|
||||||
|
try {
|
||||||
|
mi.postCommand(var);
|
||||||
|
MIVarListChildrenInfo info = var.getMIVarListChildrenInfo();
|
||||||
|
if (info == null) {
|
||||||
|
throw new CDIException("No answer");
|
||||||
|
}
|
||||||
|
MIVar[] vars = info.getMIVars();
|
||||||
|
variables = new Variable[vars.length];
|
||||||
|
for (int i = 0; i < vars.length; i++) {
|
||||||
|
variables[i] =
|
||||||
|
new Variable(variable.getStackFrame(), vars[i].getExp(), vars[i]);
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new CDIException(e.toString());
|
||||||
|
}
|
||||||
|
return variables;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,66 +1,118 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIArg;
|
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIVarAssign;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIVarShowAttributes;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIVar;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIVarShowAttributesInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author alain
|
* @author alain
|
||||||
*
|
|
||||||
* To change this generated comment edit the template variable "typecomment":
|
|
||||||
* Window>Preferences>Java>Templates.
|
|
||||||
* To enable and disable the creation of type comments go to
|
|
||||||
* Window>Preferences>Java>Code Generation.
|
|
||||||
*/
|
*/
|
||||||
public class Variable extends CObject implements ICDIVariable {
|
public class Variable extends CObject implements ICDIVariable {
|
||||||
|
|
||||||
MIArg arg;
|
MIVar miVar;
|
||||||
|
String name;
|
||||||
|
Value value;
|
||||||
|
StackFrame stack;
|
||||||
|
|
||||||
public Variable(CTarget target, MIArg a) {
|
public Variable(StackFrame stackframe, String n, MIVar v) {
|
||||||
super(target);
|
super(stackframe.getCTarget());
|
||||||
arg = a;
|
stack = stackframe;
|
||||||
|
name = n;
|
||||||
|
miVar = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StackFrame getStackFrame() {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
MIVar getMIVar() {
|
||||||
|
return miVar;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getName()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getName()
|
||||||
*/
|
*/
|
||||||
public String getName() throws CDIException {
|
public String getName() throws CDIException {
|
||||||
return arg.getName();
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getTypeName()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getTypeName()
|
||||||
*/
|
*/
|
||||||
public String getTypeName() throws CDIException {
|
public String getTypeName() throws CDIException {
|
||||||
return "";
|
return miVar.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getValue()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getValue()
|
||||||
*/
|
*/
|
||||||
public ICDIValue getValue() throws CDIException {
|
public ICDIValue getValue() throws CDIException {
|
||||||
return new Value(getCTarget(), arg.getValue());
|
if (value == null) {
|
||||||
}
|
value = new Value(this);
|
||||||
|
}
|
||||||
/**
|
return value;
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#hasValueChanged()
|
|
||||||
*/
|
|
||||||
public boolean hasValueChanged() throws CDIException {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(ICDIValue)
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(ICDIValue)
|
||||||
*/
|
*/
|
||||||
public void setValue(ICDIValue value) throws CDIException {
|
public void setValue(ICDIValue value) throws CDIException {
|
||||||
|
setValue(value.getValueString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(String)
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(String)
|
||||||
*/
|
*/
|
||||||
public void setValue(String expression) throws CDIException {
|
public void setValue(String expression) throws CDIException {
|
||||||
|
MISession mi = getCTarget().getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIVarAssign var = factory.createMIVarAssign(miVar.getVarName(), expression);
|
||||||
|
try {
|
||||||
|
mi.postCommand(var);
|
||||||
|
MIInfo info = var.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
throw new CDIException("No answer");
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new CDIException(e.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#isEditable()
|
||||||
|
*/
|
||||||
|
public boolean isEditable() throws CDIException {
|
||||||
|
MISession mi = getCTarget().getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIVarShowAttributes var = factory.createMIVarShowAttributes(miVar.getVarName());
|
||||||
|
try {
|
||||||
|
mi.postCommand(var);
|
||||||
|
MIVarShowAttributesInfo info = var.getMIVarShowAttributesInfo();
|
||||||
|
if (info == null) {
|
||||||
|
throw new CDIException("No answer");
|
||||||
|
}
|
||||||
|
return info.isEditable();
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new CDIException(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#equals()
|
||||||
|
*/
|
||||||
|
public boolean equals(ICDIVariable var) {
|
||||||
|
if (var instanceof Variable) {
|
||||||
|
Variable variable = (Variable)var;
|
||||||
|
return miVar.getVarName().equals(variable.getMIVar().getVarName());
|
||||||
|
}
|
||||||
|
return super.equals(var);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,110 +10,248 @@ import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
|
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIVariableManager;
|
import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIArgument;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
|
||||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIVarCreate;
|
import org.eclipse.cdt.debug.mi.core.command.MIVarCreate;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIVarDelete;
|
import org.eclipse.cdt.debug.mi.core.command.MIVarDelete;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIChild;
|
import org.eclipse.cdt.debug.mi.core.command.MIVarUpdate;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIVar;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIVarChange;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIVarCreateInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIVarCreateInfo;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIVarUpdateInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author alain
|
|
||||||
*
|
|
||||||
* To change this generated comment edit the template variable "typecomment":
|
|
||||||
* Window>Preferences>Java>Templates.
|
|
||||||
* To enable and disable the creation of type comments go to
|
|
||||||
* Window>Preferences>Java>Code Generation.
|
|
||||||
*/
|
*/
|
||||||
public class VariableManager
|
public class VariableManager extends SessionObject {
|
||||||
extends SessionObject
|
|
||||||
implements ICDIVariableManager {
|
List elementList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class container to regroup all info concerning a variable.
|
||||||
|
*/
|
||||||
|
class Element {
|
||||||
|
MIVar miVar;
|
||||||
|
String name;
|
||||||
|
StackFrame stackframe;
|
||||||
|
Variable variable;
|
||||||
|
}
|
||||||
|
|
||||||
List expList;
|
|
||||||
public VariableManager(CSession session) {
|
public VariableManager(CSession session) {
|
||||||
super(session);
|
super(session);
|
||||||
expList = new ArrayList();
|
elementList = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Element getElement(StackFrame stack, String name) {
|
||||||
|
Element[] elements = getElements();
|
||||||
|
for (int i = 0; i < elements.length; i++) {
|
||||||
|
if (elements[i].stackframe.equals(stack) &&
|
||||||
|
elements[i].name.equals(name)) {
|
||||||
|
return elements[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addElement(Element element) {
|
||||||
|
Element[] elements = getElements();
|
||||||
|
for (int i = 0; i < elements.length; i++) {
|
||||||
|
String name = elements[i].miVar.getVarName();
|
||||||
|
if (name.equals(element.miVar.getVarName())) {
|
||||||
|
// Thread.currentThread().dumpStack();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elementList.add(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
Element[] getElements() {
|
||||||
|
return (Element[]) elementList.toArray(new Element[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void update() throws CDIException {
|
||||||
|
MISession mi = getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIVarUpdate update = factory.createMIVarUpdate();
|
||||||
|
try {
|
||||||
|
mi.postCommand(update);
|
||||||
|
MIVarUpdateInfo info = update.getMIVarUpdateInfo();
|
||||||
|
if (info == null) {
|
||||||
|
throw new CDIException("No answer");
|
||||||
|
}
|
||||||
|
MIVarChange[]changes = info.getMIVarChanges();
|
||||||
|
for (int i = 0 ; i < changes.length; i++) {
|
||||||
|
ICDIEvent cdiEvent;
|
||||||
|
if (!changes[i].isInScope()) {
|
||||||
|
//cdiEvent = DestroyEvent(getCSession(), );
|
||||||
|
removeVariable(changes[i]);
|
||||||
|
} else {
|
||||||
|
//cdiEvent = ChangedEvent(getCSession(), );
|
||||||
|
}
|
||||||
|
//EventManager mgr = (EventManager)getCSession().getEventManager();
|
||||||
|
//mgr.fireEvent(cdiEvent);
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new CDIException(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Element createElement(StackFrame stack, String name) throws CDIException {
|
||||||
|
Element element = getElement(stack, name);
|
||||||
|
if (element == null) {
|
||||||
|
stack.getCThread().setCurrentStackFrame(stack);
|
||||||
|
MISession mi = getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIVarCreate var = factory.createMIVarCreate(name);
|
||||||
|
try {
|
||||||
|
mi.postCommand(var);
|
||||||
|
MIVarCreateInfo info = var.getMIVarCreateInfo();
|
||||||
|
if (info == null) {
|
||||||
|
throw new CDIException("No answer");
|
||||||
|
}
|
||||||
|
element = new Element();
|
||||||
|
element.miVar = info.getMIVar();
|
||||||
|
element.name = name;
|
||||||
|
element.stackframe = stack;
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new CDIException(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableManager#getExpression(String)
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#getVariable(String)
|
||||||
*/
|
*/
|
||||||
public ICDIExpression getExpression(String expressionId)
|
public ICDIVariable getVariable(String name) throws CDIException {
|
||||||
throws CDIException {
|
ICDIVariable[] variables = getVariables();
|
||||||
ICDIExpression[] expressions = getExpressions();
|
for (int i = 0; i < variables.length; i++) {
|
||||||
for (int i = 0; i < expressions.length; i++) {
|
if (name.equals(variables[i].getName())) {
|
||||||
if (expressionId.equals(expressions[i].getName())) {
|
return variables[i];
|
||||||
return expressions[i];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableManager#getExpressions()
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#getVariables()
|
||||||
*/
|
*/
|
||||||
public ICDIExpression[] getExpressions() throws CDIException {
|
public ICDIVariable[] getVariables() throws CDIException {
|
||||||
return (ICDIExpression[]) expList.toArray(new ICDIExpression[0]);
|
Element[] elements = getElements();
|
||||||
|
ICDIVariable[] variables = new ICDIVariable[elements.length];
|
||||||
|
for (int i = 0; i < elements.length; i++) {
|
||||||
|
variables[i] = elements[i].variable;
|
||||||
|
}
|
||||||
|
return variables;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void removeMIVar(MIVar miVar) throws CDIException {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableManager#removeExpression(ICDIExpression)
|
MISession mi = getCSession().getMISession();
|
||||||
*/
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
public void removeExpression(ICDIExpression expression)
|
MIVarDelete var = factory.createMIVarDelete(miVar.getVarName());
|
||||||
throws CDIException {
|
try {
|
||||||
if (expression instanceof Expression) {
|
mi.postCommand(var);
|
||||||
expList.remove(expression);
|
MIInfo info = var.getMIInfo();
|
||||||
MISession mi = getCSession().getMISession();
|
} catch (MIException e) {
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
throw new CDIException(e.toString());
|
||||||
MIVarDelete var =
|
}
|
||||||
factory.createMIVarDelete(
|
}
|
||||||
((Expression) expression).getVarName());
|
|
||||||
try {
|
void removeVariable(String varName) throws CDIException {
|
||||||
mi.postCommand(var);
|
Element[] elements = getElements();
|
||||||
} catch (MIException e) {
|
for (int i = 0; i < elements.length; i++) {
|
||||||
throw new CDIException(e.toString());
|
if (elements[i].miVar.getVarName().equals(varName)) {
|
||||||
|
elementList.remove(elements[i]);
|
||||||
|
removeMIVar(elements[i].miVar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeVariable(MIVarChange changed) throws CDIException {
|
||||||
|
String varName = changed.getVarName();
|
||||||
|
removeVariable(varName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableManager#removeExpressions(ICDIExpression[])
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeVariable(ICDIVariable)
|
||||||
*/
|
*/
|
||||||
public void removeExpressions(ICDIExpression[] expressions)
|
public void removeVariable(ICDIVariable variable) throws CDIException {
|
||||||
throws CDIException {
|
if (variable instanceof Variable) {
|
||||||
for (int i = 0; i < expressions.length; i++) {
|
String varName = ((Variable)variable).getMIVar().getVarName();
|
||||||
removeExpression(expressions[i]);
|
removeVariable(varName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableManager#createExpression(String)
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeVariable(ICDIVariable[])
|
||||||
*/
|
*/
|
||||||
public ICDIExpression createExpression(String expressionId)
|
public void removeVariables(ICDIVariable[] variables) throws CDIException {
|
||||||
throws CDIException {
|
for (int i = 0; i < variables.length; i++) {
|
||||||
|
removeVariable(variables[i]);
|
||||||
Expression cexp = null;
|
|
||||||
|
|
||||||
MISession mi = getCSession().getMISession();
|
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
|
||||||
MIVarCreate var = factory.createMIVarCreate(expressionId);
|
|
||||||
try {
|
|
||||||
mi.postCommand(var);
|
|
||||||
MIVarCreateInfo info = var.getMIVarCreateInfo();
|
|
||||||
MIChild child = info.getMIChild();
|
|
||||||
cexp = new Expression(getCSession().getCTarget(), expressionId, child);
|
|
||||||
expList.add(cexp);
|
|
||||||
} catch (MIException e) {
|
|
||||||
throw new CDIException(e.toString());
|
|
||||||
}
|
}
|
||||||
return cexp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableManager#createCondition(int, String)
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createVariable(String)
|
||||||
|
*/
|
||||||
|
public ICDIVariable createVariable(String name) throws CDIException {
|
||||||
|
ICDITarget target = getCSession().getCurrentTarget();
|
||||||
|
CThread thread = ((CTarget)target).getCurrentThread();
|
||||||
|
StackFrame stack = thread.getCurrentStackFrame();
|
||||||
|
return createVariable(stack, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createVariable(ICDIStackFrame, String)
|
||||||
|
*/
|
||||||
|
public ICDIVariable createVariable(ICDIStackFrame frame, String name) throws CDIException {
|
||||||
|
if (frame instanceof StackFrame) {
|
||||||
|
StackFrame stack = (StackFrame)frame;
|
||||||
|
Element element = createElement(stack, name);
|
||||||
|
Variable var = new Variable(stack, name, element.miVar);
|
||||||
|
element.variable = var;
|
||||||
|
addElement(element);
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
throw new CDIException("Unknow stackframe");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ICDIArgument createArgument(StackFrame stack, String name) throws CDIException {
|
||||||
|
Element element = createElement(stack, name);
|
||||||
|
Variable carg = new Argument(stack, name,element.miVar);
|
||||||
|
element.variable = carg;
|
||||||
|
addElement(element);
|
||||||
|
return (ICDIArgument)carg;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICDIExpression createExpression(StackFrame stack, String name) throws CDIException {
|
||||||
|
Element element = createElement(stack, name);
|
||||||
|
Variable cexp = new Expression(stack, name, element.miVar);
|
||||||
|
element.variable = cexp;
|
||||||
|
addElement(element);
|
||||||
|
return (ICDIExpression)cexp;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICDIRegister createRegister(StackFrame stack, String name) throws CDIException {
|
||||||
|
Element element = createElement(stack, "$" + name);
|
||||||
|
Variable reg = new Register(stack, name, element.miVar);
|
||||||
|
element.variable = reg;
|
||||||
|
addElement(element);
|
||||||
|
return (ICDIRegister)reg;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createCondition(int, String)
|
||||||
*/
|
*/
|
||||||
public ICDICondition createCondition(int ignoreCount, String expression) {
|
public ICDICondition createCondition(int ignoreCount, String expression) {
|
||||||
return new Condition(ignoreCount, expression);
|
return new Condition(ignoreCount, expression);
|
||||||
|
|
Loading…
Add table
Reference in a new issue