[Mono-patches] r134418 - in branches/mono-2-4-1/debugger: . backend backend/arch classes

Martin Baulig mono-patches-list at lists.ximian.com
Tue May 19 14:13:12 EDT 2009


Author: martin
Date: 2009-05-19 14:13:12 -0400 (Tue, 19 May 2009)
New Revision: 134418

Modified:
   branches/mono-2-4-1/debugger/ChangeLog
   branches/mono-2-4-1/debugger/backend/SingleSteppingEngine.cs
   branches/mono-2-4-1/debugger/backend/ThreadServant.cs
   branches/mono-2-4-1/debugger/backend/arch/CoreFile.cs
   branches/mono-2-4-1/debugger/classes/ExpressionEvaluator.cs
   branches/mono-2-4-1/debugger/classes/TargetException.cs
   branches/mono-2-4-1/debugger/classes/Thread.cs
Log:
Thread.AbortInvocation() now takes a 'long rti_id' argument to only abort this specific invocation.
2009-05-19  Martin Baulig  <martin at ximian.com>

	* classes/Thread.cs
	(Thread.AbortInvocation): Added `long rti_id' argument.

	* backend/SingleSteppingEngine.cs
	(SSE.AbortInvocation): Implemented this using `OperationReturn'.

	* classes/TargetException.cs
	(TargetError): Added `NoInvocation'.

Modified: branches/mono-2-4-1/debugger/ChangeLog
===================================================================
--- branches/mono-2-4-1/debugger/ChangeLog	2009-05-19 18:12:59 UTC (rev 134417)
+++ branches/mono-2-4-1/debugger/ChangeLog	2009-05-19 18:13:12 UTC (rev 134418)
@@ -1,5 +1,16 @@
 2009-05-19  Martin Baulig  <martin at ximian.com>
 
+	* classes/Thread.cs
+	(Thread.AbortInvocation): Added `long rti_id' argument.
+
+	* backend/SingleSteppingEngine.cs
+	(SSE.AbortInvocation): Implemented this using `OperationReturn'.
+
+	* classes/TargetException.cs
+	(TargetError): Added `NoInvocation'.
+
+2009-05-19  Martin Baulig  <martin at ximian.com>
+
 	* backend/Inferior.cs
 	(Inferior.AbortInvoke): Only take `long rti_id' argument; we now
 	abort one specific invocation and don't search on the stack.
@@ -29,12 +40,6 @@
 	(Backtrace.TryUnwind): Improve handling of callback frames; also
 	check `until'.
 
-	* backend/ThreadServant.cs
-	(ThreadServant.AbortInvocation): Removed.
-
-	* classes/Thread.cs
-	(Thread.AbortInvocation): Removed.
-
 2009-05-18  Martin Baulig  <martin at ximian.com>
 
 	* classes/Thread.cs

Modified: branches/mono-2-4-1/debugger/backend/SingleSteppingEngine.cs
===================================================================
--- branches/mono-2-4-1/debugger/backend/SingleSteppingEngine.cs	2009-05-19 18:12:59 UTC (rev 134417)
+++ branches/mono-2-4-1/debugger/backend/SingleSteppingEngine.cs	2009-05-19 18:13:12 UTC (rev 134418)
@@ -1773,7 +1773,7 @@
 				if (mode == ReturnMode.Invocation) {
 					Inferior.CallbackFrame cframe = inferior.GetCallbackFrame (current_frame.StackPointer, false);
 					if (cframe == null)
-						throw new TargetException (TargetError.InvalidReturn, "No invocation found.");
+						throw new TargetException (TargetError.NoInvocation);
 					bt.GetBacktrace (this, inferior, Backtrace.Mode.Native, cframe.StackPointer, -1);
 					for (int i = 0; i < bt.Count; i++) {
 						if (bt.Frames [i].Type == FrameType.Normal)
@@ -1828,6 +1828,63 @@
 			});
 		}
 
