4
// Alfonso Santos Luaces <asantosluaces@gmail.com>
5
// Lluis Sanchez Gual <lluis@novell.com>
7
// Copyright (c) 2008 Alfonso Santos Luaces
8
// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
10
// Permission is hereby granted, free of charge, to any person obtaining a copy
11
// of this software and associated documentation files (the "Software"), to deal
12
// in the Software without restriction, including without limitation the rights
13
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
// copies of the Software, and to permit persons to whom the Software is
15
// furnished to do so, subject to the following conditions:
17
// The above copyright notice and this permission notice shall be included in
18
// all copies or substantial portions of the Software.
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
36
using System.Collections;
37
using System.Globalization;
38
using System.Runtime.InteropServices;
40
using Stock = MonoDevelop.Core.Gui.Stock;
41
using MonoDevelop.Core;
42
using MonoDevelop.Core.Gui;
43
using MonoDevelop.Ide.Gui;
44
using MonoDevelop.Components;
46
using Mono.Debugging.Client;
49
namespace MonoDevelop.Debugger
51
public class ThreadsPad : Gtk.ScrolledWindow, IPadContent
56
TreeViewState treeViewState;
70
this.ShadowType = ShadowType.In;
72
store = new TreeStore (typeof(string), typeof (string), typeof(string), typeof(object), typeof(int), typeof(string));
74
tree = new TreeView (store);
75
tree.RulesHint = true;
76
tree.HeadersVisible = true;
77
treeViewState = new TreeViewState (tree, (int)Columns.Object);
79
TreeViewColumn col = new TreeViewColumn ();
80
CellRenderer crp = new CellRendererPixbuf ();
81
col.PackStart (crp, false);
82
col.AddAttribute (crp, "stock_id", (int) Columns.Icon);
83
tree.AppendColumn (col);
85
TreeViewColumn FrameCol = new TreeViewColumn ();
86
CellRendererText frameRenderer = new CellRendererText ();
87
FrameCol.Title = GettextCatalog.GetString ("Id");
88
FrameCol.PackStart (frameRenderer, true);
89
FrameCol.AddAttribute (frameRenderer, "text", (int) Columns.Id);
90
FrameCol.AddAttribute (frameRenderer, "weight", (int) Columns.Weight);
91
FrameCol.Resizable = true;
92
FrameCol.Alignment = 0.0f;
93
tree.AppendColumn (FrameCol);
95
col = new TreeViewColumn ();
96
col.Title = GettextCatalog.GetString ("Name");
98
CellRenderer crt = new CellRendererText ();
99
col.PackStart (crt, false);
100
col.AddAttribute (crt, "text", (int) Columns.Name);
101
col.AddAttribute (crt, "weight", (int) Columns.Weight);
102
tree.AppendColumn (col);
104
col = new TreeViewColumn ();
105
col.Title = GettextCatalog.GetString ("Location");
106
col.Resizable = true;
107
crt = new CellRendererText ();
108
col.PackStart (crt, false);
109
col.AddAttribute (crt, "text", (int) Columns.Location);
110
col.AddAttribute (crt, "weight", (int) Columns.Weight);
111
tree.AppendColumn (col);
118
tree.RowActivated += OnRowActivated;
119
DebuggingService.CallStackChanged += OnStackChanged;
120
DebuggingService.PausedEvent += OnDebuggerPaused;
121
DebuggingService.ResumedEvent += OnDebuggerResumed;
122
DebuggingService.StoppedEvent += OnDebuggerStopped;
125
public override void Dispose ()
128
DebuggingService.CallStackChanged -= OnStackChanged;
129
DebuggingService.PausedEvent -= OnDebuggerPaused;
130
DebuggingService.ResumedEvent -= OnDebuggerResumed;
131
DebuggingService.StoppedEvent -= OnDebuggerStopped;
134
void OnStackChanged (object s, EventArgs a)
139
void IPadContent.Initialize (IPadWindow window)
141
window.Title = "Threads List";
142
window.Icon = Stock.OutputIcon;
145
public void UpdateDisplay ()
147
treeViewState.Save ();
151
if (DebuggingService.DebuggerSession == null)
154
ProcessInfo[] currentProcesses = DebuggingService.DebuggerSession.GetPocesses ();
156
if (currentProcesses.Length == 1) {
157
AppendThreads (TreeIter.Zero, currentProcesses [0]);
160
foreach (ProcessInfo p in currentProcesses) {
161
TreeIter it = store.AppendValues (null, p.Id.ToString (), p.Name, p, (int) Pango.Weight.Normal, "");
162
AppendThreads (it, p);
167
treeViewState.Load ();
170
void AppendThreads (TreeIter it, ProcessInfo p)
172
ThreadInfo[] threads = p.GetThreads ();
173
Array.Sort (threads, delegate (ThreadInfo t1, ThreadInfo t2) {
174
return t1.Id.CompareTo (t2.Id);
176
foreach (ThreadInfo t in threads) {
177
ThreadInfo activeThread = DebuggingService.DebuggerSession.ActiveThread;
178
Pango.Weight wi = t == activeThread ? Pango.Weight.Bold : Pango.Weight.Normal;
179
string icon = t == activeThread ? Gtk.Stock.GoForward : null;
180
if (it.Equals (TreeIter.Zero))
181
store.AppendValues (icon, t.Id.ToString (), t.Name, t, (int) wi, t.Location);
183
store.AppendValues (it, icon, t.Id.ToString (), t.Name, t, (int) wi, t.Location);
187
void OnRowActivated (object s, Gtk.RowActivatedArgs args)
190
tree.Selection.GetSelected (out it);
191
ThreadInfo t = store.GetValue (it, (int)Columns.Object) as ThreadInfo;
193
DebuggingService.ActiveThread = t;
196
public Gtk.Widget Control {
203
get { return "MonoDevelop.Debugger.ThreadsPad"; }
206
public string DefaultPlacement {
207
get { return "Bottom"; }
210
public void RedrawContent ()
215
void OnDebuggerPaused (object s, EventArgs a)
220
void OnDebuggerResumed (object s, EventArgs a)
225
void OnDebuggerStopped (object s, EventArgs a)