mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Patch form chris songer deals with sparse output
in the MI format
This commit is contained in:
parent
8043fd6640
commit
e7f524f9e1
2 changed files with 33 additions and 8 deletions
|
@ -62,11 +62,13 @@ public class RegisterManager extends SessionObject implements ICDIRegisterManage
|
|||
throw new CDIException("No answer");
|
||||
}
|
||||
String[] names = info.getRegisterNames();
|
||||
RegisterObject[] regs = new RegisterObject[names.length];
|
||||
List regsList = new ArrayList(names.length);
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
regs[i] = new RegisterObject(session.getCurrentTarget(), names[i], i);
|
||||
if (names[i].length() > 0) {
|
||||
regsList.add(new RegisterObject(session.getCurrentTarget(), names[i], i));
|
||||
}
|
||||
}
|
||||
return regs;
|
||||
return (ICDIRegisterObject[])regsList.toArray(new ICDIRegisterObject[0]);
|
||||
} catch (MIException e) {
|
||||
throw new MI2CDIException(e);
|
||||
}
|
||||
|
|
|
@ -14,12 +14,18 @@ import java.util.List;
|
|||
public class MIDataListRegisterNamesInfo extends MIInfo {
|
||||
|
||||
String[] names;
|
||||
protected int realNameCount = 0;
|
||||
|
||||
public MIDataListRegisterNamesInfo(MIOutput rr) {
|
||||
super(rr);
|
||||
}
|
||||
|
||||
public String[] getRegisterNames () {
|
||||
/**
|
||||
* @return the list of register names. This list can include 0 length
|
||||
* strings in the case where the underlying GDB has a sparse set of
|
||||
* registers. They are returned as 0 length strings
|
||||
*/
|
||||
public String[] getRegisterNames() {
|
||||
if (names == null) {
|
||||
parse();
|
||||
}
|
||||
|
@ -32,30 +38,47 @@ public class MIDataListRegisterNamesInfo extends MIInfo {
|
|||
MIOutput out = getMIOutput();
|
||||
MIResultRecord rr = out.getMIResultRecord();
|
||||
if (rr != null) {
|
||||
MIResult[] results = rr.getMIResults();
|
||||
MIResult[] results = rr.getMIResults();
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
String var = results[i].getVariable();
|
||||
if (var.equals("register-names")) {
|
||||
MIValue value = results[i].getMIValue();
|
||||
if (value instanceof MIList) {
|
||||
parseRegisters((MIList)value, aList);
|
||||
parseRegisters((MIList) value, aList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
names = (String[])aList.toArray(new String[aList.size()]);
|
||||
names = (String[]) aList.toArray(new String[aList.size()]);
|
||||
}
|
||||
|
||||
void parseRegisters(MIList list, List aList) {
|
||||
MIValue[] values = list.getMIValues();
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (values[i] instanceof MIConst) {
|
||||
String str = ((MIConst)values[i]).getCString();
|
||||
String str = ((MIConst) values[i]).getCString();
|
||||
|
||||
/* this cannot filter nulls because index is critical in retreival
|
||||
* and index is assigned in the layers above. The MI spec allows
|
||||
* empty returns, for some register names. */
|
||||
if (str != null && str.length() > 0) {
|
||||
realNameCount++;
|
||||
aList.add(str);
|
||||
} else {
|
||||
aList.add("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of non-null and non-empty names in the
|
||||
* register list
|
||||
*/
|
||||
public int getNumRealNames() {
|
||||
if (names == null)
|
||||
parse();
|
||||
return realNameCount;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue