Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] gdb prompt fixes to get next/step... work.

	gdb/mi for program control command will fire a change state event:
	-exec-run
	^running
	This allow the UI to change its state and wait for the suspended.
	Providing a gdb prompt adds some problems, since there is no state
	change, i.e.(^running) after command like, next/step/...:
	next
	&"next\n"
	...
	So to palliate, the txthread do some query when the commands are
	CLI commands trying to discover the type and fire any appropriate
	events on behalf on gdb.

	* src/.../core/RxThread.java (createEvent): Adjust the parser to
	not rely on the oob "*stopped", since for CLI command it is not
	in the result-class.  So the suspended state will be base of
	the "reason" only.
	* src/.../core/TxThread.java (processCLICommand): new method,
	get the command and try to recognize if it is a program control
	command like: next, step, etc ..
	* src/.../core/command/CLICommand.java (getOperation): New method,
	returns the command string.

 
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.17
diff -u -r1.17 ChangeLog
--- ChangeLog	22 Oct 2002 20:29:02 -0000	1.17
+++ ChangeLog	24 Oct 2002 02:40:18 -0000
@@ -1,6 +1,31 @@
+2002-10-23 Alain Magloire
+
+	gdb/mi for program control command will fire a change state event:
+	-exec-run
+	^running
+	This allow the UI to change its state and wait for the suspended.
+	Providing a gdb prompt adds some problems, since there is no state
+	change, i.e.(^running) after command like, next/step/...:
+	next
+	&"next\n"
+	...
+	So to palliate, the txthread do some query when the commands are
+	CLI commands trying to discover the type and fire any appropriate
+	events on behalf on gdb.
+
+	* src/.../core/RxThread.java (createEvent): Adjust the parser to
+	not rely on the oob "*stopped", since for CLI command it is not
+	in the result-class.  So the suspended state will be base of
+	the "reason" only.
+	* src/.../core/TxThread.java (processCLICommand): new method,
+	get the command and try to recognize if it is a program control
+	command like: next, step, etc ..
+	* src/.../core/command/CLICommand.java (getOperation): New method,
+	returns the command string.
+
 2002-10-22 Alain Magloire
 
-	Change the framewor to support access to gdb prompt.
+	Change the framework to support access to gdb prompt.
 	Trying to reuse as much as possible Eclipse framework.
 	The session/gdb process is available via CDI.
 
Index: src/org/eclipse/cdt/debug/mi/core/RxThread.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/RxThread.java,v
retrieving revision 1.34
diff -u -r1.34 RxThread.java
--- src/org/eclipse/cdt/debug/mi/core/RxThread.java	21 Oct 2002 21:38:44 -0000	1.34
+++ src/org/eclipse/cdt/debug/mi/core/RxThread.java	24 Oct 2002 02:40:19 -0000
@@ -147,8 +147,13 @@
 					session.fireEvent(event);
 				} else if ("exit".equals(state)) {
 					// No need to do anything, terminate() will.
+					session.getMIInferior().setTerminated();
 				} else if ("connected".equals(state)) {
 					session.getMIInferior().setConnected();
+				} else if ("error".equals(state)) {
+					if (session.getMIInferior().isRunning()) {
+						session.getMIInferior().setSuspended();
+					}
 				}
 
 				// Clear the accumulate oobList on each new Result Command
@@ -203,7 +208,6 @@
 			String state = exec.getAsyncClass();
 			if ("stopped".equals(state)) {
 				MIEvent e = null;
-				session.getMIInferior().setSuspended();
 				MIResult[] results = exec.getMIResults();
 				for (int i = 0; i < results.length; i++) {
 					String var = results[i].getVariable();
@@ -219,14 +223,13 @@
 					}
 				}
 			
-				// HACK: GDB for temporary breakpoints will not send the
-				// "reason" ???  Fake this as breakpoint-hit 
+				// We were stopped for some unknown reason, for example
+				// GDB for temporary breakpoints will not send the
+				// "reason" ??? still fire a stopped event.
 				if (e == null) {
-					//e = createEvent("breakpoint-hit", exec);
+					session.getMIInferior().setSuspended();
 					e = new MIStoppedEvent();
-					if (e != null) {
-						list.add(e);
-					}
+					list.add(e);
 				}
 			}
 		} else if (async instanceof MIStatusAsyncOutput) {
@@ -319,52 +322,59 @@
 			} else if (rr != null) {
 				event = new MIBreakpointEvent(rr);
 			}
