Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] MI fixes

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.146
diff -u -r1.146 ChangeLog
--- ChangeLog	8 Jul 2003 15:44:54 -0000	1.146
+++ ChangeLog	10 Jul 2003 19:21:39 -0000
@@ -1,3 +1,18 @@
+2003-07-10 Alain Magloire
+
+	In the case of not having a PTY to unmixed inferior output from gdb commands
+	do the only sane thing and when a response comes in that is not a valid
+	MI format consider it as inferior output.
+
+	* src/org/eclipse/cdt/debug/mi/core/output/MIParser.java:
+	Put non valid lines in the TargetStream.
+	* src/org/eclipse/cdt/debug/mi/core/MIInferior.java:
+	Pass output straight to the target.
+	* src/org/eclipse/cdt/debug/mi/core/TxThread.java:
+	Remove unused code.
+	* src/org/eclipse/cdt/debug/mi/core/command/Command.java:
+	Try to remove duplicate errors when throwing the MIException.
+
 2003-07-08 Alain Magloire
 
 	Unfortunately GDB/MI does not make the errors available via the advertise
@@ -15,7 +30,7 @@
 	
 		CDIException.getDetailedMesssage().
 
-	src/org/eclipse/cdt/debug/mi/core/command/*.java:  All the commands
+	* src/org/eclipse/cdt/debug/mi/core/command/*.java:  All the commands
 	changed to grab also the logstream messages if any for the exception.
 	
 2003-06-25 Alain Magloire
Index: src/org/eclipse/cdt/debug/mi/core/MIInferior.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java,v
retrieving revision 1.29
diff -u -r1.29 MIInferior.java
--- src/org/eclipse/cdt/debug/mi/core/MIInferior.java	25 Apr 2003 20:50:26 -0000	1.29
+++ src/org/eclipse/cdt/debug/mi/core/MIInferior.java	10 Jul 2003 19:21:39 -0000
@@ -10,7 +10,6 @@
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
 
-import org.eclipse.cdt.debug.mi.core.command.CLICommand;
 import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
 import org.eclipse.cdt.debug.mi.core.command.MIExecAbort;
 import org.eclipse.cdt.debug.mi.core.command.MIGDBShowExitCode;
@@ -65,24 +64,14 @@
 			out = new OutputStream() {
 				StringBuffer buf = new StringBuffer();
 				public void write(int b) throws IOException {
-					buf.append((char)b);
-					if (b == '\n') {
-						flush();
+					if (!isRunning()) {
+						throw new IOException("target is suspended");
 					}
-				}
-				// Encapsulate the string sent to gdb in a fake command.
-				// and post it to the TxThread.
-				public void flush() throws IOException {
-					CLICommand cmd = new CLICommand(buf.toString()) {
-						public void setToken(int token) {
-							// override to do nothing;
-						}
-					};
-					try {
-						session.postCommand(cmd);
-					} catch (MIException e) {
-						throw new IOException("no mi session");
+					OutputStream channel = session.getChannelOutputStream();
+					if (channel == null) {
+						throw new IOException("No MI Session");
 					}
+					channel.write(b);
 				}
 			};
 		}
Index: src/org/eclipse/cdt/debug/mi/core/MIPlugin.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java,v
retrieving revision 1.40
diff -u -r1.40 MIPlugin.java
--- src/org/eclipse/cdt/debug/mi/core/MIPlugin.java	30 Apr 2003 20:56:10 -0000	1.40
+++ src/org/eclipse/cdt/debug/mi/core/MIPlugin.java	10 Jul 2003 19:21:39 -0000
@@ -39,6 +39,9 @@
 	// GDB init command file
 	private static final String GDBINIT = ".gdbinit";
 
+	// GDB command
+	private static final String GDB = "gdb";
+
 	/**
 	 * The constructor
 	 * @see org.eclipse.core.runtime.Plugin#Plugin(IPluginDescriptor)
@@ -106,7 +109,7 @@
 	 */
 	public ICDISession createCSession(String gdb, File program, File cwd, String gdbinit, PTY pty) throws IOException, MIException {
 		if (gdb == null || gdb.length() == 0) {
-			gdb =  "gdb";
+			gdb =  GDB;
 		}
 		
 		if (gdbinit == null || gdbinit.length() == 0) {
@@ -158,7 +161,7 @@
 	 */
 	public ICDISession createCSession(String gdb, File program, File core, File cwd, String gdbinit) throws IOException, MIException {
 		if (gdb == null || gdb.length() == 0) {
-			gdb =  "gdb";
+			gdb =  GDB;
 		}
 		
 		if (gdbinit == null || gdbinit.length() == 0) {
@@ -185,7 +188,7 @@
 	 */
 	public ICDISession createCSession(String gdb, File program, int pid, String[] targetParams, File cwd, String gdbinit) throws IOException, MIException {
 		if (gdb == null || gdb.length() == 0) {
-			gdb =  "gdb";
+			gdb =  GDB;
 		}
 
 		if (gdbinit == null || gdbinit.length() == 0) {
Index: src/org/eclipse/cdt/debug/mi/core/TxThread.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/TxThread.java,v
retrieving revision 1.17
diff -u -r1.17 TxThread.java
--- src/org/eclipse/cdt/debug/mi/core/TxThread.java	8 Jan 2003 15:44:04 -0000	1.17
+++ src/org/eclipse/cdt/debug/mi/core/TxThread.java	10 Jul 2003 19:21:39 -0000
@@ -10,8 +10,6 @@
 
 import org.eclipse.cdt.debug.mi.core.command.CLICommand;
 import org.eclipse.cdt.debug.mi.core.command.Command;
-import org.eclipse.cdt.debug.mi.core.event.MIEvent;
-import org.eclipse.cdt.debug.mi.core.event.MIRunningEvent;
 
 /**
  * Transmission command thread blocks on the command Queue
@@ -82,42 +80,5 @@
 			}
 		}
 	}
-	
-	/**
-	 * An attempt to discover the command type and
-	 * fire an event if necessary.
-	 */
-	void processCLICommand(CLICommand cmd) {
-		String operation = cmd.getOperation();
-		int indx = operation.indexOf(' ');
-		if (indx != -1) {
-			operation = operation.substring(0, indx).trim();
-		} else {
-			operation = operation.trim();
-		}
 
-		// Check the type of command
-		int type = -1;
-		// if it was a step instruction set state running
-		if (operation.equals("n") || operation.equals("next")) {
-			type = MIRunningEvent.NEXT;
-		} else if (operation.equals("ni") || operation.equals("nexti")) {
-			type = MIRunningEvent.NEXTI;
-		} else if (operation.equals("s") || operation.equals("step")) {
-			type = MIRunningEvent.STEP;
-		} else if (operation.equals("si") || operation.equals("stepi")) {
-			type = MIRunningEvent.STEPI;
-		} else if (operation.equals("u") || operation.startsWith("unt")) {
-			type = MIRunningEvent.UNTIL;
-		} else if (operation.startsWith("fin")) {
-			type = MIRunningEvent.FINISH;
-		} else if (operation.equals("c") || operation.equals("fg") || operation.startsWith("cont")) {
-			type = MIRunningEvent.CONTINUE;
-		}
-		if (type != -1) {
-			session.getMIInferior().setRunning();
-			MIEvent event = new MIRunningEvent(cmd.getToken(), type);
-			session.fireEvent(event);
-		}
-	}
 }
Index: src/org/eclipse/cdt/debug/mi/core/command/Command.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/Command.java,v
retrieving revision 1.11
diff -u -r1.11 Command.java
--- src/org/eclipse/cdt/debug/mi/core/command/Command.java	8 Jul 2003 15:44:41 -0000	1.11
+++ src/org/eclipse/cdt/debug/mi/core/command/Command.java	10 Jul 2003 19:21:39 -0000
@@ -80,16 +80,23 @@
 	 * throw an MIException.
 	 */
 	protected void throwMIException (MIInfo info, MIOutput out) throws MIException {
-		String mesg = info.getErrorMsg();
+		String mesg = info.getErrorMsg().trim();
 		StringBuffer sb = new StringBuffer();
 		MIOOBRecord[] oobs = out.getMIOOBRecords();
 		for (int i = 0; i < oobs.length; i++) {
 			if (oobs[i] instanceof MILogStreamOutput) {
 				MIStreamRecord o = (MIStreamRecord) oobs[i];
-				sb.append(o.getString());
+				String s = o.getString();
+				if (!s.trim().equalsIgnoreCase(mesg)) {
+					sb.append(s);
+				}
 			}
 		}
-		throw new MIException(mesg, sb.toString());
+		String details = sb.toString();
+		if (details.trim().length() == 0) {
+			details = mesg;
+		}
+		throw new MIException(mesg, details);
 	}
 
 }
Index: src/org/eclipse/cdt/debug/mi/core/output/MIParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIParser.java,v
retrieving revision 1.12
diff -u -r1.12 MIParser.java
--- src/org/eclipse/cdt/debug/mi/core/output/MIParser.java	25 Jun 2003 19:08:29 -0000	1.12
+++ src/org/eclipse/cdt/debug/mi/core/output/MIParser.java	10 Jul 2003 19:21:39 -0000
@@ -233,6 +233,11 @@
 			}
 			stream.setCString(translateCString(new FSB(buffer)));
 			oob = stream;
+		} else {
+			// Badly format MI line, just pass it to the user as target stream
+			MIStreamRecord stream = new MITargetStreamOutput();
+			stream.setCString(buffer.toString() + "\n");
+			oob = stream;
 		}
 		return oob;
 	}



Back to the top