Exemplo n.º 1
0
        static ISymUnmanagedWriter2 CreateSymUnmanagedWriter2(PdbWriterOptions options)
        {
            bool useDiaSymReader    = (options & PdbWriterOptions.NoDiaSymReader) == 0;
            bool useOldDiaSymReader = (options & PdbWriterOptions.NoOldDiaSymReader) == 0;

            if (useDiaSymReader && canTry_Microsoft_DiaSymReader_Native)
            {
                try {
                    var    guid = CLSID_CorSymWriter_SxS;
                    object symWriterObj;
                    var    machine = ProcessorArchUtils.GetProcessCpuArchitecture();
                    switch (machine)
                    {
                    case Machine.AMD64:
                        CreateSymWriter_x64(ref guid, out symWriterObj);
                        break;

                    case Machine.I386:
                        CreateSymWriter_x86(ref guid, out symWriterObj);
                        break;

                    case Machine.ARMNT:
                        CreateSymWriter_arm(ref guid, out symWriterObj);
                        break;

                    case Machine.ARM64:
                        CreateSymWriter_arm64(ref guid, out symWriterObj);
                        break;

                    default:
                        Debug.Fail($"Microsoft.DiaSymReader.Native doesn't support this CPU arch: {machine}");
                        symWriterObj = null;
                        break;
                    }
                    if (symWriterObj is ISymUnmanagedWriter2 symWriter)
                    {
                        return(symWriter);
                    }
                }
                catch (DllNotFoundException) {
                    Debug.WriteLine("Microsoft.DiaSymReader.Native not found, using diasymreader.dll instead");
                }
                catch {
                }
                canTry_Microsoft_DiaSymReader_Native = false;
            }

            if (useOldDiaSymReader)
            {
                return((ISymUnmanagedWriter2)Activator.CreateInstance(CorSymWriterType ??= Type.GetTypeFromCLSID(CLSID_CorSymWriter_SxS)));
            }

            return(null);
        }
        static bool CalculateSupportsUnalignedAccesses()
        {
            var machine = ProcessorArchUtils.GetProcessCpuArchitecture();

            switch (machine)
            {
            case Machine.I386:
            case Machine.AMD64:
                return(true);

            case Machine.ARMNT:
            case Machine.ARM64:
                return(false);

            default:
                Debug.Fail($"Unknown CPU arch: {machine}");
                return(true);
            }
        }