+		public override CommandResult AbortInvocation (long rti_id)
+		{
+			return (CommandResult) SendCommand (delegate {
+				if (!engine_stopped) {
+					Report.Debug (DebugFlags.Wait,
+						      "{0} not stopped", this);
+					throw new TargetException (TargetError.NotStopped);
+				}
+
+				if (current_frame == null)
+					throw new TargetException (TargetError.NoStack);
+
+				process.UpdateSymbolTable (inferior);
+
+				if (process.IsManagedApplication)
+					throw new TargetException (TargetError.InvalidReturn, "Not a managed application.");
+
+				Inferior.CallbackFrame cframe = inferior.GetCallbackFrame (current_frame.StackPointer, false);
+
+				bool found = false;
+				foreach (OperationRuntimeInvoke rti in rti_stack) {
+					if (rti.ID == rti_id) {
+						found = true;
+						break;
+					}
+				}
+
+				if (!found) {
+					if ((cframe == null) || (cframe.ID != rti_id))
+						throw new TargetException (TargetError.NoInvocation);
+				} else {
+					if (cframe == null)
+						throw new TargetException (TargetError.InvalidReturn, "No invocation found.");
+					else if (cframe.ID != rti_id)
+						throw new TargetException (TargetError.InvalidReturn,
+									   "Requested to abort invocation {0}, but current invocation has id {1}.",
+									   rti_id, cframe.ID);
+				}
+
+				Backtrace bt = new Backtrace (current_frame);
+
+				bt.GetBacktrace (this, inferior, Backtrace.Mode.Native, cframe.StackPointer, -1);
+				for (int i = 0; i < bt.Count; i++) {
+					if (bt.Frames [i].Type == FrameType.Normal)
+						continue;
+					else if ((bt.Frames [i].Type == FrameType.RuntimeInvoke) && (i + 1 == bt.Count))
+						break;
+					throw new TargetException (TargetError.InvalidReturn, "Cannot abort an invocation which contains non-managed frames.");
+				}
+
+				if (bt.Count < 2)
+					throw new TargetException (TargetError.NoStack);
+
+				return StartOperation (new OperationReturn (this, bt, ReturnMode.Invocation));
+			});
+		}
+
 		public override Backtrace GetBacktrace (Backtrace.Mode mode, int max_frames)
 		{
 			return (Backtrace) SendCommand (delegate {
@@ -3715,6 +3772,7 @@
 			if (helper != null)
 				throw new InternalError ("{0} rti already has a helper operation", sse);
 			helper = new OperationRuntimeInvokeHelper (sse, this);
+			Result.ID = helper.ID;
 			sse.PushOperation (helper);
 		}
 

Modified: branches/mono-2-4-1/debugger/backend/ThreadServant.cs
===================================================================
--- branches/mono-2-4-1/debugger/backend/ThreadServant.cs	2009-05-19 18:12:59 UTC (rev 134417)
+++ branches/mono-2-4-1/debugger/backend/ThreadServant.cs	2009-05-19 18:13:12 UTC (rev 134418)
@@ -247,6 +247,8 @@
 
 		public abstract CommandResult Return (ReturnMode mode);
 
+		public abstract CommandResult AbortInvocation (long ID);
+
 		public string PrintRegisters (StackFrame frame)
 		{
 			return Architecture.PrintRegisters (frame);

Modified: branches/mono-2-4-1/debugger/backend/arch/CoreFile.cs
===================================================================
--- branches/mono-2-4-1/debugger/backend/arch/CoreFile.cs	2009-05-19 18:12:59 UTC (rev 134417)
+++ branches/mono-2-4-1/debugger/backend/arch/CoreFile.cs	2009-05-19 18:13:12 UTC (rev 134418)
@@ -611,6 +611,11 @@
 				throw new InvalidOperationException ();
 			}
 
+			public override CommandResult AbortInvocation (long ID)
+			{
+				throw new InvalidOperationException ();
+			}
+
 			protected class CoreFileTargetAccess : TargetMemoryAccess
 			{
 				public readonly CoreFileThread Thread;

Modified: branches/mono-2-4-1/debugger/classes/ExpressionEvaluator.cs
===================================================================
--- branches/mono-2-4-1/debugger/classes/ExpressionEvaluator.cs	2009-05-19 18:12:59 UTC (rev 134417)
+++ branches/mono-2-4-1/debugger/classes/ExpressionEvaluator.cs	2009-05-19 18:13:12 UTC (rev 134418)
@@ -82,7 +82,7 @@
 					if (!rti.CompletedEvent.WaitOne (timeout, false)) {
 						rti.Abort ();
 						rti.CompletedEvent.WaitOne ();
-						thread.AbortInvocation ();
+						thread.AbortInvocation (rti.ID);
 						return EvaluationResult.Timeout;
 					}
 
@@ -95,7 +95,7 @@
 						result = rti.ExceptionMessage;
 						return EvaluationResult.Exception;
 					} else if (rti.ReturnObject == null) {
-						thread.AbortInvocation ();
+						thread.AbortInvocation (rti.ID);
 						return EvaluationResult.UnknownError;
 					}
 				} catch (TargetException ex) {
@@ -134,7 +134,7 @@
 				if (!rti.CompletedEvent.WaitOne (timeout, false)) {
 					rti.Abort ();
 					rti.CompletedEvent.WaitOne ();
-					thread.AbortInvocation ();
+					thread.AbortInvocation (rti.ID);
 					result = null;
 					return EvaluationResult.Timeout;
 				}
@@ -151,7 +151,7 @@
 					error = rti.ExceptionMessage;
 					return EvaluationResult.Exception;
 				} else if (rti.ReturnObject == null) {
-					thread.AbortInvocation ();
+					thread.AbortInvocation (rti.ID);
 					return EvaluationResult.UnknownError;
 				}
 

Modified: branches/mono-2-4-1/debugger/classes/TargetException.cs
===================================================================
--- branches/mono-2-4-1/debugger/classes/TargetException.cs	2009-05-19 18:12:59 UTC (rev 134417)
+++ branches/mono-2-4-1/debugger/classes/TargetException.cs	2009-05-19 18:13:12 UTC (rev 134418)
@@ -33,7 +33,8 @@
 		InvocationException,
 		LocationInvalid,
 		CannotDetach,
-		InvalidReturn
+		InvalidReturn,
+		NoInvocation
 	}
 	#endregion
 
