/// <summary> /// InternalDumpHashtable is called to write a hashtable out to the debugging stream. It can be used internally or is called /// directly from the public facing DumpHashTable methods. If called internally then internalCall must be true as this will ensure /// that all info is output with Constants.MOREINFO, and therefore form part of the calling methods output rather than /// a log in its own right. /// </summary> /// <param name="ht">The hashtable that is to be written to the trace stream</param> /// <param name="contextText">A context string describing the hash table</param> /// <param name="internalCall">A boolean to flag if method is being called internall i.e. as part of another dump method</param> /// <param name="secondaryMessage">Further contextual information</param> /// <param name="meth">The Method Name</param> /// <param name="pth">The caller path</param> /// <param name="ln">The Line Number</param> private void InternalDumpHashTable(Hashtable ht, string contextText, string secondaryMessage, bool internalCall, string meth, string pth, int ln) { TraceCommandTypes typeOfMessage = internalCall ? TraceCommandTypes.MoreInfo : baseCommandLevel; if (ht == null) { ActiveRouteMessage(typeOfMessage, "Hashtable Dump (" + contextText + ") : null", "", meth, pth, ln); return; } secondaryMessage = secondaryMessage ?? string.Empty; ActiveRouteMessage(typeOfMessage, "Hashtable Dump (" + contextText + ") : " + ht.ToString(), secondaryMessage + " \r\n Ht Entries : " + ht.Count.ToString(), meth, pth, ln); // output each item in the hashtable foreach (System.Collections.DictionaryEntry hEntry in ht) { string valText; if (hEntry.Value is Hashtable) { valText = "Value is Hashtable with " + ((Hashtable)hEntry.Value).Count.ToString() + " elements."; } else if (hEntry.Value is Array) { valText = "Value is Array with " + ((Array)hEntry.Value).Length.ToString() + " elements."; } else { valText = hEntry.Value.ToString(); } ActiveRouteMessage(TraceCommandTypes.MoreInfo, String.Format(" Key [{0}] : Value [{1}] ", hEntry.Key.ToString(), valText), ""); } ActiveRouteMessage(TraceCommandTypes.MoreInfo, "_______ Hashtable Dump End ________", ""); }
internal static string TraceCommandToReadableString(TraceCommandTypes tct) { switch (tct) { case TraceCommandTypes.AssertionFailed: return("Assertion"); case TraceCommandTypes.CommandOnly: return("Command"); case TraceCommandTypes.ErrorMsg: return("Error"); case TraceCommandTypes.ExceptionBlock: return("Exception Block"); case TraceCommandTypes.ExceptionData: return("Exception"); case TraceCommandTypes.ExcEnd: return("Exception Inner Start"); case TraceCommandTypes.ExcStart: return("Exception Inner End"); case TraceCommandTypes.InternalMsg: return("Internal"); case TraceCommandTypes.LogMessage: return("Log Message"); case TraceCommandTypes.LogMessageMini: return("Log Minimal"); case TraceCommandTypes.LogMessageVerb: return("Log Verbose"); case TraceCommandTypes.MoreInfo: return("Chain Message"); case TraceCommandTypes.TraceMessage: return("Trace Message"); case TraceCommandTypes.TraceMessageIn: return("Trace Enter"); case TraceCommandTypes.TraceMessageOut: return("Trace Exit"); case TraceCommandTypes.WarningMsg: return("Warning Message"); case TraceCommandTypes.SectionStart: return("Section Start"); case TraceCommandTypes.SectionEnd: return("Section End"); case TraceCommandTypes.ResourceEat: return("Resource Allocation"); case TraceCommandTypes.ResourcePuke: return("Resource DeAllocation"); case TraceCommandTypes.ResourceCount: return("Resource Value Setting"); case TraceCommandTypes.CommandXML: return("XML Command"); case TraceCommandTypes.Custom: return("Custom Command"); default: throw new ArgumentException("Invalid Trace Command Type selected in TraceCommandToReadableString", "tct"); } }
internal EventEntry(long newGlobalIndex, string newModule, string newLineNo, string newThreadId, string newDebugMessage, string moreLocData, string threadnetidentity) : this(newGlobalIndex) { GlobalIndex = newGlobalIndex; ThreadID = newThreadId; DebugMessage = newDebugMessage; MoreLocationData = moreLocData; ThreadNetId = threadnetidentity; Module = newModule; LineNumber = newLineNo; cmdType = TraceCommandTypes.Unknown; ViewData.isValid = false; }
public static string TraceCommandToString(TraceCommandTypes theCommand) { switch (theCommand) { case TraceCommandTypes.LogMessage: return(Constants.MSGFMT_LOG); case TraceCommandTypes.LogMessageVerb: return(Constants.MSGFMT_LOGVERBOSE); case TraceCommandTypes.InternalMsg: return(Constants.INTERNALMSG); case TraceCommandTypes.TraceMessageIn: return(Constants.TRACEMESSAGEIN); case TraceCommandTypes.TraceMessageOut: return(Constants.TRACEMESSAGEOUT); case TraceCommandTypes.AssertionFailed: return(Constants.ASSERTIONFAILED); case TraceCommandTypes.MoreInfo: return(Constants.MOREINFO); case TraceCommandTypes.CommandOnly: return(Constants.COMMANDONLY); case TraceCommandTypes.ErrorMsg: return(Constants.ERRORMSG); case TraceCommandTypes.WarningMsg: return(Constants.WARNINGMSG); case TraceCommandTypes.ExceptionData: return(Constants.EXCEPTIONDATA); case TraceCommandTypes.ExceptionBlock: return(Constants.EXCEPTIONBLOCK); case TraceCommandTypes.ExcStart: return(Constants.EXCSTART); case TraceCommandTypes.ExcEnd: return(Constants.EXCEND); case TraceCommandTypes.SectionStart: return(Constants.SECTIONSTART); case TraceCommandTypes.SectionEnd: return(Constants.SECTIONEND); case TraceCommandTypes.ResourceEat: return(Constants.RESOURCEEAT); case TraceCommandTypes.ResourcePuke: return(Constants.RESOURCEPUKE); case TraceCommandTypes.ResourceCount: return(Constants.RESOURCECOUNT); case TraceCommandTypes.CommandXML: return(Constants.MSGFMT_XMLCOMMAND); case TraceCommandTypes.Alert: return(Constants.MSGFMT_ALERT); case TraceCommandTypes.Custom: return(Constants.MSGFMT_CUSTOM); } throw new ArgumentException("Unreachable Code, the value of the parameter is invalid, this code should not be executed.", "theCommand"); }
protected void ActiveRouteMessage(TraceCommandTypes tct, string messageBody, string furtherInfo = null, string methodName = null, string fileName = null, int lineNumber = 0) { MessageMetadata mmd = new MessageMetadata() { CommandType = tct, MethodName = methodName, FileName = fileName, LineNumber = lineNumber.ToString(), Body = messageBody, FurtherDetails = furtherInfo }; ActiveRouteMessage(mmd); }
public static SupportingMessageData ParseAsMessageData(TraceCommandTypes tct, ref string PrimaryMessagData, ref string MoreInfoData) { try { if ((tct == TraceCommandTypes.SectionStart) || (tct == TraceCommandTypes.SectionEnd)) { // Sections can contain timer data, if so then we abstract the timer data here. TimerInstanceData tid = null; if (PrimaryMessagData.StartsWith(Constants.TIMER_SECTIONIDENTIFIER)) { // This is only a timer based section if it has this specfic tag in its debug message. try { tid = new TimerInstanceData(MoreInfoData); } catch (ArgumentException aex) { //Bilge.Dump(aex, "Timer error, couldnt parse timer message as timer message structure: (" + MoreInfoData + ")"); MexCore.TheCore.ViewManager.AddUserNotificationMessageByIndex(ViewSupportManager.UserMessages.CorruptStringFound, ViewSupportManager.UserMessageType.ErrorMessage, "A timing message was recieved but it was corrupt. Try removing any strange characters from the timer names. Timing data may be innaccurate."); } PrimaryMessagData = PrimaryMessagData.Substring(Constants.TIMER_SECTIONIDENTIFIER.Length); // Strip the intiial identifier MoreInfoData = string.Empty; // All of the more info should be consumed when creating the timer event. } return(tid); } if ((tct == TraceCommandTypes.ResourcePuke) || (tct == TraceCommandTypes.ResourceEat)) { // Resource alteration identifiers contain values for named resources incrementing or decrementing by amounts. ResourceInstanceData rid = new ResourceInstanceData(MoreInfoData); PrimaryMessagData = "Resource Alteration for " + rid.ResourceName; MoreInfoData = "Value Change " + rid.ResourceValue.ToString(); return(rid); } if (tct == TraceCommandTypes.ResourceCount) { ResourceInstanceData rid = new ResourceInstanceData(MoreInfoData); PrimaryMessagData = "Resource Set For " + rid.ResourceName; MoreInfoData = "Value = " + rid.ResourceValue; return(rid); } } catch (ArgumentException aex) { //Bilge.Dump(aex, "There was a problem when trying to extract data from a message type."); //Bilge.Warning("Failed to interpret the data string sent to Mex as valid data containing more info. Returning null for this instance", "Trace Command Type : " + tct.ToString()); //Bilge.FurtherInfo("Primary:" + PrimaryMessagData); //Bilge.FurtherInfo("Secondary:" + MoreInfoData); MexCore.TheCore.ViewManager.AddUserNotificationMessageByIndex(ViewSupportManager.UserMessages.CorruptStringFound, ViewSupportManager.UserMessageType.ErrorMessage, "Unable to extract the expected information from a message. One of the strings arriving in Mex was corrupt."); } return(null); }
internal EventEntry(EventEntry copyMe) { this.cmdType = copyMe.cmdType; this.DebugMessage = copyMe.DebugMessage; this.HasMoreInfo = copyMe.HasMoreInfo; this.LastVisitedFilter = copyMe.LastVisitedFilter; this.LastVisitedFilterResult = copyMe.LastVisitedFilterResult; this.LineNumber = copyMe.LineNumber; this.Module = copyMe.Module; this.MoreLocationData = copyMe.MoreLocationData; this.SecondaryMessage = copyMe.SecondaryMessage; this.ThreadID = copyMe.ThreadID; this.ThreadNetId = copyMe.ThreadNetId; this.ViewData = new ViewSpecificData(); }
} // End SetThreadsModulesLocations internal void SetMessageTypeIncludeByType(TraceCommandTypes tct, bool newValue) { #region entry code //Bilge.Assert(!m_readonly, "You must call BeginFilterUpdate before setting filter values"); #endregion if (newValue) { m_flagsForInclude |= (uint)tct; // turn the bit on } else { m_flagsForInclude &= ~(uint)tct; // turn the bit off } }
public void WriteMessage_ArrivesAsMessage(TraceCommandTypes testCase) { var sut = TestHelper.GetBilgeAndClearDown(); sut.ActiveTraceLevel = SourceLevels.Verbose; var mmh = new MockMessageHandler(); sut.AddHandler(mmh); WriteCorrectTypeOfMessage(sut, testCase); sut.Flush(); Thread.Sleep(10); var msg = mmh.GetMostRecentMessage(); Assert.NotNull(msg); Assert.Equal(testCase, msg.CommandType); }
internal AHighlightRequest(Color bkCol, Color fgCol, TraceCommandTypes matchType, string match, bool invertMatch, bool checkCase) : this() { if (bkCol != Color.Empty) { BackColorSpecified = true; BackgroundColor = bkCol; } else { BackColorSpecified = false; BackgroundColor = Color.Empty; } if (fgCol != Color.Empty) { ForeColorSpecified = true; ForegroundColor = fgCol; } else { ForeColorSpecified = false; ForegroundColor = Color.Empty; } matchTct = matchType; MakeMatchUsingType = false; MakeMatchUsingString = false; if (matchTct != TraceCommandTypes.Unknown) { MakeMatchUsingType = true; } ComparisonStringToMatchOn = match; if ((ComparisonStringToMatchOn != null) && (ComparisonStringToMatchOn.Length > 0)) { MakeMatchUsingString = true; } NotMatch = invertMatch; CaseSensitive = checkCase; SetNamestringDefault(); DescriptionString = NameString; // Now just check that we havent allowed them not to match on anything at all as that would be really quite lame. //Bilge.Assert(MakeMatchUsingType || MakeMatchUsingString, "Highlight object is invalid. The UI should ensure that a highlight object is created to either highlight the event type or on a matching string or possibly both but it should not allow no match criteia."); }
private void WriteCorrectTypeOfMessage(Bilge sut, TraceCommandTypes testCase) { switch (testCase) { case TraceCommandTypes.LogMessage: sut.Info.Log("Test"); break; case TraceCommandTypes.LogMessageVerb: sut.Verbose.Log("Test"); break; case TraceCommandTypes.TraceMessageIn: sut.Info.EnterSection("Test"); break; case TraceCommandTypes.ErrorMsg: sut.Error.Log("Test"); break; case TraceCommandTypes.WarningMsg: sut.Warning.Log("Test"); break; case TraceCommandTypes.LogMessageMini: case TraceCommandTypes.InternalMsg: case TraceCommandTypes.TraceMessageOut: case TraceCommandTypes.TraceMessage: case TraceCommandTypes.AssertionFailed: case TraceCommandTypes.MoreInfo: case TraceCommandTypes.CommandOnly: case TraceCommandTypes.ExceptionBlock: case TraceCommandTypes.ExceptionData: case TraceCommandTypes.ExcStart: case TraceCommandTypes.ExcEnd: case TraceCommandTypes.SectionStart: case TraceCommandTypes.SectionEnd: case TraceCommandTypes.ResourceEat: case TraceCommandTypes.ResourcePuke: case TraceCommandTypes.ResourceCount: case TraceCommandTypes.Standard: case TraceCommandTypes.CommandXML: case TraceCommandTypes.Custom: case TraceCommandTypes.Alert: case TraceCommandTypes.Unknown: default: throw new NotImplementedException(); } }
public static bool IsTraceCommand(TraceCommandTypes tct) { return(((uint)tct & TRACECOMMANDS) == (uint)tct); }
internal AHighlightRequest(Color bkCol, Color fgCol, TraceCommandTypes matchType, bool invertMatch, bool checkCase) : this(bkCol, fgCol, matchType, null, invertMatch, checkCase) { }
public static bool IsLogMessageCommand(TraceCommandTypes tct) { return(((uint)tct & LOGCOMMANDS) == (uint)tct); }
/// <summary> /// called when there are messages queued ready to be added to the data manager - this method will take either the next one or all available /// pending messaged from the queue and add it to the data structures that atre used to store the information. /// </summary> public void ProcessNextStoredMessage(bool doAll, bool reporting) { if (m_incommingMsgQueue.Count == 0) { //Bilge.Warning("WARNING INNEFFICIENT --> ProcessNextStoredMessage Called when there are no messages on queue INC_CHECKDUPEJOBS"); return; } #if DUAL if (rapc == null) { rapc = RawEntryParserChain.CreateChain(RawEntryParserChain.VAL_LINK + RawEntryParserChain.V2_LINK + RawEntryParserChain.LEG_LINK + RawEntryParserChain.ALL_LINK, store); } if (dp == null) { dp = new DataParser(store, rapc, comparer); } #endif List <int> appIndexesAffectedByImport = new List <int>(); DateTime startTime = DateTime.Now; // how long have we been running DateTime overallStartTime = DateTime.Now; FileStream everythingStream = null; StreamWriter everythingLog = null; if (MexCore.TheCore.Options.PersistEverything) { everythingStream = new FileStream(MexCore.TheCore.Options.CurrentFilename, FileMode.Append, FileAccess.Write); everythingLog = new StreamWriter(everythingStream); } try { do { if (m_shutdownRequested) { //Bilge.Log("Aborting import as shutdown has been requested."); break; } // we have a piece of work #if !DEBUG // We only want this catch block in release code, to at least try and find out whats gone wrong, in debug code we want it // to simply explode. try { #endif IncomingEventStore nextEvent = (IncomingEventStore)m_incommingMsgQueue.Dequeue(); if (MexCore.TheCore.Options.PersistEverything) { everythingLog.WriteLine("\"" + nextEvent.MachineName + "\",\"" + nextEvent.Pid + "\",\"" + nextEvent.MessageString + "\",\"" + "DE\""); } if (MexCore.TheCore.Options.RemoveDuplicatesOnImport) { bool dupeFound = true; while ((dupeFound) && (m_incommingMsgQueue.Count > 0)) { IncomingEventStore potentialNext = (IncomingEventStore)m_incommingMsgQueue.Peek(); dupeFound = potentialNext.Equals(nextEvent); if (dupeFound) { // Throw the dupe away. m_incommingMsgQueue.Dequeue(); } } } #if DUAL RawApplicationEvent rae = new RawApplicationEvent() { ArrivalTime = nextEvent.TimeRecieved, OriginId = store.GetOriginIdentity(nextEvent.MachineName, nextEvent.Pid.ToString()), Machine = nextEvent.MachineName, Process = nextEvent.Pid.ToString(), Text = nextEvent.MessageString }; dp.AddRawEvent(rae); #endif EventEntry ee = null; string tempMachineName = null; bool legacyMode = false; bool isCommand = false; // firstly is this a truncation ? if (nextEvent.MessageString.StartsWith(Constants.MESSAGETRUNCATE)) { #region This message was a truncation of the previous one, deal with it like that // This is a truncation, it should be added to the last message that was added to the process with the same pid. //Bilge.Warning("WARNING INNEFFICIENT --> Looking for non existant GI Sux in timed view could cache this -> Global Index " + nextEvent.GlobalIndex.ToString() + " skipped as its a truncate message"); int endMachineNameIdx = nextEvent.MessageString.IndexOf(']'); int startMachineNameIdx = Constants.MESSAGETRUNCATE.Length + 1; // 1 is for length of "[" int endUniqueIdIdx = nextEvent.MessageString.IndexOf(Constants.TRUNCATE_DATAENDMARKER); if ((endMachineNameIdx < 0) || (startMachineNameIdx < 0) || (endUniqueIdIdx < 0)) { //Bilge.Warning("WARNING --> INVAID truncate join string found, probably old version of//Bilge. Ignoring this command."); MexCore.TheCore.ViewManager.AddUserNotificationMessageByIndex(ViewSupportManager.UserMessages.InvalidTruncateStringFound, ViewSupportManager.UserMessageType.WarningMessage, null); return; } string machineName = nextEvent.MessageString.Substring(startMachineNameIdx, endMachineNameIdx - startMachineNameIdx); string truncateUniqueJoinId = nextEvent.MessageString.Substring(endMachineNameIdx + 2, (endUniqueIdIdx - (endMachineNameIdx + 2))); bool anotherExpected = nextEvent.MessageString.EndsWith(Constants.MESSAGETRUNCATE); ee = MexCore.TheCore.CacheManager.CacheGet_EventEntryExpectingTruncate(nextEvent.Pid, machineName, truncateUniqueJoinId, !anotherExpected); if (ee == null) { // This can only happen following a purge i guess //Bilge.Warning("ProcessNextStoredMessage --> WARNING --> Invalid truncation message found. Couldnt find the EE in the structure to append this trunc to. Skipping it"); return; } // Patch it together, removing the truncate markers from the middle. if ((ee.SecondaryMessage != null) && (ee.SecondaryMessage.Length > 0)) { ee.SecondaryMessage = ee.SecondaryMessage.Substring(0, (ee.SecondaryMessage.Length - Constants.MESSAGETRUNCATE.Length)) + nextEvent.MessageString.Substring(Constants.MESSAGETRUNCATE.Length); } else { ee.SetDebugMessage(ee.DebugMessage.Substring(0, (ee.DebugMessage.Length - Constants.MESSAGETRUNCATE.Length)) + nextEvent.MessageString.Substring(Constants.MESSAGETRUNCATE.Length)); } #endregion continue; } // If we get here then this message is not a truncation so its either an ODS or Tex message // If it was not a truncation its either a message from another app or a tex message if (!TraceMessageFormat.IsTexString(nextEvent.MessageString)) { // Horrid workaround but whatever, patched this in after the code will refactor in phase 2 if (TraceMessageFormat.IsLegacyTexString(nextEvent.MessageString)) { legacyMode = true; goto LEGACYSUPPORT; } // if its not tex the assumption is that it has always come from this machine, although if mex gets v clever this could change NonTracedApplicationEntry newNte = new NonTracedApplicationEntry(nextEvent.Pid, nextEvent.MessageString, nextEvent.GlobalIndex); if ((MexCore.TheCore.Options.XRefMatchingProcessIdsIntoEventEntries) && (MexCore.TheCore.DataManager.IsPidAKnownApplication(nextEvent.Pid, nextEvent.MachineName))) { // We need to check whether or not this came form the same PID if it did we need to cross reference it. ee = EventEntry.CreatePseudoEE(nextEvent.GlobalIndex, nextEvent.MessageString); tempMachineName = nextEvent.MachineName; if (MexCore.TheCore.Options.XRefReverseCopyEnabled) { // If were doing cross references by PID then we need to determine whether to dupe into the NTA list too. MexCore.TheCore.DataManager.PlaceUnknownEventIntoDataStructure(newNte); } // else we just throw away the NTA as its really a traced app malformed message } else { MexCore.TheCore.DataManager.PlaceUnknownEventIntoDataStructure(newNte); continue; } } // The goto bypasses the non legacy code LEGACYSUPPORT: int nextLogicalIndexAffected = -1; if (ee == null) { // Must be at least close to legit string as it passed our validation. Therefore we create a new known event entry and provide it with // the required information to be stored in the traced applications. string tempCommandType; string tempPid; int tPid; string tempDebugMessage; ee = new EventEntry(nextEvent.GlobalIndex); // Create new entry giving it next index ee.m_timeMessageRecieved = nextEvent.TimeRecieved; if (legacyMode) { TraceMessageFormat.ReturnPartsOfStringLegacy(nextEvent.MessageString, out tempCommandType, out tempPid, out tempMachineName, out ee.ThreadID, out ee.Module, out ee.LineNumber, out tempDebugMessage); ee.ThreadNetId = "??"; ee.MoreLocationData = "LegacyTexSupport"; legacyMode = false; } else { TraceMessageFormat.ReturnPartsOfString(nextEvent.MessageString, out tempCommandType, out tempPid, out ee.ThreadNetId, out tempMachineName, out ee.ThreadID, out ee.Module, out ee.LineNumber, out ee.MoreLocationData, out tempDebugMessage); } tPid = int.Parse(tempPid); ee.SetDebugMessage(tempDebugMessage); // Checks for secondary data and splits accordingly TraceCommandTypes tct = TraceCommands.StringToTraceCommand(tempCommandType); if (tct == TraceCommandTypes.CommandXML) { TracedApplication additionalDataTracedApp = GetTracedApplicationWithCreate(tempMachineName, tPid); additionalDataTracedApp.SetStatusContentsFromXml(tempDebugMessage); nextLogicalIndexAffected = additionalDataTracedApp.VirtualIndex; isCommand = true; } else { if ((tct == TraceCommandTypes.MoreInfo) && (tempDebugMessage.StartsWith(Constants.DATAINDICATOR))) { // Data indicator messages include things like the initialisation strings sent when you call//Bilge.Initialise() - this is where additional // information is given about the process and additionally where things like the intitialisation / partial purge on init takes place. TracedApplication additionalDataTracedApp = GetTracedApplicationWithCreate(tempMachineName, tPid); #region Data indicator messages are not imported, they change the viewer behaviour. tempDebugMessage = tempDebugMessage.Substring(Constants.DATAINDICATOR.Length); ee.DebugMessage = ee.DebugMessage.Substring(Constants.DATAINDICATOR.Length); // Chopped off ~~DATA:: switch (ee.DebugMessage[0]) { case 'P': //ProcessName // If they have specified their own preferred name for the application then it is passed through here, this preferred name // should replace most of the alternative views. if ((ee.SecondaryMessage != null) && (ee.SecondaryMessage.Length > 0)) { additionalDataTracedApp.PreferredName = ee.SecondaryMessage; } // The process name is contained in ProcessName() string actualAppName = ee.DebugMessage.Substring(Consts.PROCNAMEIDENT_PREFIX.Length); actualAppName = actualAppName.Substring(0, (actualAppName.Length - Consts.PROCNAMEIDENT_POSTFIX.Length)); ee.DebugMessage = actualAppName; if (MexCore.TheCore.Options.XRefAppInitialiseToMain) { // If this option is selected we place a message into the unknown events to indicate that theres an Xref occured MexCore.TheCore.DataManager.PlaceUnknownEventIntoDataStructure(new NonTracedApplicationEntry(tPid, "Process " + actualAppName + " Started with pid : (" + tPid.ToString() + ")", nextEvent.GlobalIndex)); } if (MexCore.TheCore.Options.AutoPurgeApplicationOnMatchingName) { // BUG!!! Omg too dumb. Realised only after coding this that if oyu add autopurge as a job option it kicks // in after the import and then purges all of the new messages. Aysnchthink ftw. //Bilge.Log("Synchronous Purge By Matching Name starting. Trying to purge name " + actualAppName, "However skipping new pid which is " + tPid); MexCore.TheCore.DataManager.PurgeByName(actualAppName, tempMachineName, tPid); //MexCore.TheCore.WorkManager.ProcessJob(new Job_PartialPurgeApp(tempMachineName,tPid)); //Bilge.Log("Synchronous Purge By Matching Name Completes."); } additionalDataTracedApp.ProcessName = actualAppName; MexCore.TheCore.WorkManager.AddJob(new Job_NotifyKnownProcessUpdate(MexCore.TheCore.ViewManager.SelectedTracedAppIdx)); break; case 'M': //MainModule additionalDataTracedApp.MainModule = ee.DebugMessage; break; case 'W': additionalDataTracedApp.WindowTitle = ee.DebugMessage; break; case 'I': // Initialise(MachineName\appName) skipped. string initName = ee.DebugMessage.Substring(10, ee.DebugMessage.Length - 10); additionalDataTracedApp.AssemblyFullName = ee.SecondaryMessage; additionalDataTracedApp.InitialiseName = initName; ee.DebugMessage = initName; break; case 'C': // Calling Assembly string assemblyData = tempDebugMessage.Substring(16, tempDebugMessage.Length - 17); additionalDataTracedApp.CallingAssemblyInfo = assemblyData; break; case 'E': // Executing Assembly assemblyData = tempDebugMessage.Substring(18, tempDebugMessage.Length - 19); additionalDataTracedApp.ExecutingAssemblyInfo = assemblyData; break; case 'T': // ThreadName //Bilge.Warning("Not Implemented, thread name request recieved but this functionality is not implemented in MEX yet"); break; default: //Bilge.Assert(false, "This should not be possible, we should never reach this bit of code."); break; } #endregion continue; } // End if it starts with a data indicator // If we get here its a Tex message that is not a data indicator // This is looking like a normal message. IE Not a moreinfo / data string if (nextEvent.Pid == -1) { nextEvent.Pid = int.Parse(tempPid); } ee.cmdType = tct; // Some messages can be cross referenced into the main view if the options say that. This section deals with // creating the duplicate messages for this cross reference to work. #region support cross references to main view based on type of event if (MexCore.TheCore.Options.XRefAssertionsToMain && ee.cmdType == TraceCommandTypes.AssertionFailed) { MexCore.TheCore.DataManager.PlaceUnknownEventIntoDataStructure(new NonTracedApplicationEntry(tPid, ee.DebugMessage, ee.GlobalIndex)); } if (MexCore.TheCore.Options.XRefErrorsToMain && ee.cmdType == TraceCommandTypes.ErrorMsg) { MexCore.TheCore.DataManager.PlaceUnknownEventIntoDataStructure(new NonTracedApplicationEntry(tPid, ee.DebugMessage, ee.GlobalIndex)); } if (MexCore.TheCore.Options.XRefExceptionsToMain && ee.cmdType == TraceCommandTypes.ExceptionBlock) { MexCore.TheCore.DataManager.PlaceUnknownEventIntoDataStructure(new NonTracedApplicationEntry(tPid, ee.DebugMessage, ee.GlobalIndex)); } if (MexCore.TheCore.Options.XRefLogsToMain && ee.cmdType == TraceCommandTypes.LogMessage) { MexCore.TheCore.DataManager.PlaceUnknownEventIntoDataStructure(new NonTracedApplicationEntry(tPid, ee.DebugMessage, ee.GlobalIndex)); } if (MexCore.TheCore.Options.XRefVerbLogsToMain && ee.cmdType == TraceCommandTypes.LogMessageVerb) { MexCore.TheCore.DataManager.PlaceUnknownEventIntoDataStructure(new NonTracedApplicationEntry(tPid, ee.DebugMessage, ee.GlobalIndex)); } if (MexCore.TheCore.Options.XRefResourceMessagesToMain) { if ((ee.cmdType == TraceCommandTypes.ResourceEat) || (ee.cmdType == TraceCommandTypes.ResourcePuke) || (ee.cmdType == TraceCommandTypes.ResourceCount)) { MexCore.TheCore.DataManager.PlaceUnknownEventIntoDataStructure(new NonTracedApplicationEntry(tPid, ee.DebugMessage, ee.GlobalIndex)); } } if (MexCore.TheCore.Options.XRefWarningsToMain && ee.cmdType == TraceCommandTypes.WarningMsg) { MexCore.TheCore.DataManager.PlaceUnknownEventIntoDataStructure(new NonTracedApplicationEntry(tPid, ee.DebugMessage, ee.GlobalIndex)); } #endregion if (tempDebugMessage.EndsWith(Constants.MESSAGETRUNCATE)) { //Bilge.Log("IncommingMessageManager::ProcessNextStoredMessage --> Truncation message found, storing event for future"); // Truncated messages end with #TNK#JoinID#TNK# this lets us join them back together using the unique join id - however // joinIds are only unique per process/machien therefore all of this info is used as a key. int idxStart = tempDebugMessage.IndexOf(Constants.MESSAGETRUNCATE) + Constants.MESSAGETRUNCATE.Length; string joinIdentifier = tempDebugMessage.Substring(idxStart, tempDebugMessage.Length - (idxStart + Constants.MESSAGETRUNCATE.Length)); MexCore.TheCore.CacheManager.CacheAdd_EventEntryExpectingTruncate(ee, nextEvent.Pid, tempMachineName, joinIdentifier); } } } // End if it was a normal tex message (ee==null) if (!isCommand) { //Bilge.Assert(ee != null, "The event entry must be populated by now in the code"); // Whether or not it was a cross reference its imported into the data structures now. //Bilge.Assert(tempMachineName != null, "machine name must be populated by the time we add it to the data structures"); ee.SupportingData = SupportingMessageData.ParseAsMessageData(ee.cmdType, ref ee.DebugMessage, ref ee.SecondaryMessage); MexCore.TheCore.ViewManager.CurrentHighlightOptions.ModifyEventEntryForHighlight(ee); // *************** Actually add it into the structure here *************** nextLogicalIndexAffected = MexCore.TheCore.DataManager.PlaceNewEventIntoDataStructure(ee, nextEvent.Pid, tempMachineName); } if (!appIndexesAffectedByImport.Contains(nextLogicalIndexAffected)) { appIndexesAffectedByImport.Add(nextLogicalIndexAffected); } #if DUAL if (!comparer.Compare(ee)) { // This is our porting code, if this fires then we have got a problem with our new parser. //Bilge.WarningLog("FAILED A COMPARISON"); throw new InvalidOperationException("The new parser is out of sync"); } #endif #if !DEBUG } catch (Exception ex) { //Bilge.Dump(ex, "IncommingMessageManager::ProcessNextStoredMessage Trying to process a string from the stack, lost string during processing."); // DO NOT SWALLOW THIS!, results in an infinite loop throw; } #endif if (reporting) { // For long running imports make sure that we tell the client side every now and again TimeSpan ts = DateTime.Now - startTime; if ((ts.TotalSeconds > MexCore.TheCore.Options.NoSecondsForRefreshOnImport)) { startTime = DateTime.Now; TimeSpan overall = DateTime.Now - overallStartTime; MexCore.TheCore.ViewManager.AddUserNotificationMessageByIndex(ViewSupportManager.UserMessages.MessageImportLongRunning, ViewSupportManager.UserMessageType.InformationMessage, overall.TotalSeconds.ToString() + "s elapsed."); foreach (int appAffectedIdx in appIndexesAffectedByImport) { MexCore.TheCore.WorkManager.ProcessJob(new Job_NotifyNewEventAdded(appAffectedIdx)); } } } } while ((m_incommingMsgQueue.Count > 0) && (doAll)); } finally { if (MexCore.TheCore.Options.PersistEverything) { everythingLog.Close(); everythingStream.Close(); everythingLog.Dispose(); everythingStream.Dispose(); } } foreach (int appAffectedIdx in appIndexesAffectedByImport) { MexCore.TheCore.WorkManager.AddJob(new Job_NotifyNewEventAdded(appAffectedIdx)); } }
public static bool IsResourceCommand(TraceCommandTypes tct) { return(((uint)tct & RESOURCECOMMANDS) == (uint)tct); }
public static bool IsExceptionCommand(TraceCommandTypes tct) { return(((uint)tct & EXCEPTIONCOMMANDS) == (uint)tct); }
private bool WriteConsolePreamble(TraceCommandTypes commandType) { bool doWrite = true; string preamble = ""; ConsoleColor cc = ConsoleColor.White; switch (commandType) { case TraceCommandTypes.LogMessageVerb: cc = ConsoleColor.Blue; preamble = "Verb"; break; case TraceCommandTypes.LogMessage: case TraceCommandTypes.LogMessageMini: cc = ConsoleColor.Green; preamble = "Info"; break; case TraceCommandTypes.SectionStart: case TraceCommandTypes.SectionEnd: case TraceCommandTypes.ResourceEat: case TraceCommandTypes.ResourcePuke: case TraceCommandTypes.ResourceCount: case TraceCommandTypes.Standard: case TraceCommandTypes.CommandXML: case TraceCommandTypes.Custom: case TraceCommandTypes.MoreInfo: case TraceCommandTypes.CommandOnly: case TraceCommandTypes.InternalMsg: case TraceCommandTypes.TraceMessageIn: case TraceCommandTypes.TraceMessageOut: case TraceCommandTypes.TraceMessage: doWrite = false; break; case TraceCommandTypes.AssertionFailed: cc = ConsoleColor.Blue; preamble = "Assert"; break; case TraceCommandTypes.ErrorMsg: cc = ConsoleColor.Red; preamble = "Error"; break; case TraceCommandTypes.WarningMsg: cc = ConsoleColor.DarkYellow; preamble = "Warn"; break; case TraceCommandTypes.ExceptionBlock: case TraceCommandTypes.ExceptionData: case TraceCommandTypes.ExcStart: case TraceCommandTypes.ExcEnd: cc = ConsoleColor.DarkMagenta; preamble = "Fault"; break; case TraceCommandTypes.Alert: cc = ConsoleColor.Blue; preamble = "Alert"; break; case TraceCommandTypes.Unknown: doWrite = false; break; } if (doWrite) { Console.ForegroundColor = cc; Console.Write(preamble); Console.ForegroundColor = ConsoleColor.White; Console.Write(" : "); } return(doWrite); }
public static bool IsSectionCommand(TraceCommandTypes tct) { return(((uint)tct & SECTIONCOMMANDS) == (uint)tct); }
/// <summary> /// Takes the name of a secific message type and indicates whether or not this filter will allow this message type to be displayed. /// </summary> /// <param name="tct">The trace command type to check the filter against</param> /// <returns>True if this type is displayed after filter processing, false if the filter removes these types</returns> internal bool TraceMessageTypeIncludedByFilter(TraceCommandTypes tct) { return((((uint)tct) & m_flagsForInclude) == (uint)tct); }