Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-debug-dev] Re: [cdt-patch] MISession terminate patch

Hi Alain,

i've just tried this, but i can still get into a state where the suspend
event is still running by the time the inferior has been destroyed.  

I've managed to isolate a reproducible case for this.  In this case, the
inferior terminates (kill sent out) while the EventManager is in the
middle of the processSuspendedEvent function. 
	EventThread.run()
WorkerThread : 
------------------------------------------------------------------------
-----------------------------------------------------
	notifyObservers()
	EventManager.update()
	EventManager.processSuspendedEvent(..)
	  . updates current target ('info threads/info registers')
	  . gets response from target 
	  . everything is successful so far
	
MIInferior.terminate()
	
. postCommand0 (kill)
	
. inferior process terminates, state set to TERMINATED
	  . tries to update managers
	  . in RegisterManager.update() 
	  . postCommand("-data-list-changed-registers")
	  . fails on the timeout, throws
MIException(Target_not_responding)
	  . exception ignored.
			
I've attached a patch, which throws a MIInferior(Inferior_is_terminated)
exception in the postCommand function if the inferior is destroyed. This
exception is then captured in the
EventManager.processSuspendedEvent(...) function which will return false
(and the event is ignored in the update(...) function). Apologies that
the patch comes in 2 parts - terminate_patch.txt is to be applied on
org.eclipse.cdt.debug.mi.core, and EventManager_patch.txt to be applied
on EventManager.java.

I think this patch reduces the occurence of PR 90089, but doesn't fix
it.

thanks,
Li-Wei
Altera Europe

-----Original Message-----
From: cdt-debug-dev-bounces@xxxxxxxxxxx
[mailto:cdt-debug-dev-bounces@xxxxxxxxxxx] On Behalf Of Alain Magloire
Sent: 05 April 2005 19:15
To: cdt-patch@xxxxxxxxxxx
Cc: cdt-debug-dev@xxxxxxxxxxx
Subject: Re: [cdt-debug-dev] Re: [cdt-patch] MISession terminate patch


Bonjour,

> 
> I'll be happy to submit a patch to you with my proposed fix when it's
> done.
> 

Committed, something to the head.  The patch is attach
could give it a try in your environment.  This for PR 90090
it may also address PR 90089.
Index: MIPluginResources.properties
===================================================================
RCS file: /data1/cvs/repository/eclipse/patches/org.eclipse.cdt.debug.mi.core/MIPluginResources.properties,v
retrieving revision 1.1
diff -u -r1.1 MIPluginResources.properties
--- MIPluginResources.properties	6 Apr 2005 13:12:07 -0000	1.1
+++ MIPluginResources.properties	6 Apr 2005 13:21:18 -0000
@@ -27,4 +27,5 @@
 src.CygwinGDBDebugger.Error_init_shared_lib_options=Error initializing shared library options: 
 src.MIInferior.target_is_suspended=target is suspended
 src.MIInferior.No_session=No MI Session
-src.MIInferior.Failed_to_interrupt=Failed to interrupt
\ No newline at end of file
+src.MIInferior.Failed_to_interrupt=Failed to interrupt
+src.MISession.Session_terminated=Inferior has terminated
\ No newline at end of file
Index: MISession.java
===================================================================
RCS file: /data1/cvs/repository/eclipse/patches/org.eclipse.cdt.debug.mi.core/MISession.java,v
retrieving revision 1.2
diff -u -r1.2 MISession.java
--- MISession.java	1 Apr 2005 10:10:30 -0000	1.2
+++ MISession.java	6 Apr 2005 13:21:18 -0000
@@ -24,6 +24,7 @@
 import org.eclipse.cdt.debug.mi.core.command.MIExecInterrupt;
 import org.eclipse.cdt.debug.mi.core.command.MIGDBExit;
 import org.eclipse.cdt.debug.mi.core.command.MIGDBSet;
+import org.eclipse.cdt.debug.mi.core.command.MIGDBShowExitCode;
 import org.eclipse.cdt.debug.mi.core.command.MIGDBShowPrompt;
 import org.eclipse.cdt.debug.mi.core.command.MIInterpreterExecConsole;
 import org.eclipse.cdt.debug.mi.core.event.MIEvent;
@@ -343,6 +344,13 @@
 			}
 		}
 
+		if (inferior.isTerminated()) {
+			// the only thing that can call postCommand when the inferior is in a TERMINATED
+			// state is MIGDBShowExitCode, for when MIInferior is computing error code.
+			if (!(cmd instanceof MIGDBShowExitCode)) {
+				throw new MIException(MIPlugin.getResourceString("src.MISession.Inferior_Terminated"));
+			}
+		}
 		if (isTerminated()) {
 			throw new MIException(MIPlugin.getResourceString("src.MISession.Session_terminated")); //$NON-NLS-1$
 		}
Index: EventManager.java
===================================================================
RCS file: /data1/cvs/repository/eclipse/patches/org.eclipse.cdt.debug.mi.core/EventManager.java,v
retrieving revision 1.1
diff -u -r1.1 EventManager.java
--- EventManager.java	6 Apr 2005 12:28:13 -0000	1.1
+++ EventManager.java	6 Apr 2005 13:16:20 -0000
@@ -321,7 +321,9 @@
 				srcMgr.update(currentTarget);
 			}
 		} catch (CDIException e) {
-			//System.out.println(e);
+			if (currentTarget.getMISession().getMIInferior().isTerminated()) {
+				return false;
+			}
 		}
 		return true;
 	}

Back to the top