Author: martin
Date: 2007-01-16 13:22:43 -0500 (Tue, 16 Jan 2007)
New Revision: 71160
Modified:
trunk/debugger/ChangeLog
trunk/debugger/frontend/CL.cs
trunk/debugger/frontend/Command.cs
trunk/debugger/frontend/Expression.cs
trunk/debugger/frontend/Interpreter.cs
trunk/debugger/frontend/Main.cs
Log:
2007-01-16 Martin Baulig <[EMAIL PROTECTED]>
* frontend/Interpreter.cs
(Interpreter.CheckLastEvent): New method.
(Interpreter.WaitAll): Correctly implement this.
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2007-01-16 18:20:36 UTC (rev 71159)
+++ trunk/debugger/ChangeLog 2007-01-16 18:22:43 UTC (rev 71160)
@@ -1,5 +1,11 @@
2007-01-16 Martin Baulig <[EMAIL PROTECTED]>
+ * frontend/Interpreter.cs
+ (Interpreter.CheckLastEvent): New method.
+ (Interpreter.WaitAll): Correctly implement this.
+
+2007-01-16 Martin Baulig <[EMAIL PROTECTED]>
+
* classes/Thread.cs (Thread.Flags): Added `AutoRun'.
(Thread.AutoStop): New public method.
Modified: trunk/debugger/frontend/CL.cs
===================================================================
--- trunk/debugger/frontend/CL.cs 2007-01-16 18:20:36 UTC (rev 71159)
+++ trunk/debugger/frontend/CL.cs 2007-01-16 18:22:43 UTC (rev 71160)
@@ -110,7 +110,7 @@
int num_args = args != null ? args.Count : 0;
for (int i = 0; i < num_args; i++){
string arg = (string) args [i];
-
+
if (!arg.StartsWith ("-")){
if (c.Args == null)
c.Args = new ArrayList ();
@@ -131,8 +131,7 @@
if ((attrs != null) && (attrs.Length >
0)) {
PropertyAttribute attr =
(PropertyAttribute) attrs [0];
- if ((pi [j].Name != attr.Name)
&&
- (pi [j].Name !=
attr.ShortName))
+ if ((arg != attr.Name) && (arg
!= attr.ShortName))
continue;
} else if (pi [j].Name.ToLower () !=
arg)
continue;
Modified: trunk/debugger/frontend/Command.cs
===================================================================
--- trunk/debugger/frontend/Command.cs 2007-01-16 18:20:36 UTC (rev 71159)
+++ trunk/debugger/frontend/Command.cs 2007-01-16 18:22:43 UTC (rev 71160)
@@ -807,9 +807,7 @@
WaitHandle.WaitAll (handles);
- TargetEventArgs args = CurrentThread.GetLastTargetEvent
();
- if (args != null)
- context.Interpreter.Style.TargetEvent
(CurrentThread, args);
+ context.Interpreter.CheckLastEvent (CurrentThread);
return null;
}
@@ -822,7 +820,7 @@
public abstract class SteppingCommand : ThreadCommand
{
bool in_background;
- bool wait;
+ bool wait, has_wait;
[Property ("in-background", "bg")]
public bool InBackground {
@@ -832,9 +830,21 @@
public bool Wait {
get { return wait; }
- set { wait = value; }
+ set {
+ has_wait = true;
+ wait = value;
+ }
}
+ protected override bool DoResolveBase (ScriptingContext context)
+ {
+ if (!has_wait) {
+ wait =
context.Interpreter.DebuggerConfiguration.StayInThread;
+ has_wait = true;
+ }
+ return base.DoResolveBase (context);
+ }
+
protected override object DoExecute (ScriptingContext context)
{
Thread thread = CurrentThread;
@@ -842,20 +852,10 @@
if (in_background)
return result;
- Thread ret;
- do {
- ret = context.Interpreter.WaitAll (result);
- if (ret == null)
- return null;
+ Thread ret = context.Interpreter.WaitAll (result, wait);
+ if (ret == null)
+ return null;
- TargetEventArgs args = ret.GetLastTargetEvent
();
- if (args != null)
- context.Interpreter.Style.TargetEvent
(ret, args);
-
- if (ret == thread)
- return thread;
- } while (wait && (ret != thread));
-
context.Interpreter.CurrentThread = ret;
return ret;
}
@@ -2834,10 +2834,16 @@
protected override object DoExecute (ScriptingContext context)
{
+ Thread thread = CurrentThread;
if (Invocation)
- CurrentThread.AbortInvocation ();
+ thread.AbortInvocation ();
else
- CurrentThread.Return (true);
+ thread.Return (true);
+
+ TargetEventArgs args = thread.GetLastTargetEvent ();
+ if (args != null)
+ context.Interpreter.Style.TargetEvent (thread,
args);
+
return null;
}
Modified: trunk/debugger/frontend/Expression.cs
===================================================================
--- trunk/debugger/frontend/Expression.cs 2007-01-16 18:20:36 UTC (rev
71159)
+++ trunk/debugger/frontend/Expression.cs 2007-01-16 18:22:43 UTC (rev
71160)
@@ -2777,6 +2777,9 @@
context.Interpreter.Wait (result);
+ if (debug)
+ context.Interpreter.CheckLastEvent
(thread);
+
if (result.ExceptionMessage != null)
throw new ScriptingException (
"Invocation of `{0}' raised an
exception: {1}",
Modified: trunk/debugger/frontend/Interpreter.cs
===================================================================
--- trunk/debugger/frontend/Interpreter.cs 2007-01-16 18:20:36 UTC (rev
71159)
+++ trunk/debugger/frontend/Interpreter.cs 2007-01-16 18:22:43 UTC (rev
71160)
@@ -99,6 +99,10 @@
}
}
+ public DebuggerConfiguration DebuggerConfiguration {
+ get { return config; }
+ }
+
public DebuggerEngine DebuggerEngine {
get { return engine; }
}
@@ -294,8 +298,18 @@
}
}
- public Process Start ()
+ public void CheckLastEvent (Thread thread)
{
+ TargetEventArgs args = thread.GetLastTargetEvent ();
+ if (args == null)
+ return;
+
+ if ((args.Type == TargetEventType.TargetStopped) &&
((int) args.Data == 0))
+ Style.TargetEvent (current_thread, args);
+ }
+
+ public virtual Process Start ()
+ {
if ((debugger != null) || (main_process != null))
throw new TargetException
(TargetError.AlreadyHaveTarget);
@@ -313,6 +327,8 @@
current_thread = current_process.MainThread;
Wait (current_thread);
+ CheckLastEvent (current_thread);
+
// FIXME: Read the FIXME in DebuggerSession.cs !
session.MainProcessReachedMain
(current_process);
@@ -341,6 +357,8 @@
current_process = main_process =
debugger.Attach (session, pid);
current_thread = current_process.MainThread;
Wait (current_thread);
+ CheckLastEvent (current_thread);
+
session.MainProcessReachedMain
(current_process);
return current_process;
@@ -370,6 +388,8 @@
current_thread = current_process.MainThread;
+ CheckLastEvent (current_thread);
+
return current_process;
} catch (TargetException) {
debugger.Dispose ();
@@ -401,6 +421,8 @@
Wait (current_thread);
session.MainProcessReachedMain
(current_process);
+ CheckLastEvent (current_thread);
+
return current_process;
} catch (TargetException ex) {
Console.WriteLine ("FUCK: {0}", ex);
@@ -439,36 +461,66 @@
return true;
}
- public Thread WaitAll (ThreadCommandResult result)
+ public Thread WaitAll (ThreadCommandResult result, bool wait)
{
if (result == null)
return null;
ClearInterrupt ();
- ArrayList list = new ArrayList ();
+
+ Thread stopped;
+ do {
+ ArrayList list = new ArrayList ();
+ foreach (Process process in Processes) {
+ foreach (Thread thread in
process.GetThreads ()) {
+ if (thread.IsRunning)
+ list.Add (thread);
+ else if ((thread.ThreadFlags &
Thread.Flags.AutoRun) != 0) {
+ thread.Continue ();
+ list.Add (thread);
+ }
+ }
+ }
+
+ WaitHandle[] handles = new WaitHandle
[list.Count + 1];
+ handles [0] = interrupt_event;
+ for (int i = 0; i < list.Count; i++)
+ handles [i + 1] = ((Thread) list
[i]).WaitHandle;
+
+ int ret = WaitHandle.WaitAny (handles);
+
+ if (ret == 0) {
+ stopped = null;
+ result.Abort ();
+ result.CompletedEvent.WaitOne ();
+ break;
+ }
+
+ if (result.Result is Exception)
+ throw (Exception) result.Result;
+
+ stopped = (Thread) list [ret - 1];
+
+ CheckLastEvent (stopped);
+ } while (wait && (stopped != null) && (stopped !=
result.Thread));
+
foreach (Process process in Processes) {
foreach (Thread thread in process.GetThreads
()) {
- if (thread.IsRunning)
- list.Add (thread);
+ if (thread == stopped)
+ continue;
+ // Never touch immutable threads.
+ if ((thread.ThreadFlags &
Thread.Flags.Immutable) != 0)
+ continue;
+ // Background thread -> keep running.
+ if ((thread.ThreadFlags &
Thread.Flags.Background) != 0)
+ continue;
+
+ // Stop and set AutoRun.
+ thread.AutoStop ();
}
}
- WaitHandle[] handles = new WaitHandle [list.Count + 1];
- handles [0] = interrupt_event;
- for (int i = 0; i < list.Count; i++)
- handles [i + 1] = ((Thread) list
[i]).WaitHandle;
- int ret = WaitHandle.WaitAny (handles);
-
- if (ret == 0) {
- result.Abort ();
- result.CompletedEvent.WaitOne ();
- return null;
- }
-
- if (result.Result is Exception)
- throw (Exception) result.Result;
-
- return (Thread) list [ret - 1];
+ return stopped;
}
protected void Wait (Thread thread)
@@ -573,6 +625,10 @@
protected virtual void OnTargetEvent (Thread thread,
TargetEventArgs args)
{
+ if ((args.Type != TargetEventType.TargetStopped) ||
((int) args.Data != 0))
+ Style.TargetEvent (thread, args);
+ else if ((thread.ThreadFlags & Thread.Flags.Background)
!= 0)
+ Style.TargetEvent (thread, args);
}
protected virtual void OnTargetOutput (bool is_stderr, string
line)
Modified: trunk/debugger/frontend/Main.cs
===================================================================
--- trunk/debugger/frontend/Main.cs 2007-01-16 18:20:36 UTC (rev 71159)
+++ trunk/debugger/frontend/Main.cs 2007-01-16 18:22:43 UTC (rev 71160)
@@ -54,18 +54,6 @@
string s;
bool is_complete = true;
- if (interpreter.HasTarget) {
- foreach (Process process in
interpreter.Processes) {
- foreach (Thread thread in
process.GetThreads ()) {
- if (!thread.WaitHandle.WaitOne
(0, false))
- continue;
- TargetEventArgs args =
thread.GetLastTargetEvent ();
- if (args != null)
-
interpreter.Style.TargetEvent (thread, args);
- }
- }
- }
-
parser.Reset ();
while ((s = ReadInput (is_complete)) != null) {
parser.Append (s);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches