[Monodevelop-patches-list] r1996 - in trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn: . Gui
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Sat Oct 23 22:16:32 EDT 2004
Author: toshok
Date: 2004-10-23 22:16:32 -0400 (Sat, 23 Oct 2004)
New Revision: 1996
Added:
trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Gui/DebuggerThreadPad.cs
Modified:
trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/ChangeLog
trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/DebuggingService.cs
Log:
2004-10-23 Chris Toshok <toshok at ximian.com>
* Gui/DebuggerThreadPad.cs: add the current location to stopped
threads.
* DebuggingService.cs: add thread (process) events and generate
thread state change events so the threadpad will update properly.
Modified: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/ChangeLog 2004-10-23 19:50:01 UTC (rev 1995)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/ChangeLog 2004-10-24 02:16:32 UTC (rev 1996)
@@ -1,3 +1,11 @@
+2004-10-23 Chris Toshok <toshok at ximian.com>
+
+ * Gui/DebuggerThreadPad.cs: add the current location to stopped
+ threads.
+
+ * DebuggingService.cs: add thread (process) events and generate
+ thread state change events so the threadpad will update properly.
+
2004-10-22 Chris Toshok <toshok at ximian.com>
* Makefile.am (FILES): add Gui/DebuggerThreadPad.cs
@@ -4,9 +12,6 @@
* MonoDevelopDebugger.addin.xml: add the threadpad xml.
- * DebuggingService.cs: add thread (process) events and generate
- thread state change events so the threadpad will update properly.
-
* Gui/DebuggerThreadPad.cs: new pad, displaying a (for now very
unreactive) thread list.
Modified: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/DebuggingService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/DebuggingService.cs 2004-10-23 19:50:01 UTC (rev 1995)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/DebuggingService.cs 2004-10-24 02:16:32 UTC (rev 1996)
@@ -14,6 +14,7 @@
using MonoDevelop.Gui;
using Mono.Debugger;
+using Mono.Debugger.Languages;
/*
* Some places we should be doing some error handling we used to toss
@@ -26,6 +27,7 @@
public class DebuggingService : AbstractService, IDebuggingService
{
Process proc;
+ Hashtable procs = new Hashtable ();
Hashtable breakpoints = new Hashtable ();
DebuggerBackend backend;
Breakpoint point;
@@ -106,6 +108,25 @@
return true;
}
+ private void thread_created (ThreadManager manager, Process process)
+ {
+ lock (procs) {
+ // process.ProcessExitedEvent += new ProcessExitedHandler (thread_exited);
+ procs.Add (process.ID, process);
+ }
+
+ Gtk.Timeout.Add (1, new Gtk.Function (EmitThreadStateEvent));
+ }
+
+ private void thread_exited (ThreadManager manager, Process process)
+ {
+ lock (procs) {
+ procs.Remove (process.ID);
+ }
+
+ Gtk.Timeout.Add (1, new Gtk.Function (EmitThreadStateEvent));
+ }
+
private void initialized_event (ThreadManager manager, Process process)
{
this.proc = process;
@@ -153,6 +174,14 @@
}
}
+ bool EmitThreadStateEvent ()
+ {
+ if (ThreadStateEvent != null)
+ ThreadStateEvent (this, new EventArgs ());
+
+ return false;
+ }
+
bool EmitStarted ()
{
insert_breakpoints ();
@@ -167,6 +196,8 @@
bool ChangeState ()
{
+ if (ThreadStateEvent != null)
+ ThreadStateEvent (this, new EventArgs ());
if (IsRunning) {
if (ResumedEvent != null) {
ResumedEvent (this, new EventArgs ());
@@ -181,6 +212,7 @@
public event EventHandler ResumedEvent;
public event EventHandler StartedEvent;
public event EventHandler StoppedEvent;
+ public event EventHandler ThreadStateEvent;
bool KillApplication ()
{
@@ -219,6 +251,8 @@
backend = new DebuggerBackend ();
backend.ThreadManager.InitializedEvent += new ThreadEventHandler (initialized_event);
+ backend.ThreadManager.ThreadCreatedEvent += new ThreadEventHandler (thread_created);
+ backend.ThreadManager.ThreadExitedEvent += new ThreadEventHandler (thread_exited);
backend.Run (new ProcessStart (null, argv));
}
@@ -265,6 +299,14 @@
}
}
+ public Process[] Threads {
+ get {
+ Process[] retval = new Process [procs.Count];
+ procs.Values.CopyTo (retval, 0);
+ return retval;
+ }
+ }
+
public object CurrentFrame {
get {
if (IsRunning)
Added: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Gui/DebuggerThreadPad.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Gui/DebuggerThreadPad.cs 2004-10-23 19:50:01 UTC (rev 1995)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Gui/DebuggerThreadPad.cs 2004-10-24 02:16:32 UTC (rev 1996)
@@ -0,0 +1,163 @@
+using GLib;
+using Gtk;
+using GtkSharp;
+using System;
+using System.IO;
+using System.Collections;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using Mono.Debugger;
+using Mono.Debugger.Languages;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+using MonoDevelop.Gui;
+
+namespace MonoDevelop.SourceEditor.Gui
+{
+ public class DebuggerThreadPad : Gtk.ScrolledWindow, IPadContent
+ {
+ Gtk.TreeView tree;
+ Gtk.TreeStore store;
+
+ public DebuggerThreadPad ()
+ {
+ this.ShadowType = ShadowType.In;
+
+ store = new TreeStore (typeof (int),
+ typeof (int),
+ typeof (string),
+ typeof (string));
+
+ tree = new TreeView (store);
+ tree.RulesHint = true;
+ tree.HeadersVisible = true;
+
+ TreeViewColumn Col;
+ CellRenderer ThreadRenderer;
+
+ Col = new TreeViewColumn ();
+ ThreadRenderer = new CellRendererText ();
+ Col.Title = "Id";
+ Col.PackStart (ThreadRenderer, true);
+ Col.AddAttribute (ThreadRenderer, "text", 0);
+ Col.Resizable = true;
+ Col.Alignment = 0.0f;
+ tree.AppendColumn (Col);
+
+ Col = new TreeViewColumn ();
+ ThreadRenderer = new CellRendererText ();
+ Col.Title = "PID";
+ Col.PackStart (ThreadRenderer, true);
+ Col.AddAttribute (ThreadRenderer, "text", 1);
+ Col.Resizable = true;
+ Col.Alignment = 0.0f;
+ tree.AppendColumn (Col);
+
+ Col = new TreeViewColumn ();
+ ThreadRenderer = new CellRendererText ();
+ Col.Title = "State";
+ Col.PackStart (ThreadRenderer, true);
+ Col.AddAttribute (ThreadRenderer, "text", 2);
+ Col.Resizable = true;
+ Col.Alignment = 0.0f;
+ tree.AppendColumn (Col);
+
+ Col = new TreeViewColumn ();
+ ThreadRenderer = new CellRendererText ();
+ Col.Title = "Current Location";
+ Col.PackStart (ThreadRenderer, true);
+ Col.AddAttribute (ThreadRenderer, "text", 3);
+ Col.Resizable = true;
+ Col.Alignment = 0.0f;
+ tree.AppendColumn (Col);
+
+ Add (tree);
+ ShowAll ();
+
+ DebuggingService dbgr = (DebuggingService)ServiceManager.GetService (typeof (DebuggingService));
+ dbgr.ThreadStateEvent += new EventHandler (OnThreadEvent);
+ }
+
+ void add_thread (Process thread)
+ {
+ TreeIter iter;
+ store.Append (out iter);
+ store.SetValue (iter, 0, new GLib.Value (thread.ID));
+ store.SetValue (iter, 1, new GLib.Value (thread.PID));
+ store.SetValue (iter, 2, new GLib.Value (thread.State.ToString()));
+ if (thread.IsStopped)
+ store.SetValue (iter, 3, new GLib.Value (thread.GetBacktrace().Frames[0].SourceAddress.Name));
+ else
+ store.SetValue (iter, 3, new GLib.Value (""));
+ }
+
+ Hashtable iters = null;
+
+ public void CleanDisplay ()
+ {
+ store.Clear ();
+ iters = new Hashtable ();
+ }
+
+ public void UpdateDisplay ()
+ {
+ CleanDisplay ();
+
+ DebuggingService dbgr = (DebuggingService)ServiceManager.GetService (typeof (DebuggingService));
+ Process[] threads = dbgr.Threads;
+
+ foreach (Process t in threads)
+ if (!t.IsDaemon)
+ add_thread (t);
+ }
+
+ protected void OnThreadEvent (object o, EventArgs args)
+ {
+ UpdateDisplay ();
+ }
+
+ public Gtk.Widget Control {
+ get {
+ return this;
+ }
+ }
+
+ public string Title {
+ get {
+ return "Threads";
+ }
+ }
+
+ public string Icon {
+ get {
+ return MonoDevelop.Gui.Stock.OutputIcon;
+ }
+ }
+
+ public void RedrawContent ()
+ {
+ UpdateDisplay ();
+ }
+
+ public void BringToFront ()
+ {
+ }
+
+ protected virtual void OnTitleChanged(EventArgs e)
+ {
+ if (TitleChanged != null) {
+ TitleChanged(this, e);
+ }
+ }
+ protected virtual void OnIconChanged(EventArgs e)
+ {
+ if (IconChanged != null) {
+ IconChanged(this, e);
+ }
+ }
+ public event EventHandler TitleChanged;
+ public event EventHandler IconChanged;
+
+ }
+}
More information about the Monodevelop-patches-list
mailing list