コード例 #1
0
        static void Throw(System.Exception exception)
        {
            // cause indefinite halt at the end of this function
            libsupcs.OtherOperations.EnterUninterruptibleSection();

            Formatter.WriteLine("Exception thrown!", Program.arch.BootInfoOutput);

            Formatter.Write("PC: ", Program.arch.DebugOutput);
            Formatter.Write((ulong)Program.arch.GetUnwinder().Init().UnwindOne().GetInstructionPointer(), "X", Program.arch.DebugOutput);
            Formatter.WriteLine(Program.arch.DebugOutput);

            Formatter.WriteLine(exception.ToString(), Program.arch.BootInfoOutput);

            /* Unwind the stack */
            Arch.unwinding = true;
            Formatter.WriteLine("Stack trace: ", Program.arch.DebugOutput);

            // Switch to protected heap and unwind stack

            /*bool old_cpu_alloc = false;
             * if (Program.arch.CurrentCpu != null)
             * {
             *  old_cpu_alloc = Program.arch.CurrentCpu.UseCpuAlloc;
             *  Program.arch.CurrentCpu.UseCpuAlloc = true;
             * }*/
            Unwind.DumpUnwindInfo(Program.arch.GetUnwinder().Init().UnwindOne().DoUnwind((UIntPtr)Program.arch.ExitAddress), Program.arch.DebugOutput);

            /*if (Program.arch.CurrentCpu != null)
             *  Program.arch.CurrentCpu.UseCpuAlloc = old_cpu_alloc;*/
            libsupcs.OtherOperations.Halt();
        }
コード例 #2
0
        internal static int Assert_ShowDefaultAssertDialog(string conditionString, string message, string stackTrace, string windowTitle)
        {
            libsupcs.OtherOperations.EnterUninterruptibleSection();

            System.Diagnostics.Debugger.Log(0, "Assert", windowTitle);
            System.Diagnostics.Debugger.Log(0, "Assert", conditionString);
            System.Diagnostics.Debugger.Log(0, "Assert", message);
            System.Diagnostics.Debugger.Log(0, "Assert", stackTrace);

            Arch.unwinding = true;
            Formatter.WriteLine("Stack trace: ", Program.arch.DebugOutput);

            // Switch to protected heap and unwind stack

            /*bool old_cpu_alloc = false;
             * if (Program.arch.CurrentCpu != null)
             * {
             *  old_cpu_alloc = Program.arch.CurrentCpu.UseCpuAlloc;
             *  Program.arch.CurrentCpu.UseCpuAlloc = true;
             * }*/
            Unwind.DumpUnwindInfo(Program.arch.GetUnwinder().Init().UnwindOne().DoUnwind((UIntPtr)Program.arch.ExitAddress), Program.arch.DebugOutput);

            /*if (Program.arch.CurrentCpu != null)
             *  Program.arch.CurrentCpu.UseCpuAlloc = old_cpu_alloc;*/
            while (true)
            {
                libsupcs.OtherOperations.Halt();
            }
        }
コード例 #3
0
        static void SimpleThrow(int exception_id, libsupcs.TysosMethod methinfo)
        {
            if (exception_id == -1)
            {
                HandleFinally(methinfo);
                return;
            }
            if (exception_id == 1)
            {
                Formatter.WriteLine("OverflowException", Program.arch.BootInfoOutput);
                Formatter.WriteLine("OverflowException", Program.arch.DebugOutput);
            }
            else if (exception_id == 2)
            {
                Formatter.WriteLine("InvalidCastException", Program.arch.BootInfoOutput);
                Formatter.WriteLine("InvalidCastException", Program.arch.DebugOutput);
            }
            else if (exception_id == 3)
            {
                Formatter.WriteLine("NullReferenceException", Program.arch.BootInfoOutput);
                Formatter.WriteLine("NullReferenceException", Program.arch.DebugOutput);
            }
            else if (exception_id == 4)
            {
                Formatter.WriteLine("MissingMethodException", Program.arch.BootInfoOutput);
                Formatter.WriteLine("MissingMethodException", Program.arch.DebugOutput);
            }
            else if (exception_id == 5)
            {
                Formatter.WriteLine("IndexOutOfRangeException", Program.arch.BootInfoOutput);
                Formatter.WriteLine("IndexOutOfRangeException", Program.arch.DebugOutput);
            }
            else
            {
                Formatter.Write("Unknown exception:", Program.arch.BootInfoOutput);
                Formatter.Write((ulong)exception_id, "d", Program.arch.BootInfoOutput);
                Formatter.Write("Unknown exception:", Program.arch.DebugOutput);
                Formatter.Write((ulong)exception_id, "d", Program.arch.DebugOutput);
            }

            // Switch to protected heap and unwind stack
            bool old_cpu_alloc = false;

            if (Program.arch.CurrentCpu != null)
            {
                old_cpu_alloc = Program.arch.CurrentCpu.UseCpuAlloc;
                Program.arch.CurrentCpu.UseCpuAlloc = true;
            }
            Unwind.DumpUnwindInfo(Program.arch.GetUnwinder().Init().UnwindOne().DoUnwind((UIntPtr)Program.arch.ExitAddress), Program.arch.DebugOutput);
            if (Program.arch.CurrentCpu != null)
            {
                Program.arch.CurrentCpu.UseCpuAlloc = old_cpu_alloc;
            }
            libsupcs.OtherOperations.Halt();
        }