+			session.getMIInferior().setSuspended();
 		} else if ("watchpoint-trigger".equals(reason)) {
 			if (exec != null) {
 				event = new MIWatchpointTriggerEvent(exec);
 			} else if (rr != null) {
 				event = new MIWatchpointTriggerEvent(rr);
 			}
+			session.getMIInferior().setSuspended();
 		} else if ("watchpoint-scope".equals(reason)) {
 			if (exec != null) {
 				event = new MIWatchpointScopeEvent(exec);
 			} else if (rr != null) {
 				event = new MIWatchpointScopeEvent(rr);
 			}
+			session.getMIInferior().setSuspended();
 		} else if ("end-stepping-range".equals(reason)) {
 			if (exec != null) {
 				event = new MISteppingRangeEvent(exec);
 			} else if (rr != null) {
 				event = new MISteppingRangeEvent(rr);
 			}
+			session.getMIInferior().setSuspended();
 		} else if ("signal-received".equals(reason)) {
 			if (exec != null) {
 				event = new MISignalEvent(exec);
 			} else if (rr != null) {
 				event = new MISignalEvent(rr);
 			}
+			session.getMIInferior().setSuspended();
 		} else if ("location-reached".equals(reason)) {
 			if (exec != null) {
 				event = new MILocationReachedEvent(exec);
 			} else if (rr != null) {
 				event = new MILocationReachedEvent(rr);
 			}
+			session.getMIInferior().setSuspended();
 		} else if ("function-finished".equals(reason)) {
 			if (exec != null) {
 				event = new MIFunctionFinishedEvent(exec);
 			} else if (rr != null) {
 				event = new MIFunctionFinishedEvent(rr);
 			}
+			session.getMIInferior().setSuspended();
 		} else if ("exited-normally".equals(reason) ||
 			"exited-signalled".equals(reason) ||
 			"exited-signalled".equals(reason) ||
 			"exited".equals(reason)) {
-			session.getMIInferior().setTerminated();
 			if (exec != null) {
 				event = new MIInferiorExitEvent(exec);
 			} else if (rr != null) {
 				event = new MIInferiorExitEvent(rr);
 			}
+			session.getMIInferior().setTerminated();
 		}
 		return event;
 	}
Index: src/org/eclipse/cdt/debug/mi/core/SessionProcess.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/SessionProcess.java,v
retrieving revision 1.1
diff -u -r1.1 SessionProcess.java
--- src/org/eclipse/cdt/debug/mi/core/SessionProcess.java	22 Oct 2002 20:28:54 -0000	1.1
+++ src/org/eclipse/cdt/debug/mi/core/SessionProcess.java	24 Oct 2002 02:40:19 -0000
@@ -69,6 +69,7 @@
 					try {
 						session.postCommand(cmd);
 					} catch (MIException e) {
+						//e.printStackTrace();
 						throw new IOException(e.getMessage());
 					}
 				}
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.13
diff -u -r1.13 TxThread.java
--- src/org/eclipse/cdt/debug/mi/core/TxThread.java	13 Oct 2002 02:28:28 -0000	1.13
+++ src/org/eclipse/cdt/debug/mi/core/TxThread.java	24 Oct 2002 02:40:19 -0000
@@ -8,7 +8,10 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
+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
@@ -55,7 +58,12 @@
 							cmd.notifyAll();
 						}
 					}
-
+					
+					// May need to fire event.
+					if (cmd instanceof CLICommand) {
+						processCLICommand((CLICommand)cmd);
+					}
+				
 					// shove in the pipe
 					String str = cmd.toString();
 					if (out != null) {
@@ -78,5 +86,43 @@
                                 }
                         }
                 }
+	}
+	
+	/**
+	 * 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(type);
+			session.fireEvent(event);
+		}
 	}
 }
Index: src/org/eclipse/cdt/debug/mi/core/command/CLICommand.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CLICommand.java,v
retrieving revision 1.10
diff -u -r1.10 CLICommand.java
--- src/org/eclipse/cdt/debug/mi/core/command/CLICommand.java	9 Oct 2002 14:08:42 -0000	1.10
+++ src/org/eclipse/cdt/debug/mi/core/command/CLICommand.java	24 Oct 2002 02:40:20 -0000
@@ -20,6 +20,10 @@
 		operation = oper;
 	}
 
+	public String getOperation() {
+		return operation;
+	}
+
 	/**
 	 * Returns the text representation of this command.
 	 * 



Back to the top