[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] mi/core fix for registers
|
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.95
diff -u -r1.95 ChangeLog
--- ChangeLog 7 Feb 2003 03:50:03 -0000 1.95
+++ ChangeLog 9 Feb 2003 22:08:18 -0000
@@ -1,3 +1,37 @@
+2003-02-09 Alain Magloire
+
+ in GDB/MI 5.3 and below, the -data-list-register-xxx can bring gdb down with
+ an assert(). The problem is that code like this
+ ui_out_list_begin();
+ for () {
+ if(error)
+ return ERROR;
+ }
+ ui_out_list_end();
+ The ui_out_list_end() is never call.
+ However gdb offers the varobj to deal cleanly with register but calling
+ "-var-update *" seems to make gdb misbehave and hang after a while.
+ So we use a mixed of -data-list-register-xxx calls and var-object to deal
+ with registers and do not call "-var-update *" but rather call it for
+ each time for individual objects to see the updates.
+
+ * src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java:
+ Reimplemented to use the var obj.
+ * src/org/eclipse/cdt/debug/mi/core/cdi/model/RegisterValue.java:
+ New file implement ICDIValue.
+ * src/org/eclipse/cdt/debug/mi/core/cdi/EventManagero.java (processSuspendedEvent):
+ Call each manager.update().
+ * src/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java (update):
+ Reimplemented.
+ * src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java (update):
+ Reimplemented
+ * src/org/eclipse/cdt/debug/mi/core/cdi/UpdateManager.java:
+ Removed.
+ * src/org/eclipse/cdt/debug/mi/core/cdi/IUpdateListener.java:
+ Removed.
+ * src/org/eclipse/cdt/debug/mi/core/CLIProcessor.java:
+ Catch the cli "run" command.
+
2003-02-06 Alain Magloire
* src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java (getVariableArrayObject):
Index: src/org/eclipse/cdt/debug/mi/core/CLIProcessor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CLIProcessor.java,v
retrieving revision 1.8
diff -u -r1.8 CLIProcessor.java
--- src/org/eclipse/cdt/debug/mi/core/CLIProcessor.java 5 Feb 2003 03:17:09 -0000 1.8
+++ src/org/eclipse/cdt/debug/mi/core/CLIProcessor.java 9 Feb 2003 22:08:19 -0000
@@ -81,6 +81,8 @@
type = MIRunningEvent.CONTINUE;
} else if (operation.startsWith("j") && "jump".indexOf(operation) != -1) {
type = MIRunningEvent.CONTINUE;
+ } else if (operation.equals("r") || operation.equals("run")) {
+ type = MIRunningEvent.CONTINUE;
}
return type;
}
Index: src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java,v
retrieving revision 1.36
diff -u -r1.36 EventManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java 3 Feb 2003 21:29:37 -0000 1.36
+++ src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java 9 Feb 2003 22:08:24 -0000
@@ -252,7 +252,6 @@
}
// Update the managers.
// For the Variable/Expression Managers call only the updateManager.
- UpdateManager upMgr = session.getUpdateManager();
ICDIVariableManager varMgr = session.getVariableManager();
ICDIExpressionManager expMgr = session.getExpressionManager();
ICDIRegisterManager regMgr = session.getRegisterManager();
@@ -262,8 +261,11 @@
ICDISignalManager sigMgr = session.getSignalManager();
ICDISourceManager srcMgr = session.getSourceManager();
try {
- if (varMgr.isAutoUpdate() || expMgr.isAutoUpdate()) {
- upMgr.update();
+ if (varMgr.isAutoUpdate()) {
+ varMgr.update();
+ }
+ if (expMgr.isAutoUpdate()) {
+ expMgr.update();
}
if (regMgr.isAutoUpdate()) {
regMgr.update();
Index: src/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java,v
retrieving revision 1.18
diff -u -r1.18 ExpressionManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java 29 Jan 2003 02:57:16 -0000 1.18
+++ src/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java 9 Feb 2003 22:08:21 -0000
@@ -21,17 +21,20 @@
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.MIVarCreate;
+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.MIVarChangedEvent;
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;
/**
*/
-public class ExpressionManager extends SessionObject implements ICDIExpressionManager, IUpdateListener {
+public class ExpressionManager extends SessionObject implements ICDIExpressionManager{
private List expList;
private boolean autoupdate;
+ MIVarChange[] noChanges = new MIVarChange[0];
public ExpressionManager(Session session) {
super(session);
@@ -138,25 +141,31 @@
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#update()
*/
public void update() throws CDIException {
+ List eventList = new ArrayList();
Session session = (Session)getSession();
- UpdateManager mgr = session.getUpdateManager();
- mgr.update();
- }
-
- /**
- * @see org.eclipse.cdt.debug.mi.core.cdi.IUpdateListener#changeList(MIVarChange[])
- */
- public void changeList(MIVarChange[] changes) {
- List eventList = new ArrayList(changes.length);
- for (int i = 0 ; i < changes.length; i++) {
- String varName = changes[i].getVarName();
- Expression expression = getExpression(varName);
- if (expression != null) {
- eventList.add(new MIVarChangedEvent(0, varName, changes[i].isInScope()));
+ MISession mi = session.getMISession();
+ CommandFactory factory = mi.getCommandFactory();
+ Expression[] exps = (Expression[])expList.toArray(new Expression[0]);
+ for (int i = 0; i < exps.length; i++) {
+ String varName = exps[i].getMIVar().getVarName();
+ MIVarChange[] changes = noChanges;
+ MIVarUpdate update = factory.createMIVarUpdate(varName);
+ try {
+ mi.postCommand(update);
+ MIVarUpdateInfo info = update.getMIVarUpdateInfo();
+ if (info == null) {
+ throw new CDIException("No answer");
+ }
+ changes = info.getMIVarChanges();
+ } catch (MIException e) {
+ //throw new MI2CDIException(e);
+ eventList.add(new MIVarChangedEvent(0, varName, false));
+ }
+ for (int j = 0 ; j < changes.length; j++) {
+ String n = changes[j].getVarName();
+ eventList.add(new MIVarChangedEvent(0, n, changes[j].isInScope()));
}
}
- Session session = (Session)getSession();
- MISession mi = session.getMISession();
MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]);
mi.fireEvents(events);
}
Index: src/org/eclipse/cdt/debug/mi/core/cdi/IUpdateListener.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/cdi/IUpdateListener.java
diff -N src/org/eclipse/cdt/debug/mi/core/cdi/IUpdateListener.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/IUpdateListener.java 27 Jan 2003 03:18:54 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,12 +0,0 @@
-/*
- *(c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- *
- */
-package org.eclipse.cdt.debug.mi.core.cdi;
-
-import org.eclipse.cdt.debug.mi.core.output.MIVarChange;
-
-public interface IUpdateListener {
- void changeList(MIVarChange[] changes);
-}
Index: src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java,v
retrieving revision 1.8
diff -u -r1.8 RegisterManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java 27 Jan 2003 16:15:43 -0000 1.8
+++ src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java 9 Feb 2003 22:08:22 -0000
@@ -15,16 +15,18 @@
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterObject;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.MISession;
-import org.eclipse.cdt.debug.mi.core.cdi.model.*;
import org.eclipse.cdt.debug.mi.core.cdi.model.Register;
+import org.eclipse.cdt.debug.mi.core.cdi.model.RegisterObject;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIDataListChangedRegisters;
import org.eclipse.cdt.debug.mi.core.command.MIDataListRegisterNames;
+import org.eclipse.cdt.debug.mi.core.command.MIVarCreate;
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
import org.eclipse.cdt.debug.mi.core.event.MIRegisterChangedEvent;
-import org.eclipse.cdt.debug.mi.core.event.MIRegisterCreatedEvent;
import org.eclipse.cdt.debug.mi.core.output.MIDataListChangedRegistersInfo;
import org.eclipse.cdt.debug.mi.core.output.MIDataListRegisterNamesInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIVar;
+import org.eclipse.cdt.debug.mi.core.output.MIVarCreateInfo;
/**
*/
@@ -69,14 +71,35 @@
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#createRegister()
*/
public ICDIRegister createRegister(ICDIRegisterObject regObject) throws CDIException {
- Register reg = getRegister(regObject);
- if (reg == null) {
- Session session = (Session)getSession();
- reg = new Register(session.getCurrentTarget(), regObject);
- regList.add(reg);
- MISession mi = session.getMISession();
- mi.fireEvent(new MIRegisterCreatedEvent(reg.getName(), reg.getID()));
+ if (regObject instanceof RegisterObject) {
+ RegisterObject regObj = (RegisterObject)regObject;
+ Register reg = getRegister(regObject);
+ if (reg == null) {
+ try {
+ String name = "$" + regObj.getName();
+ Session session = (Session)getSession();
+ MISession mi = session.getMISession();
+ CommandFactory factory = mi.getCommandFactory();
+ MIVarCreate var = factory.createMIVarCreate(name);
+ mi.postCommand(var);
+ MIVarCreateInfo info = var.getMIVarCreateInfo();
+ if (info == null) {
+ throw new CDIException("No answer");
+ }
+ reg = new Register(regObj, info.getMIVar());
+ regList.add(reg);
+ } catch (MIException e) {
+ throw new MI2CDIException(e);
+ }
+ }
+ return reg;
}
+ throw new CDIException("Wrong register type");
+ }
+
+ public Register createRegister(RegisterObject v, MIVar mivar) throws CDIException {
+ Register reg = new Register(v, mivar);
+ regList.add(reg);
return reg;
}
@@ -104,16 +127,28 @@
/**
* Use by the eventManager to find the Register;
*/
- public Register getRegister(int regno) throws CDIException {
+ public Register getRegister(String name) throws CDIException {
Register[] regs = getRegisters();
for (int i = 0; i < regs.length; i++) {
- if (regs[i].getID() == regno) {
+ if (regs[i].getName().equals(name)) {
return regs[i];
}
}
return null;
}
+ /**
+ * Use by the eventManager to find the Register;
+ */
+ public Register getRegister(int regno) throws CDIException {
+ Register[] regs = getRegisters();
+ for (int i = 0; i < regs.length; i++) {
+ if (regs[i].getVariableObject().getPosition() == regno) {
+ return regs[i];
+ }
+ }
+ return null;
+ }
/**
* Call the by the EventManager when the target is suspended.
*/
Index: src/org/eclipse/cdt/debug/mi/core/cdi/Session.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Session.java,v
retrieving revision 1.3
diff -u -r1.3 Session.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/Session.java 27 Jan 2003 03:18:54 -0000 1.3
+++ src/org/eclipse/cdt/debug/mi/core/cdi/Session.java 9 Feb 2003 22:08:21 -0000
@@ -36,7 +36,6 @@
Properties props;
MISession session;
- UpdateManager updateManager;
EventManager eventManager;
BreakpointManager breakpointManager;
ExpressionManager expressionManager;
@@ -68,12 +67,8 @@
eventManager = new EventManager(this);
s.addObserver(eventManager);
- updateManager = new UpdateManager(this);
expressionManager = new ExpressionManager(this);
variableManager = new VariableManager(this);
- updateManager.addUpdateListener(variableManager);
- updateManager.addUpdateListener(expressionManager);
-
registerManager = new RegisterManager(this);
memoryManager = new MemoryManager(this);
signalManager = new SignalManager(this);
@@ -84,10 +79,6 @@
public MISession getMISession() {
return session;
- }
-
- public UpdateManager getUpdateManager() {
- return updateManager;
}
/**
Index: src/org/eclipse/cdt/debug/mi/core/cdi/UpdateManager.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/cdi/UpdateManager.java
diff -N src/org/eclipse/cdt/debug/mi/core/cdi/UpdateManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/UpdateManager.java 27 Jan 2003 03:19:46 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,64 +0,0 @@
-/*
- *(c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- *
- */
-package org.eclipse.cdt.debug.mi.core.cdi;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.cdt.debug.core.cdi.CDIException;
-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.MIVarUpdate;
-import org.eclipse.cdt.debug.mi.core.output.MIVarChange;
-import org.eclipse.cdt.debug.mi.core.output.MIVarUpdateInfo;
-
-/**
- */
-public class UpdateManager {
-
- Session session;
- List updateList = Collections.synchronizedList(new ArrayList(5));
- MIVarChange[] noChanges = new MIVarChange[0];
-
- public UpdateManager(Session s) {
- session = s;
- }
-
- public void addUpdateListener(IUpdateListener listener) {
- updateList.add(listener);
- }
-
- public void removeUpdateListener(IUpdateListener listener) {
- updateList.remove(listener);
- }
-
- /**
- * Update the variables, from the response of the "-var-update *"
- * mi/command.
- */
- public void update() throws CDIException {
- MIVarChange[] changes = noChanges;
- MISession mi = session.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");
- }
- changes = info.getMIVarChanges();
- } catch (MIException e) {
- throw new MI2CDIException(e);
- }
- IUpdateListener[] listeners = (IUpdateListener[])updateList.toArray(new IUpdateListener[0]);
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].changeList(changes);
- }
- }
-}
Index: src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java,v
retrieving revision 1.20
diff -u -r1.20 VariableManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java 7 Feb 2003 03:49:51 -0000 1.20
+++ src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java 9 Feb 2003 22:08:23 -0000
@@ -29,6 +29,7 @@
import org.eclipse.cdt.debug.mi.core.command.MIStackListLocals;
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.event.MIEvent;
import org.eclipse.cdt.debug.mi.core.event.MIVarChangedEvent;
import org.eclipse.cdt.debug.mi.core.output.MIArg;
@@ -38,13 +39,15 @@
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.MIVarUpdateInfo;
/**
*/
-public class VariableManager extends SessionObject implements ICDIVariableManager, IUpdateListener {
+public class VariableManager extends SessionObject implements ICDIVariableManager {
List variableList;
boolean autoupdate;
+ MIVarChange[] noChanges = new MIVarChange[0];
public VariableManager(Session session) {
super(session);
@@ -413,24 +416,6 @@
}
/**
- * @see org.eclipse.cdt.debug.mi.core.cdi.IVarUpdateListener#changeList(MIVarChange[])
- */
- public void changeList(MIVarChange[] changes) {
- List eventList = new ArrayList(changes.length);
- for (int i = 0 ; i < changes.length; i++) {
- String varName = changes[i].getVarName();
- Variable variable = getVariable(varName);
- if (variable != null) {
- eventList.add(new MIVarChangedEvent(0, varName, changes[i].isInScope()));
- }
- }
- Session session = (Session)getSession();
- MISession mi = session.getMISession();
- MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]);
- mi.fireEvents(events);
- }
-
- /**
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableManager#isAutoUpdate()
*/
public boolean isAutoUpdate() {
@@ -451,9 +436,33 @@
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableManager#createArgument(ICDIArgumentObject)
*/
public void update() throws CDIException {
+ List eventList = new ArrayList();
Session session = (Session)getSession();
- UpdateManager mgr = session.getUpdateManager();
- mgr.update();
+ MISession mi = session.getMISession();
+ CommandFactory factory = mi.getCommandFactory();
+ Variable[] vars = getVariables();
+ for (int i = 0; i < vars.length; i++) {
+ String varName = vars[i].getMIVar().getVarName();
+ MIVarChange[] changes = noChanges;
+ MIVarUpdate update = factory.createMIVarUpdate(varName);
+ try {
+ mi.postCommand(update);
+ MIVarUpdateInfo info = update.getMIVarUpdateInfo();
+ if (info == null) {
+ throw new CDIException("No answer");
+ }
+ changes = info.getMIVarChanges();
+ } catch (MIException e) {
+ //throw new MI2CDIException(e);
+ eventList.add(new MIVarChangedEvent(0, varName, false));
+ }
+ for (int j = 0 ; j < changes.length; j++) {
+ String n = changes[j].getVarName();
+ eventList.add(new MIVarChangedEvent(0, n, changes[j].isInScope()));
+ }
+ }
+ MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]);
+ mi.fireEvents(events);
}
}
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java,v
retrieving revision 1.5
diff -u -r1.5 Register.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java 28 Jan 2003 03:45:20 -0000 1.5
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java 9 Feb 2003 22:08:24 -0000
@@ -1,355 +1,59 @@
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
- *
*/
package org.eclipse.cdt.debug.mi.core.cdi.model;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
-import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterObject;
-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.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.MIFormat;
import org.eclipse.cdt.debug.mi.core.MISession;
-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.Session;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
-import org.eclipse.cdt.debug.mi.core.command.MIDataListRegisterValues;
-import org.eclipse.cdt.debug.mi.core.command.MIDataWriteRegisterValues;
-import org.eclipse.cdt.debug.mi.core.command.MIWhatis;
+import org.eclipse.cdt.debug.mi.core.command.MIVarAssign;
import org.eclipse.cdt.debug.mi.core.event.MIRegisterChangedEvent;
-import org.eclipse.cdt.debug.mi.core.output.MIDataListRegisterValuesInfo;
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
-import org.eclipse.cdt.debug.mi.core.output.MIRegisterValue;
-import org.eclipse.cdt.debug.mi.core.output.MIWhatisInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIVar;
/**
*/
-public class Register extends CObject implements ICDIRegister, ICDIValue {
+public class Register extends Variable implements ICDIRegister {
- RegisterObject regObject;
- int format = MIFormat.HEXADECIMAL;
- Register parent;
- String lastname;
- String typename = null;
- int childrenNumber = -1;
- ICDIVariable[] variables = null;
-
- /**
- * A container class to hold the values of the registers and sub values
- * for example on x86, xmm0 register is consider to be a struct
- * gdb/mi -data-list-register-values returns the value like this
- * value="{f = {0x0, 0x0, 0x0, 0x0}}"
- * we'll parse() it and change it to:
- * Argument[0] = { "xmm0", "{f = {0x0, 0x1, 0x2, 0x3}}"}
- * Argument[1] = { "xmm0.f", "{0x0, 0x1, 0x2, 0x3}"}
- * Argument[2] = { "xmm0.f.0", "0x0"}
- * Argument[3] = { "xmm0.f.1", "0x1"}
- * Argument[4] = { "xmm0.f.2", "0x2"}
- * Argument[5] = { "xmm0.f.3", "0x3"}
- * see @parse()
- */
- class Argument {
- String name;
- String val;
- Argument(String n, String v) {
- name = n;
- val = v;
- }
- String getKey() {
- return name;
- }
- String getValue() {
- return val;
- }
- }
-
- public Register(ICDITarget target, ICDIRegisterObject r) {
- super(target);
- parent = null;
- lastname = r.getName();
- regObject = (RegisterObject)r;
- }
-
- public Register(Register p, String n) {
- super(p.getTarget());
- parent = p;
- lastname = n;
- }
-
- /**
- * return the MI regno.
- */
- public int getID() {
- return regObject.getPosition();
- }
-
- /**
- * Returns a Unique name separated by '.' to describe the path
- * for example xmm0.f.0
- */
- public String getUniqName() {
- String n = "";
- if (parent != null) {
- n = parent.getUniqName() + "." + getLastName();
- } else {
- n = getLastName();
- }
- return n;
- }
-
- /**
- * Returns the name of the register, for example xmm0.
- */
- public String getBaseName() {
- String base = "";
- if (parent != null) {
- base = parent.getBaseName();
- } else {
- base = getLastName();
- }
- return base;
- }
-
- /**
- * Returns the current name for xmm0.f the last name is "f".
- */
- public String getLastName() {
- return lastname;
- }
-
- /**
- * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getName()
- */
- public String getName() throws CDIException {
- return getLastName();
- }
-
- /**
- * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getTypeName()
- */
- public String getTypeName() throws CDIException {
- if (typename == null) {
- Session session = (Session)getTarget().getSession();
- MISession mi = session.getMISession();
- CommandFactory factory = mi.getCommandFactory();
- String var = "$" + getUniqName();
- MIWhatis whatis = factory.createMIWhatis(var);
- try {
- mi.postCommand(whatis);
- MIWhatisInfo info = whatis.getMIWhatisInfo();
- if (info == null) {
- throw new CDIException("No answer");
- }
- typename = info.getType();
- } catch (MIException e) {
- throw new MI2CDIException(e);
- }
- }
- return typename;
+ public Register(RegisterObject obj, MIVar var) {
+ super(obj, var);
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getValue()
*/
public ICDIValue getValue() throws CDIException {
- return this;
- }
-
- /**
- * @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getValueString()
- */
- public String getValueString() throws CDIException {
- if (parent == null) {
- Session session = (Session)getTarget().getSession();
- MISession mi = session.getMISession();
- CommandFactory factory = mi.getCommandFactory();
- int[] regno = new int[]{regObject.getPosition()};
- MIDataListRegisterValues registers =
- factory.createMIDataListRegisterValues(format, regno);
- try {
- mi.postCommand(registers);
- MIDataListRegisterValuesInfo info =
- registers.getMIDataListRegisterValuesInfo();
- if (info == null) {
- throw new CDIException("No answer");
- }
- MIRegisterValue[] regValues = info.getMIRegisterValues();
- // We only ask for one. But do the right thing
- for (int i = 0; i < regValues.length; i++) {
- if (regValues[i].getNumber() == regno[i]) {
- return regValues[i].getValue();
- }
- }
- } catch (MIException e) {
- throw new MI2CDIException(e);
- }
- } else {
- String u = getUniqName();
- String v = parent.getValueString();
- Argument[] args = parse(parent.getUniqName(), v);
- for (int i = 0; i < args.length; i++) {
- if (u.equals(args[i].getKey())) {
- return args[i].getValue();
- }
- }
+ if (value == null) {
+ value = new RegisterValue(this);
}
- return "";
- }
-
- /**
- * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#isEditable()
- */
- public boolean isEditable() throws CDIException {
- return false;
- }
-
- /**
- * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(ICDIValue)
- */
- public void setValue(ICDIValue val) throws CDIException {
- setValue(val.getValueString());
+ return value;
}
/**
* @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();
+ MISession mi = ((Session)(getTarget().getSession())).getMISession();
CommandFactory factory = mi.getCommandFactory();
- int[] regnos = new int[]{regObject.getPosition()};
- String[] values = new String[]{expression};
- MIDataWriteRegisterValues registers =
- factory.createMIDataWriteRegisterValues(format, regnos, values);
+ MIVarAssign var = factory.createMIVarAssign(getMIVar().getVarName(), expression);
try {
- mi.postCommand(registers);
- MIInfo info = registers.getMIInfo();
+ 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 MIRegisterChangedEvent()
- MIRegisterChangedEvent change = new MIRegisterChangedEvent(registers.getToken(),
- regObject.getName(), regObject.getPosition());
+ // If the assign was succesfull fire a MIVarChangedEvent()
+ MIRegisterChangedEvent change =
+ new MIRegisterChangedEvent(0, getName(), getVariableObject().getPosition());
mi.fireEvent(change);
-
- }
-
- /**
- * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setFormat()
- */
- public void setFormat(int fmt) throws CDIException {
- format = Format.toMIFormat(fmt);
- }
-
- /**
- * @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getChildrenNumber()
- */
- public int getChildrenNumber() throws CDIException {
- if (childrenNumber == -1) {
- childrenNumber = getVariables().length;
- }
- return childrenNumber;
- }
-
- /**
- * @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getVariables()
- */
- public ICDIVariable[] getVariables() throws CDIException {
- if (variables == null) {
- List aList = new ArrayList(1);
- String v = getValueString();
- Argument[] args = parse(getUniqName(), v);
- /* The idea here is to get the first level
- *
- * Argument[0] = { "xmm0", "{f = {0x0, 0x1, 0x2, 0x3}}"
- * Argument[1] = { "xmm0.f", "{0x0, 0x1, 0x2, 0x3}"}
- * Argument[2] = { "xmm0.f.0", "0x0"}
- * Argument[3] = { "xmm0.f.1", "0x1"}
- * Argument[4] = { "xmm0.f.2", "0x2"}
- * Argument[5] = { "xmm0.f.3", "0x3"}
- *
- * For example the children or xmm0.f are xmm0.f.{0,1,2,3,}
- *
- */
- for (int i = 0; i < args.length; i++) {
- String n = args[i].getKey();
- String u = getUniqName();
- if (n.startsWith(u) && n.length() > u.length()) {
- String p = n.substring(u.length());
- StringTokenizer st = new StringTokenizer(p, ".");
- if (st.countTokens() == 1) {
- aList.add(new Register(this, (String)st.nextElement()));
- }
- }
- }
- variables = (ICDIVariable[])aList.toArray(new ICDIVariable[0]);
- }
- return variables;
- }
-
- /**
- * @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#hasChildren()
- */
- public boolean hasChildren() throws CDIException {
- return getChildrenNumber() > 0;
- }
-
- /**
- * We are parsing this:
- * "{f = {0x0, 0x0, 0x0, 0x0}}"
- * into:
- * Argument[0] = { "xmm0", "{f = {0x0, 0x1, 0x2, 0x3}}"
- * Argument[1] = { "xmm0.f", "{0x0, 0x1, 0x2, 0x3}"}
- * Argument[2] = { "xmm0.f.0", "0x0"}
- * Argument[3] = { "xmm0.f.1", "0x1"}
- * Argument[4] = { "xmm0.f.2", "0x2"}
- * Argument[5] = { "xmm0.f.3", "0x3"}
- */
- Argument[] parse(String base, String v) throws CDIException {
- List aList = new ArrayList(1);
- StringBuffer sb = new StringBuffer(base);
- aList.add(new Argument(sb.toString(), v.trim()));
- while (v.startsWith("{")) {
- int idx;
- v = v.substring(1);
- if (v.endsWith("}")) {
- idx = v.lastIndexOf('}');
- v = v.substring(0, idx);
- }
- idx = v.indexOf('=');
- if (idx != -1) {
- String n = v.substring(0, idx).trim();
- sb.append('.').append(n);
- v = v.substring(idx + 1).trim();
- aList.add(new Argument(sb.toString(), v));
- } else {
- StringTokenizer st = new StringTokenizer(v, ",");
- for (int i = 0; st.hasMoreElements(); i++) {
- aList.add(new Argument(sb.toString() + "." + Integer.toString(i), ((String)st.nextElement()).trim()));
- }
- }
- }
- return (Argument[])aList.toArray(new Argument[0]);
}
-
- /**
- * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getStackFrame()
- */
- public ICDIStackFrame getStackFrame() throws CDIException {
- return null;
- }
-
}
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/RegisterValue.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/cdi/model/RegisterValue.java
diff -N src/org/eclipse/cdt/debug/mi/core/cdi/model/RegisterValue.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/RegisterValue.java 9 Feb 2003 22:08:25 -0000
@@ -0,0 +1,58 @@
+/*
+ * (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;
+ }
+
+}