Example #1
0
        /// <summary>
        /// Reads symbol record from symbol references for the specified index.
        /// </summary>
        /// <param name="index">Index of the symbol record.</param>
        private SymbolRecord GetSymbol(int index)
        {
            // Since DictionaryCache is allowing only single thread to call this function, we don't need to lock reader here.
            SymbolReference reference = references[index];

            Reader.Position = reference.DataOffset;
            switch (reference.Kind)
            {
            case SymbolRecordKind.S_GPROC32:
            case SymbolRecordKind.S_LPROC32:
            case SymbolRecordKind.S_GPROC32_ID:
            case SymbolRecordKind.S_LPROC32_ID:
            case SymbolRecordKind.S_LPROC32_DPC:
            case SymbolRecordKind.S_LPROC32_DPC_ID:
                return(ProcedureSymbol.Read(Reader, reference.Kind));

            case SymbolRecordKind.S_PUB32:
                return(Public32Symbol.Read(Reader, reference.Kind));

            case SymbolRecordKind.S_CONSTANT:
            case SymbolRecordKind.S_MANCONSTANT:
                return(ConstantSymbol.Read(Reader, reference.Kind));

            case SymbolRecordKind.S_LDATA32:
            case SymbolRecordKind.S_GDATA32:
            case SymbolRecordKind.S_LMANDATA:
            case SymbolRecordKind.S_GMANDATA:
                return(DataSymbol.Read(Reader, reference.Kind));

            case SymbolRecordKind.S_PROCREF:
            case SymbolRecordKind.S_LPROCREF:
                return(ProcedureReferenceSymbol.Read(Reader, reference.Kind));

            case SymbolRecordKind.S_UDT:
            case SymbolRecordKind.S_COBOLUDT:
                return(UdtSymbol.Read(Reader, reference.Kind));

            case SymbolRecordKind.S_LTHREAD32:
            case SymbolRecordKind.S_GTHREAD32:
                return(ThreadLocalDataSymbol.Read(Reader, reference.Kind));

            default:
                throw new NotImplementedException();
            }
        }
Example #2
0
        /// <summary>
        /// Reads symbol record from symbol references for the specified index.
        /// </summary>
        /// <param name="index">Index of the symbol record.</param>
        private SymbolRecord GetSymbol(int index)
        {
            // Since DictionaryCache is allowing only single thread to call this function, we don't need to lock reader here.
            SymbolRecordReference reference = references[index];

            Reader.Position = reference.DataOffset;
            switch (reference.Kind)
            {
            case SymbolRecordKind.S_GPROC32:
            case SymbolRecordKind.S_LPROC32:
            case SymbolRecordKind.S_GPROC32_ID:
            case SymbolRecordKind.S_LPROC32_ID:
            case SymbolRecordKind.S_LPROC32_DPC:
            case SymbolRecordKind.S_LPROC32_DPC_ID:
                return(ProcedureSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_PUB32:
                return(Public32Symbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_CONSTANT:
            case SymbolRecordKind.S_MANCONSTANT:
                return(ConstantSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_LDATA32:
            case SymbolRecordKind.S_GDATA32:
            case SymbolRecordKind.S_LMANDATA:
            case SymbolRecordKind.S_GMANDATA:
                return(DataSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_PROCREF:
            case SymbolRecordKind.S_LPROCREF:
                return(ProcedureReferenceSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_TOKENREF:
                return(TokenReferenceSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_UDT:
            case SymbolRecordKind.S_COBOLUDT:
                return(UdtSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_LTHREAD32:
            case SymbolRecordKind.S_GTHREAD32:
                return(ThreadLocalDataSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_GMANPROC:
            case SymbolRecordKind.S_LMANPROC:
                return(ManagedProcedureSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_BLOCK32:
                return(BlockSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_OEM:
                return(OemSymbol.Read(Reader, this, index, reference.Kind, reference.DataLen));

            case SymbolRecordKind.S_UNAMESPACE:
                return(NamespaceSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_MANSLOT:
                return(AttributeSlotSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_END:
            case SymbolRecordKind.S_INLINESITE_END:
                return(EndSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_ANNOTATION:
                return(AnnotationSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_ANNOTATIONREF:
                return(AnnotationReferenceSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_REGREL32:
                return(RegisterRelativeSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_OBJNAME:
                return(ObjectNameSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_COMPILE2:
                return(Compile2Symbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_COMPILE3:
                return(Compile3Symbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_ENVBLOCK:
                return(EnvironmentBlockSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_BUILDINFO:
                return(BuildInfoSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_FRAMEPROC:
                return(FrameProcedureSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_LABEL32:
                return(LabelSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_HEAPALLOCSITE:
                return(HeapAllocationSiteSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_CALLSITEINFO:
                return(CallSiteInfoSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_FRAMECOOKIE:
                return(FrameCookieSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_THUNK32:
                return(Thunk32Symbol.Read(Reader, this, index, reference.Kind, reference.DataLen));

            case SymbolRecordKind.S_LOCAL:
                return(LocalSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_DEFRANGE_REGISTER:
                return(DefRangeRegisterSymbol.Read(Reader, this, index, reference.Kind, reference.DataLen));

            case SymbolRecordKind.S_DEFRANGE_REGISTER_REL:
                return(DefRangeRegisterRelativeSymbol.Read(Reader, this, index, reference.Kind, reference.DataLen));

            case SymbolRecordKind.S_DEFRANGE_SUBFIELD_REGISTER:
                return(DefRangeSubfieldRegisterSymbol.Read(Reader, this, index, reference.Kind, reference.DataLen));

            case SymbolRecordKind.S_DEFRANGE_FRAMEPOINTER_REL:
                return(DefRangeFramePointerRelativeSymbol.Read(Reader, this, index, reference.Kind, reference.DataLen));

            case SymbolRecordKind.S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE:
                return(DefRangeFramePointerRelativeFullScopeSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_CALLEES:
            case SymbolRecordKind.S_CALLERS:
                return(FunctionListSymbol.Read(Reader, this, index, reference.Kind, reference.DataLen));

            case SymbolRecordKind.S_FILESTATIC:
                return(FileStaticSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_TRAMPOLINE:
                return(TrampolineSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_SECTION:
                return(SectionSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_COFFGROUP:
                return(CoffGroupSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_EXPORT:
                return(ExportSymbol.Read(Reader, this, index, reference.Kind));

            case SymbolRecordKind.S_INLINESITE:
                return(InlineSiteSymbol.Read(Reader, this, index, reference.Kind, reference.DataLen));

            default:
#if DEBUG
                throw new NotImplementedException($"Unknown reference kind: {reference.Kind}");
#else
                return(null);
#endif
            }
        }