[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.165
diff -u -r1.165 ChangeLog
--- ChangeLog 20 Aug 2003 01:22:56 -0000 1.165
+++ ChangeLog 20 Aug 2003 15:40:23 -0000
@@ -1,3 +1,16 @@
+2003-08-20 Alain Magloire
+
+ GDB/MI altough define an interface that all commands should
+ follow .. they do not. For example, we should be able
+ to separate options from agument with a "--" string not
+ all commands. The latest is -break-condition.
+ So we override the MICommand.toString() to do specific
+ parsing for specific commands.
+
+ * src/org/eclipse/cdt/debug/mi/core/command/MICommand.java
+ break the toString() method.
+ * src/org/eclipse/cdt/debug/mi/core/command/MIBreakCondition.java
+
2003-08-19 Alain Magloire
Fix to the GDBTypeParser to deal with gdb
Index: src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java,v
retrieving revision 1.26
diff -u -r1.26 SourceManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java 3 Jun 2003 19:46:07 -0000 1.26
+++ src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java 20 Aug 2003 15:40:24 -0000
@@ -235,6 +235,8 @@
Type headType = null;
Type type = null;
+ // Convert the GDBType to an ICDIType.
+ // So we go through the gdbType tree and reconstruct an ICDIType tree
for (Type aType = null; gdbType != null; type = aType) {
if (gdbType instanceof GDBDerivedType) {
switch(gdbType.getType()) {
Index: src/org/eclipse/cdt/debug/mi/core/command/MIBreakCondition.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIBreakCondition.java,v
retrieving revision 1.2
diff -u -r1.2 MIBreakCondition.java
--- src/org/eclipse/cdt/debug/mi/core/command/MIBreakCondition.java 8 Aug 2002 04:07:00 -0000 1.2
+++ src/org/eclipse/cdt/debug/mi/core/command/MIBreakCondition.java 20 Aug 2003 15:40:24 -0000
@@ -16,9 +16,20 @@
* Result:
* ^done
*/
-public class MIBreakCondition extends MICommand
-{
- public MIBreakCondition (int brknum, String expr) {
- super("-break-condition", new String[]{Integer.toString(brknum), expr});
+public class MIBreakCondition extends MICommand {
+ public MIBreakCondition(int brknum, String expr) {
+ super("-break-condition", new String[] { Integer.toString(brknum), expr });
+ }
+
+ /**
+ * Do not do any munging on the string i.e. quoting spaces
+ * etc .. doing this will break the command -break-condition.
+ */
+ protected String parametersToString() {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < parameters.length; i++) {
+ buffer.append(' ').append(parameters[i]);
+ }
+ return buffer.toString().trim();
}
}
Index: src/org/eclipse/cdt/debug/mi/core/command/MICommand.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MICommand.java,v
retrieving revision 1.13
diff -u -r1.13 MICommand.java
--- src/org/eclipse/cdt/debug/mi/core/command/MICommand.java 7 Oct 2002 00:58:53 -0000 1.13
+++ src/org/eclipse/cdt/debug/mi/core/command/MICommand.java 20 Aug 2003 15:40:24 -0000
@@ -6,14 +6,11 @@
package org.eclipse.cdt.debug.mi.core.command;
-
-
/**
*
* Represents a MI command.
*/
-public class MICommand extends Command
-{
+public class MICommand extends Command {
final String[] empty = new String[0];
String[] options = empty;
String[] parameters = empty;
@@ -42,7 +39,7 @@
public String getOperation() {
return operation;
}
-
+
/**
* Returns an array of command's options. An empty collection is
* returned if there are no options.
@@ -56,7 +53,7 @@
public void setOptions(String[] opt) {
options = opt;
}
-
+
/**
* Returns an array of command's parameters. An empty collection is
* returned if there are no parameters.
@@ -71,24 +68,31 @@
parameters = p;
}
- public String toString() {
- String command = getToken() + getOperation();
+ protected String optionsToString() {
+ StringBuffer sb = new StringBuffer();
if (options != null && options.length > 0) {
for (int i = 0; i < options.length; i++) {
- if (options[i].indexOf('\t') != -1 ||
- options[i].indexOf(' ') != -1) {
- command += " \"" + options[i] + "\"";
+ // If the option contains a space according to
+ // GDB/MI spec we must surround it with double quotes.
+ if (options[i].indexOf('\t') != -1 || options[i].indexOf(' ') != -1) {
+ sb.append(' ').append('"').append(options[i]).append('"');
} else {
- command += " " + options[i];
+ sb.append(' ').append(options[i]);
}
}
}
+ return sb.toString().trim();
+ }
+
+ protected String parametersToString() {
+ StringBuffer buffer = new StringBuffer();
if (parameters != null && parameters.length > 0) {
- // Add a "--" separator if a parameter starts with "-"
+ // According to GDB/MI spec
+ // Add a "--" separator if any parameters start with "-"
if (options != null && options.length > 0) {
for (int i = 0; i < parameters.length; i++) {
if (parameters[i].startsWith("-")) {
- command += " --";
+ buffer.append('-').append('-');
break;
}
}
@@ -106,19 +110,33 @@
}
sb.append(c);
}
-
+
// If the string contains spaces instead of escaping
// surround the parameter with double quotes.
if (containsWhitespace(param)) {
sb.insert(0, '"');
sb.append('"');
}
- command += " " + sb.toString();
+ buffer.append(' ').append(sb);
}
}
- return command + "\n";
+ return buffer.toString().trim();
}
-
+
+ public String toString() {
+ StringBuffer command = new StringBuffer(getToken() + getOperation());
+ String opt = optionsToString();
+ if (opt.length() > 0) {
+ command.append(' ').append(opt);
+ }
+ String p = parametersToString();
+ if (p.length() > 0) {
+ command.append(' ').append(p);
+ }
+ command.append('\n');
+ return command.toString();
+ }
+
boolean containsWhitespace(String s) {
for (int i = 0; i < s.length(); i++) {
if (Character.isWhitespace(s.charAt(i))) {