Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kestner <mkestner@gmail.com>2009-09-04 00:54:22 +0400
committerMike Kestner <mkestner@gmail.com>2009-09-04 00:54:22 +0400
commit8504766756a339199c570063a330f411bd3a4b57 (patch)
tree4c48c9f9b8c2bdae799868d5abe380440555fd1b
parent980171b54149f39413a9caeb7673463f7699a2a7 (diff)
2009-09-03 Mike Kestner <mkestner@novell.com>
* History.cs: add recent config support. * ProfileConfiguration.cs: new encapsulation for profile params. * ProfilerProcess.cs: construct from ProfileConfiguation. * ProfileSetupDialog.cs: expose Config prop. Manage the Execute response button sensitivity proactively. 2009-09-03 Mike Kestner <mkestner@novell.com> * MainWindow.cs : refactor for ProfileConfiguration. Add recent configs to history. svn path=/trunk/mono-tools/; revision=141284
-rw-r--r--Mono.Profiler/Mono.Profiler.Widgets/ChangeLog8
-rw-r--r--Mono.Profiler/Mono.Profiler.Widgets/History.cs52
-rw-r--r--Mono.Profiler/Mono.Profiler.Widgets/Makefile.am1
-rw-r--r--Mono.Profiler/Mono.Profiler.Widgets/ProfileConfiguration.cs108
-rw-r--r--Mono.Profiler/Mono.Profiler.Widgets/ProfileSetupDialog.cs61
-rw-r--r--Mono.Profiler/Mono.Profiler.Widgets/ProfilerProcess.cs4
-rw-r--r--Mono.Profiler/mprof-gui/ChangeLog5
-rw-r--r--Mono.Profiler/mprof-gui/MainWindow.cs10
8 files changed, 196 insertions, 53 deletions
diff --git a/Mono.Profiler/Mono.Profiler.Widgets/ChangeLog b/Mono.Profiler/Mono.Profiler.Widgets/ChangeLog
index 7de3194d..3632b657 100644
--- a/Mono.Profiler/Mono.Profiler.Widgets/ChangeLog
+++ b/Mono.Profiler/Mono.Profiler.Widgets/ChangeLog
@@ -1,3 +1,11 @@
+2009-09-03 Mike Kestner <mkestner@novell.com>
+
+ * History.cs: add recent config support.
+ * ProfileConfiguration.cs: new encapsulation for profile params.
+ * ProfilerProcess.cs: construct from ProfileConfiguation.
+ * ProfileSetupDialog.cs: expose Config prop. Manage the Execute
+ response button sensitivity proactively.
+
2009-08-28 Mike Kestner <mkestner@novell.com>
* StartPage.cs: a little banner gradient tweaking.
diff --git a/Mono.Profiler/Mono.Profiler.Widgets/History.cs b/Mono.Profiler/Mono.Profiler.Widgets/History.cs
index 469db1ee..0c0de32c 100644
--- a/Mono.Profiler/Mono.Profiler.Widgets/History.cs
+++ b/Mono.Profiler/Mono.Profiler.Widgets/History.cs
@@ -113,9 +113,59 @@ namespace Mono.Profiler.Widgets {
}
}
+ public class ProfileConfigList : IEnumerable {
+
+ int max_items = 5;
+ List<ProfileConfiguration> list = new List<ProfileConfiguration> ();
+
+ public int Count {
+ get { return list.Count; }
+ }
+
+ public ProfileConfiguration this [int index] {
+ get { return list [index]; }
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return list.GetEnumerator ();
+ }
+
+ public event EventHandler Changed;
+
+ void OnChanged ()
+ {
+ if (Changed != null)
+ Changed (this, EventArgs.Empty);
+ }
+
+ // Used by XmlSerializer
+ public void Add (object obj)
+ {
+ ProfileConfiguration config = obj as ProfileConfiguration;
+ if (config != null) {
+ list.Add (config);
+ OnChanged ();
+ }
+ }
+
+ public void Prepend (ProfileConfiguration config)
+ {
+ list.Remove (config);
+ list.Insert (0, config);
+ while (list.Count > max_items)
+ list.RemoveAt (max_items);
+ OnChanged ();
+ }
+ }
+
public class History {
[XmlArray]
+ [XmlArrayItem (ElementName="ProfileConfiguration", Type=typeof (ProfileConfiguration))]
+ public ProfileConfigList Configs;
+
+ [XmlArray]
[XmlArrayItem (ElementName="LogInfo", Type=typeof (LogInfo))]
public LogInfoList LogFiles;
@@ -123,6 +173,8 @@ namespace Mono.Profiler.Widgets {
{
LogFiles = new LogInfoList ();
LogFiles.Changed += delegate { OnChanged (); };
+ Configs = new ProfileConfigList ();
+ Configs.Changed += delegate { OnChanged (); };
}
public event EventHandler Changed;
diff --git a/Mono.Profiler/Mono.Profiler.Widgets/Makefile.am b/Mono.Profiler/Mono.Profiler.Widgets/Makefile.am
index ea97ac34..7b91e6b0 100644
--- a/Mono.Profiler/Mono.Profiler.Widgets/Makefile.am
+++ b/Mono.Profiler/Mono.Profiler.Widgets/Makefile.am
@@ -22,6 +22,7 @@ FILES = \
DisplayOptions.cs \
History.cs \
Node.cs \
+ ProfileConfiguration.cs \
ProfileSetupDialog.cs \
ProfileStore.cs \
ProfileView.cs \
diff --git a/Mono.Profiler/Mono.Profiler.Widgets/ProfileConfiguration.cs b/Mono.Profiler/Mono.Profiler.Widgets/ProfileConfiguration.cs
new file mode 100644
index 00000000..6712ca21
--- /dev/null
+++ b/Mono.Profiler/Mono.Profiler.Widgets/ProfileConfiguration.cs
@@ -0,0 +1,108 @@
+// Copyright (c) 2009 Novell, Inc. <http://www.novell.com>
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+using System;
+using System.Text;
+using System.Xml.Serialization;
+
+namespace Mono.Profiler.Widgets {
+
+ [Flags]
+ public enum ProfileMode {
+ None = 0,
+ Allocations = 1 << 0,
+ Instrumented = 1 << 1,
+ Statistical = 1 << 2,
+ HeapSummary = 1 << 3,
+ HeapSnaphot = 1 << 4,
+ }
+
+ public class ProfileConfiguration {
+
+ public ProfileConfiguration () {}
+
+ string assembly_path;
+ [XmlAttribute]
+ public string AssemblyPath {
+ get { return assembly_path; }
+ set { assembly_path = value; }
+ }
+
+ ProfileMode mode = ProfileMode.Statistical;
+ [XmlAttribute]
+ public ProfileMode Mode {
+ get { return mode; }
+ set { mode = value; }
+ }
+
+ bool start_enabled = true;
+ [XmlAttribute]
+ public bool StartEnabled {
+ get { return start_enabled; }
+ set { start_enabled = value; }
+ }
+
+ public string ToArgs ()
+ {
+ StringBuilder sb = new StringBuilder ();
+ if ((Mode | ProfileMode.Allocations) != 0)
+ sb.Append ("alloc");
+
+ if ((Mode | ProfileMode.Instrumented) != 0) {
+ if (sb.Length > 0)
+ sb.Append (",");
+ sb.Append ("calls");
+ }
+
+ if ((Mode | ProfileMode.Statistical) != 0) {
+ if (sb.Length > 0)
+ sb.Append (",");
+ sb.Append ("s=128");
+ }
+
+ if (!StartEnabled)
+ sb.Append (",sd");
+
+ return sb.ToString ();
+ }
+
+ public override string ToString ()
+ {
+ return System.IO.Path.GetFileName (AssemblyPath) + ":" + Mode + ", StartEnabled=" + StartEnabled;
+ }
+
+ public override bool Equals (object o)
+ {
+ if (o is ProfileConfiguration) {
+ ProfileConfiguration c = o as ProfileConfiguration;
+ return AssemblyPath == c.AssemblyPath && Mode == c.Mode && StartEnabled == c.StartEnabled;
+ } else
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ return AssemblyPath.GetHashCode () ^ Mode.GetHashCode () ^ StartEnabled.GetHashCode ();
+ }
+ }
+}
+
diff --git a/Mono.Profiler/Mono.Profiler.Widgets/ProfileSetupDialog.cs b/Mono.Profiler/Mono.Profiler.Widgets/ProfileSetupDialog.cs
index c1c4e2f8..212de837 100644
--- a/Mono.Profiler/Mono.Profiler.Widgets/ProfileSetupDialog.cs
+++ b/Mono.Profiler/Mono.Profiler.Widgets/ProfileSetupDialog.cs
@@ -26,80 +26,49 @@ using Gtk;
namespace Mono.Profiler.Widgets {
- public enum ProfileType {
-
- Allocations,
- Calls,
- Statistical,
- }
-
public class ProfileSetupDialog : Dialog {
- CheckButton start_enabled_chkbtn;
- ComboBox type_combo;
- FileChooserButton assembly_button;
+ ProfileConfiguration config;
public ProfileSetupDialog (Gtk.Window parent) : base ("Profile Options", parent, DialogFlags.DestroyWithParent, Stock.Cancel, ResponseType.Cancel, Stock.Execute, ResponseType.Accept)
{
+ config = new ProfileConfiguration ();
HBox box = new HBox (false, 6);
box.PackStart (new Label ("Assembly:"), false, false, 0);
- assembly_button = new FileChooserButton ("Select Assembly", FileChooserAction.Open);
+ FileChooserButton assembly_button = new FileChooserButton ("Select Assembly", FileChooserAction.Open);
FileFilter filter = new FileFilter ();
filter.AddPattern ("*.exe");
assembly_button.Filter = filter;
+ assembly_button.SelectionChanged += delegate {
+ config.AssemblyPath = assembly_button.Filename;
+ SetResponseSensitive (ResponseType.Accept, !String.IsNullOrEmpty (assembly_button.Filename));
+ };
box.PackStart (assembly_button, true, true, 0);
box.ShowAll ();
VBox.PackStart (box, false, false, 3);
box = new HBox (false, 6);
box.PackStart (new Label ("Type:"), false, false, 0);
- type_combo = ComboBox.NewText ();
+ ComboBox type_combo = ComboBox.NewText ();
type_combo.AppendText ("Allocations");
- type_combo.AppendText ("Calls");
+ type_combo.AppendText ("Calls/Instrumented");
type_combo.AppendText ("Statistical");
type_combo.Active = 2;
+ type_combo.Changed += delegate { config.Mode = (ProfileMode) (1 << type_combo.Active); };
box.PackStart (type_combo, false, false, 0);
box.ShowAll ();
VBox.PackStart (box, false, false, 3);
box = new HBox (false, 6);
- start_enabled_chkbtn = new CheckButton ("Enabled at Startup");
+ CheckButton start_enabled_chkbtn = new CheckButton ("Enabled at Startup");
start_enabled_chkbtn.Active = true;
+ start_enabled_chkbtn.Toggled += delegate { config.StartEnabled = start_enabled_chkbtn.Active; };
box.PackStart (start_enabled_chkbtn, false, false, 0);
box.ShowAll ();
VBox.PackStart (box, false, false, 3);
+ SetResponseSensitive (ResponseType.Accept, false);
}
- public string Args {
- get {
- StringBuilder sb = new StringBuilder ();
- switch (ProfileType) {
- case ProfileType.Allocations:
- sb.Append ("alloc");
- break;
- case ProfileType.Calls:
- sb.Append ("calls");
- break;
- case ProfileType.Statistical:
- sb.Append ("s=16");
- break;
- default:
- throw new Exception ("Unexpected profile type: " + ProfileType);
- }
- if (!start_enabled_chkbtn.Active)
- sb.Append (",sd");
- return sb.ToString ();
- }
- }
-
- public string AssemblyPath {
- get { return assembly_button.Filename; }
- }
-
- public ProfileType ProfileType {
- get { return (ProfileType) type_combo.Active; }
- }
-
- public bool StartEnabled {
- get { return start_enabled_chkbtn.Active; }
+ public ProfileConfiguration Config {
+ get { return config; }
}
}
}
diff --git a/Mono.Profiler/Mono.Profiler.Widgets/ProfilerProcess.cs b/Mono.Profiler/Mono.Profiler.Widgets/ProfilerProcess.cs
index b1a54c8b..0a24efb6 100644
--- a/Mono.Profiler/Mono.Profiler.Widgets/ProfilerProcess.cs
+++ b/Mono.Profiler/Mono.Profiler.Widgets/ProfilerProcess.cs
@@ -34,12 +34,12 @@ namespace Mono.Profiler.Widgets {
Process proc;
string log_file;
- public ProfilerProcess (string profiler_args, string assembly_path)
+ public ProfilerProcess (ProfileConfiguration config)
{
log_file = System.IO.Path.GetTempFileName ();
proc = new Process ();
proc.StartInfo.FileName = "mono";
- proc.StartInfo.Arguments = "--profile=logging:" + profiler_args + ",o=" + log_file + ",cp=" + Port.ToString () + " " + assembly_path;
+ proc.StartInfo.Arguments = "--profile=logging:" + config.ToArgs () + ",o=" + log_file + ",cp=" + Port.ToString () + " " + config.AssemblyPath;
proc.EnableRaisingEvents = true;
proc.Exited += delegate { OnExited (); };
}
diff --git a/Mono.Profiler/mprof-gui/ChangeLog b/Mono.Profiler/mprof-gui/ChangeLog
index 44d849f6..7693216a 100644
--- a/Mono.Profiler/mprof-gui/ChangeLog
+++ b/Mono.Profiler/mprof-gui/ChangeLog
@@ -1,3 +1,8 @@
+2009-09-03 Mike Kestner <mkestner@novell.com>
+
+ * MainWindow.cs : refactor for ProfileConfiguration. Add recent
+ configs to history.
+
2009-08-28 Mike Kestner <mkestner@novell.com>
* MainWindow.cs : add RecentLogs menu to Profile menu.
diff --git a/Mono.Profiler/mprof-gui/MainWindow.cs b/Mono.Profiler/mprof-gui/MainWindow.cs
index 452571d0..8ed371b7 100644
--- a/Mono.Profiler/mprof-gui/MainWindow.cs
+++ b/Mono.Profiler/mprof-gui/MainWindow.cs
@@ -120,19 +120,19 @@ namespace Mono.Profiler.Gui {
void OnNewActivated (object sender, System.EventArgs e)
{
ProfileSetupDialog d = new ProfileSetupDialog (this);
- if (d.Run () == (int) Gtk.ResponseType.Accept && !String.IsNullOrEmpty (d.AssemblyPath)) {
+ if (d.Run () == (int) Gtk.ResponseType.Accept) {
ProfileView view = new ProfileView ();
view.Show ();
View = view;
logging_enabled_action.Visible = true;
- logging_enabled_action.Active = d.StartEnabled;
- string args = d.Args;
- proc = new ProfilerProcess (args, d.AssemblyPath);
+ logging_enabled_action.Active = d.Config.StartEnabled;
+ proc = new ProfilerProcess (d.Config);
proc.Paused += delegate { Refresh (view); };
proc.Exited += delegate { Refresh (view); logging_enabled_action.Visible = false; };
proc.Start ();
- log_info = new LogInfo (proc.LogFile, System.IO.Path.GetFileName (d.AssemblyPath) + ":" + args);
+ log_info = new LogInfo (proc.LogFile, d.Config.ToString ());
history.LogFiles.Prepend (log_info);
+ history.Configs.Prepend (d.Config);
}
d.Destroy ();
}