1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Patch form chris songer deals with sparse output

in the MI format
This commit is contained in:
Alain Magloire 2003-08-19 02:38:41 +00:00
parent 8043fd6640
commit e7f524f9e1
2 changed files with 33 additions and 8 deletions

View file

@ -62,11 +62,13 @@ public class RegisterManager extends SessionObject implements ICDIRegisterManage
throw new CDIException("No answer"); throw new CDIException("No answer");
} }
String[] names = info.getRegisterNames(); String[] names = info.getRegisterNames();
RegisterObject[] regs = new RegisterObject[names.length]; List regsList = new ArrayList(names.length);
for (int i = 0; i < names.length; i++) { 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) { } catch (MIException e) {
throw new MI2CDIException(e); throw new MI2CDIException(e);
} }

View file

@ -14,11 +14,17 @@ import java.util.List;
public class MIDataListRegisterNamesInfo extends MIInfo { public class MIDataListRegisterNamesInfo extends MIInfo {
String[] names; String[] names;
protected int realNameCount = 0;
public MIDataListRegisterNamesInfo(MIOutput rr) { public MIDataListRegisterNamesInfo(MIOutput rr) {
super(rr); super(rr);
} }
/**
* @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() { public String[] getRegisterNames() {
if (names == null) { if (names == null) {
parse(); parse();
@ -52,10 +58,27 @@ public class MIDataListRegisterNamesInfo extends MIInfo {
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
if (values[i] instanceof MIConst) { 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) { if (str != null && str.length() > 0) {
realNameCount++;
aList.add(str); 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;
}
} }