Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] MI do not call "info program" for attach sessions

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.125
diff -u -r1.125 ChangeLog
--- ChangeLog	25 Apr 2003 19:35:38 -0000	1.125
+++ ChangeLog	25 Apr 2003 20:40:56 -0000
@@ -1,4 +1,16 @@
+2003-04-25 Alain Magloire
+
+	* src/org/eclipse/cdt/debug/mi/core/EventManager.java (update):
+	Remove the call to MIInferior.update(), wrong place.
+	* src/org/eclipse/cdt/debug/mi/core/EventThread.java (run):
+	Call MIInferior.update() when suspended.
+	* src/org/eclipse/cdt/debug/mi/core/MIInferior.java (update):
+	Do not do the call to "info program" for type "attached" sessions.
+	* src/org/eclipse/cdt/debug/mi/core/MISession.java (terminate):
+	When terminate() is call disable posting commands to the queue etc...
+
 2003-04-25 Mikhail Khodjaiants
+
 	Fix for bug 36909.
 	* MIFrame.java: 
 	gdb returns "??" as a function name if symbols are not available.
Index: src/org/eclipse/cdt/debug/mi/core/EventThread.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/EventThread.java,v
retrieving revision 1.4
diff -u -r1.4 EventThread.java
--- src/org/eclipse/cdt/debug/mi/core/EventThread.java	9 Oct 2002 14:08:42 -0000	1.4
+++ src/org/eclipse/cdt/debug/mi/core/EventThread.java	25 Apr 2003 20:40:56 -0000
@@ -6,6 +6,7 @@
 package org.eclipse.cdt.debug.mi.core;
 
 import org.eclipse.cdt.debug.mi.core.event.MIEvent;
+import org.eclipse.cdt.debug.mi.core.event.MIStoppedEvent;
 
 /**
  * Event Thread blocks on the event Queue, wakes up
@@ -31,6 +32,9 @@
 			} catch (InterruptedException e) {
 				//e.printStackTrace();
 			}
+			if (event instanceof MIStoppedEvent) {
+				processSuspendedEvent((MIStoppedEvent)event);
+			}
 			try {
 				if (event != null) {
 					session.notifyObservers(event);
@@ -40,4 +44,11 @@
 			}
 		}
 	}
+
+	void processSuspendedEvent(MIStoppedEvent stopped) {
+		// give a chance also to the underlying inferior.
+		session.getMIInferior().update();
+
+	}
+
 }
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.28
diff -u -r1.28 MIInferior.java
--- src/org/eclipse/cdt/debug/mi/core/MIInferior.java	24 Apr 2003 15:21:10 -0000	1.28
+++ src/org/eclipse/cdt/debug/mi/core/MIInferior.java	25 Apr 2003 20:40:56 -0000
@@ -191,7 +191,7 @@
 				} catch (InterruptedException e) {
 				}
 			}
-			if (isRunning() && inferiorPid != 0) {
+			if (isRunning() && inferiorPid > 0) {
 				// lets try something else.
 				gdbSpawner.raise(inferiorPid, gdbSpawner.INT);
 			}
@@ -275,7 +275,7 @@
 		if (pty != null) {
 			if (in != null) {
 				try {
-						in.close();
+					in.close();
 				} catch (IOException e) {
 					//e.printStackTrace();
 				}
@@ -310,15 +310,22 @@
 
 	public void update() {
 		if (inferiorPid == 0) {
-			// Try to discover the pid
-			CommandFactory factory = session.getCommandFactory();
-			MIInfoProgram prog = factory.createMIInfoProgram();
-			try {
-				session.postCommand(prog);
-				MIInfoProgramInfo info = prog.getMIInfoProgramInfo();
-				inferiorPid = info.getPID();
-			} catch (MIException e) {
-				// no rethrown.
+			// Do not try this on attach session.
+			if (!isConnected()) {
+				// Try to discover the pid
+				CommandFactory factory = session.getCommandFactory();
+				MIInfoProgram prog = factory.createMIInfoProgram();
+				try {
+					session.postCommand(prog);
+					MIInfoProgramInfo info = prog.getMIInfoProgramInfo();
+					inferiorPid = info.getPID();
+				} catch (MIException e) {
+					// no rethrown.
+				}
+			}
+			// We fail permantely.
+			if (inferiorPid == 0) {
+				inferiorPid = -1;
 			}
 		}
 	}
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.42
diff -u -r1.42 MISession.java
--- src/org/eclipse/cdt/debug/mi/core/MISession.java	22 Apr 2003 20:56:34 -0000	1.42
+++ src/org/eclipse/cdt/debug/mi/core/MISession.java	25 Apr 2003 20:40:56 -0000
@@ -275,9 +275,6 @@
 	 */
 	public synchronized void postCommand(Command cmd, long timeout) throws MIException {
 
-		// TRACING: print the command;
-		MIPlugin.getDefault().debugLog(cmd.toString());
-
 		// Test if we are in a sane state.
 		if (!txThread.isAlive() || !rxThread.isAlive()) {
 			throw new MIException("{R,T}xThread terminated");
@@ -288,9 +285,17 @@
 			// REMINDER: if we support -exec-interrupt
 			// Let it throught:
 			// if (cmd instanceof MIExecInterrupt) { }
+			// else
 			throw new MIException("Target is not suspended");
 		}
 
+		if (isTerminated()) {
+			throw new MIException("Session terminated");
+		}
+
+		// TRACING: print the command;
+		MIPlugin.getDefault().debugLog(cmd.toString());
+
 		txQueue.addCommand(cmd);
 
 		// Wait for the response or timedout
@@ -364,11 +369,20 @@
 		OutputStream outGDB = outChannel;
 		outChannel = null;
 
+		// Although we will close the pipe().  It is cleaner
+		// to give a chance to gdb to cleanup.
 		// send the exit(-gdb-exit).
-		try {
-			MIGDBExit exit = factory.createMIGDBExit();
-			postCommand(exit);
-		} catch (MIException e) {
+		MIGDBExit exit = factory.createMIGDBExit();
+		txQueue.addCommand(exit);
+
+		// Wait for the response
+		synchronized (exit) {
+			// RxThread will set the MIOutput on the cmd
+			// when the response arrive.
+			try {
+				exit.wait(2000);
+			} catch (InterruptedException e) {
+			}
 		}
 		
 		// Make sure gdb is killed.
@@ -446,14 +460,8 @@
 		} 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.
+		// Tell the observers that the session is terminated
 		notifyObservers(new MIGDBExitEvent(0));
-
 	}
 
 	/**
Index: src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java,v
retrieving revision 1.39
diff -u -r1.39 EventManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java	24 Apr 2003 15:20:10 -0000	1.39
+++ src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java	25 Apr 2003 20:40:56 -0000
@@ -24,7 +24,6 @@
 import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
 import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
 import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
-import org.eclipse.cdt.debug.mi.core.MISession;
 import org.eclipse.cdt.debug.mi.core.cdi.event.ChangedEvent;
 import org.eclipse.cdt.debug.mi.core.cdi.event.CreatedEvent;
 import org.eclipse.cdt.debug.mi.core.cdi.event.DestroyedEvent;
@@ -282,9 +281,6 @@
 			if (srcMgr.isAutoUpdate()) {
 				srcMgr.update();
 			}
-			// give a chance also to the underlying inferior.
-			MISession mi = session.getMISession();
-			mi.getMIInferior().update();
 		} catch (CDIException e) {
 			//System.out.println(e);
 		}



Back to the top