Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] MI delay when suspending

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.121
diff -u -r1.121 ChangeLog
--- ChangeLog	21 Apr 2003 15:15:25 -0000	1.121
+++ ChangeLog	22 Apr 2003 20:55:17 -0000
@@ -1,5 +1,16 @@
 2003-04-21 Alain Magloire
 
+	* src/org/eclipse/cdt/debug/mi/core/cdi/Target.java (suspend):
+	Remove the delay of 10 secs.
+	* src/org/eclipse/cdt/debug/mi/core/MIInferior.java (interrupt):
+	Do a delay of 10 secs to allow time for the inferior to stop.
+	* src/org/eclipse/cdt/debug/mi/core/MISession.java (terminate) :
+	Clear the EventQueue, if we restart.
+	* src/org/eclipse/cdt/debug/mi/core/Queue (isEmpty):
+	New method.
+
+2003-04-21 Alain Magloire
+
 	* src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java:
 	* src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java:
 	Ignore exception when doing "set auto-solib-path on".
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.25
diff -u -r1.25 MIInferior.java
--- src/org/eclipse/cdt/debug/mi/core/MIInferior.java	7 Jan 2003 17:12:01 -0000	1.25
+++ src/org/eclipse/cdt/debug/mi/core/MIInferior.java	22 Apr 2003 20:55:17 -0000
@@ -179,6 +179,13 @@
 		if (gdb instanceof Spawner) {
 			Spawner gdbSpawner = (Spawner)gdb;
 			gdbSpawner.interrupt();
+			// Allow (5 secs) for the interrupt to propagate.
+			for (int i = 0; isRunning() && i < 5; i++) {
+				try {
+					java.lang.Thread.sleep(1000);
+				} catch (InterruptedException e) {
+				}
+			}
 		} else {
 			// Try the exec-interrupt; this will be for "gdb --async"
 			// CommandFactory factory = session.getCommandFactory();
Index: src/org/eclipse/cdt/debug/mi/core/MISession.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java,v
retrieving revision 1.41
diff -u -r1.41 MISession.java
--- src/org/eclipse/cdt/debug/mi/core/MISession.java	7 Apr 2003 22:45:11 -0000	1.41
+++ src/org/eclipse/cdt/debug/mi/core/MISession.java	22 Apr 2003 20:55:17 -0000
@@ -356,11 +356,6 @@
 		// Destroy any MI Inferior(Process) and streams.
 		inferior.destroy();
 		
-		// Tell the observers that the session
-		// is finish, but we can not use the Event Thread.
-		// The Event Thread is being kill below.
-		notifyObservers(new MIGDBExitEvent(0));
-		
 		// {in,out}Channel is use as predicate/condition
 		// in the {RX,TX,Event}Thread to detect termination
 		// and bail out.  So they are set to null.
@@ -433,6 +428,15 @@
 		} catch (InterruptedException e) {
 		}
 
+		// Allow (10 secs) for the EventThread  to finish processing the queue.
+		Queue queue = getEventQueue();
+		for (int i = 0; !queue.isEmpty() && i < 5; i++) {
+			try {
+				java.lang.Thread.sleep(2000);
+			} catch (InterruptedException e) {
+			}
+		}
+
 		// Kill the event Thread.
 		try {
 			if (eventThread.isAlive()) {
@@ -441,6 +445,15 @@
 			}
 		} catch (InterruptedException e) {
 		}		
+
+		// Flush the queue.
+		queue.clearItems();
+
+		// Tell the observers that the session
+		// is finish, but we can not use the Event Thread.
+		// The Event Thread was  kill above.
+		notifyObservers(new MIGDBExitEvent(0));
+
 	}
 
 	/**
Index: src/org/eclipse/cdt/debug/mi/core/Queue.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/Queue.java,v
retrieving revision 1.6
diff -u -r1.6 Queue.java
--- src/org/eclipse/cdt/debug/mi/core/Queue.java	3 Mar 2003 15:18:30 -0000	1.6
+++ src/org/eclipse/cdt/debug/mi/core/Queue.java	22 Apr 2003 20:55:17 -0000
@@ -61,6 +61,14 @@
 		return array;
 	}
 
+	public boolean isEmpty() {
+		boolean empty;
+		synchronized (list) {
+			empty = list.isEmpty();
+		}
+		return empty;
+	}
+
 //	private static void print(String msg) {
 //		String name = Thread.currentThread().getName();
 //		System.out.println(name + ": " + msg);
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java,v
retrieving revision 1.10
diff -u -r1.10 Target.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java	17 Apr 2003 20:40:09 -0000	1.10
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java	22 Apr 2003 20:55:17 -0000
@@ -486,12 +486,6 @@
 		MISession mi = session.getMISession();
 		try {
 			mi.getMIInferior().interrupt();
-			for (int i = 0; isRunning() && i < 5; i++) {
-				try {
-					java.lang.Thread.sleep(2000);
-				} catch (InterruptedException e) {
-				}
-			}
 			if (isRunning()) {
 				throw new CDIException("Unable to suspend target");
 			}



Back to the top