コード例 #1
0
 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);
     }
 }
コード例 #2
0
 public CallbackData(DEBUG_OUTPUT Mask, DbgStringBuilder Data, bool isDML = true, DEBUG_OUTCBF dmlFlags = 0)
 {
     this.Mask = Mask;
     this.Data = Data;
     IsDML     = isDML;
     DMLFlags  = dmlFlags;
 }
コード例 #3
0
        public int Output2(DEBUG_OUTCB Which, DEBUG_OUTCBF Flags, ulong Arg, string Text)
        {
            _buffer.Append(Text);
            DoOutput(Text);

            return(HResult.Ok);
        }
コード例 #4
0
        //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;
            }
        }
コード例 #5
0
        public int Output2(DEBUG_OUTCB Which, DEBUG_OUTCBF Flags, ulong Arg, string Text)
        {
            if (Which != DEBUG_OUTCB.DML)
            {
                return(Output(DEBUG_OUTPUT.NORMAL, Text));
            }

            Console.Write("DML: {0}", Text);
            return(0);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
ファイル: OutputHandler.cs プロジェクト: rohithkrajan/ExtCS
        /// <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;
        }
コード例 #9
0
 int IDebugOutputCallbacks2.Output2(DEBUG_OUTCB Which, DEBUG_OUTCBF Flags, ulong Arg, string Text)
 {
     return(Output2(Which, Flags, Arg, Text));
 }
コード例 #10
0
 private void ProcessLineNoFilter(DEBUG_OUTPUT Mask, string line, bool textIsDml, DEBUG_OUTCBF dmlFlags)
 {
     if (line == null)
     {
         return;
     }
     if (LogFile != null)
     {
         LogFile.Write(line);
     }
     if (PassThrough)
     {
         PassThroughLine(Mask, line, textIsDml, dmlFlags);
     }
     if (PassThroughOnly == false)
     {
         DataBuffer.Append(line);
     }
 }
コード例 #11
0
        /// <summary>
        ///     Implements IDebugOutputCallbacks2::Output2
        /// </summary>
        public int Output2(DEBUG_OUTCB Which, DEBUG_OUTCBF Flags, UInt64 Arg, string Text)
        {
            var mask = (DEBUG_OUTPUT)Arg;

            if (Which == DEBUG_OUTCB.EXPLICIT_FLUSH)
            {
                //Flush();
                return(S_OK);
            }
            if (string.IsNullOrEmpty(Text))
            {
                return(S_OK);
            }
            bool textIsDml = (Which == DEBUG_OUTCB.DML);

            if (OutputActive)
            {
                lock (this)
                {
                    OutputActive       = false;
                    PreviousTextWasDml = textIsDml;
                    PreviousDmlFlags   = Flags;
                    DbgStringBuilder LineBuffer;
                    LineBuffers.TryGetValue(mask, out LineBuffer);
                    int LineInputPos = 0;
                    LineInputPositions.TryGetValue(mask, out LineInputPos);
                    bool waitForClosingDML = false;

                    if (LineBuffer == null)
                    {
                        LineBuffer        = new DbgStringBuilder(ExecutionUtilities, 1024);
                        LineBuffers[mask] = LineBuffer;
                    }
                    for (int i = 0; i < Text.Length; ++i)
                    {
                        char c = Text[i];
                        if (c == '<')
                        {
                            waitForClosingDML = true;
                        }
                        if (waitForClosingDML)
                        {
                            if (c == '>')
                            {
                                waitForClosingDML = false;
                            }
                        }
                        if (c == '\n' && waitForClosingDML == false)
                        {
                            LineBuffer.AppendLine();
                            ProcessLine(mask, LineBuffer.ToString(), textIsDml, Flags);
                            LineBuffer.Clear();
                            LineInputPos = 0;
                        }
                        else if (c == '\r')
                        {
                            LineInputPos = 0;
                        }
                        else
                        {
                            if (LineInputPos >= LineBuffer.Length)
                            {
                                LineBuffer.Append(c);
                            }
                            else
                            {
                                LineBuffer[LineInputPos] = c;
                            }
                            ++LineInputPos;
                        }
                    }

                    LineInputPositions[mask] = LineInputPos;

                    OutputActive = true;
                }
            }

            return(S_OK);
        }
コード例 #12
0
 public int Output2(DEBUG_OUTCB Which, DEBUG_OUTCBF Flags, ulong Arg, string Text)
 {
     Console.ForegroundColor = ConsoleColor.White;
     Console.Write(Text);
     return(0);
 }
コード例 #13
0
ファイル: OutputHandler.cs プロジェクト: rohithkrajan/ExtCS
 int IDebugOutputCallbacks2.Output2(DEBUG_OUTCB Which, DEBUG_OUTCBF Flags, ulong Arg, string Text)
 {
     return Output2(Which, Flags, Arg,Text);
 }
コード例 #14
0
        /// <summary>
        ///     Implements IDebugOutputCallbacks2::Output2
        /// </summary>
        public int Output2(DEBUG_OUTCB Which, DEBUG_OUTCBF Flags, ulong Arg, string Text)
        {
            var mask = (DEBUG_OUTPUT)Arg;

            if (string.IsNullOrEmpty(Text))
            {
                return(S_OK);
            }

            _executionUtilities.OutputMaskRestore();
            var textIsDml = Which == DEBUG_OUTCB.DML;

            if (_outputActive)
            {
                lock (this)
                {
                    _outputActive = false;

                    var sb = new DbgStringBuilder(_passthroughUtilities, Text.Length);
                    sb.Append(Text);
                    var callbackData = new CallbackData(mask, sb, textIsDml, Flags);

                    // The advanced filter gets 1st crack at the data before it goes to the line by line filter.
                    callbackData = _outputFilter.AdvancedFilterText(callbackData);
                    if (callbackData == null)
                    {
                        _outputActive = true;
                        return(S_OK);
                    }
                    // It can force data to be output now, skipping the line-by-line filtering.
                    if (callbackData.ForceOutputNow)
                    {
                        PassThroughLine(callbackData);
                        _outputActive = true;
                        return(S_OK);
                    }

                    Text = callbackData.Data.ToString();
                    // Was there a partial line for this mask? if so, lets finish it and send it to the filter!
                    CallbackData lineBuffer;
                    _lineBuffers.TryGetValue(callbackData.Mask, out lineBuffer);

                    if (lineBuffer == null)
                    {
                        lineBuffer         = new CallbackData(callbackData.Mask, new DbgStringBuilder(_passthroughUtilities, Text.Length), callbackData.IsDML, callbackData.DMLFlags);
                        _lineBuffers[mask] = lineBuffer;
                    }

                    for (var i = 0; i < Text.Length; ++i)
                    {
                        var c = Text[i];
                        if (c == '\n')
                        {
                            lineBuffer.Data.Append(c);
                            ProcessLine(lineBuffer.Copy(_passthroughUtilities));
                            lineBuffer.Clear();
                        }
                        else if (c == '\r')
                        {
                            if ((i + 1) < Text.Length && Text[i + 1] != '\n')
                            {
                                lineBuffer.Clear();
                            }
                        }
                        else
                        {
                            lineBuffer.Data.Append(c);
                        }
                    }

                    //if (Which == DEBUG_OUTCB.EXPLICIT_FLUSH)
                    //{
                    //    _passthroughUtilities.DebugClient.FlushCallbacks();
                    //}
                    _outputActive = true;
                }
            }

            return(S_OK);
        }