@@ -109,6 +110,8 @@
 					"attach to it.";
 			case TargetError.InvalidReturn:
 				return "Cannot return from this kind of stack frame.";
+			case TargetError.NoInvocation:
+				return "No invocation found.";
 			default:
 				return "Unknown error";
 			}

Modified: branches/mono-2-4-1/debugger/classes/Thread.cs
===================================================================
--- branches/mono-2-4-1/debugger/classes/Thread.cs	2009-05-19 18:12:59 UTC (rev 134417)
+++ branches/mono-2-4-1/debugger/classes/Thread.cs	2009-05-19 18:13:12 UTC (rev 134418)
@@ -658,10 +658,25 @@
 			result.Wait ();
 		}
 
-		[Obsolete("FUCK")]
-		public void AbortInvocation ()
+		public bool AbortInvocation (long rti_id)
 		{
-			throw new InternalError ();
+			CommandResult result;
+
+			lock (this) {
+				check_alive ();
+				try {
+					result = servant.AbortInvocation (rti_id);
+				} catch (TargetException ex) {
+					if (ex.Type == TargetError.NoInvocation)
+						return false;
+					throw;
+				}
+				if (result == null)
+					return false;
+			}
+
+			result.Wait ();
+			return true;
 		}
 
 		public string PrintRegisters (StackFrame frame)
@@ -922,6 +937,7 @@
 			thread.Stop ();
 		}
 
+		public long ID;
 		public bool InvocationCompleted;
 		public TargetObject ReturnObject;
 		public string ExceptionMessage;



More information about the Mono-patches mailing list