private static XDocument GetExceptionInfo(Assembly assembly, string resourceName) { var retVal = (XDocument)null; var exceptionInfoKey = new ExceptionInfoKey(assembly, resourceName); lock (exceptionInfosLock) { if (exceptionInfos.ContainsKey(exceptionInfoKey)) { retVal = exceptionInfos[exceptionInfoKey]; } else { var stream = assembly.GetManifestResourceStream(resourceName); if (stream == null) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "XML resource file '{0}' could not be found in assembly '{1}'.", resourceName, assembly.FullName)); } using (var streamReader = new StreamReader(stream)) { retVal = XDocument.Load(streamReader); } exceptionInfos[exceptionInfoKey] = retVal; } } return(retVal); }
void Load() { exceptionService.RestoreDefaults(); var section = settingsService.GetOrCreateSection(SETTINGS_GUID); foreach (var exx in section.SectionsWithName("Exception")) { var exceptionType = exx.Attribute<ExceptionType?>("ExceptionType"); var fullName = exx.Attribute<string>("FullName"); bool? breakOnFirstChance = exx.Attribute<bool?>("BreakOnFirstChance"); bool isOtherExceptions = exx.Attribute<bool?>("IsOtherExceptions") ?? false; var diffType = exx.Attribute<ExceptionDiffType?>("DiffType"); if (diffType == null) continue; if (exceptionType == null || exceptionType.Value < 0 || exceptionType.Value >= ExceptionType.Last) continue; if (fullName == null) continue; var key = new ExceptionInfoKey(exceptionType.Value, fullName); switch (diffType.Value) { case ExceptionDiffType.Remove: exceptionService.Remove(key); break; case ExceptionDiffType.AddOrUpdate: if (breakOnFirstChance == null) continue; exceptionService.AddOrUpdate(key, breakOnFirstChance.Value, isOtherExceptions); break; default: Debug.Fail("Unknown ExceptionDiffType"); break; } } }
public void Add(ExceptionInfoKey key) { ExceptionInfo info; if (exceptions.TryGetValue(key, out info)) return; info = new ExceptionInfo(key, true); exceptions.Add(key, info); if (Changed != null) Changed(this, new ExceptionManagerEventArgs(ExceptionManagerEventType.Added, info)); }
private static XDocument GetExceptionInfo(Assembly assembly, string resourceName) { XDocument document = null; var key = new ExceptionInfoKey(assembly, resourceName); lock (exceptionInfosLock) { if (exceptionInfos.ContainsKey(key)) { return(exceptionInfos[key]); } var manifestResourceStream = assembly.GetManifestResourceStream(resourceName); if (manifestResourceStream == null) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "XML resource file '{0}' could not be found in assembly '{1}'.", new object[] { resourceName, assembly.FullName })); } using (var reader = new StreamReader(manifestResourceStream)) { document = XDocument.Load(reader); } exceptionInfos[key] = document; } return(document); }
void LoadInternal() { DNSpySettings settings = DNSpySettings.Load(); var exs = settings[SETTINGS_NAME]; ExceptionManager.Instance.RestoreDefaults(); foreach (var exx in exs.Elements("Exception")) { var exceptionType = (ExceptionType?)(int?)exx.Attribute("ExceptionType"); var fullName = SessionSettings.Unescape((string)exx.Attribute("FullName")); bool? breakOnFirstChance = (bool?)exx.Attribute("BreakOnFirstChance"); bool isOtherExceptions = (bool?)exx.Attribute("IsOtherExceptions") ?? false; var diffType = (ExceptionDiffType?)(int?)exx.Attribute("DiffType"); if (diffType == null) continue; if (exceptionType == null || (int)exceptionType.Value < 0 || exceptionType.Value >= ExceptionType.Last) continue; if (fullName == null) continue; var key = new ExceptionInfoKey(exceptionType.Value, fullName); switch (diffType.Value) { case ExceptionDiffType.Remove: ExceptionManager.Instance.Remove(key); break; case ExceptionDiffType.AddOrUpdate: if (breakOnFirstChance == null) continue; ExceptionManager.Instance.AddOrUpdate(key, breakOnFirstChance.Value, isOtherExceptions); break; default: Debug.Fail("Unknown ExceptionDiffType"); break; } } }
public bool Exists(ExceptionInfoKey key) { return exceptions.ContainsKey(key); }
void OnException(Exception2DebugCallbackEventArgs e) { if (e.EventType != CorDebugExceptionCallbackType.DEBUG_EXCEPTION_FIRST_CHANCE) return; var thread = e.CorThread; if (thread == null) return; var exValue = thread.CurrentException; if (exValue == null) return; var exType = exValue.ExactType; if (exType == null) return; var exTypeName = exType.ToString(TypePrinterFlags.ShowNamespaces); var key = new ExceptionInfoKey(ExceptionType.DotNet, exTypeName); ExceptionInfo info; if (!exceptions.TryGetValue(key, out info)) info = otherExceptions[(int)ExceptionType.DotNet]; if (!info.BreakOnFirstChance) return; e.AddStopReason(DebuggerStopReason.Exception); }
internal void AddOrUpdate(ExceptionInfoKey key, bool breakOnFirstChance, bool isOtherExceptions) { if (isOtherExceptions) { int index = (int)key.ExceptionType; if ((uint)index < (uint)otherExceptions.Length) WriteBreakOnFirstChance(otherExceptions[index], breakOnFirstChance); } else { ExceptionInfo info; if (exceptions.TryGetValue(key, out info)) WriteBreakOnFirstChance(info, breakOnFirstChance); else { exceptions[key] = info = new ExceptionInfo(key, breakOnFirstChance); if (Changed != null) Changed(this, new ExceptionManagerEventArgs(ExceptionManagerEventType.Added, info)); } } }
public void Remove(ExceptionInfoKey key) { ExceptionInfo info; if (!exceptions.TryGetValue(key, out info)) return; RemoveExceptions(new ExceptionInfo[] { info }); }
public void Add(ExceptionInfoKey key) { ExceptionInfo info; if (exceptions.TryGetValue(key, out info)) return; info = new ExceptionInfo(key, true); exceptions.Add(key, info); Changed?.Invoke(this, new ExceptionServiceEventArgs(ExceptionServiceEventType.Added, info)); }
public bool Exists(ExceptionInfoKey key) => exceptions.ContainsKey(key);
public void BreakWhenThrown(ExceptionType type, string name) { var key = new ExceptionInfoKey(type, name); if (!exceptionService.Exists(key)) exceptionService.Add(key); var vm = Collection.FirstOrDefault(a => a.ExceptionInfo.Key.Equals(key)); Debug.Assert(vm != null); if (vm != null) vm.BreakOnFirstChance = true; }