Author: martin
Date: 2006-05-31 08:37:06 -0400 (Wed, 31 May 2006)
New Revision: 61316

Modified:
   trunk/debugger/ChangeLog
   trunk/debugger/backends/SingleSteppingEngine.cs
   trunk/debugger/classes/Thread.cs
   trunk/debugger/frontend/Command.cs
   trunk/debugger/frontend/Interpreter.cs
Log:
2006-05-31  Martin Baulig  <[EMAIL PROTECTED]>

        * frontend/Command.cs
        (SteppingCommand.DoStep): Return a `CommandResult'.

        * frontend/Interpreter.cs
        (Interpreter.Wait): Added overloaded version which takes a
        `CommandResult'; check for exceptions.

        * backends/SingleSteppingEngine.cs
        (CommandResult): Moved to classes/Thread.cs and made public.

        * classes/Thread.cs (CommandResult): Moved here from
        SingleSteppingEngine.cs and made public.        
        (Thread.StepInstruction): Return a `CommandResult'.
        (Thread.StepNativeInstruction): Likewise.
        (Thread.NextInstruction): Likewise.
        (Thread.StepLine): Likewise.
        (Thread.NextLine): Likewise.
        (Thread.Finish): Likewise.
        (Thread.FinishNative): Likewise.
        (Thread.Continue): Likewise.
        (Thread.FinishNative): Likewise.



Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog    2006-05-31 12:36:02 UTC (rev 61315)
+++ trunk/debugger/ChangeLog    2006-05-31 12:37:06 UTC (rev 61316)
@@ -1,3 +1,27 @@
+2006-05-31  Martin Baulig  <[EMAIL PROTECTED]>
+
+       * frontend/Command.cs
+       (SteppingCommand.DoStep): Return a `CommandResult'.
+
+       * frontend/Interpreter.cs
+       (Interpreter.Wait): Added overloaded version which takes a
+       `CommandResult'; check for exceptions.
+
+       * backends/SingleSteppingEngine.cs
+       (CommandResult): Moved to classes/Thread.cs and made public.
+
+       * classes/Thread.cs (CommandResult): Moved here from
+       SingleSteppingEngine.cs and made public.        
+       (Thread.StepInstruction): Return a `CommandResult'.
+       (Thread.StepNativeInstruction): Likewise.
+       (Thread.NextInstruction): Likewise.
+       (Thread.StepLine): Likewise.
+       (Thread.NextLine): Likewise.
+       (Thread.Finish): Likewise.
+       (Thread.FinishNative): Likewise.
+       (Thread.Continue): Likewise.
+       (Thread.FinishNative): Likewise.
+
 2006-05-30  Martin Baulig  <[EMAIL PROTECTED]>
 
        * backends/server/x86_64-arch.c

Modified: trunk/debugger/backends/SingleSteppingEngine.cs
===================================================================
--- trunk/debugger/backends/SingleSteppingEngine.cs     2006-05-31 12:36:02 UTC 
(rev 61315)
+++ trunk/debugger/backends/SingleSteppingEngine.cs     2006-05-31 12:37:06 UTC 
(rev 61316)
@@ -3495,24 +3495,6 @@
                public string ExceptionMessage;
        }
 
