Пример #1
0
        private static void _Write(ulong v, int Base, IDebugOutput s, bool uppercase, int min_digits)
        {
            if (digits == null)
            {
                s.Write("<error>");
                return;
            }

            int cur_digit = 0;

            while (v != 0)
            {
                digits[cur_digit] = (byte)(v % (ulong)Base);
                v /= (ulong)Base;
                cur_digit++;
            }

            while (cur_digit < min_digits)
            {
                digits[cur_digit] = 0;
                cur_digit++;
            }

            for (int i = (cur_digit - 1); i >= 0; i--)
            {
                if (uppercase)
                {
                    s.Write(UppercaseDigits[digits[i]]);
                }
                else
                {
                    s.Write(LowercaseDigits[digits[i]]);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Initialises a new instance of the <see cref="DebugEmitter"/> class.
 /// </summary>
 /// <param name="emitter">The emitter to call through to.</param>
 /// <param name="debugOutput">The debug output to write to.</param>
 public DebugEmitter(IEmitter emitter, IDebugOutput debugOutput)
 {
     this.emitter     = emitter;
     this.debugOutput = debugOutput;
     this.offset      = 0;
     this.index       = 0;
 }
Пример #3
0
 public static void Write(ulong v, IDebugOutput s)
 {
     if (s != null)
     {
         Write(v, null, s);
     }
 }
Пример #4
0
 public static void WriteLine(IDebugOutput s)
 {
     if (s != null)
     {
         s.Write('\n');
         s.Flush();
     }
 }
Пример #5
0
 public static void Write(char ch, IDebugOutput s)
 {
     if (s != null)
     {
         s.Write(ch);
         s.Flush();
     }
 }
Пример #6
0
 public static void WriteLine(string str, IDebugOutput s)
 {
     if (s != null)
     {
         Write(str, s);
         s.Write('\n');
         s.Flush();
     }
 }
Пример #7
0
        public DebugLogger(IDebugOutput output)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }

            _output = output;
        }
        /// <summary>
        /// Returns the platform specific Debugger writer to the VS output console.
        /// </summary>
        public IDebugOutput GetDebugOutput()
        {
            if (this.debugOutput == null)
            {
                this.debugOutput = new TelemetryDebugWriter();
            }

            return this.debugOutput;
        }
        /// <summary>
        /// Returns the platform specific Debugger writer to the VS output console.
        /// </summary>
        public IDebugOutput GetDebugOutput()
        {
            if (this.debugOutput == null)
            {
                this.debugOutput = new TelemetryDebugWriter();
            }

            return(this.debugOutput);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TransmissionProcessor"/> class.
        /// </summary>        
        /// <param name="configuration">The <see cref="TelemetryConfiguration"/> to get the channel from.</param>
        internal TransmissionProcessor(TelemetryConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            this.configuration = configuration;
            this.debugOutput = PlatformSingleton.Current.GetDebugOutput();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TransmissionProcessor"/> class.
        /// </summary>
        /// <param name="configuration">The <see cref="TelemetryConfiguration"/> to get the channel from.</param>
        internal TransmissionProcessor(TelemetryConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            this.configuration = configuration;
            this.debugOutput   = PlatformSingleton.Current.GetDebugOutput();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TransmissionProcessor"/> class.
        /// </summary>
        /// <param name="sink">The <see cref="TelemetrySink"/> holding to the telemetry channel to use for sending telemetry.</param>
        internal TransmissionProcessor(TelemetrySink sink)
        {
            if (sink == null)
            {
                throw new ArgumentNullException(nameof(sink));
            }

            this.sink        = sink;
            this.debugOutput = PlatformSingleton.Current.GetDebugOutput();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TelemetryClient" /> class. Send telemetry with the specified <paramref name="configuration"/>.
        /// </summary>
        /// <exception cref="ArgumentNullException">The <paramref name="configuration"/> is null.</exception>
        public TelemetryClient(TelemetryConfiguration configuration)
        {
            if (configuration == null)
            {
                CoreEventSource.Log.TelemetryClientConstructorWithNoTelemetryConfiguration();
                configuration = TelemetryConfiguration.Active;
            }

            this.configuration = configuration;
            this.debugOutput = PlatformSingleton.Current.GetDebugOutput();
        }
Пример #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TelemetryClient" /> class. Send telemetry with the specified <paramref name="configuration"/>.
        /// </summary>
        /// <exception cref="ArgumentNullException">The <paramref name="configuration"/> is null.</exception>
        public TelemetryClient(TelemetryConfiguration configuration)
        {
            if (configuration == null)
            {
                CoreEventSource.Log.TelemetryClientConstructorWithNoTelemetryConfiguration();
                configuration = TelemetryConfiguration.Active;
            }

            this.configuration = configuration;
            this.debugOutput   = PlatformSingleton.Current.GetDebugOutput();
        }
Пример #15
0
 public static void Write(string str, IDebugOutput s)
 {
     if (s != null)
     {
         for (int i = 0; i < str.Length; i++)
         {
             var c = str[i];
             s.Write(c);
         }
         s.Flush();
     }
 }
Пример #16
0
        public void Dump(IDebugOutput o)
        {
            Formatter.WriteLine("Virtual regions:", o);

            Region cur_r = list_start;

            while (cur_r != null)
            {
                Formatter.Write(cur_r.name, o);
                Formatter.Write("  start: 0x", o);
                Formatter.Write(cur_r.start, "X", o);
                Formatter.Write("  end: 0x", o);
                Formatter.Write(cur_r.end, "X", o);
                Formatter.WriteLine(o);

                cur_r = cur_r.next;
            }
        }
Пример #17
0
        internal static void DumpUnwindInfo(object[] uinfo, IDebugOutput output)
        {
            foreach (object ueo in uinfo)
            {
                // We use this cast to avoid a dependency on UnwinderEntry[], the typeinfo
                //  for which is not produced by default in AOT mode for libsupcs
                libsupcs.Unwinder.UnwinderEntry ue = ueo as libsupcs.Unwinder.UnwinderEntry;

                if (ue != null)
                {
                    Formatter.Write((ulong)ue.ProgramCounter, "X", output);
                    Formatter.Write(": ", output);

                    if (ue.Symbol != null)
                    {
                        Formatter.Write(ue.Symbol, output);

                        if ((ulong)ue.Offset != 0)
                        {
                            Formatter.Write(" + ", output);
                            Formatter.Write((ulong)ue.Offset, "x", output);
                        }

                        Formatter.WriteLine(output);
                    }

                    /*else if(Program.stab != null)
                     * {
                     *  ulong offset;
                     *  string meth = Program.stab.GetSymbolAndOffset((ulong)ue.ProgramCounter, out offset);
                     *  Formatter.Write(meth, output);
                     *  Formatter.Write(" + ", output);
                     *  Formatter.Write(offset, "X", output);
                     *  Formatter.WriteLine(output);
                     * }*/
                    else
                    {
                        Formatter.WriteLine("unknown method", output);
                    }
                }
            }
        }
Пример #18
0
 public static void Write(ulong v, string fmt, IDebugOutput s)
 {
     if (s == null)
     {
         return;
     }
     if (fmt == null)
     {
         _Write(v, 10, s, false, 1);
     }
     else
     {
         if (fmt.Length == 0)
         {
             _Write(v, 10, s, false, 1);
         }
         else
         {
             if ((fmt[0] == 'D') || (fmt[0] == 'd'))
             {
                 _Write(v, 10, s, false, 1);
             }
             else if (fmt[0] == 'X')
             {
                 _Write(v, 16, s, true, 16);
             }
             else if (fmt[0] == 'x')
             {
                 _Write(v, 16, s, false, 16);
             }
             else if ((fmt[0] == 'b') || (fmt[0] == 'B'))
             {
                 _Write(v, 2, s, false, 64);
             }
         }
     }
     s.Flush();
 }
Пример #19
0
 /// <summary>
 /// Returns the platform specific Debugger writer to the VS output console.
 /// </summary>
 public IDebugOutput GetDebugOutput()
 {
     return(this.debugOutput ?? (this.debugOutput = new TelemetryDebugWriter()));
 }
Пример #20
0
 public DebugLogger()
 {
     _output = new StandardDebugOutput();
 }
Пример #21
0
        public static void Write(string fmt, IDebugOutput s, params object[] p)
        {
            if (s == null)
            {
                return;
            }

            // define the current state of the iteration
            bool in_escape       = false;
            bool in_index        = false;
            bool in_alignment    = false;
            bool in_format       = false;
            int  index_start     = 0;
            int  alignment_start = 0;
            int  format_start    = 0;
            int  index_end       = 0;
            int  alignment_end   = 0;
            int  format_end      = 0;
            bool has_alignment   = false;
            bool has_format      = false;

            for (int i = 0; i < fmt.Length; i++)
            {
                if (in_escape)
                {
                    if (fmt[i] == '\\')
                    {
                        s.Write('\\');
                    }
                    else if (fmt[i] == 'n')
                    {
                        s.Write('\n');
                    }

                    in_escape = false;
                }
                else if ((in_format || in_alignment || in_index) && (fmt[i] == '}'))
                {
                    if ((i < (fmt.Length - 1)) && (fmt[i + i] == '}'))
                    {
                        s.Write('}');
                        i++;
                    }
                    else
                    {
                        if (in_format)
                        {
                            format_end = i;
                        }
                        if (in_alignment)
                        {
                            alignment_end = i;
                        }
                        if (in_index)
                        {
                            index_end = i;
                        }
                        in_format = in_alignment = in_index = false;

                        // interpret the format, alignment and index and output the appropriate value

                        // index is a integer in decimal format
                        int mult  = 1;
                        int index = 0;
                        for (int j = index_end - 1; j >= index_start; j++)
                        {
                            int diff = (int)fmt[j] - (int)'0';
                            if ((diff >= 0) && (diff <= 9))
                            {
                                index += (diff * mult);
                            }
                            if (fmt[j] == '-')
                            {
                                index = -index;
                                break;
                            }
                            mult *= 10;
                        }
                        // as is alignment
                        int alignment = 0;
                        mult = 1;
                        if (has_alignment)
                        {
                            for (int j = alignment_end - 1; j >= alignment_start; j++)
                            {
                                int diff = (int)fmt[j] - (int)'0';
                                if ((diff >= 0) && (diff <= 9))
                                {
                                    alignment += (diff * mult);
                                }
                                if (fmt[j] == '-')
                                {
                                    alignment = -alignment;
                                    break;
                                }
                                mult *= 10;
                            }
                        }

                        // TODO: interpret format string
                        // Use RTTI to determine what p[index] is and display it using the specified alignment
                        //  and format string

                        has_alignment = has_format = false;
                    }
                }
                else if (in_format)
                {
                    // Nothing to do
                }
                else if (in_alignment)
                {
                    if (fmt[i] == ':')
                    {
                        in_alignment  = false;
                        in_format     = true;
                        alignment_end = i;
                        format_start  = i + 1;
                        has_format    = true;
                    }
                }
                else if (in_index)
                {
                    if (fmt[i] == ',')
                    {
                        in_index        = false;
                        in_alignment    = true;
                        index_end       = i;
                        alignment_start = i + 1;
                        has_alignment   = true;
                    }
                    if (fmt[i] == ':')
                    {
                        in_index     = false;
                        in_format    = true;
                        index_end    = i;
                        format_start = i + 1;
                        has_format   = true;
                    }
                }
                else
                {
                    if (fmt[i] == '{')
                    {
                        if ((i < (fmt.Length - 1)) && (fmt[i + i] == '{'))
                        {
                            s.Write('{');
                            i++;
                        }
                        else
                        {
                            index_start = i + 1;
                            in_index    = true;
                        }
                    }
                    else
                    {
                        if (fmt[i] == '\\')
                        {
                            in_escape = true;
                        }
                        else
                        {
                            s.Write(fmt[i]);
                        }
                    }
                }
            }
            s.Flush();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="F5DiagnosticsSender"/> class. 
 /// </summary>
 public F5DiagnosticsSender()
 {
     this.debugOutput = PlatformSingleton.Current.GetDebugOutput();
 }
Пример #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="F5DiagnosticsSender"/> class.
 /// </summary>
 public F5DiagnosticsSender()
 {
     this.debugOutput = PlatformSingleton.Current.GetDebugOutput();
 }