mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Use MIWhatis.
This commit is contained in:
parent
8fdc0ff5f8
commit
419c4372a6
1 changed files with 59 additions and 36 deletions
|
@ -25,10 +25,12 @@ 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.MIDataListRegisterValues;
|
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.MIDataWriteRegisterValues;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIWhatis;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIRegisterChangedEvent;
|
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.MIDataListRegisterValuesInfo;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIRegisterValue;
|
import org.eclipse.cdt.debug.mi.core.output.MIRegisterValue;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIWhatisInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -38,6 +40,9 @@ public class Register extends CObject implements ICDIRegister, ICDIValue {
|
||||||
int format = MIFormat.HEXADECIMAL;
|
int format = MIFormat.HEXADECIMAL;
|
||||||
Register parent;
|
Register parent;
|
||||||
String lastname;
|
String lastname;
|
||||||
|
String typename = null;
|
||||||
|
int childrenNumber = -1;
|
||||||
|
ICDIVariable[] variables = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A container class to hold the values of the registers and sub values
|
* A container class to hold the values of the registers and sub values
|
||||||
|
@ -133,12 +138,24 @@ public class Register extends CObject implements ICDIRegister, ICDIValue {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getTypeName()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getTypeName()
|
||||||
*/
|
*/
|
||||||
public String getTypeName() throws CDIException {
|
public String getTypeName() throws CDIException {
|
||||||
String v = getValueString();
|
if (typename == null) {
|
||||||
if (v.startsWith("{")) {
|
Session session = (Session)getTarget().getSession();
|
||||||
// Use ptype?
|
MISession mi = session.getMISession();
|
||||||
return "struct ";
|
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 "int";
|
return typename;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -241,40 +258,46 @@ public class Register extends CObject implements ICDIRegister, ICDIValue {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getChildrenNumber()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getChildrenNumber()
|
||||||
*/
|
*/
|
||||||
public int getChildrenNumber() throws CDIException {
|
public int getChildrenNumber() throws CDIException {
|
||||||
return getVariables().length;
|
if (childrenNumber == -1) {
|
||||||
|
childrenNumber = getVariables().length;
|
||||||
|
}
|
||||||
|
return childrenNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getVariables()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getVariables()
|
||||||
*/
|
*/
|
||||||
public ICDIVariable[] getVariables() throws CDIException {
|
public ICDIVariable[] getVariables() throws CDIException {
|
||||||
List aList = new ArrayList(1);
|
if (variables == null) {
|
||||||
String v = getValueString();
|
List aList = new ArrayList(1);
|
||||||
Argument[] args = parse(getUniqName(), v);
|
String v = getValueString();
|
||||||
/* The idea here s to get the first level
|
Argument[] args = parse(getUniqName(), v);
|
||||||
*
|
/* The idea here is to get the first level
|
||||||
* Argument[0] = { "xmm0", "{f = {0x0, 0x0, 0x0, 0x0}}"
|
*
|
||||||
* Argument[1] = { "xmm0.f", "{0x0, 0x0, 0x0, 0x0}"}
|
* Argument[0] = { "xmm0", "{f = {0x0, 0x1, 0x2, 0x3}}"
|
||||||
* Argument[2] = { "xmm0.f.0", "0x0"}
|
* Argument[1] = { "xmm0.f", "{0x0, 0x1, 0x2, 0x3}"}
|
||||||
* Argument[3] = { "xmm0.f.1", "0x0"}
|
* Argument[2] = { "xmm0.f.0", "0x0"}
|
||||||
* Argument[4] = { "xmm0.f.2", "0x0"}
|
* Argument[3] = { "xmm0.f.1", "0x1"}
|
||||||
* Argument[5] = { "xmm0.f.3", "0x0"}
|
* 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 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();
|
for (int i = 0; i < args.length; i++) {
|
||||||
String u = getUniqName();
|
String n = args[i].getKey();
|
||||||
if (n.startsWith(u) && n.length() > u.length()) {
|
String u = getUniqName();
|
||||||
String p = n.substring(u.length());
|
if (n.startsWith(u) && n.length() > u.length()) {
|
||||||
StringTokenizer st = new StringTokenizer(p, ".");
|
String p = n.substring(u.length());
|
||||||
if (st.countTokens() == 1) {
|
StringTokenizer st = new StringTokenizer(p, ".");
|
||||||
aList.add(new Register(this, (String)st.nextElement()));
|
if (st.countTokens() == 1) {
|
||||||
|
aList.add(new Register(this, (String)st.nextElement()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
variables = (ICDIVariable[])aList.toArray(new ICDIVariable[0]);
|
||||||
return (ICDIVariable[])aList.toArray(new ICDIVariable[0]);
|
}
|
||||||
|
return variables;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -288,12 +311,12 @@ public class Register extends CObject implements ICDIRegister, ICDIValue {
|
||||||
* We are parsing this:
|
* We are parsing this:
|
||||||
* "{f = {0x0, 0x0, 0x0, 0x0}}"
|
* "{f = {0x0, 0x0, 0x0, 0x0}}"
|
||||||
* into:
|
* into:
|
||||||
* Argument[0] = { "xmm0", "{f = {0x0, 0x0, 0x0, 0x0}}"
|
* Argument[0] = { "xmm0", "{f = {0x0, 0x1, 0x2, 0x3}}"
|
||||||
* Argument[1] = { "xmm0.f", "{0x0, 0x0, 0x0, 0x0}"}
|
* Argument[1] = { "xmm0.f", "{0x0, 0x1, 0x2, 0x3}"}
|
||||||
* Argument[2] = { "xmm0.f.0", "0x0"}
|
* Argument[2] = { "xmm0.f.0", "0x0"}
|
||||||
* Argument[3] = { "xmm0.f.1", "0x0"}
|
* Argument[3] = { "xmm0.f.1", "0x1"}
|
||||||
* Argument[4] = { "xmm0.f.2", "0x0"}
|
* Argument[4] = { "xmm0.f.2", "0x2"}
|
||||||
* Argument[5] = { "xmm0.f.3", "0x0"}
|
* Argument[5] = { "xmm0.f.3", "0x3"}
|
||||||
*/
|
*/
|
||||||
Argument[] parse(String base, String v) throws CDIException {
|
Argument[] parse(String base, String v) throws CDIException {
|
||||||
List aList = new ArrayList(1);
|
List aList = new ArrayList(1);
|
||||||
|
|
Loading…
Add table
Reference in a new issue