-       internal abstract class CommandResult : DebuggerMarshalByRefObject
-       {
-               public object Result;
-
-               public abstract WaitHandle CompletedEvent {
-                       get;
-               }
-
-               public abstract void Completed ();
-
-               public void Wait ()
-               {
-                       CompletedEvent.WaitOne ();
-                       if (Result is Exception)
-                               throw (Exception) Result;
-               }
-       }
-
        internal class SimpleCommandResult : CommandResult
        {
                ManualResetEvent completed_event = new ManualResetEvent (false);

Modified: trunk/debugger/classes/Thread.cs
===================================================================
--- trunk/debugger/classes/Thread.cs    2006-05-31 12:36:02 UTC (rev 61315)
+++ trunk/debugger/classes/Thread.cs    2006-05-31 12:37:06 UTC (rev 61316)
@@ -244,108 +244,124 @@
                // <summary>
                //   Step one machine instruction, but don't step into 
trampolines.
                // </summary>
-               public void StepInstruction ()
+               public CommandResult StepInstruction ()
                {
                        lock (this) {
                                check_servant ();
                                operation_completed_event.Reset ();
-                               servant.StepInstruction (new StepCommandResult 
(this));
+                               CommandResult result = new StepCommandResult 
(this);
+                               servant.StepInstruction (result);
+                               return result;
                        }
                }
 
                // <summary>
                //   Step one machine instruction, always step into method 
calls.
                // </summary>
-               public void StepNativeInstruction ()
+               public CommandResult StepNativeInstruction ()
                {
                        lock (this) {
                                check_servant ();
                                operation_completed_event.Reset ();
-                               servant.StepNativeInstruction (new 
StepCommandResult (this));
+                               CommandResult result = new StepCommandResult 
(this);
+                               servant.StepNativeInstruction (result);
+                               return result;
                        }
                }
 
                // <summary>
                //   Step one machine instruction, but step over method calls.
                // </summary>
-               public void NextInstruction ()
+               public CommandResult NextInstruction ()
                {
                        lock (this) {
                                check_servant ();
                                operation_completed_event.Reset ();
-                               servant.NextInstruction (new StepCommandResult 
(this));
+                               CommandResult result = new StepCommandResult 
(this);
+                               servant.NextInstruction (result);
+                               return result;
                        }
                }
 
                // <summary>
                //   Step one source line.
                // </summary>
-               public void StepLine ()
+               public CommandResult StepLine ()
                {
                        lock (this) {
                                check_servant ();
                                operation_completed_event.Reset ();
-                               servant.StepLine (new StepCommandResult (this));
+                               CommandResult result = new StepCommandResult 
(this);
+                               servant.StepLine (result);
+                               return result;
                        }
                }
 
                // <summary>
                //   Step one source line, but step over method calls.
                // </summary>
-               public void NextLine ()
+               public CommandResult NextLine ()
                {
                        lock (this) {
                                check_servant ();
                                operation_completed_event.Reset ();
-                               servant.NextLine (new StepCommandResult (this));
+                               CommandResult result = new StepCommandResult 
(this);
+                               servant.NextLine (result);
+                               return result;
                        }
                }
 
                // <summary>
                //   Continue until leaving the current method.
                // </summary>
-               public void Finish ()
+               public CommandResult Finish ()
                {
                        lock (this) {
                                check_servant ();
                                operation_completed_event.Reset ();
-                               servant.Finish (new StepCommandResult (this));
+                               CommandResult result = new StepCommandResult 
(this);
+                               servant.Finish (result);
+                               return result;
                        }
                }
 
                // <summary>
                //   Continue until leaving the current method.
                // </summary>
-               public void FinishNative ()
+               public CommandResult FinishNative ()
                {
                        lock (this) {
                                check_servant ();
                                operation_completed_event.Reset ();
-                               servant.FinishNative (new StepCommandResult 
(this));
+                               CommandResult result = new StepCommandResult 
(this);
+                               servant.FinishNative (result);
+                               return result;
                        }
                }
 
-               public void Continue ()
+               public CommandResult Continue ()
                {
-                       Continue (TargetAddress.Null, false);
+                       return Continue (TargetAddress.Null, false);
                }
 
-               public void Continue (TargetAddress until)
+               public CommandResult Continue (TargetAddress until)
                {
-                       Continue (until, false);
+                       return Continue (until, false);
                }
 
-               public void Continue (bool in_background)
+               public CommandResult Continue (bool in_background)
                {
-                       Continue (TargetAddress.Null, in_background);
+                       return Continue (TargetAddress.Null, in_background);
                }
 
-               public void Continue (TargetAddress until, bool in_background)
+               public CommandResult Continue (TargetAddress until, bool 
in_background)
                {
                        lock (this) {
                                check_servant ();
                                operation_completed_event.Reset ();
+                               CommandResult result = new StepCommandResult 
(this);
                                servant.Continue (until, in_background, new 
StepCommandResult (this));
+                               return result;
                        }
                }
 
@@ -784,4 +800,22 @@
                        Dispose (false);
                }
        }
+
+       public abstract class CommandResult : DebuggerMarshalByRefObject
+       {
+               public object Result;
+
+               public abstract ST.WaitHandle CompletedEvent {
+                       get;
+               }
+
+               public abstract void Completed ();
+
+               public void Wait ()
+               {
+                       CompletedEvent.WaitOne ();
+                       if (Result is Exception)
+                               throw (Exception) Result;
+               }
+       }
 }

