Exemple #1
0
 internal static void enter_try(void *eh, void *fp)
 {
     if (eh == PeekEhdr())
     {
         System.Diagnostics.Debugger.Log(0, "libsupcs", "enter_try: recursive try block found from calling_pc: " +
                                         ((ulong)OtherOperations.GetUnwinder().UnwindOne().GetInstructionPointer()).ToString("X"));
     }
     PushEhdr(eh, fp);
 }
Exemple #2
0
        internal static void leave_try(void *eh)
        {
            void *fp     = PopFramePointer();
            void *popped = PopEhdr();

            if (eh != popped)
            {
                System.Diagnostics.Debugger.Log(0, "libsupcs", "leave_try: popping incorrect exception header");
                System.Diagnostics.Debugger.Log(0, "libsupcs", "expected: " + ((ulong)eh).ToString("X"));
                System.Diagnostics.Debugger.Log(0, "libsupcs", "got: " + ((ulong)popped).ToString("X") + ", fp: " + ((ulong)fp).ToString("X"));
                System.Diagnostics.Debugger.Log(0, "libsupcs", "start: " + ((ulong)start).ToString("X"));
                System.Diagnostics.Debugger.Log(0, "libsupcs", "end: " + ((ulong)end).ToString("X"));
                System.Diagnostics.Debugger.Log(0, "libsupcs", "cur: " + ((ulong)cur).ToString("X"));
                System.Diagnostics.Debugger.Log(0, "libsupcs", "calling_pc: " + ((ulong)OtherOperations.GetUnwinder().UnwindOne().GetInstructionPointer()).ToString("X"));
                while (true)
                {
                    ;
                }
            }

            void **ehdr = (void **)eh;

            int eh_type = *(int *)ehdr;

            if (eh_type == 2)
            {
                // handle finally clause
                void *handler = *(ehdr + 1);
                OtherOperations.CallI(fp, handler);
                PopFramePointer();
                PopEhdr();
            }
        }
Exemple #3
0
        static void GetExecutingAssembly(StackCrawlMarkHandle scmh, TysosModule.ObjectHandleOnStack ret)
        {
            int scm = *(int *)scmh.ptr;

            System.Diagnostics.Debugger.Log(0, "libsupcs", "TysosAssembly.GetExecutingAssembly: scm: " + scm.ToString());

            Unwinder u = OtherOperations.GetUnwinder();

            u.UnwindOne();
            u.UnwindOne();      // we are double-nested within coreclr so unwind this and calling method (GetExecutingAssembly(ref StackMarkHandle)) first

            switch (scm)
            {
            case 0:
                break;

            case 1:
                u.UnwindOne();
                break;

            case 2:
                u.UnwindOne();
                u.UnwindOne();
                break;

            default:
                System.Diagnostics.Debugger.Log(0, "libsupcs", "TysosAssembly.GetExecutingAssembly: unsupported scm: " + scm.ToString());
                throw new NotSupportedException();
            }

            System.Diagnostics.Debugger.Log(0, "libsupcs", "TysosAssembly.GetExecutingAssembly: requested pc " + ((ulong)u.GetInstructionPointer()).ToString("X"));

            void *offset;
            var   name = JitOperations.GetNameOfAddress((void *)u.GetInstructionPointer(), out offset);

            if (name == null)
            {
                System.Diagnostics.Debugger.Log(0, "libsupcs", "TysosAssembly.GetExecutingAssembly: symbol not found");
                *ret.ptr = null;
                return;
            }

            System.Diagnostics.Debugger.Log(0, "libsupcs", "TysosAssembly.GetExecutingAssembly: found method " + name);

            var ts = Metadata.MSCorlib.DemangleObject(name);

            if (ts == null)
            {
                System.Diagnostics.Debugger.Log(0, "libsupcs", "TysosAssembly.GetExecutingAssembly: demangler returned null");
                *ret.ptr = null;
                return;
            }
            var m = ts.Metadata;

            if (m == null)
            {
                System.Diagnostics.Debugger.Log(0, "libsupcs", "TysosAssembly.GetExecutingAssembly: returned ts had no assembly");
                *ret.ptr = null;
                return;
            }
            var aptr = (m.file as Metadata.BinaryInterface).b;
            var retm = TysosModule.GetModule(aptr, m.AssemblyName);

            System.Diagnostics.Debugger.Log(0, "libsupcs", "TysosAssembly.GetExecutingAssembly: returning " + retm.ass.assemblyName);
            *ret.ptr = CastOperations.ReinterpretAsPointer(retm.ass);
        }