mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
2004-10-25 Alain Magloire
Remove of ICDExpressionManager in CDI ICDIExpression changes in the interface. * cdi/rg/eclipse/cdt/debug/mo/core/cdi/EventManager.java * cdi/rg/eclipse/cdt/debug/mo/core/cdi/ExpressionManager.java * cdi/rg/eclipse/cdt/debug/mo/core/cdi/Session.java * cdi/rg/eclipse/cdt/debug/mo/core/cdi/event/ChangedEvent.java * cdi/rg/eclipse/cdt/debug/mo/core/cdi/event/DestroyedEvent.java * cdi/rg/eclipse/cdt/debug/mo/core/cdi/model/Expression.java * cdi/rg/eclipse/cdt/debug/mo/core/cdi/model/Target.java * cdi/rg/eclipse/cdt/debug/mo/core/cdi/model/Variable.java
This commit is contained in:
parent
7f18452d63
commit
1c05c517d0
9 changed files with 239 additions and 208 deletions
|
@ -1,3 +1,15 @@
|
||||||
|
2004-10-25 Alain Magloire
|
||||||
|
Remove of ICDExpressionManager in CDI
|
||||||
|
ICDIExpression changes in the interface.
|
||||||
|
* cdi/rg/eclipse/cdt/debug/mo/core/cdi/EventManager.java
|
||||||
|
* cdi/rg/eclipse/cdt/debug/mo/core/cdi/ExpressionManager.java
|
||||||
|
* cdi/rg/eclipse/cdt/debug/mo/core/cdi/Session.java
|
||||||
|
* cdi/rg/eclipse/cdt/debug/mo/core/cdi/event/ChangedEvent.java
|
||||||
|
* cdi/rg/eclipse/cdt/debug/mo/core/cdi/event/DestroyedEvent.java
|
||||||
|
* cdi/rg/eclipse/cdt/debug/mo/core/cdi/model/Expression.java
|
||||||
|
* cdi/rg/eclipse/cdt/debug/mo/core/cdi/model/Target.java
|
||||||
|
* cdi/rg/eclipse/cdt/debug/mo/core/cdi/model/Variable.java
|
||||||
|
|
||||||
2004-10-24 Alain Magloire
|
2004-10-24 Alain Magloire
|
||||||
Changes in ICDITarget.evaluateExpressionToString()
|
Changes in ICDITarget.evaluateExpressionToString()
|
||||||
* org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
|
* org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
|
||||||
|
|
|
@ -299,7 +299,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
|
||||||
// Update the managers.
|
// Update the managers.
|
||||||
// For the Variable/Expression Managers call only the updateManager.
|
// For the Variable/Expression Managers call only the updateManager.
|
||||||
VariableManager varMgr = (VariableManager)session.getVariableManager();
|
VariableManager varMgr = (VariableManager)session.getVariableManager();
|
||||||
ExpressionManager expMgr = (ExpressionManager)session.getExpressionManager();
|
ExpressionManager expMgr = session.getExpressionManager();
|
||||||
RegisterManager regMgr = (RegisterManager)session.getRegisterManager();
|
RegisterManager regMgr = (RegisterManager)session.getRegisterManager();
|
||||||
MemoryManager memMgr = (MemoryManager)session.getMemoryManager();
|
MemoryManager memMgr = (MemoryManager)session.getMemoryManager();
|
||||||
BreakpointManager bpMgr = session.getBreakpointManager();
|
BreakpointManager bpMgr = session.getBreakpointManager();
|
||||||
|
|
|
@ -11,39 +11,29 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager;
|
|
||||||
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.ICDIStackFrame;
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
|
|
||||||
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.cdi.model.Expression;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Expression;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.VariableObject;
|
|
||||||
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.MIVarDelete;
|
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIVarUpdate;
|
import org.eclipse.cdt.debug.mi.core.command.MIVarUpdate;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIVarChangedEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIVarChangedEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIVarDeletedEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIVarDeletedEvent;
|
||||||
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.MIVarChange;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIVarCreateInfo;
|
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIVarUpdateInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIVarUpdateInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class ExpressionManager extends Manager implements ICDIExpressionManager{
|
public class ExpressionManager extends Manager {
|
||||||
|
|
||||||
final static ICDIExpression[] EMPTY_EXPRESSIONS = {};
|
final static ICDIExpression[] EMPTY_EXPRESSIONS = {};
|
||||||
Map expMap;
|
Map expMap;
|
||||||
|
@ -62,132 +52,17 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{
|
||||||
}
|
}
|
||||||
return expList;
|
return expList;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Tell gdb to remove the underlying var-object also.
|
|
||||||
*/
|
|
||||||
void removeMIVar(MISession miSession, MIVar miVar) throws CDIException {
|
|
||||||
CommandFactory factory = miSession.getCommandFactory();
|
|
||||||
MIVarDelete var = factory.createMIVarDelete(miVar.getVarName());
|
|
||||||
try {
|
|
||||||
miSession.postCommand(var);
|
|
||||||
var.getMIInfo();
|
|
||||||
} catch (MIException e) {
|
|
||||||
throw new MI2CDIException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When element are remove from the cache,
|
|
||||||
* The destroy event will call removeExpression.
|
|
||||||
*/
|
|
||||||
public void removeExpression(MISession miSession, String varName) throws CDIException {
|
|
||||||
Target target = ((Session)getSession()).getTarget(miSession);
|
|
||||||
List expList = (List)expMap.get(target);
|
|
||||||
if (expList != null) {
|
|
||||||
Expression[] exps = (Expression[]) expList.toArray(new Expression[expList.size()]);
|
|
||||||
for (int i = 0; i < exps.length; i++) {
|
|
||||||
if (exps[i].getMIVar().getVarName().equals(varName)) {
|
|
||||||
expList.remove(exps[i]);
|
|
||||||
removeMIVar(miSession, exps[i].getMIVar());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This should bo remove to evaluate an expression we nee a context.
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createExpression(String)
|
|
||||||
*/
|
|
||||||
public ICDIExpression createExpression(String name) throws CDIException {
|
|
||||||
Target target = ((Session)getSession()).getCurrentTarget();
|
|
||||||
return createExpression(target, name);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* This should bo remove to evaluate an expression we nee a context.
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createExpression(String)
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createExpression(String)
|
||||||
*/
|
*/
|
||||||
public ICDIExpression createExpression(Target target, String name) throws CDIException {
|
public ICDIExpression createExpression(Target target, String name) throws CDIException {
|
||||||
Expression expression = null;
|
Expression expression = new Expression(target, name);
|
||||||
Session session = (Session)getSession();
|
List exprList = getExpressionList(target);
|
||||||
Target currentTarget = session.getCurrentTarget();
|
exprList.add(expression);
|
||||||
session.setCurrentTarget(target);
|
|
||||||
try {
|
|
||||||
MISession mi = target.getMISession();
|
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
|
||||||
MIVarCreate var = factory.createMIVarCreate(name);
|
|
||||||
mi.postCommand(var);
|
|
||||||
MIVarCreateInfo info = var.getMIVarCreateInfo();
|
|
||||||
if (info == null) {
|
|
||||||
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
VariableObject varObj = new VariableObject(target, name, null, 0, 0);
|
|
||||||
expression = new Expression(varObj, info.getMIVar());
|
|
||||||
List expList = getExpressionList(target);
|
|
||||||
expList.add(expression);
|
|
||||||
} catch (MIException e) {
|
|
||||||
throw new MI2CDIException(e);
|
|
||||||
} finally {
|
|
||||||
session.setCurrentTarget(currentTarget);
|
|
||||||
}
|
|
||||||
return expression;
|
return expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createExpression(ICDIStackFrame, String)
|
|
||||||
*/
|
|
||||||
public ICDIExpression createExpression(ICDIStackFrame frame, String name) throws CDIException {
|
|
||||||
Expression expression = null;
|
|
||||||
Session session = (Session)getSession();
|
|
||||||
Target currentTarget = session.getCurrentTarget();
|
|
||||||
ICDIThread currentThread = currentTarget.getCurrentThread();
|
|
||||||
ICDIStackFrame currentFrame = currentThread.getCurrentStackFrame();
|
|
||||||
Target target = (Target)frame.getTarget();
|
|
||||||
session.setCurrentTarget(target);
|
|
||||||
target.setCurrentThread(frame.getThread(), false);
|
|
||||||
frame.getThread().setCurrentStackFrame(frame, false);
|
|
||||||
try {
|
|
||||||
MISession mi = target.getMISession();
|
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
|
||||||
MIVarCreate var = factory.createMIVarCreate(name);
|
|
||||||
mi.postCommand(var);
|
|
||||||
MIVarCreateInfo info = var.getMIVarCreateInfo();
|
|
||||||
if (info == null) {
|
|
||||||
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
VariableObject varObj = new VariableObject(target, name, frame, 0, 0);
|
|
||||||
expression = new Expression(varObj, info.getMIVar());
|
|
||||||
List expList = getExpressionList(target);
|
|
||||||
expList.add(expression);
|
|
||||||
} catch (MIException e) {
|
|
||||||
throw new MI2CDIException(e);
|
|
||||||
} finally {
|
|
||||||
session.setCurrentTarget(currentTarget);
|
|
||||||
target.setCurrentThread(currentThread, false);
|
|
||||||
currentThread.setCurrentStackFrame(currentFrame, false);
|
|
||||||
}
|
|
||||||
return expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#getExpressions()
|
|
||||||
*/
|
|
||||||
public ICDIExpression[] getExpressions() throws CDIException {
|
|
||||||
ICDITarget[] targets = getSession().getTargets();
|
|
||||||
List list = new ArrayList(targets.length);
|
|
||||||
for (int i = 0; i < targets.length; i++) {
|
|
||||||
if (targets[i] instanceof Target) {
|
|
||||||
ICDIExpression[] exprs = getExpressions((Target)targets[i]);
|
|
||||||
list.addAll(Arrays.asList(exprs));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ICDIExpression[]) list.toArray(new ICDIExpression[list.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICDIExpression[] getExpressions(Target target) throws CDIException {
|
public ICDIExpression[] getExpressions(Target target) throws CDIException {
|
||||||
List expList = (List) expMap.get(target);
|
List expList = (List) expMap.get(target);
|
||||||
if (expList != null) {
|
if (expList != null) {
|
||||||
|
@ -195,40 +70,26 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{
|
||||||
}
|
}
|
||||||
return EMPTY_EXPRESSIONS;
|
return EMPTY_EXPRESSIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeExpression(ICDIExpression)
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeExpression(ICDIExpression)
|
||||||
*/
|
*/
|
||||||
public void destroyExpression(ICDIExpression expression) throws CDIException {
|
public void destroyExpressions(Target target, ICDIExpression[] expressions) throws CDIException {
|
||||||
if (expression instanceof Expression) {
|
List expList = getExpressionList(target);
|
||||||
// Fire a destroyEvent ?
|
for (int i = 0; i < expressions.length; ++i) {
|
||||||
Expression exp= (Expression)expression;
|
if (expressions[i] instanceof Expression) {
|
||||||
Target target = (Target)exp.getTarget();
|
expList.remove(expressions[i]);
|
||||||
MISession miSession = target.getMISession();
|
((Expression)expressions[i]).deleteVariable();
|
||||||
MIVarDeletedEvent del = new MIVarDeletedEvent(miSession, exp.getMIVar().getVarName());
|
}
|
||||||
miSession.fireEvent(del);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the element that have the uniq varName.
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeExpression(ICDIExpression)
|
||||||
* null is return if the element is not in the cache.
|
|
||||||
*/
|
*/
|
||||||
public Variable getExpression(MISession miSession, String varName) {
|
public void destroyAllExpressions(Target target) throws CDIException {
|
||||||
Target target = ((Session)getSession()).getTarget(miSession);
|
ICDIExpression[] expressions = getExpressions(target);
|
||||||
List expList = (List)expMap.get(target);
|
destroyExpressions(target, expressions);
|
||||||
if (expList != null) {
|
|
||||||
Expression[] exps = (Expression[]) expList.toArray(new Expression[expList.size()]);
|
|
||||||
for (int i = 0; i < exps.length; i++) {
|
|
||||||
if (exps[i].getMIVar().getVarName().equals(varName)) {
|
|
||||||
return exps[i];
|
|
||||||
}
|
|
||||||
Variable v = exps[i].getChild(varName);
|
|
||||||
if (v != null) {
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Target target) throws CDIException {
|
public void update(Target target) throws CDIException {
|
||||||
|
@ -238,7 +99,9 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{
|
||||||
List expList = getExpressionList(target);
|
List expList = getExpressionList(target);
|
||||||
Expression[] exps = (Expression[])expList.toArray(new Expression[0]);
|
Expression[] exps = (Expression[])expList.toArray(new Expression[0]);
|
||||||
for (int i = 0; i < exps.length; i++) {
|
for (int i = 0; i < exps.length; i++) {
|
||||||
String varName = exps[i].getMIVar().getVarName();
|
Variable variable = exps[i].getVariable();
|
||||||
|
if (variable != null) {
|
||||||
|
String varName = variable.getMIVar().getVarName();
|
||||||
MIVarChange[] changes = noChanges;
|
MIVarChange[] changes = noChanges;
|
||||||
MIVarUpdate update = factory.createMIVarUpdate(varName);
|
MIVarUpdate update = factory.createMIVarUpdate(varName);
|
||||||
try {
|
try {
|
||||||
|
@ -257,14 +120,32 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{
|
||||||
if (changes[j].isInScope()) {
|
if (changes[j].isInScope()) {
|
||||||
eventList.add(new MIVarChangedEvent(mi, n));
|
eventList.add(new MIVarChangedEvent(mi, n));
|
||||||
}
|
}
|
||||||
// We do not implicitely delete Expressions.
|
}
|
||||||
//else {
|
|
||||||
// eventList.add(new MIVarDeletedEvent(n));
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]);
|
MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]);
|
||||||
mi.fireEvents(events);
|
mi.fireEvents(events);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param miSession
|
||||||
|
* @param varName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Expression getExpression(MISession miSession, String varName) {
|
||||||
|
Session session = (Session)getSession();
|
||||||
|
Target target = session.getTarget(miSession);
|
||||||
|
List expList = getExpressionList(target);
|
||||||
|
Expression[] exps = (Expression[])expList.toArray(new Expression[0]);
|
||||||
|
for (int i = 0; i < exps.length; i++) {
|
||||||
|
Variable variable = exps[i].getVariable();
|
||||||
|
if (variable != null) {
|
||||||
|
if (variable.getMIVar().getVarName().equals(varName)) {
|
||||||
|
return exps[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import java.util.Properties;
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
|
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIEventManager;
|
import org.eclipse.cdt.debug.core.cdi.ICDIEventManager;
|
||||||
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.ICDIRegisterManager;
|
import org.eclipse.cdt.debug.core.cdi.ICDIRegisterManager;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||||
|
@ -137,7 +136,7 @@ public class Session implements ICDISession, ICDISessionObject {
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDISession#getExpressionManager()
|
* @see org.eclipse.cdt.debug.core.cdi.ICDISession#getExpressionManager()
|
||||||
*/
|
*/
|
||||||
public ICDIExpressionManager getExpressionManager() {
|
public ExpressionManager getExpressionManager() {
|
||||||
return expressionManager;
|
return expressionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +195,7 @@ public class Session implements ICDISession, ICDISessionObject {
|
||||||
*/
|
*/
|
||||||
public void setCurrentTarget(Target target) throws CDIException {
|
public void setCurrentTarget(Target target) throws CDIException {
|
||||||
ProcessManager pMgr = getProcessManager();
|
ProcessManager pMgr = getProcessManager();
|
||||||
pMgr.setCurrentTarget((Target)target);
|
pMgr.setCurrentTarget(target);
|
||||||
// throw new CDIException(CdiResources.getString("cdi.Session.Unknown_target")); //$NON-NLS-1$
|
// throw new CDIException(CdiResources.getString("cdi.Session.Unknown_target")); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class ChangedEvent implements ICDIChangedEvent {
|
||||||
|
|
||||||
// Try the Expression manager
|
// Try the Expression manager
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
ExpressionManager expMgr = (ExpressionManager)session.getExpressionManager();
|
ExpressionManager expMgr = session.getExpressionManager();
|
||||||
source = expMgr.getExpression(miSession, varName);
|
source = expMgr.getExpression(miSession, varName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.VariableManager;
|
import org.eclipse.cdt.debug.mi.core.cdi.VariableManager;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.CObject;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.CObject;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Expression;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Thread;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Thread;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
|
||||||
|
@ -56,12 +57,12 @@ public class DestroyedEvent implements ICDIDestroyedEvent {
|
||||||
} catch (CDIException e) {
|
} catch (CDIException e) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ExpressionManager expMgr = (ExpressionManager)session.getExpressionManager();
|
ExpressionManager expMgr = session.getExpressionManager();
|
||||||
variable = expMgr.getExpression(miSession, varName);
|
Expression expression = expMgr.getExpression(miSession, varName);
|
||||||
if (variable != null) {
|
if (expression != null) {
|
||||||
source = variable;
|
source = expression;
|
||||||
try {
|
try {
|
||||||
expMgr.removeExpression(miSession, variable.getMIVar().getVarName());
|
expression.deleteVariable();
|
||||||
} catch (CDIException e) {
|
} catch (CDIException e) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,14 +10,128 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi.model;
|
package org.eclipse.cdt.debug.mi.core.cdi.model;
|
||||||
|
|
||||||
|
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.ICDIStackFrame;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
|
||||||
|
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.cdi.CdiResources;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||||
|
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.MIVar;
|
import org.eclipse.cdt.debug.mi.core.output.MIVar;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIVarCreateInfo;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class Expression extends Variable implements ICDIExpression {
|
public class Expression extends CObject implements ICDIExpression {
|
||||||
|
|
||||||
public Expression(VariableObject obj, MIVar var) {
|
private static int ID_COUNT = 0;
|
||||||
super(obj, var);
|
private int id;
|
||||||
|
String fExpression;
|
||||||
|
Variable fVariable;
|
||||||
|
|
||||||
|
public Expression(Target target, String ex) {
|
||||||
|
super(target);
|
||||||
|
fExpression = ex;
|
||||||
|
id = ++ID_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExpression#getExpressionText()
|
||||||
|
*/
|
||||||
|
public String getExpressionText() {
|
||||||
|
return fExpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExpression#equals(org.eclipse.cdt.debug.core.cdi.model.ICDIExpression)
|
||||||
|
*/
|
||||||
|
public boolean equals(ICDIExpression obj) {
|
||||||
|
if (obj instanceof Expression) {
|
||||||
|
Expression other = (Expression)obj;
|
||||||
|
return other.id == id;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExpression#getValue(org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame)
|
||||||
|
*/
|
||||||
|
public ICDIValue getValue(ICDIStackFrame context) throws CDIException {
|
||||||
|
if (fVariable != null) {
|
||||||
|
Target target = (Target)getTarget();
|
||||||
|
MISession miSession = target.getMISession();
|
||||||
|
removeMIVar(miSession, fVariable.getMIVar());
|
||||||
|
}
|
||||||
|
fVariable = createVariable(context);
|
||||||
|
return fVariable.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Variable getVariable() {
|
||||||
|
return fVariable;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Variable createVariable(ICDIStackFrame frame) throws CDIException {
|
||||||
|
Session session = (Session)getTarget().getSession();
|
||||||
|
Target currentTarget = session.getCurrentTarget();
|
||||||
|
ICDIThread currentThread = currentTarget.getCurrentThread();
|
||||||
|
ICDIStackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
|
Target target = (Target)frame.getTarget();
|
||||||
|
session.setCurrentTarget(target);
|
||||||
|
target.setCurrentThread(frame.getThread(), false);
|
||||||
|
frame.getThread().setCurrentStackFrame(frame, false);
|
||||||
|
try {
|
||||||
|
MISession mi = target.getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIVarCreate var = factory.createMIVarCreate(fExpression);
|
||||||
|
mi.postCommand(var);
|
||||||
|
MIVarCreateInfo info = var.getMIVarCreateInfo();
|
||||||
|
if (info == null) {
|
||||||
|
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
VariableObject varObj = new VariableObject(target, fExpression, frame, 0, 0);
|
||||||
|
return new Variable(varObj, info.getMIVar());
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new MI2CDIException(e);
|
||||||
|
} finally {
|
||||||
|
session.setCurrentTarget(currentTarget);
|
||||||
|
target.setCurrentThread(currentThread, false);
|
||||||
|
currentThread.setCurrentStackFrame(currentFrame, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rid of the underlying variable.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void deleteVariable() throws CDIException {
|
||||||
|
if (fVariable != null) {
|
||||||
|
Target target = (Target)getTarget();
|
||||||
|
MISession miSession = target.getMISession();
|
||||||
|
MIVar miVar = fVariable.getMIVar();
|
||||||
|
removeMIVar(miSession, fVariable.getMIVar());
|
||||||
|
fVariable = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell gdb to remove the underlying var-object also.
|
||||||
|
*/
|
||||||
|
public void removeMIVar(MISession miSession, MIVar miVar) throws CDIException {
|
||||||
|
CommandFactory factory = miSession.getCommandFactory();
|
||||||
|
MIVarDelete var = factory.createMIVarDelete(miVar.getVarName());
|
||||||
|
try {
|
||||||
|
miSession.postCommand(var);
|
||||||
|
var.getMIInfo();
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new MI2CDIException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDICondition;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
|
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRuntimeOptions;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIRuntimeOptions;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDISignal;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDISignal;
|
||||||
|
@ -31,6 +32,7 @@ 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.cdi.BreakpointManager;
|
import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.CdiResources;
|
import org.eclipse.cdt.debug.mi.core.cdi.CdiResources;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.ExpressionManager;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException;
|
import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.RegisterManager;
|
import org.eclipse.cdt.debug.mi.core.cdi.RegisterManager;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||||
|
@ -625,17 +627,6 @@ public class Target implements ICDITarget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#evaluateExpressionToString(String)
|
|
||||||
*/
|
|
||||||
public String evaluateExpressionToString(String expressionText) throws CDIException {
|
|
||||||
Session session = (Session)getSession();
|
|
||||||
Target currentTarget = session.getCurrentTarget();
|
|
||||||
ICDIThread currentThread = currentTarget.getCurrentThread();
|
|
||||||
ICDIStackFrame currentFrame = currentThread.getCurrentStackFrame();
|
|
||||||
return evaluateExpressionToString(currentFrame, expressionText);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String evaluateExpressionToString(ICDIStackFrame frame, String expressionText) throws CDIException {
|
public String evaluateExpressionToString(ICDIStackFrame frame, String expressionText) throws CDIException {
|
||||||
Session session = (Session)getSession();
|
Session session = (Session)getSession();
|
||||||
Target currentTarget = session.getCurrentTarget();
|
Target currentTarget = session.getCurrentTarget();
|
||||||
|
@ -783,4 +774,36 @@ public class Target implements ICDITarget {
|
||||||
public ICDIRuntimeOptions getRuntimeOptions() {
|
public ICDIRuntimeOptions getRuntimeOptions() {
|
||||||
return new RuntimeOptions(this);
|
return new RuntimeOptions(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExpressionManagement#createExpression(java.lang.String)
|
||||||
|
*/
|
||||||
|
public ICDIExpression createExpression(String code) throws CDIException {
|
||||||
|
ExpressionManager expMgr = ((Session)getSession()).getExpressionManager();
|
||||||
|
return expMgr.createExpression(this, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExpressionManagement#getExpressions()
|
||||||
|
*/
|
||||||
|
public ICDIExpression[] getExpressions() throws CDIException {
|
||||||
|
ExpressionManager expMgr = ((Session)getSession()).getExpressionManager();
|
||||||
|
return expMgr.getExpressions(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExpressionManagement#destroyExpression(org.eclipse.cdt.debug.core.cdi.model.ICDIExpression[])
|
||||||
|
*/
|
||||||
|
public void destroyExpressions(ICDIExpression[] expressions) throws CDIException {
|
||||||
|
ExpressionManager expMgr = ((Session)getSession()).getExpressionManager();
|
||||||
|
expMgr.destroyExpressions(this, expressions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExpressionManagement#destroyAllExpression()
|
||||||
|
*/
|
||||||
|
public void destroyAllExpressions() throws CDIException {
|
||||||
|
ExpressionManager expMgr = ((Session)getSession()).getExpressionManager();
|
||||||
|
expMgr.destroyAllExpressions(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.ExpressionManager;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.Format;
|
import org.eclipse.cdt.debug.mi.core.cdi.Format;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException;
|
import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.RegisterManager;
|
import org.eclipse.cdt.debug.mi.core.cdi.RegisterManager;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.VariableManager;
|
import org.eclipse.cdt.debug.mi.core.cdi.VariableManager;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.type.ArrayValue;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.type.ArrayValue;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.type.BoolValue;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.type.BoolValue;
|
||||||
|
@ -320,18 +321,18 @@ public class Variable extends VariableObject implements ICDIVariable {
|
||||||
if (mgr.isAutoUpdate()) {
|
if (mgr.isAutoUpdate()) {
|
||||||
mgr.update(target);
|
mgr.update(target);
|
||||||
}
|
}
|
||||||
} else if (this instanceof Expression) {
|
} else {
|
||||||
// If expression was on autoupdate, update all the other expression
|
// If expression was on autoupdate, update all the other expression
|
||||||
// assigning may have side effects i.e. affecting other expressions.
|
// assigning may have side effects i.e. affecting other expressions.
|
||||||
ExpressionManager mgr = (ExpressionManager)target.getSession().getExpressionManager();
|
ExpressionManager expMgr = ((Session)target.getSession()).getExpressionManager();
|
||||||
if (mgr.isAutoUpdate()) {
|
if (expMgr.isAutoUpdate()) {
|
||||||
mgr.update(target);
|
expMgr.update(target);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// FIXME: Should we always call the Variable Manager ?
|
// FIXME: Should we always call the Variable Manager ?
|
||||||
VariableManager mgr = (VariableManager)target.getSession().getVariableManager();
|
VariableManager varMgr = (VariableManager)target.getSession().getVariableManager();
|
||||||
if (mgr.isAutoUpdate()) {
|
if (varMgr.isAutoUpdate()) {
|
||||||
mgr.update(target);
|
varMgr.update(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue