private void ProcessLine(DEBUG_OUTPUT Mask, string line) { if (OutputFilter != null) { if (!Mask.HasFlag(DEBUG_OUTPUT.STATUS)) { string filteredLine = OutputFilter.FilterText(line); if (!string.IsNullOrEmpty(filteredLine)) { line = filteredLine; } else { return; } } } if (LogFile != null) { LogFile.Write(line); } if (PassThrough) { PassThroughLine(Mask, line); } if (PassThroughOnly == false) { DataBuffer.Append(line); } }
private void ProcessLine(DEBUG_OUTPUT Mask, string line, bool textIsDml, DEBUG_OUTCBF dmlFlags) { if (OutputFilter != null) { string filteredLine = OutputFilter.FilterText(Mask, line, textIsDml, dmlFlags); if (!string.IsNullOrEmpty(filteredLine)) { line = filteredLine; } else { return; } } if (LogFile != null) { LogFile.Write(line); } if (PassThrough) { PassThroughLine(Mask, line, textIsDml, dmlFlags); } if (PassThroughOnly == false) { DataBuffer.Append(line); } }
private int OutputLineHelper(string formattedString, DEBUG_OUTPUT outputType) { formattedString = EscapePercents(formattedString); int hr = DebugControl.ControlledOutputWide(OutCtl, outputType, formattedString); return(FAILED(hr) ? hr : DebugControl.ControlledOutputWide(OutCtl, outputType, "\n")); }
/// <summary> /// Process any remaining data such as a partial (non-terminated) line or output cached by a filter. /// </summary> public void Flush() { lock (this) { if (PreviousMask == DEBUG_OUTPUT.STATUS || PreviousMask == (int)0) { PreviousMask = DEBUG_OUTPUT.NORMAL; } foreach (var LineBuffer in LineBuffers) { if (LineBuffer.Value.Length != 0) { LineBuffer.Value.AppendLine(); /* Decided it is always best to end with a line break, so adding one here during a flush */ ProcessLine(LineBuffer.Key, LineBuffer.Value.ToString(), PreviousTextWasDml, PreviousDmlFlags); LineBuffer.Value.Length = 0; LineInputPositions[LineBuffer.Key] = 0; } } if (OutputFilter != null) { string flushedData = OutputFilter.Flush(); if (!string.IsNullOrEmpty(flushedData)) { ProcessLineNoFilter(PreviousMask, flushedData, PreviousTextWasDml, PreviousDmlFlags); } } PassthroughUtilities.OutputMaskRestore(); } }
public int Output(DEBUG_OUTPUT Mask, string Text) { switch (Mask) { case DEBUG_OUTPUT.DEBUGGEE: Console.ForegroundColor = ConsoleColor.Gray; break; case DEBUG_OUTPUT.PROMPT: Console.ForegroundColor = ConsoleColor.Magenta; break; case DEBUG_OUTPUT.ERROR: Console.ForegroundColor = ConsoleColor.Red; break; case DEBUG_OUTPUT.EXTENSION_WARNING: case DEBUG_OUTPUT.WARNING: Console.ForegroundColor = ConsoleColor.Yellow; break; case DEBUG_OUTPUT.SYMBOLS: Console.ForegroundColor = ConsoleColor.Cyan; break; default: Console.ForegroundColor = ConsoleColor.White; break; } Console.Write(Text); return((int)DEBUG_STATUS.NO_CHANGE); }
/// <summary> /// Execute a debugger command. /// </summary> public string Execute(string command) { StringBuilder outputText = _OutputCallbacks.OutputText; DEBUG_OUTPUT mask = _OutputCallbacks.OutputMask; outputText.Clear(); _OutputCallbacks.OutputMask = DEBUG_OUTPUT.NORMAL | DEBUG_OUTPUT.SYMBOLS | DEBUG_OUTPUT.ERROR | DEBUG_OUTPUT.WARNING; _Log.WriteLine("Executing Debugger Command: " + command); string result = null; try { int hr = DebugControl.Execute(DEBUG_OUTCTL.ALL_CLIENTS, command, DEBUG_EXECUTE.DEFAULT); if (hr < 0) { outputText.Append(string.Format("Command encountered an error. HRESULT={0:X8}", hr)); } result = _OutputCallbacks.OutputText.ToString(); } finally { _OutputCallbacks.OutputMask = mask; outputText.Clear(); } _Log.WriteLine("Debugger Command Result:"); _Log.WriteLine(result); return(result); }
public string Execute(ulong handle, string command, string args) { DEBUG_OUTPUT mask = _outputMask; _output.Clear(); _outputMask = DEBUG_OUTPUT.NORMAL | DEBUG_OUTPUT.SYMBOLS | DEBUG_OUTPUT.ERROR | DEBUG_OUTPUT.WARNING | DEBUG_OUTPUT.DEBUGGEE; string result = null; try { int hr = _control.CallExtension(handle, command, args); if (hr < 0) { _output.Append(string.Format("Command encountered an error. HRESULT={0:X8}", hr)); } result = _output.ToString(); } finally { _outputMask = mask; _output.Clear(); } return(result); }
public string ExecuteScript(string script) { DEBUG_OUTPUT mask = _outputMask; _output.Clear(); _outputMask = DEBUG_OUTPUT.NORMAL | DEBUG_OUTPUT.SYMBOLS | DEBUG_OUTPUT.ERROR | DEBUG_OUTPUT.WARNING | DEBUG_OUTPUT.DEBUGGEE; string result = null; try { int hr = _control.ExecuteCommandFile(DEBUG_OUTCTL.ALL_CLIENTS, script, DEBUG_EXECUTE.DEFAULT); if (hr < 0) { _output.Append(string.Format("Script encountered an error. HRESULT={0:X8}", hr)); } result = _output.ToString(); } finally { _outputMask = mask; _output.Clear(); } return(result); }
/// <summary> /// Outputs a line of text. /// </summary> /// <param name="Mask">Flags describing the output.</param> /// <param name="Text">The text to output.</param> /// <returns>HRESULT which is almost always S_OK since errors are ignored by the debugger engine unless they signal an RPC error.</returns> public int Output(DEBUG_OUTPUT Mask, string Text) { //stbOutPut.Append(Text); //return S_OK; return Output2(DEBUG_OUTCB.TEXT, 0, (UInt64)Mask, Text); }
public CallbackData(DEBUG_OUTPUT Mask, DbgStringBuilder Data, bool isDML = true, DEBUG_OUTCBF dmlFlags = 0) { this.Mask = Mask; this.Data = Data; IsDML = isDML; DMLFlags = dmlFlags; }
//public void Output(string format,params string[] args) //{ // OutputHelper(output, DEBUG_OUTPUT.NORMAL | DEBUG_OUTPUT.VERBOSE); //} private int OutputHelper(string formattedString, DEBUG_OUTPUT outputType) { //formattedString = EscapePercents(formattedString); //debugOutput.Append(formattedString); return(DebugControl.ControlledOutput(DEBUG_OUTCTL.ALL_OTHER_CLIENTS | DEBUG_OUTCTL.DML, outputType, formattedString)); //return DebugControl.ControlledOutputWide(OutCtl, outputType, formattedString); }
//FIX ME!!! This is a hack due to Win8:235420 private void PassThroughLine(DEBUG_OUTPUT Mask, string line, bool textIsDml, DEBUG_OUTCBF dmlFlags) { if (ReEnter == false) { ReEnter = true; DEBUG_OUTCTL outctl; if (PassthroughUtilities.IsFirstCommand) { outctl = DEBUG_OUTCTL.ALL_CLIENTS; } else { outctl = DEBUG_OUTCTL.THIS_CLIENT | DEBUG_OUTCTL.NOT_LOGGED; } if (textIsDml) { outctl |= DEBUG_OUTCTL.DML; } if (Mask.HasFlag(DEBUG_OUTPUT.ADDR_TRANSLATE) && (Mask.HasFlag(DEBUG_OUTPUT.NORMAL | DEBUG_OUTPUT.ERROR | DEBUG_OUTPUT.WARNING | DEBUG_OUTPUT.VERBOSE) == false)) { Mask = Mask | DEBUG_OUTPUT.NORMAL; } try { PreviousMask = Mask; if (InstalledThreadId == Thread.CurrentThread.ManagedThreadId) { PassthroughUtilities.DebugClient.FlushCallbacks(); PassthroughUtilities.OutputMaskRestore(); PassthroughUtilities.ControlledOutputWide(outctl, Mask, line); PassthroughUtilities.OutputMaskDisableAll(); } else { BufferedOutput.Add(new BufferLine(outctl, Mask, line)); } } catch { DebugUtilities.CoUninitialize(); if (InstalledThreadId == Thread.CurrentThread.ManagedThreadId) { PassthroughUtilities.OutputMaskRestore(); PassthroughUtilities.ControlledOutputWide(outctl, Mask, line); PassthroughUtilities.OutputMaskDisableAll(); } else { BufferedOutput.Add(new BufferLine(outctl, Mask, line)); } } ReEnter = false; } }
public int Output(DEBUG_OUTPUT Mask, string Text) { if (_Output != null && ((Mask & _OutputMask) != 0)) { _Output.Append(Text); } return((int)DEBUG_STATUS.GO); }
/// <summary> /// Outputs some text using the specified mask /// </summary> /// <param name="mask">The mask.</param> /// <param name="text">The text.</param> /// <returns>System.Int32.</returns> int IDebugOutputCallbacks.Output(DEBUG_OUTPUT mask, string text) { lock (_builder) { _builder.Append(text); } return(0); }
public int Output(DEBUG_OUTPUT Mask, string Text) { if (_output != null && (_outputMask & Mask) != 0) { _output.Append(Text); } return(0); }
public void OutputString(DEBUG_OUTPUT mask, string message) { if (message == null) throw new ArgumentNullException(nameof(message)); byte[] messageBytes = Encoding.ASCII.GetBytes(message + "\0"); fixed (byte* messagePtr = messageBytes) { VTable.OutputString(Self, mask, messagePtr); } }
int IDebugOutputCallbacks.Output(DEBUG_OUTPUT mask, string text) { try { _converter.Input(text); } catch (Exception) { } return(0); }
private RgbColor ColorFromType(DEBUG_OUTPUT type) { RgbColor color; if (_historyColors.TryGetValue(type, out color)) { return(color); } return(new RgbColor()); }
public int Output(DEBUG_OUTPUT Mask, string Text) { if (Mask.HasFlag(DEBUG_OUTPUT.NORMAL)) { text.Append(Text); } if (Mask.HasFlag(DEBUG_OUTPUT.ERROR)) { error.Append(Text); } return(0); // S_OK }
private string FilterLine(DEBUG_OUTPUT Mask, string line, bool textIsDml, DEBUG_OUTCBF dmlFlags) { if (Mask.HasFlag(DEBUG_OUTPUT.STATUS)) { return(line); } if (OutputFilter != null) { string filteredLine = OutputFilter.FilterText(Mask, line, textIsDml, dmlFlags); return(!string.IsNullOrEmpty(filteredLine) ? filteredLine : ""); } return(line); }
int OutputVaList( IntPtr self, DEBUG_OUTPUT mask, string format, IntPtr va_list) { try { _context.Write(format); } catch (OperationCanceledException) { // ctrl-c interrupted the command } return(S_OK); }
internal int OutputVaList( IntPtr self, DEBUG_OUTPUT mask, string format, IntPtr va_list) { try { // The text has already been formated by sos _console.Write(format); } catch (OperationCanceledException) { // ctrl-c interrupted the command } return(S_OK); }
int IDebugOutputCallbacksWide.Output(DEBUG_OUTPUT Mask, string Text) { if (ConsumeOutput && Mask.HasFlag(DEBUG_OUTPUT.NORMAL)) { OutputText.Append(Text); } else if (ConsumeOutput) { using (var ev = new EventWaitHandle(false, EventResetMode.AutoReset, OutputTextEventName)) { ev.Set(); } ConsumeOutput = false; } else { OnOutputCallback(new OutputCallbackEventArgs(Text, Mask)); } return(0); }
} // end constructor // TODO: maybe I want this always turned on?? I had a case where an Ioctl returned S_OK, // but spewed some error text to the output; it woulda been nice to have seen that before // I debugged through it all. public int Output(DEBUG_OUTPUT Mask, string Text) { try { Util.Assert(null != Text); if (String.IsNullOrEmpty(Text)) { return(0); } // TODO: powershell-ize, using Mask for (int i = 0; i < Text.Length; i++) { if (0 == m_sb.Length) { m_sb.Append(m_prefix); } if ('\r' == Text[i]) { continue; } if ('\n' == Text[i]) { Util.Assert(m_sb.Length >= m_prefix.Length); var line = m_sb.ToString(); m_sb.Clear(); m_recentDbgEngOutput.Add(line); m_ConsumeLine(line); } else { m_sb.Append(Text[i]); } } // end foreach( char ) } catch (Exception e) { Util.FailFast("Unexpected exception in output callback", e); } return(0); } // end Output()
/// <summary> /// Implements IDebugOutputCallbacks2::Output2 /// </summary> public int Output2(DEBUG_OUTCB Which, DEBUG_OUTCBF Flags, UInt64 Arg, string Text) { DEBUG_OUTPUT Mask = (DEBUG_OUTPUT)Arg; if (Which == DEBUG_OUTCB.EXPLICIT_FLUSH) { //Flush(); return(S_OK); } else if ((Text == null) || (Text.Length == 0)) { return(S_OK); } bool textIsDml = (Which == DEBUG_OUTCB.DML); stbOutPut.Append(Text); return(S_OK); }
private void ProcessLineNoFilter(DEBUG_OUTPUT Mask, string line) { if (line == null) { return; } if (LogFile != null) { LogFile.Write(line); } if (PassThrough) { PassThroughLine(Mask, line); } if (PassThroughOnly == false) { DataBuffer.Append(line); } }
/// <summary> /// Outputs a line of test. /// </summary> /// <param name="Mask">Flags describing the output.</param> /// <param name="Text">The text to output.</param> /// <returns> /// HRESULT which is almost always S_OK since errors are ignored by the debugger engine unless they signal an RPC /// error. /// </returns> public int Output(DEBUG_OUTPUT Mask, string Text) { if (OutputActive) { lock (this) { OutputActive = false; PreviousMask = Mask; for (int i = 0; i < Text.Length; ++i) { char c = Text[i]; if (c == '\n') { LineBuffer.AppendLine(); ProcessLine(Mask, LineBuffer.ToString()); LineBuffer.Clear(); LineInputPos = 0; } else if (c == '\r') { LineInputPos = 0; } else { if (LineInputPos >= LineBuffer.Length) { LineBuffer.Append(c); } else { LineBuffer[LineInputPos] = c; } ++LineInputPos; } } OutputActive = true; } } return(S_OK); }
public int Output(DEBUG_OUTPUT mask, string text) { switch (mask) { case DEBUG_OUTPUT.ERROR: _context.WriteError(text); break; case DEBUG_OUTPUT.EXTENSION_WARNING: case DEBUG_OUTPUT.WARNING: _context.WriteWarning(text); break; case DEBUG_OUTPUT.SYMBOLS: _context.WriteInfo(text); break; default: _context.Write(text); break; } return 0; }
public int Output([In] DEBUG_OUTPUT Mask, [In, MarshalAs(UnmanagedType.LPStr)] string Text) { if (_outputText == false) { return(0); } switch (Mask) { case DEBUG_OUTPUT.DEBUGGEE: Console.ForegroundColor = ConsoleColor.Gray; break; case DEBUG_OUTPUT.PROMPT: Console.ForegroundColor = ConsoleColor.Magenta; break; case DEBUG_OUTPUT.ERROR: Console.ForegroundColor = ConsoleColor.Red; break; case DEBUG_OUTPUT.EXTENSION_WARNING: case DEBUG_OUTPUT.WARNING: Console.ForegroundColor = ConsoleColor.Yellow; break; case DEBUG_OUTPUT.SYMBOLS: Console.ForegroundColor = ConsoleColor.Cyan; break; default: Console.ForegroundColor = ConsoleColor.White; break; } Console.Write(Text); return(0); }
/// <summary> /// Process any remaining data such as a partial (non-terminated) line or output cached by a filter. /// </summary> public void Flush() { lock (this) { if (PreviousMask == DEBUG_OUTPUT.STATUS || PreviousMask == (int)0) { PreviousMask = DEBUG_OUTPUT.NORMAL; } if (LineBuffer.Length != 0) { LineBuffer.AppendLine(); /* Decided it is always best to end with a line break, so adding one here during a flush */ ProcessLine(PreviousMask, LineBuffer.ToString()); LineBuffer.Length = 0; LineInputPos = 0; } if (OutputFilter != null) { string flushedData = OutputFilter.Flush(); if (!string.IsNullOrEmpty(flushedData)) { ProcessLineNoFilter(PreviousMask, flushedData); } } if (LogFile != null) { try { LogFile.Flush(); } catch {} } PassthroughUtilities.OutputMaskRestore(); } }
/// <summary> /// Callback for when text is received by the callbacks object /// </summary> /// <param name="mask">The mask.</param> /// <param name="text">The text.</param> /// <returns>System.Int32.</returns> int IDebugOutputCallbacks.Output(DEBUG_OUTPUT mask, string text) { switch (mask) { case DEBUG_OUTPUT.ERROR: Log.Error("{CommandError}", text); break; case DEBUG_OUTPUT.EXTENSION_WARNING: case DEBUG_OUTPUT.WARNING: Log.Warning("{CommandWarning}", text); break; case DEBUG_OUTPUT.SYMBOLS: Log.Information("{SymbolOutput}", text); break; default: Builder.Append(text); break; } return(0); }
public int Output(DEBUG_OUTPUT mask, string text) { switch (mask) { case DEBUG_OUTPUT.ERROR: _context.WriteError(text); break; case DEBUG_OUTPUT.EXTENSION_WARNING: case DEBUG_OUTPUT.WARNING: _context.WriteWarning(text); break; case DEBUG_OUTPUT.SYMBOLS: _context.WriteInfo(text); break; default: _context.Write(text); break; } return(0); }
int IDebugOutputCallbacks.Output(DEBUG_OUTPUT Mask, string Text) { return Output(Mask, Text); }
private int OutputHelper(string formattedString, DEBUG_OUTPUT outputType) { formattedString = EscapePercents(formattedString); return DebugControl.ControlledOutputWide(OutCtl, outputType, formattedString); }
public string ExecuteScript(string script) { DEBUG_OUTPUT mask = _outputMask; _output.Clear(); _outputMask = DEBUG_OUTPUT.NORMAL | DEBUG_OUTPUT.SYMBOLS | DEBUG_OUTPUT.ERROR | DEBUG_OUTPUT.WARNING | DEBUG_OUTPUT.DEBUGGEE; string result = null; try { int hr = _control.ExecuteCommandFile(DEBUG_OUTCTL.ALL_CLIENTS, script, DEBUG_EXECUTE.DEFAULT); if (hr < 0) _output.Append(string.Format("Script encountered an error. HRESULT={0:X8}", hr)); result = _output.ToString(); } finally { _outputMask = mask; _output.Clear(); } return result; }
private int OutputLineHelper(string formattedString, DEBUG_OUTPUT outputType) { formattedString = EscapePercents(formattedString); int hr = DebugControl.ControlledOutputWide(OutCtl, outputType, formattedString); return FAILED(hr) ? hr : DebugControl.ControlledOutputWide(OutCtl, outputType, "\n"); }
public string Execute(ulong handle, string command, string args) { DEBUG_OUTPUT mask = _outputMask; _output.Clear(); _outputMask = DEBUG_OUTPUT.NORMAL | DEBUG_OUTPUT.SYMBOLS | DEBUG_OUTPUT.ERROR | DEBUG_OUTPUT.WARNING | DEBUG_OUTPUT.DEBUGGEE; string result = null; try { int hr = _control.CallExtension(handle, command, args); if (hr < 0) _output.Append(string.Format("Command encountered an error. HRESULT={0:X8}", hr)); result = _output.ToString(); } finally { _outputMask = mask; _output.Clear(); } return result; }
//public void Output(string format,params string[] args) //{ // OutputHelper(output, DEBUG_OUTPUT.NORMAL | DEBUG_OUTPUT.VERBOSE); //} private int OutputHelper(string formattedString, DEBUG_OUTPUT outputType) { //formattedString = EscapePercents(formattedString); //debugOutput.Append(formattedString); return DebugControl.ControlledOutput(DEBUG_OUTCTL.ALL_OTHER_CLIENTS|DEBUG_OUTCTL.DML,outputType, formattedString); //return DebugControl.ControlledOutputWide(OutCtl, outputType, formattedString); }
public int Output(DEBUG_OUTPUT Mask, string Text) { if (_output != null && (_outputMask & Mask) != 0) _output.Append(Text); return 0; }