mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-26 10:25:32 +02:00
Cleanup the register to use GDB/MI objects.
This commit is contained in:
parent
0728b66c10
commit
7d026a2568
3 changed files with 55 additions and 103 deletions
|
@ -5,18 +5,17 @@
|
||||||
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.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIRegisterManager;
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
|
||||||
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.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.Session;
|
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.CommandFactory;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIVarAssign;
|
import org.eclipse.cdt.debug.mi.core.command.MIVarListChildren;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIRegisterChangedEvent;
|
|
||||||
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.MIVar;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIVarListChildrenInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -30,42 +29,33 @@ public class Register extends Variable implements ICDIRegister {
|
||||||
return (RegisterObject)super.getVariableObject();
|
return (RegisterObject)super.getVariableObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getValue()
|
* @see org.eclipse.cdt.debug.mi.core.cdi.model.Variable#getChildren()
|
||||||
*/
|
*/
|
||||||
public ICDIValue getValue() throws CDIException {
|
public ICDIVariable[] getChildren() throws CDIException {
|
||||||
if (value == null) {
|
Session session = (Session)(getTarget().getSession());
|
||||||
value = new RegisterValue(this);
|
MISession mi = session.getMISession();
|
||||||
}
|
RegisterManager mgr = (RegisterManager)session.getRegisterManager();
|
||||||
return value;
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIVarListChildren var =
|
||||||
|
factory.createMIVarListChildren(getMIVar().getVarName());
|
||||||
|
try {
|
||||||
|
mi.postCommand(var);
|
||||||
|
MIVarListChildrenInfo info = var.getMIVarListChildrenInfo();
|
||||||
|
if (info == null) {
|
||||||
|
throw new CDIException("No answer");
|
||||||
|
}
|
||||||
|
MIVar[] vars = info.getMIVars();
|
||||||
|
children = new Register[vars.length];
|
||||||
|
for (int i = 0; i < vars.length; i++) {
|
||||||
|
RegisterObject regObj = new RegisterObject(getTarget(),
|
||||||
|
vars[i].getExp(), getVariableObject().getPosition());
|
||||||
|
children[i] = mgr.createRegister(regObj, vars[i]);
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new MI2CDIException(e);
|
||||||
|
}
|
||||||
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(String)
|
|
||||||
*/
|
|
||||||
public void setValue(String expression) throws CDIException {
|
|
||||||
Session session = (Session)(getTarget().getSession());
|
|
||||||
MISession mi = session.getMISession();
|
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
|
||||||
MIVarAssign var = factory.createMIVarAssign(getMIVar().getVarName(), expression);
|
|
||||||
try {
|
|
||||||
mi.postCommand(var);
|
|
||||||
MIInfo info = var.getMIInfo();
|
|
||||||
if (info == null) {
|
|
||||||
throw new CDIException("No answer");
|
|
||||||
}
|
|
||||||
} catch (MIException e) {
|
|
||||||
throw new MI2CDIException(e);
|
|
||||||
}
|
|
||||||
// If the assign was succesfull fire a MIVarChangedEvent()
|
|
||||||
// Note gdb may not fire an event for the change register, do it manually.
|
|
||||||
MIRegisterChangedEvent change = new MIRegisterChangedEvent(0, getName(), getVariableObject().getPosition());
|
|
||||||
mi.fireEvent(change);
|
|
||||||
// If register was on autoupdate, update all the other registers
|
|
||||||
// assigning may have side effects i.e. affecting other registers.
|
|
||||||
ICDIRegisterManager mgr = session.getRegisterManager();
|
|
||||||
if (mgr.isAutoUpdate()) {
|
|
||||||
mgr.update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
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.ICDIVariable;
|
|
||||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
|
||||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
|
||||||
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.Session;
|
|
||||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
|
||||||
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.MIVarListChildrenInfo;
|
|
||||||
|
|
||||||
public class RegisterValue extends Value {
|
|
||||||
|
|
||||||
Register reg;
|
|
||||||
|
|
||||||
public RegisterValue(Register r) {
|
|
||||||
super(r);
|
|
||||||
reg = r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getVariables()
|
|
||||||
*/
|
|
||||||
public ICDIVariable[] getVariables() throws CDIException {
|
|
||||||
Register[] registers = null;
|
|
||||||
Session session = (Session)(getTarget().getSession());
|
|
||||||
MISession mi = session.getMISession();
|
|
||||||
RegisterManager mgr = (RegisterManager)session.getRegisterManager();
|
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
|
||||||
MIVarListChildren var =
|
|
||||||
factory.createMIVarListChildren(reg.getMIVar().getVarName());
|
|
||||||
try {
|
|
||||||
mi.postCommand(var);
|
|
||||||
MIVarListChildrenInfo info = var.getMIVarListChildrenInfo();
|
|
||||||
if (info == null) {
|
|
||||||
throw new CDIException("No answer");
|
|
||||||
}
|
|
||||||
MIVar[] vars = info.getMIVars();
|
|
||||||
registers = new Register[vars.length];
|
|
||||||
for (int i = 0; i < vars.length; i++) {
|
|
||||||
RegisterObject regObj = new RegisterObject(getTarget(),
|
|
||||||
vars[i].getExp(), reg.getVariableObject().getPosition());
|
|
||||||
registers[i] = mgr.createRegister(regObj, vars[i]);
|
|
||||||
}
|
|
||||||
} catch (MIException e) {
|
|
||||||
throw new MI2CDIException(e);
|
|
||||||
}
|
|
||||||
return registers;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -6,6 +6,8 @@
|
||||||
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.CDIException;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICDIRegisterManager;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIVariableManager;
|
import org.eclipse.cdt.debug.core.cdi.ICDIVariableManager;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
|
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.ICDITarget;
|
||||||
|
@ -216,17 +218,35 @@ public class Variable extends CObject implements ICDIVariable {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new MI2CDIException(e);
|
throw new MI2CDIException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
ICDIVariableManager mgr = session.getVariableManager();
|
|
||||||
// If the assign was succesfull fire a MIVarChangedEvent() for the variable
|
// If the assign was succesfull fire a MIVarChangedEvent() for the variable
|
||||||
// Note GDB will not fire an event for the changed variable we have to do it manually.
|
// Note GDB will not fire an event for the changed variable we have to do it manually.
|
||||||
MIVarChangedEvent change = new MIVarChangedEvent(var.getToken(), miVar.getVarName());
|
MIVarChangedEvent change = new MIVarChangedEvent(var.getToken(), miVar.getVarName());
|
||||||
mi.fireEvent(change);
|
mi.fireEvent(change);
|
||||||
// Changing values may have side effects i.e. affecting other variable
|
|
||||||
|
// Changing values may have side effects i.e. affecting other variables
|
||||||
// if the manager is on autoupdate check all the other variables.
|
// if the manager is on autoupdate check all the other variables.
|
||||||
// Note: This maybe very costly.
|
// Note: This maybe very costly.
|
||||||
if (mgr.isAutoUpdate()) {
|
if (this instanceof Register) {
|
||||||
mgr.update();
|
// If register was on autoupdate, update all the other registers
|
||||||
|
// assigning may have side effects i.e. affecting other registers.
|
||||||
|
ICDIRegisterManager mgr = session.getRegisterManager();
|
||||||
|
if (mgr.isAutoUpdate()) {
|
||||||
|
mgr.update();
|
||||||
|
}
|
||||||
|
} else if (this instanceof Expression) {
|
||||||
|
// If expression was on autoupdate, update all the other expression
|
||||||
|
// assigning may have side effects i.e. affecting other expressions.
|
||||||
|
ICDIExpressionManager mgr = session.getExpressionManager();
|
||||||
|
if (mgr.isAutoUpdate()) {
|
||||||
|
mgr.update();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// FIXME: Should we always call the Variable Manager ?
|
||||||
|
ICDIVariableManager mgr = session.getVariableManager();
|
||||||
|
if (mgr.isAutoUpdate()) {
|
||||||
|
mgr.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue