[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-debug-dev] 1.0.1 Register Handling Fix.
|
Hi,
Just an FYI, you all may have covered this already in the head.
Using the phrase "To ensure consistency between a register name and its
number, the output list may include empty register names," the MI protocol
appears to allow gdb to return a "sparse" array of registers by giving a 0
length name in response to the -data-list-register-names-command. CDT 1.0.1
does not handle this especially well and subsequently exposes a bug in GDB
5.1.3 and crashes it if the debugger has more than 3 register names of 0
length.
Attached is the fix we used to correct this.
Thanks!
-Chris
(Here is an example of a sparse register response from GDB. Most folks may
not do this, our debugger does because there are certain registers that are
visible to a simulator that are not actually visible on real hardware. We
list all registers to create a canonical numbering and then just null the
names of the ones that are not visible when targeting hardware.)
8-data-list-register-names
(gdb)
8^done,register-names=["ar0","ar1","ar2","ar3","ar4","ar5","ar6","ar7","ar8","ar9","ar10","ar11","ar\
12","ar13","ar14","ar15","ar16","ar17","ar18","ar19","ar20","ar21","ar22","ar23","ar24","ar25","ar26\
","ar27","ar28","ar29","ar30","ar31","ar32","ar33","ar34","ar35","ar36","ar37","ar38","ar39","ar40",\
"ar41","ar42","ar43","ar44","ar45","ar46","ar47","ar48","ar49","ar50","ar51","ar52","ar53","ar54","a\
r55","ar56","ar57","ar58","ar59","ar60","ar61","ar62","ar63","aes0","aes1","dr0","dr1","dr2","dr3","\
rr0","rr1","rr2","rr3","ps","dbreakc0","dbreakc1","ibreaka0","ibreaka1","cpenable","lend","intenable\
","exccause","excsave1","excsave2","excsave3","excsave4","wb","sar","interrupt","interrupt2","icount\
lvl","epc1","epc2","epc3","epc4","ccount","ibreakenable","misc_reg0","dtlbcfg","itlbcfg","ws","ccomp\
are0","ccompare1","ccompare2","pc","eps2","eps3","eps4","depc","excvaddr","ddr","lbeg","lcount","deb\
ugcause","rasid","icount","dbreaka0","dbreaka1","","","","","","","","","ur0","ur1","ur2","ur3","ur4\
","ur5","ur6","ur7","","","","","","","","","","","","","","","","","","","","","","","","","","",""\
,"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",\
"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\
","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""\
,"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",\
"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\
","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""\
,"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",\
"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\
","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""\
,"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",\
"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\
","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""\
,"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",\
"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\
","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""\
,"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",\
"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\
","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""\
,"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",\
"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\
","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""\
,"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",\
"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\
","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""\
,"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",\
"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\
","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""\
,"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",\
"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\
","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""\
,"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",\
"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\
","","","","","","","","","","","","","psintlvl","psowb","pswoe","psexcm","pscallinc","psusrmode","p\
sring","accumdist0","accumdist1","accumdist2","accumdist3","accumdist4","accumdist5","accumdist6","a\
ccumdist7","accumdist8","accumdist9","accumdista","accumdistb","accumdistc","accumdistd","accumdiste\
","accumdistf","ginput","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","a10","a11","a12","a13","a\
14","a15","fp"]
diff -u -r xide_compare/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java xide/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java
--- xide_compare/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java Thu Aug 14 15:33:45 2003
+++ xide/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java Mon Aug 18 11:28:29 2003
@@ -45,10 +45,13 @@
if (info == null) {
throw new CDIException("No answer");
}
+
String[] names = info.getRegisterNames();
- RegisterObject[] regs = new RegisterObject[names.length];
+ RegisterObject[] regs = new RegisterObject[info.getNumRealNames()];
+ int realIndex = 0;
for (int i = 0; i < names.length; i++) {
- regs[i] = new RegisterObject(names[i], i);
+ if( names[i].length() > 0 )
+ regs[realIndex++] = new RegisterObject(names[i], i);
}
return regs;
} catch (MIException e) {
diff -u -r xide_compare/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIDataListRegisterNamesInfo.java xide/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIDataListRegisterNamesInfo.java
--- xide_compare/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIDataListRegisterNamesInfo.java Thu Aug 14 15:33:45 2003
+++ xide/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIDataListRegisterNamesInfo.java Mon Aug 18 11:28:30 2003
@@ -14,11 +14,17 @@
public class MIDataListRegisterNamesInfo extends MIInfo {
String[] names;
+ protected int realNameCount = 0;
public MIDataListRegisterNamesInfo(MIOutput 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 () {
if (names == null) {
parse();
@@ -52,10 +58,29 @@
for (int i = 0; i < values.length; i++) {
if (values[i] instanceof MIConst) {
String str = ((MIConst)values[i]).getCString();
- if (str != null && str.length() > 0) {
+
+ /* 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;
+ }
}