Exemple #1
0
 internal void AppendThreadExclusion(KeyDisplayRepresentation threadId)
 {
     if (m_excludedThreads == null)
     {
         m_excludedThreads = new List <KeyDisplayRepresentation>();
     }
     if (!m_excludedThreads.Contains(threadId))
     {
         m_excludedThreads.Add(threadId);
     }
 }
        internal KeyDisplayRepresentation GetThreadDisplayValue(EventEntry ee)
        {
            KeyDisplayRepresentation result;

            switch (MexCore.TheCore.Options.ThreadDisplayOption)
            {
            case ThreadDisplayMode.UseDotNetThread:
                result = new KeyDisplayRepresentation(ee.CurrentThreadKey, ee.ThreadNetId);
                break;

            case ThreadDisplayMode.UseOSThread:
                result = new KeyDisplayRepresentation(ee.CurrentThreadKey, ee.ThreadID);
                break;

            case ThreadDisplayMode.DefaultUseThreadNameAndOS:
                if (ThreadNames.ContainsKey(ee.CurrentThreadKey))
                {
                    result = new KeyDisplayRepresentation(ee.CurrentThreadKey, ThreadNames[ee.CurrentThreadKey] + " on " + ee.ThreadID);
                }
                else
                {
                    result = new KeyDisplayRepresentation(ee.CurrentThreadKey, ee.ThreadNetId + " on " + ee.ThreadID);
                }
                break;

            case ThreadDisplayMode.ShowFullInformation:
                if (ThreadNames.ContainsKey(ee.CurrentThreadKey))
                {
                    result = new KeyDisplayRepresentation(ee.CurrentThreadKey, ThreadNames[ee.CurrentThreadKey] + " on " + ee.ThreadNetId + " on os: " + ee.ThreadID);
                }
                else
                {
                    result = new KeyDisplayRepresentation(ee.CurrentThreadKey, "Unknown on " + ee.ThreadNetId + " on os: " + ee.ThreadID);
                }
                break;

            default:
                throw new InvalidOperationException("This code should not be reachable");
            }

            return(result);
        }
Exemple #3
0
        private bool BaseIncludeEventEntry(EventEntry ee)
        {
            /* filter created in order of most likely reasons to fail therefore for performance tried to shift the types to the top then the
             * inclusion / exclusion fitlers as these will be used the most.  Ive optimised this to be a single comparison so it should be very
             * quick. */
            if ((m_flagsForInclude & (uint)ee.cmdType) != (uint)ee.cmdType)
            {
                return(false);
            }

            // Performance cache to stop checking all of the complex filters in the default scenario.  Basically the default scenario only
            // filters on type therefore all of the good stuff coming up is pointless.
            if (!m_filterMoreComplexThanType)
            {
                return(true);
            }

            // Now we check for the more complicated filtering options such as index filtering

            if (m_useIndexBasedFilters)
            {
                if (UseBelowThisFilter)
                {
                    if (ee.GlobalIndex < ExcludeEventsBelowThisIndex)
                    {
                        return(false);
                    }
                }
                if (UseAboveThisFilter)
                {
                    if (ee.GlobalIndex > ExcludeEventsAboveThisIndex)
                    {
                        return(false);
                    }
                }
            }

            if ((m_inclusionStrings != null) && (m_inclusionStrings.Count > 0))
            {
                // check for inclusion strings
                string debugCheckString;
                if (m_caseSensitive)
                {
                    debugCheckString = ee.DebugMessage;
                }
                else
                {
                    debugCheckString = ee.DebugMessage.ToLower();
                }

                for (int i = 0; i < m_inclusionStrings.Count; i++)
                {
                    if (debugCheckString.IndexOf(m_inclusionStrings[i]) >= 0)
                    {
                        ee.LastVisitedFilter = m_currentFilterIndex;
                        return(true);  // matched one of the inclusion strings
                    }
                } // End for each of the inclusion strings

                return(false); // none of the inclusion strings matched
            } // end if there are inclusionStrings to worry about

            if ((m_exclusionStrings != null) && (m_exclusionStrings.Count > 0))
            {
                // check for exclusion strings

                string exclusionCheckString;
                if (m_caseSensitive)
                {
                    exclusionCheckString = ee.DebugMessage;
                }
                else
                {
                    exclusionCheckString = ee.DebugMessage.ToLower();
                }

                for (int i = 0; i < m_exclusionStrings.Count; i++)
                {
                    if (exclusionCheckString.IndexOf(m_exclusionStrings[i]) >= 0)
                    {
                        ee.LastVisitedFilter       = m_currentFilterIndex;
                        ee.LastVisitedFilterResult = false;
                        return(false);  //  found a rejected one
                    }
                }
            }// end if there are exclusion strings to worry about

            //Bilge.Assert(ee.Module != null, "The module value should not be null when checked by the filter, it should be empty if not known");
            if ((m_excludedModules != null) && (ee.Module.Length > 0))
            {
                //Bilge.Assert(m_excludedModules.Count > 0, "There should not be a module list of 0 entries");

                if (m_excludedModules.Contains(ee.Module))
                {
                    return(false);
                }
            }

            //Bilge.Assert(ee.CurrentThreadKey != null, "The thread id for an event entry should not be null when checked by the filter, if its not known it should be empty");
            if ((m_excludedThreads != null) && (ee.CurrentThreadKey.Length > 0))
            {
                //Bilge.Assert(m_excludedThreads.Count > 0, "The threads to be excluded should not be of length 0");

                // check for threads we specifically dont include.  This allows new threads to arrive and be included
                if (KeyDisplayRepresentation.ContainsKey(m_excludedThreads, ee.CurrentThreadKey))    // return true if its NOT in the exclusions
                {
                    return(false);
                }
            }

            //Bilge.Assert(ee.MoreLocationData != null, "The additional location data should not be null when checked by the filter, if its not known it should be empty");
            if ((m_excludedLocationsClass != null) && (ee.MoreLocationData.Length > 0))
            {
                //Bilge.Assert(m_excludedLocationsClass.Count > 0, "This should not be callable when the number of excluded locations by class is 0");

                int offsetOfColons = ee.MoreLocationData.IndexOf("::");
                if (offsetOfColons > 0)
                {
                    // There is a class look alike
                    string locForEntry = ee.MoreLocationData.Substring(0, offsetOfColons);

                    if (m_excludedLocationsClass.Contains(locForEntry))
                    {
                        return(false);
                    }
                }
            }
            if ((m_excludedLocationsFull != null) && (ee.MoreLocationData.Length > 0))
            {
                //Bilge.Assert(m_excludedLocationsFull.Count > 0, "This should not be callable when the number of excluded locations is 0");

                ee.LastVisitedFilter = m_currentFilterIndex;
                if (m_excludedLocationsFull.Contains(ee.MoreLocationData))   // return true if its NOT in the exclusions
                {
                    return(false);
                }
            }

            return(true);
        }