Ejemplo n.º 1
0
        ///////////////////////////////////////////////////////////////////////

        public TclBuild(
            FindFlags findFlags,
            LoadFlags loadFlags,
            object findData,
            string fileName,
            Priority priority,
            Sequence sequence,
            OperatingSystemId operatingSystemId,
            Version patchLevel,
            Tcl_ReleaseLevel releaseLevel,
            ushort magic,
            bool threaded,
            bool debug
            )
        {
            this.findFlags         = findFlags;
            this.loadFlags         = loadFlags;
            this.findData          = findData;
            this.fileName          = fileName;
            this.priority          = priority;
            this.sequence          = sequence;
            this.operatingSystemId = operatingSystemId;
            this.patchLevel        = patchLevel;
            this.releaseLevel      = releaseLevel;
            this.magic             = magic;
            this.threaded          = threaded;
            this.debug             = debug;

            //
            // NOTE: The version may only contain the major and minor parts.
            //
            this.version = GlobalState.GetTwoPartVersion(patchLevel);
        }
Ejemplo n.º 2
0
        /////////////////////////////////////////////////////////////////////////////////

        #region Thread Context Support Methods
        private static void SetupThreadContextMetadata()
        {
            CanQueryThread = false;

            OperatingSystemId operatingSystemId = PlatformOps.GetOperatingSystemId();

            switch (operatingSystemId)
            {
            case OperatingSystemId.WindowsNT:
            {
                ProcessorArchitecture processorArchitecture =
                    PlatformOps.GetProcessorArchitecture();

                switch (processorArchitecture)
                {
                case ProcessorArchitecture.Intel:
                case ProcessorArchitecture.IA32_on_Win64:
                {
                    TebStackBaseOffset   = TebStackBaseOffset32Bit;
                    TebStackLimitOffset  = TebStackLimitOffset32Bit;
                    TebDeallocationStack = TebDeallocationStack32Bit;

                    CONTEXT_FLAGS_OFFSET = CONTEXT_FLAGS_OFFSET_i386;
                    CONTEXT_CONTROL      = CONTEXT_CONTROL_i386;
                    CONTEXT_SIZE         = CONTEXT_SIZE_i386;
                    CONTEXT_ESP_OFFSET   = CONTEXT_ESP_OFFSET_i386;

                    //
                    // NOTE: Support is present in NTDLL, use the direct
                    //       (fast) method.
                    //
                    NtCurrentTeb = null;

                    TraceOps.DebugTrace(
                        "selected x86 architecture",
                        typeof(NativeStack).Name,
                        TracePriority.NativeDebug);

                    CanQueryThread = true;
                    break;
                }

                case ProcessorArchitecture.ARM:
                {
                    TebStackBaseOffset   = TebStackBaseOffset32Bit;
                    TebStackLimitOffset  = TebStackLimitOffset32Bit;
                    TebDeallocationStack = TebDeallocationStack32Bit;

                    CONTEXT_FLAGS_OFFSET = CONTEXT_FLAGS_OFFSET_ARM;
                    CONTEXT_CONTROL      = CONTEXT_CONTROL_ARM;
                    CONTEXT_SIZE         = CONTEXT_SIZE_ARM;
                    CONTEXT_ESP_OFFSET   = CONTEXT_ESP_OFFSET_ARM;

                    //
                    // NOTE: Native stack checking is not "officially"
                    //       supported on this architecture; however,
                    //       it may work.
                    //
                    NtCurrentTeb = new NtCurrentTeb(NtCurrentTebSlow);

                    TraceOps.DebugTrace(
                        "selected ARM architecture",
                        typeof(NativeStack).Name,
                        TracePriority.NativeDebug);

                    CanQueryThread = true;
                    break;
                }

                case ProcessorArchitecture.IA64:
                {
                    TebStackBaseOffset   = TebStackBaseOffset64Bit;
                    TebStackLimitOffset  = TebStackLimitOffset64Bit;
                    TebDeallocationStack = TebDeallocationStack64Bit;

                    CONTEXT_FLAGS_OFFSET = CONTEXT_FLAGS_OFFSET_IA64;
                    CONTEXT_CONTROL      = CONTEXT_CONTROL_IA64;
                    CONTEXT_SIZE         = CONTEXT_SIZE_IA64;
                    CONTEXT_ESP_OFFSET   = CONTEXT_ESP_OFFSET_IA64;

                    //
                    // NOTE: Native stack checking is not "officially"
                    //       supported on this architecture; however,
                    //       it may work.
                    //
                    NtCurrentTeb = new NtCurrentTeb(NtCurrentTebSlow);

                    TraceOps.DebugTrace(
                        "selected ia64 architecture",
                        typeof(NativeStack).Name,
                        TracePriority.NativeDebug);

                    CanQueryThread = true;
                    break;
                }

                case ProcessorArchitecture.AMD64:
                {
                    TebStackBaseOffset   = TebStackBaseOffset64Bit;
                    TebStackLimitOffset  = TebStackLimitOffset64Bit;
                    TebDeallocationStack = TebDeallocationStack64Bit;

                    CONTEXT_FLAGS_OFFSET = CONTEXT_FLAGS_OFFSET_AMD64;
                    CONTEXT_CONTROL      = CONTEXT_CONTROL_AMD64;
                    CONTEXT_SIZE         = CONTEXT_SIZE_AMD64;
                    CONTEXT_ESP_OFFSET   = CONTEXT_ESP_OFFSET_AMD64;

                    //
                    // HACK: Thanks for not exporting this function from
                    //       NTDLL on x64 (you know who you are).  Since
                    //       support is not present in NTDLL, use the
                    //       slow method.
                    //
                    NtCurrentTeb = new NtCurrentTeb(NtCurrentTebSlow);

                    TraceOps.DebugTrace(
                        "selected x64 architecture",
                        typeof(NativeStack).Name,
                        TracePriority.NativeDebug);

                    CanQueryThread = true;
                    break;
                }

                case ProcessorArchitecture.ARM64:
                {
                    TebStackBaseOffset   = TebStackBaseOffset64Bit;
                    TebStackLimitOffset  = TebStackLimitOffset64Bit;
                    TebDeallocationStack = TebDeallocationStack64Bit;

                    CONTEXT_FLAGS_OFFSET = CONTEXT_FLAGS_OFFSET_ARM64;
                    CONTEXT_CONTROL      = CONTEXT_CONTROL_ARM64;
                    CONTEXT_SIZE         = CONTEXT_SIZE_ARM64;
                    CONTEXT_ESP_OFFSET   = CONTEXT_ESP_OFFSET_ARM64;

                    //
                    // NOTE: Native stack checking is not "officially"
                    //       supported on this architecture; however,
                    //       it may work.
                    //
                    NtCurrentTeb = new NtCurrentTeb(NtCurrentTebSlow);

                    TraceOps.DebugTrace(
                        "selected ARM64 architecture",
                        typeof(NativeStack).Name,
                        TracePriority.NativeDebug);

                    CanQueryThread = true;
                    break;
                }

                default:
                {
                    //
                    // NOTE: We have no idea what processor architecture
                    //       this is.  Native stack checking is disabled.
                    //
                    TraceOps.DebugTrace(String.Format(
                                            "unknown architecture {0}",
                                            processorArchitecture),
                                        typeof(NativeStack).Name,
                                        TracePriority.NativeError);

                    break;
                }
                }
                break;
            }

            default:
            {
                //
                // NOTE: We have no idea what operating system this is.
                //       Native stack checking is disabled.
                //
                TraceOps.DebugTrace(String.Format(
                                        "unknown operating system {0}",
                                        operatingSystemId),
                                    typeof(NativeStack).Name,
                                    TracePriority.NativeError);

                break;
            }
            }
        }