mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
First to implement the ExpressionManager.
This commit is contained in:
parent
660ff8e39d
commit
a91b54c65f
14 changed files with 279 additions and 100 deletions
|
@ -42,6 +42,7 @@ public class CSession implements ICDISession, ICDISessionObject {
|
|||
props = new Properties();
|
||||
breakpointManager = new BreakpointManager(this);
|
||||
eventManager = new EventManager(this);
|
||||
s.addObserver(eventManager);
|
||||
expressionManager = new ExpressionManager(this);
|
||||
memoryManager = new MemoryManager(this);
|
||||
signalManager = new SignalManager(this);
|
||||
|
|
|
@ -9,7 +9,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
|
||||
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.ICDIRegisterGroup;
|
||||
|
@ -41,10 +43,15 @@ public class CTarget implements ICDITarget {
|
|||
|
||||
List threadList;
|
||||
CSession session;
|
||||
CThread dummyThread; // Dummy for non multi-thread programs.
|
||||
CThread currentThread;
|
||||
|
||||
public CTarget(CSession s) {
|
||||
session = s;
|
||||
threadList = new ArrayList(1);
|
||||
dummyThread = new CThread(this, 0);
|
||||
currentThread = dummyThread;
|
||||
threadList.add(dummyThread);
|
||||
}
|
||||
|
||||
CSession getCSession() {
|
||||
|
@ -59,6 +66,16 @@ public class CTarget implements ICDITarget {
|
|||
threadList.remove(cthread);
|
||||
}
|
||||
|
||||
void setCurrentThread(int id) {
|
||||
for (int i = 0; i < threadList.size(); i++) {
|
||||
CThread cthread = (CThread)threadList.get(i);
|
||||
if (cthread.getId() == id) {
|
||||
currentThread = cthread;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean containsCThread(int id) {
|
||||
for (int i = 0; i < threadList.size(); i++) {
|
||||
CThread cthread = (CThread)threadList.get(i);
|
||||
|
@ -149,7 +166,7 @@ public class CTarget implements ICDITarget {
|
|||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getCurrentThread()
|
||||
*/
|
||||
public ICDIThread getCurrentThread() throws CDIException {
|
||||
return null;
|
||||
return currentThread;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,16 +181,13 @@ public class CTarget implements ICDITarget {
|
|||
MIThreadListIdsInfo info = tids.getMIThreadListIdsInfo();
|
||||
int[] ids = info.getThreadIds();
|
||||
if (ids != null && ids.length > 0) {
|
||||
// Ok that means it is a multiThreaded, remove the dummy Thread
|
||||
removeCThread(dummyThread);
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
if (! containsCThread(ids[i])) {
|
||||
addCThread(new CThread(this, ids[i]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// HACK create a dummy thread
|
||||
if (threadList.size() == 0) {
|
||||
addCThread(new CThread(this, 1));
|
||||
}
|
||||
}
|
||||
} catch (MIException e) {
|
||||
throw new CDIException(e.toString());
|
||||
|
@ -379,7 +393,11 @@ public class CTarget implements ICDITarget {
|
|||
*/
|
||||
public ICDIValue evaluateExpressionToValue(String expressionText)
|
||||
throws CDIException {
|
||||
return null;
|
||||
ICDIExpressionManager mgr = session.getExpressionManager();
|
||||
ICDIExpression cexp = mgr.createExpression(expressionText);
|
||||
ICDIValue value = cexp.getValue();
|
||||
mgr.removeExpression(cexp);
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIStackListFramesInfo;
|
|||
*/
|
||||
public class CThread extends CObject implements ICDIThread {
|
||||
|
||||
int id = 0;
|
||||
int id;
|
||||
|
||||
public CThread(CTarget target, int threadId) {
|
||||
super(target);
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIExitEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MILocationReachedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIRunningEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MISignalEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MISteppingRangeEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class EventAdapter {
|
||||
|
||||
public static ICDIEvent getCDIEvent(CSession session, MIEvent miEvent) {
|
||||
if (miEvent instanceof MIBreakpointEvent
|
||||
|| miEvent instanceof MIFunctionFinishedEvent
|
||||
|| miEvent instanceof MILocationReachedEvent
|
||||
|| miEvent instanceof MISignalEvent
|
||||
|| miEvent instanceof MISteppingRangeEvent
|
||||
|| miEvent instanceof MIWatchpointEvent) {
|
||||
return new SuspendedEvent(session, miEvent);
|
||||
} else if (miEvent instanceof MIRunningEvent) {
|
||||
return new ResumedEvent(session, (MIRunningEvent)miEvent);
|
||||
} else if (miEvent instanceof MIInferiorExitEvent) {
|
||||
return new ExitedEvent(session, (MIInferiorExitEvent)miEvent);
|
||||
} else if (miEvent instanceof MIExitEvent) {
|
||||
return new DestroyedEvent(session, (MIExitEvent)miEvent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -5,39 +5,87 @@
|
|||
*/
|
||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIEventManager;
|
||||
import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
|
||||
import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
|
||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIExitEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MILocationReachedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIRunningEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MISignalEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MISteppingRangeEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
|
||||
|
||||
/**
|
||||
* @author alain
|
||||
*
|
||||
* To change this generated comment edit the template variable "typecomment":
|
||||
* Window>Preferences>Java>Templates.
|
||||
* To enable and disable the creation oEventManagerts go to
|
||||
* Window>Preferences>Java>Code Generation.
|
||||
*/
|
||||
public class EventManager extends SessionObject implements ICDIEventManager {
|
||||
public class EventManager extends SessionObject implements ICDIEventManager, Observer {
|
||||
|
||||
Map map = Collections.synchronizedMap(new HashMap());
|
||||
List list = Collections.synchronizedList(new ArrayList(1));
|
||||
|
||||
class CDIObserver implements Observer {
|
||||
ICDIEventListener listener;
|
||||
public CDIObserver(ICDIEventListener l) {
|
||||
listener = l;
|
||||
}
|
||||
/**
|
||||
* Process the event from MI and do any state work on the CDI.
|
||||
*/
|
||||
public void update(Observable o, Object arg) {
|
||||
MIEvent event = (MIEvent)arg;
|
||||
ICDIEvent cdiEvent = EventAdapter.getCDIEvent(getCSession(), event);
|
||||
listener.handleDebugEvent(cdiEvent);
|
||||
MIEvent miEvent = (MIEvent)arg;
|
||||
CSession session = getCSession();
|
||||
ICDIEvent cdiEvent = null;
|
||||
int threadId = 0;
|
||||
|
||||
if (miEvent instanceof MIBreakpointEvent) {
|
||||
MIBreakpointEvent breakEvent = (MIBreakpointEvent)miEvent;
|
||||
threadId = breakEvent.getThreadId();
|
||||
session.getCTarget().setCurrentThread(threadId);
|
||||
cdiEvent = new SuspendedEvent(session, miEvent);
|
||||
} else if (miEvent instanceof MIFunctionFinishedEvent) {
|
||||
MIFunctionFinishedEvent funcEvent = (MIFunctionFinishedEvent)miEvent;
|
||||
threadId = funcEvent.getThreadId();
|
||||
session.getCTarget().setCurrentThread(threadId);
|
||||
cdiEvent = new SuspendedEvent(session, miEvent);
|
||||
} else if (miEvent instanceof MILocationReachedEvent) {
|
||||
MILocationReachedEvent locEvent = (MILocationReachedEvent)miEvent;
|
||||
threadId = locEvent.getThreadId();
|
||||
session.getCTarget().setCurrentThread(threadId);
|
||||
cdiEvent = new SuspendedEvent(session, miEvent);
|
||||
} else if (miEvent instanceof MISignalEvent) {
|
||||
MISignalEvent sigEvent = (MISignalEvent)miEvent;
|
||||
threadId = sigEvent.getThreadId();
|
||||
session.getCTarget().setCurrentThread(threadId);
|
||||
cdiEvent = new SuspendedEvent(session, miEvent);
|
||||
} else if (miEvent instanceof MISteppingRangeEvent) {
|
||||
MISteppingRangeEvent rangeEvent = (MISteppingRangeEvent)miEvent;
|
||||
threadId = rangeEvent.getThreadId();
|
||||
session.getCTarget().setCurrentThread(threadId);
|
||||
cdiEvent = new SuspendedEvent(session, miEvent);
|
||||
} else if (miEvent instanceof MIWatchpointEvent) {
|
||||
MIWatchpointEvent watchEvent = (MIWatchpointEvent)miEvent;
|
||||
threadId = watchEvent.getThreadId();
|
||||
session.getCTarget().setCurrentThread(threadId);
|
||||
cdiEvent = new SuspendedEvent(session, miEvent);
|
||||
} else if (miEvent instanceof MIRunningEvent) {
|
||||
cdiEvent = new ResumedEvent(session, (MIRunningEvent)miEvent);
|
||||
} else if (miEvent instanceof MIInferiorExitEvent) {
|
||||
cdiEvent = new ExitedEvent(session, (MIInferiorExitEvent)miEvent);
|
||||
} else if (miEvent instanceof MIExitEvent) {
|
||||
cdiEvent = new DestroyedEvent(session, (MIExitEvent)miEvent);
|
||||
}
|
||||
|
||||
// Fire the event;
|
||||
if (cdiEvent != null) {
|
||||
ICDIEventListener[] listeners =
|
||||
(ICDIEventListener[])list.toArray(new ICDIEventListener[0]);
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
listeners[i].handleDebugEvent(cdiEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,20 +97,13 @@ public class EventManager extends SessionObject implements ICDIEventManager {
|
|||
* @see org.eclipse.cdt.debug.core.cdi.ICDIEventManager#addEventListener(ICDIEventListener)
|
||||
*/
|
||||
public void addEventListener(ICDIEventListener listener) {
|
||||
CDIObserver cdiObserver = new CDIObserver(listener);
|
||||
map.put(listener, cdiObserver);
|
||||
MISession session = getCSession().getMISession();
|
||||
session.addObserver(cdiObserver);
|
||||
list.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIEventManager#removeEventListener(ICDIEventListener)
|
||||
*/
|
||||
public void removeEventListener(ICDIEventListener listener) {
|
||||
CDIObserver cdiObserver = (CDIObserver)map.remove(listener);
|
||||
if (cdiObserver != null) {
|
||||
MISession session = getCSession().getMISession();
|
||||
session.deleteObserver(cdiObserver);
|
||||
}
|
||||
list.remove(listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,14 @@ 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.ICDIObject;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
|
||||
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
|
||||
|
@ -16,41 +21,71 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
|
|||
*/
|
||||
public class Expression extends CObject implements ICDIExpression {
|
||||
|
||||
public Expression(CTarget target) {
|
||||
MIChild child;
|
||||
String exp;
|
||||
|
||||
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 null;
|
||||
return exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getTypeName()
|
||||
*/
|
||||
public String getTypeName() throws CDIException {
|
||||
return null;
|
||||
return child.getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getValue()
|
||||
*/
|
||||
public ICDIValue getValue() throws CDIException {
|
||||
return null;
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,11 +5,20 @@
|
|||
*/
|
||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.ICDISession;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
|
||||
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.MIVarCreate;
|
||||
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.output.MIVarCreateInfo;
|
||||
|
||||
/**
|
||||
* @author alain
|
||||
|
@ -19,10 +28,14 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
|
|||
* To enable and disable the creation of type comments go to
|
||||
* Window>Preferences>Java>Code Generation.
|
||||
*/
|
||||
public class ExpressionManager extends SessionObject implements ICDIExpressionManager {
|
||||
public class ExpressionManager
|
||||
extends SessionObject
|
||||
implements ICDIExpressionManager {
|
||||
|
||||
List expList;
|
||||
public ExpressionManager(CSession session) {
|
||||
super(session);
|
||||
expList = new ArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,6 +43,12 @@ public class ExpressionManager extends SessionObject implements ICDIExpressionMa
|
|||
*/
|
||||
public ICDIExpression getExpression(String expressionId)
|
||||
throws CDIException {
|
||||
ICDIExpression[] expressions = getExpressions();
|
||||
for (int i = 0; i < expressions.length; i++) {
|
||||
if (expressionId.equals(expressions[i].getName())) {
|
||||
return expressions[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -37,13 +56,27 @@ public class ExpressionManager extends SessionObject implements ICDIExpressionMa
|
|||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#getExpressions()
|
||||
*/
|
||||
public ICDIExpression[] getExpressions() throws CDIException {
|
||||
return null;
|
||||
return (ICDIExpression[]) expList.toArray(new ICDIExpression[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeExpression(ICDIExpression)
|
||||
*/
|
||||
public void removeExpression(ICDIExpression expression) throws CDIException {
|
||||
public void removeExpression(ICDIExpression expression)
|
||||
throws CDIException {
|
||||
if (expression instanceof Expression) {
|
||||
expList.remove(expression);
|
||||
MISession mi = getCSession().getMISession();
|
||||
CommandFactory factory = mi.getCommandFactory();
|
||||
MIVarDelete var =
|
||||
factory.createMIVarDelete(
|
||||
((Expression) expression).getVarName());
|
||||
try {
|
||||
mi.postCommand(var);
|
||||
} catch (MIException e) {
|
||||
throw new CDIException(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,6 +84,9 @@ public class ExpressionManager extends SessionObject implements ICDIExpressionMa
|
|||
*/
|
||||
public void removeExpressions(ICDIExpression[] expressions)
|
||||
throws CDIException {
|
||||
for (int i = 0; i < expressions.length; i++) {
|
||||
removeExpression(expressions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +94,22 @@ public class ExpressionManager extends SessionObject implements ICDIExpressionMa
|
|||
*/
|
||||
public ICDIExpression createExpression(String expressionId)
|
||||
throws CDIException {
|
||||
return null;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -214,6 +214,10 @@ public class CommandFactory {
|
|||
return new MIThreadSelect(threadNum);
|
||||
}
|
||||
|
||||
public MIVarCreate createMIVarCreate(String expression) {
|
||||
return new MIVarCreate(expression);
|
||||
}
|
||||
|
||||
public MIVarCreate createMIVarCreate(String name, String frameAddr, String expression) {
|
||||
return new MIVarCreate(name, frameAddr, expression);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIVarCreateInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* -var-create {NAME | "-"}
|
||||
|
@ -40,11 +45,28 @@ public class MIVarCreate extends MICommand
|
|||
public MIVarCreate(String expression) {
|
||||
this("-", "*", expression);
|
||||
}
|
||||
|
||||
public MIVarCreate(String name, String expression) {
|
||||
this(name, "*", expression);
|
||||
}
|
||||
|
||||
public MIVarCreate(String name, String frameAddr, String expression) {
|
||||
super("-var-name", new String[]{name, frameAddr, expression});
|
||||
}
|
||||
|
||||
public MIVarCreateInfo getMIVarCreateInfo() throws MIException {
|
||||
return (MIVarCreateInfo)getMIInfo();
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIVarCreateInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIVarDeleteInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* -var-delete NAME
|
||||
|
@ -21,4 +26,19 @@ public class MIVarDelete extends MICommand
|
|||
super("-var-delete", new String[]{name});
|
||||
}
|
||||
|
||||
public MIVarDeleteInfo getMIVarDeleteInfo() throws MIException {
|
||||
return (MIVarDeleteInfo)getMIInfo();
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIVarDeleteInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core.command;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIVarEvaluateExpressionInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* -var-evaluate-expression NAME
|
||||
|
@ -22,4 +27,20 @@ public class MIVarEvaluateExpression extends MICommand
|
|||
public MIVarEvaluateExpression(String expression) {
|
||||
super("-var-evaluate-expression", new String[]{expression});
|
||||
}
|
||||
|
||||
public MIVarEvaluateExpressionInfo getMIVarEvaluateExpressionInfo() throws MIException {
|
||||
return (MIVarEvaluateExpressionInfo)getMIInfo();
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIVarEvaluateExpressionInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,12 @@ public class MIChild {
|
|||
int numchild;
|
||||
|
||||
|
||||
public MIChild(String n, int num, String t) {
|
||||
name = n;
|
||||
numchild = num;
|
||||
type = t;
|
||||
}
|
||||
|
||||
public MIChild(MITuple tuple) {
|
||||
parse(tuple);
|
||||
}
|
||||
|
@ -29,7 +35,7 @@ public class MIChild {
|
|||
return type;
|
||||
}
|
||||
|
||||
public int getnumChild() {
|
||||
public int getNumChild() {
|
||||
return numchild;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,24 +13,20 @@ package org.eclipse.cdt.debug.mi.core.output;
|
|||
public class MIVarCreateInfo extends MIInfo {
|
||||
|
||||
String name = "";
|
||||
int children;
|
||||
int numChild;
|
||||
String type = "";
|
||||
MIChild child;
|
||||
|
||||
public MIVarCreateInfo(MIOutput record) {
|
||||
super(record);
|
||||
parse();
|
||||
}
|
||||
|
||||
public String getName () {
|
||||
return name;
|
||||
public MIChild getMIChild() {
|
||||
if (child == null) {
|
||||
child = new MIChild(name, numChild, type);
|
||||
}
|
||||
|
||||
public int getChildNumber() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
return child;
|
||||
}
|
||||
|
||||
void parse() {
|
||||
|
@ -51,7 +47,7 @@ public class MIVarCreateInfo extends MIInfo {
|
|||
name = str;
|
||||
} else if (var.equals("numchild")) {
|
||||
try {
|
||||
children = Integer.parseInt(str.trim());
|
||||
numChild = Integer.parseInt(str.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (var.equals("type")) {
|
||||
|
|
Loading…
Add table
Reference in a new issue