Modified: trunk/debugger/frontend/Command.cs
===================================================================
--- trunk/debugger/frontend/Command.cs  2006-05-31 12:36:02 UTC (rev 61315)
+++ trunk/debugger/frontend/Command.cs  2006-05-31 12:37:06 UTC (rev 61316)
@@ -797,21 +797,21 @@
        {
                protected override object DoExecute (ScriptingContext context)
                {
-                       DoStep (context);
+                       CommandResult result = DoStep (context);
                        if (context.Interpreter.IsSynchronous)
-                               context.Interpreter.Wait (CurrentThread);
+                               context.Interpreter.Wait (result);
                        return null;
 
                }
 
-               protected abstract void DoStep (ScriptingContext context);
+               protected abstract CommandResult DoStep (ScriptingContext 
context);
        }
 
        public class ContinueCommand : SteppingCommand, IDocumentableCommand
        {
-               protected override void DoStep (ScriptingContext context)
+               protected override CommandResult DoStep (ScriptingContext 
context)
                {
-                       CurrentThread.Continue ();
+                       return CurrentThread.Continue ();
                }
 
                // IDocumentableCommand
@@ -822,10 +822,10 @@
 
        public class StepCommand : SteppingCommand, IDocumentableCommand
        {
-               protected override void DoStep (ScriptingContext context)
+               protected override CommandResult DoStep (ScriptingContext 
context)
                {
                        context.Interpreter.Style.IsNative = false;
-                       CurrentThread.StepLine ();
+                       return CurrentThread.StepLine ();
                }
 
                // IDocumentableCommand
@@ -836,10 +836,10 @@
 
        public class NextCommand : SteppingCommand, IDocumentableCommand
        {
-               protected override void DoStep (ScriptingContext context)
+               protected override CommandResult DoStep (ScriptingContext 
context)
                {
                        context.Interpreter.Style.IsNative = false;
-                       CurrentThread.NextLine ();
+                       return CurrentThread.NextLine ();
                }
 
                // IDocumentableCommand
@@ -857,13 +857,13 @@
                        set { native = value; }
                }
 
-               protected override void DoStep (ScriptingContext context)
+               protected override CommandResult DoStep (ScriptingContext 
context)
                {
                        context.Interpreter.Style.IsNative = true;
                        if (Native)
-                               CurrentThread.StepNativeInstruction ();
+                               return CurrentThread.StepNativeInstruction ();
                        else
-                               CurrentThread.StepInstruction ();
+                               return CurrentThread.StepInstruction ();
                }
 
                // IDocumentableCommand
@@ -874,10 +874,10 @@
 
        public class NextInstructionCommand : SteppingCommand, 
IDocumentableCommand
        {
-               protected override void DoStep (ScriptingContext context)
+               protected override CommandResult DoStep (ScriptingContext 
context)
                {
                        context.Interpreter.Style.IsNative = true;
-                       CurrentThread.NextInstruction ();
+                       return CurrentThread.NextInstruction ();
                }
 
                // IDocumentableCommand
@@ -895,12 +895,12 @@
                        set { native = value; }
                }
 
-               protected override void DoStep (ScriptingContext context)
+               protected override CommandResult DoStep (ScriptingContext 
context)
                {
                        if (Native)
-                               CurrentThread.FinishNative ();
+                               return CurrentThread.FinishNative ();
                        else
-                               CurrentThread.Finish ();
+                               return CurrentThread.Finish ();
                }
 
                // IDocumentableCommand

Modified: trunk/debugger/frontend/Interpreter.cs
===================================================================
--- trunk/debugger/frontend/Interpreter.cs      2006-05-31 12:36:02 UTC (rev 
61315)
+++ trunk/debugger/frontend/Interpreter.cs      2006-05-31 12:37:06 UTC (rev 
61316)
@@ -410,6 +410,21 @@
                        }
                }
 
+               public void Wait (CommandResult result)
+               {
+                       if (result == null)
+                               return;
+
+                       WaitHandle[] handles = new WaitHandle [2];
+                       handles [0] = interrupt_event;
+                       handles [1] = result.CompletedEvent;
+
+                       WaitHandle.WaitAny (handles);
+
+                       if (result.Result is Exception)
+                               throw (Exception) result.Result;
+               }
+
                public void Wait (Thread thread)
                {
                        if (thread == null)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to