Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

2008-10-03 Lluis Sanchez Gual <lluis@novell.com>

	* classes/GUIManager.cs: Revert my changes.
	

svn path=/branches/mono-2-0/debugger/; revision=112151
  • Loading branch information...
commit 38c45a7776f4cfad34aad6f6cee57dc2e777e75f 1 parent 777a7f3
@slluis slluis authored
Showing with 44 additions and 73 deletions.
  1. +4 −0 ChangeLog
  2. +40 −73 classes/GUIManager.cs
View
4 ChangeLog
@@ -1,3 +1,7 @@
+2008-10-03 Lluis Sanchez Gual <lluis@novell.com>
+
+ * classes/GUIManager.cs: Revert my changes.
+
2008-08-19 Martin Baulig <martin@ximian.com>
* backend/ThreadManager.cs: Fixed a hard to find race condition.
View
113 classes/GUIManager.cs
@@ -25,20 +25,10 @@ internal GUIManager (Process process)
ST.Thread manager_thread;
ST.AutoResetEvent manager_event;
Queue<Event> event_queue;
-
- object stopLock = new object ();
- List<Thread> stoppedList;
- bool stopping;
-
- BreakpointHitHandler breakpointHitHandler;
+ bool break_mode;
public event TargetEventHandler TargetEvent;
-
- public BreakpointHitHandler BreakpointHitHandler {
- get { return breakpointHitHandler; }
- set { breakpointHitHandler = value; }
- }
public void StartGUIManager ()
{
@@ -52,51 +42,28 @@ internal void OnTargetEvent (SingleSteppingEngine sse, TargetEventArgs args)
{
switch (args.Type){
case TargetEventType.TargetHitBreakpoint:
- case TargetEventType.Exception:
case TargetEventType.TargetStopped:
- case TargetEventType.TargetInterrupted:
- case TargetEventType.TargetSignaled:
case TargetEventType.UnhandledException:
+ case TargetEventType.Exception:
handle_autostop_event (sse, args);
break;
- case TargetEventType.TargetExited:
- case TargetEventType.FrameChanged:
- // Ignore
+ case TargetEventType.TargetInterrupted:
+ if (!break_mode) {
+ args = new TargetEventArgs (TargetEventType.TargetStopped, 0);
+ handle_autostop_event (sse, args);
+ }
+ break;
+
+ default:
+ SendTargetEvent (sse.Thread, args);
break;
}
}
void handle_autostop_event (SingleSteppingEngine sse, TargetEventArgs args)
{
- bool stopRequested = true;
-
- // Always run the breakpoint handler for breakpoint hits,
- // even when the debugger is already stopping
- if ((args.Type == TargetEventType.TargetHitBreakpoint || args.Type == TargetEventType.Exception) && breakpointHitHandler != null)
- stopRequested = breakpointHitHandler (args);
-
- lock (stopLock) {
-
- // If the debugger is already being stopped, make sure this event doesn't
- // reach the GUI.
- if (stopping) {
- if (!stoppedList.Contains (sse.Thread)) {
- stoppedList.Add (sse.Thread);
- ST.Monitor.Pulse (stopLock);
- }
- return;
- }
-
- // If the thread doesn't need to be stopped, resume it here
- if (!stopRequested) {
- Continue (sse.Thread);
- return;
- }
-
- stopping = true;
- stoppedList = new List<Thread> ();
- }
+ break_mode = true;
List<Thread> stopped = new List<Thread> ();
@@ -118,12 +85,15 @@ void handle_autostop_event (SingleSteppingEngine sse, TargetEventArgs args)
stopped.Add (thread);
}
- QueueEvent (new StopEvent {
- Manager = this, Thread = sse.Client, Args = args,
- Stopped = stopped
- });
+ lock (event_queue) {
+ event_queue.Enqueue (new StoppingEvent {
+ Manager = this, Thread = sse.Client, Args = args,
+ Stopped = stopped
+ });
+ manager_event.Set ();
+ }
}
-
+
internal void SendTargetEvent (Thread thread, TargetEventArgs args)
{
try {
@@ -135,24 +105,17 @@ internal void SendTargetEvent (Thread thread, TargetEventArgs args)
}
}
- protected void ProcessStopEvent (StopEvent e)
+ protected void ProcessStoppingEvent (StoppingEvent e)
{
- // Wait until all threads have reported a stop event.
- // Waiting on the wait handle is not enough since
- // events are fired asynchronously, so they might come
- // after the wait handle is signaled
-
- lock (stopLock) {
- while (stoppedList.Count != e.Stopped.Count) {
- ST.Monitor.Wait (stopLock);
- }
- stoppedList = null;
- stopping = false;
- }
+ List<ST.WaitHandle> wait_list = new List<ST.WaitHandle> ();
+ foreach (Thread thread in e.Stopped)
+ wait_list.Add (thread.WaitHandle);
+
+ ST.WaitHandle.WaitAll (wait_list.ToArray ());
SendTargetEvent (e.Thread, e.Args);
}
-
+
protected void QueueEvent (Event e)
{
lock (event_queue) {
@@ -160,10 +123,10 @@ protected void QueueEvent (Event e)
manager_event.Set ();
}
}
-
- public void Break (Thread thread)
+
+ public void Stop (Thread thread)
{
- QueueEvent (new BreakEvent { Manager = this, Thread = thread });
+ QueueEvent (new StopEvent { Manager = this, Thread = thread });
}
public void Continue (Thread thread)
@@ -188,6 +151,7 @@ public void StepOut (Thread thread)
void ProcessRunEvent (RunEvent e)
{
+ break_mode = false;
Thread[] threads = Process.GetThreads ();
foreach (Thread t in threads) {
if (t == e.Thread)
@@ -224,7 +188,7 @@ protected abstract class Event
public abstract void ProcessEvent ();
}
- protected class StopEvent : Event
+ protected class StoppingEvent : Event
{
public Thread Thread {
get; set;
@@ -240,10 +204,11 @@ protected class StopEvent : Event
public override void ProcessEvent ()
{
- Manager.ProcessStopEvent (this);
+ Manager.ProcessStoppingEvent (this);
}
}
+
protected abstract class RunEvent : Event
{
public Thread Thread {
@@ -291,14 +256,16 @@ protected override void DoRun ()
}
}
- protected class BreakEvent : RunEvent
+ protected class StopEvent : Event
{
- protected override void DoRun ()
+ public Thread Thread {
+ get; set;
+ }
+
+ public override void ProcessEvent ()
{
Thread.ThreadServant.Stop ();
}
}
}
-
- public delegate bool BreakpointHitHandler (TargetEventArgs args);
}
Please sign in to comment.
Something went wrong with that request. Please try again.