public ColorString ToColorString() { if (DEBUG_EVENT.NONE == EventType) { return(ColorString.Empty); } ColorString csThreadId; if (0xffffffff == ThreadId) { csThreadId = new ColorString(ConsoleColor.Red, "ffffffff"); } else { csThreadId = new ColorString(m_debugger.GetUModeThreadByDebuggerId(ThreadId).Tid.ToString("x")); } ColorString cs = new ColorString(ConsoleColor.Black, ConsoleColor.White, " Last event:") .Append(" ") .Append(m_debugger.GetProcessSystemId(ProcessId).ToString("x")) .Append(".") .Append(csThreadId) .Append(": "); DbgModuleInfo mod = null; string tmp = null; string[] lines = null; switch (EventType) { case DEBUG_EVENT.NONE: Util.Fail("can't get here"); // we returned ColorString.Empty above break; case DEBUG_EVENT.BREAKPOINT: cs.Append(Description); break; case DEBUG_EVENT.EXCEPTION: tmp = ExceptionEventArgs._CreateMessage(m_debugger, ExtraInformation.Exception.ExceptionRecord, ExtraInformation.Exception.FirstChance != 0, 0, null, false).ToString(DbgProvider.HostSupportsColor); lines = tmp.Split(sm_newline, StringSplitOptions.None); cs.AppendLine(lines[0]); for (int i = 1; i < lines.Length; i++) { cs.AppendPushPopFgBg(ConsoleColor.Black, ConsoleColor.White, " ") .Append(" ") .Append(lines[i]); if (i != lines.Length - 1) { cs.AppendLine(); } } break; case DEBUG_EVENT.CREATE_THREAD: cs.Append(Description); break; case DEBUG_EVENT.EXIT_THREAD: cs.Append(Description); break; case DEBUG_EVENT.CREATE_PROCESS: cs.Append(Description); break; case DEBUG_EVENT.EXIT_PROCESS: cs.Append(Description); break; case DEBUG_EVENT.LOAD_MODULE: // // Last event: 9c84.3984: Load module C:\WINDOWS\system32\ADVAPI32.dll at 00007ffb`b0cd0000 // debugger time: Mon Oct 20 19:30:56.164 2014 (UTC - 7:00) mod = m_debugger.GetModuleByAddress(ExtraInformation.LoadModule.Base); cs.Append("Loaded module ") .AppendPushPopFg(ConsoleColor.White, mod.ImageName) .Append(" at ") .Append(DbgProvider.FormatAddress(ExtraInformation.LoadModule.Base, m_debugger.TargetIs32Bit, true)); break; case DEBUG_EVENT.UNLOAD_MODULE: // TODO: test this! mod = m_debugger.GetModuleByAddress(ExtraInformation.UnloadModule.Base); cs.AppendPushPopFg(ConsoleColor.DarkRed, "Unloaded module ") .AppendPushPopFg(ConsoleColor.White, mod.ImageName) .Append(" at ") .Append(DbgProvider.FormatAddress(ExtraInformation.UnloadModule.Base, m_debugger.TargetIs32Bit, true)); break; case DEBUG_EVENT.SYSTEM_ERROR: // TODO: test this! cs.AppendPushPopFgBg(ConsoleColor.White, ConsoleColor.Red, "System error:") .Append(" ") .AppendPushPopFg(ConsoleColor.Red, Util.FormatErrorCode(ExtraInformation.SystemError.Error)) .Append(".") .AppendPushPopFg(ConsoleColor.Red, Util.FormatErrorCode(ExtraInformation.SystemError.Level)); // TODO: This is a hack. var w32e = new System.ComponentModel.Win32Exception((int)ExtraInformation.SystemError.Error); cs.AppendLine(); cs.AppendPushPopFg(ConsoleColor.Red, w32e.Message).Append("."); break; case DEBUG_EVENT.SESSION_STATUS: // DbgEng doesn't save these as "last events". Util.Fail(Util.Sprintf("Unexpected last event type: {0}", EventType)); break; case DEBUG_EVENT.CHANGE_DEBUGGEE_STATE: // DbgEng doesn't save these as "last events". Util.Fail(Util.Sprintf("Unexpected last event type: {0}", EventType)); break; case DEBUG_EVENT.CHANGE_ENGINE_STATE: // DbgEng doesn't save these as "last events". Util.Fail(Util.Sprintf("Unexpected last event type: {0}", EventType)); break; case DEBUG_EVENT.CHANGE_SYMBOL_STATE: // DbgEng doesn't save these as "last events". Util.Fail(Util.Sprintf("Unexpected last event type: {0}", EventType)); break; default: Util.Fail(Util.Sprintf("Unexpected event type: {0}", EventType)); throw new Exception(Util.Sprintf("Unexpected event type: {0}", EventType)); } // end switch( event type ) cs.AppendLine() .AppendPushPopFgBg(ConsoleColor.Black, ConsoleColor.White, " Debugger time:") .Append(" ") .Append(DbgProvider.FormatTimestamp(_GetDbgEngLastEventTimestamp(), true)); return(cs); } // end ToColorString()