public 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 });
        }
Exemple #3
0
        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));
        }
        void LoadInternal()
        {
            ILSpySettings settings = ILSpySettings.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 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));
            }
        }
Exemple #6
0
        public void BreakWhenThrown(ExceptionType type, string name)
        {
            var key = new ExceptionInfoKey(type, name);

            if (!exceptionManager.Exists(key))
            {
                exceptionManager.Add(key);
            }
            var vm = Collection.FirstOrDefault(a => a.ExceptionInfo.Key.Equals(key));

            Debug.Assert(vm != null);
            if (vm != null)
            {
                vm.BreakOnFirstChance = true;
            }
        }
Exemple #7
0
        void Load()
        {
            exceptionManager.RestoreDefaults();
            var section = settingsManager.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:
                    exceptionManager.Remove(key);
                    break;

                case ExceptionDiffType.AddOrUpdate:
                    if (breakOnFirstChance == null)
                    {
                        continue;
                    }
                    exceptionManager.AddOrUpdate(key, breakOnFirstChance.Value, isOtherExceptions);
                    break;

                default:
                    Debug.Fail("Unknown ExceptionDiffType");
                    break;
                }
            }
        }
        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.AddPauseReason(DebuggerPauseReason.Exception);
        }
Exemple #9
0
 public ExceptionInfo(ExceptionType exceptionType, EXCEPTION_INFO info)
 {
     exceptionInfoKey   = new ExceptionInfoKey(exceptionType, info.Name);
     BreakOnFirstChance = (info.State & ExceptionState.EXCEPTION_STOP_FIRST_CHANCE) != 0;
     IsOtherExceptions  = false;
 }
Exemple #10
0
 public ExceptionInfo(ExceptionType exceptionType, string name)
 {
     exceptionInfoKey   = new ExceptionInfoKey(exceptionType, name);
     BreakOnFirstChance = false;
     IsOtherExceptions  = true;
 }
Exemple #11
0
 public ExceptionInfo(ExceptionInfoKey key, bool breakOnFirstChance)
 {
     exceptionInfoKey   = key;
     BreakOnFirstChance = breakOnFirstChance;
     IsOtherExceptions  = false;
 }
Exemple #12
0
 public ExceptionInfo(ExceptionType exceptionType, string name)
 {
     this.exceptionInfoKey   = new ExceptionInfoKey(exceptionType, name);
     this.breakOnFirstChance = false;
     this.isOtherExceptions  = true;
 }
Exemple #13
0
 public ExceptionInfo(ExceptionInfoKey key, bool breakOnFirstChance)
 {
     this.exceptionInfoKey   = key;
     this.breakOnFirstChance = breakOnFirstChance;
     this.isOtherExceptions  = false;
 }
Exemple #14
0
 public bool Exists(ExceptionInfoKey key)
 {
     return(exceptions.ContainsKey(key));
 }
Exemple #15
0
 public bool Exists(ExceptionInfoKey key) => exceptions.ContainsKey(key);