This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add 'DebuggerConfiguration.UserNotifications'.

2009-11-29  Martin Baulig  <martin@ximian.com>

	* classes/DebuggerConfiguration.cs
	(DebuggerConfiguration.LoadConfigurationFromStream): Use
	Report.Error() to report errors instead of throwing an exception.
	(DebuggerConfiguration.UserNotifications): New public property.
	(DebuggerConfiguration.NotifyUser_ThreadCreation): Mark as obsolete.
	(DebuggerConfiguration.UserNotificationType): New public enum.

	* frontend/Command.cs
	(ConfigCommand): Add `user-notifications' option to modify the new
	`DebuggerConfiguration.UserNotifications'.

svn path=/trunk/debugger/; revision=147679
  • Loading branch information...
Martin Baulig
Martin Baulig committed Dec 4, 2009
1 parent aef4b91 commit 0a383c6d57c6b3050119873e038a18da89b4f4b4
Showing with 93 additions and 12 deletions.
  1. +13 −0 ChangeLog
  2. +53 −10 classes/DebuggerConfiguration.cs
  3. +8 −0 classes/DebuggerConfiguration.xsd
  4. +17 −0 frontend/Command.cs
  5. +2 −2 frontend/Interpreter.cs
View
@@ -1,3 +1,16 @@
+2009-11-29 Martin Baulig <martin@ximian.com>
+
+ * classes/DebuggerConfiguration.cs
+ (DebuggerConfiguration.LoadConfigurationFromStream): Use
+ Report.Error() to report errors instead of throwing an exception.
+ (DebuggerConfiguration.UserNotifications): New public property.
+ (DebuggerConfiguration.NotifyUser_ThreadCreation): Mark as obsolete.
+ (DebuggerConfiguration.UserNotificationType): New public enum.
+
+ * frontend/Command.cs
+ (ConfigCommand): Add `user-notifications' option to modify the new
+ `DebuggerConfiguration.UserNotifications'.
+
2009-11-25 Martin Baulig <martin@ximian.com>
* classes/DebuggerConfiguration.cs
@@ -76,7 +76,7 @@ public void SetupXSP ()
stay_in_thread = false;
load_native_symtabs = false;
follow_fork = false;
- notify_thread_creation = false;
+ UserNotifications &= ~UserNotificationType.Threads;
hide_auto_generated = true;
is_xsp = true;
}
@@ -150,12 +150,24 @@ void LoadConfigurationFromStream (Stream stream)
case "default":
break;
default:
- throw new ArgumentException (String.Format (
- "Invalid value `{0}' in 'ThreadingModel'", iter.Current.Value));
+ Report.Error ("Invalid value `{0}' in 'ThreadingModel'", iter.Current.Value);
+ break;
+ }
+ } else if (iter.Current.Name == "UserNotifications") {
+ switch (iter.Current.Value.ToLower ()) {
+ case "+threads":
+ case "threads":
+ user_notifications |= UserNotificationType.Threads;
+ break;
+ case "-threads":
+ user_notifications &= ~UserNotificationType.Threads;
+ break;
+ default:
+ Report.Error ("Invalid value `{0}' in 'UserNotifications'", iter.Current.Value);
+ break;
}
} else {
- throw new ArgumentException (String.Format (
- "Invalid configuration item `{0}'", iter.Current.Name));
+ Report.Error ("Invalid configuration item `{0}'", iter.Current.Name);
}
}
@@ -232,6 +244,13 @@ void SaveConfigurationToStream (string filename)
}
element.AppendChild (threading_model_e);
+ XmlElement user_notifications_e = doc.CreateElement ("UserNotifications");
+ if ((user_notifications & UserNotificationType.Threads) != 0)
+ user_notifications_e.InnerText = "+threads";
+ else
+ user_notifications_e.InnerText = "-threads";
+ element.AppendChild (user_notifications_e);
+
XmlElement module_groups = doc.CreateElement ("ModuleGroups");
doc.DocumentElement.AppendChild (module_groups);
@@ -245,14 +264,14 @@ void SaveConfigurationToStream (string filename)
bool stay_in_thread = true;
bool load_native_symtabs = false;
bool follow_fork = false;
- bool notify_thread_creation = true;
bool hide_auto_generated = false;
bool opaque_file_names = false;
bool stop_on_managed_signals = true;
bool nested_break_states = false;
bool redirect_output = false;
bool is_xsp = false;
bool is_cli = false;
+ UserNotificationType user_notifications = UserNotificationType.Threads;
ThreadingModel threading_model = ThreadingModel.Default;
Hashtable module_groups;
Dictionary<string,string> directory_maps;
@@ -386,12 +405,22 @@ internal ModuleGroup GetModuleGroup (SymbolFile symfile)
}
/*
- * Whether or not to notify the user when new threads have
- * been created / threads exited.
+ * Configurable user notifications.
*/
+ public UserNotificationType UserNotifications {
+ get { return user_notifications; }
+ set { user_notifications = value; }
+ }
+
+ [Obsolete("Use 'UserNotifications' instead.")]
public bool NotifyUser_ThreadCreation {
- get { return notify_thread_creation; }
- set { notify_thread_creation = value; }
+ get { return (user_notifications & UserNotificationType.Threads) != 0; }
+ set {
+ if (value)
+ user_notifications |= UserNotificationType.Threads;
+ else
+ user_notifications &= UserNotificationType.Threads;
+ }
}
public bool HideAutoGenerated {
@@ -427,6 +456,13 @@ public string PrintConfiguration (bool expert_mode)
StopOnManagedSignals ? "yes" : "no"));
sb.Append (String.Format (" Enable nested break states (nested-break-states): {0}\n",
NestedBreakStates ? "yes" : "no"));
+
+ string notifications = null;
+ if ((user_notifications & UserNotificationType.Threads) != 0)
+ notifications = "threads";
+ sb.Append (String.Format (" User notifications (user-notifications): {0}\n",
+ notifications ?? "none"));
+
sb.Append (String.Format (" Redirect output (redirect-output): {0}\n",
RedirectOutput ? "yes" : "no"));
@@ -455,5 +491,12 @@ public string PrintConfiguration (bool expert_mode)
}
return sb.ToString ();
}
+
+ [Flags]
+ public enum UserNotificationType
+ {
+ None = 0,
+ Threads
+ }
}
}
@@ -14,6 +14,7 @@
<xs:element name="StopDaemonThreads" type="xs:boolean" minOccurs="0" maxOccurs="1" />
<xs:element name="StopImmutableThreads" type="xs:boolean" minOccurs="0" maxOccurs="1" />
<xs:element name="ThreadingModel" type="ThreadingModel" minOccurs="0" maxOccurs="1" />
+ <xs:element name="UserNotifications" type="UserNotifications" minOccurs="0" maxOccurs="1" />
</xs:choice>
</xs:complexType>
<xs:simpleType name="ThreadingModel">
@@ -22,6 +23,13 @@
<xs:enumeration value="process"/>
</xs:restriction>
</xs:simpleType>
+ <xs:simpleType name="UserNotifications">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="threads"/>
+ <xs:enumeration value="+threads"/>
+ <xs:enumeration value="-threads"/>
+ </xs:restriction>
+ </xs:simpleType>
<xs:complexType name="Options">
<xs:choice maxOccurs="unbounded">
<xs:element name="File" type="xs:string" minOccurs="1" />
View
@@ -3826,6 +3826,23 @@ protected override bool DoResolve (ScriptingContext context)
continue;
}
+ if (arg.StartsWith ("user-notifications=")) {
+ foreach (string arg1 in arg.Substring (19).Split (',')) {
+ switch (arg1) {
+ case "threads":
+ case "+threads":
+ config.UserNotifications |= DebuggerConfiguration.UserNotificationType.Threads;
+ break;
+ case "-threads":
+ config.UserNotifications &= ~DebuggerConfiguration.UserNotificationType.Threads;
+ break;
+ default:
+ throw new ScriptingException ("Invalid 'user-notifications' option '{0}'.", arg1);
+ }
+ }
+ continue;
+ }
+
if ((arg [0] != '+') && (arg [0] != '-'))
throw new ScriptingException ("Expected `+option' or `-option'.");
View
@@ -470,14 +470,14 @@ public Event GetEvent (int index)
protected virtual void OnThreadCreated (Thread thread)
{
process_event.Set ();
- if (DebuggerConfiguration.NotifyUser_ThreadCreation)
+ if ((DebuggerConfiguration.UserNotifications & DebuggerConfiguration.UserNotificationType.Threads) != 0)
Print ("Process #{0} created new thread @{1}.",
thread.Process.ID, thread.ID);
}
protected virtual void OnThreadExited (Thread thread)
{
- if (DebuggerConfiguration.NotifyUser_ThreadCreation)
+ if ((DebuggerConfiguration.UserNotifications & DebuggerConfiguration.UserNotificationType.Threads) != 0)
Print ("Thread @{0} exited.", thread.ID);
if (thread == current_thread)
current_thread = null;

0 comments on commit 0a383c6

Please sign in to comment.