示例#1
0
        static void ModuleHandle_GetModuleType(TysosModule mod, ObjectHandleOnStack oh)
        {
            // Get the <Module> type name for the current module.  This is always defined as tdrow 1.
            var ts = (TysosType)mod.m.GetTypeSpec(metadata.MetadataStream.tid_TypeDef, 1);

            *oh.ptr = CastOperations.ReinterpretAsPointer(ts);
        }
示例#2
0
        static internal TysosModule GetModule(void *aptr, string ass_name)
        {
            var mfile = CastOperations.ReinterpretAsUlong(CastOperations.ReinterpretAsObject(aptr));

            lock (mod_cache)
            {
                if (!mod_cache.TryGetValue(mfile, out var ret))
                {
                    ret = new TysosModule(aptr, ass_name);
                    mod_cache[mfile] = ret;

                    System.Diagnostics.Debugger.Log(0, "libsupcs", "TysosType: building new TysosModule for " + ass_name);
                }
                return(ret);
            }
        }
示例#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);
        }
示例#4
0
 internal TysosAssembly(TysosModule mod, string ass_name)
 {
     m            = mod;
     assemblyName = ass_name;
 }