diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index 7ce133bdddd..bc6300dfb85 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -1,3 +1,8 @@ +2006-01-31 Mikhail Khodjaiants + Bug 124966: GDBTypeParser.parse(String) parses incorrectly. + Applied patch from Matthias Spycher (matthias@coware.com). + * GDBTypeParser.java + 2006-01-27 Mikhail Khodjaiants Bug 107202: slow debug launch with external sources. Use "-p" option when passing a large number of directories to "cygpath". diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/GDBTypeParser.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/GDBTypeParser.java index e8bed433b5b..9b4fb708650 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/GDBTypeParser.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/GDBTypeParser.java @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Matthias Spycher (matthias@coware.com) - bug 124966 *******************************************************************************/ package org.eclipse.cdt.debug.mi.core; @@ -82,13 +83,16 @@ public class GDBTypeParser { // Hack for GDB, the typename can be something like // class A : public B, C { ... } * // We are only interested in "class A" - // Carefull for class A::data + // Carefull for class A::data or class ns::A int column = dataType.indexOf(':'); - if (column > 0) { - if ((column + 1) < dataType.length() && dataType.charAt(column + 1) != ':') { - dataType = dataType.substring(0, column); - } - } + while (column > 0) { + if ((column + 2) < dataType.length() && dataType.charAt(column + 1) == ':') { + column = dataType.indexOf(':', column+2); + continue; + } + dataType = dataType.substring(0, column); + break; + } genericType = new GDBType(dataType); // Start the recursive parser. @@ -336,13 +340,29 @@ public class GDBTypeParser { } tokenType = BRACKETS; } else if (isCIdentifierStart(c)) { - token = "" + (char) c; //$NON-NLS-1$ + StringBuffer sb = new StringBuffer(); + sb.append((char) c); while (isCIdentifierPart((c = getch())) && c != EOF) { - token += (char) c; + sb.append((char) c); } - if (c != EOF) { + if (c == '<') { + // Swallow template args in types like "class foobar : public C {..} *" + // FIXME: if the bracket is not terminate do we throw exception? + sb.append((char) c); + int count = 1; + do { + c = getch(); + if (c == '<') { + count++; + } else if (c == '>') { + count--; + } + sb.append((char)c); + } while (count > 0 && c != EOF); + } else if (c != EOF) { ungetch(); } + token = sb.toString(); tokenType = NAME; } else if (c == '{') { // Swallow gdb sends things like "struct foobar {..} *" @@ -464,7 +484,13 @@ public class GDBTypeParser { System.out.println(parser.getGDBType().verbose()); System.out.println(); - System.out.println("char **argv"); //$NON-NLS-1$ + System.out.println("class ns::link<8, ns::A> : public ns::B { int i; int j; struct link * next;} *"); //$NON-NLS-1$ + parser.parse("class ns::link<8, ns::A> : public ns::B { int i; int j; struct link * next;} *"); //$NON-NLS-1$ + System.out.println(GDBTypeParser.unParse(parser.getGDBType())); + System.out.println(parser.getGDBType().verbose()); + System.out.println(); + + System.out.println("char **argv"); //$NON-NLS-1$ parser.parse("char **argv"); //$NON-NLS-1$ System.out.println(GDBTypeParser.unParse(parser.getGDBType())); System.out.println(parser.getGDBType().verbose());