/// <summary> /// Load debug info /// </summary> /// <param name="peOrPdbPath"></param> /// <param name="symbolPath"></param> private void Init(string peOrPdbPath, string symbolPath) { try { DiaSource diaSource = new DiaSource(); Environment.SetEnvironmentVariable("_NT_SYMBOL_PATH", ""); if (symbolPath == null) { string pdbPath = Path.ChangeExtension(peOrPdbPath, ".pdb"); if (File.Exists(pdbPath)) { peOrPdbPath = pdbPath; } } // load the debug info depending on the file type if (peOrPdbPath.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase)) { diaSource.loadDataFromPdb(peOrPdbPath); } else { diaSource.loadDataForExe(peOrPdbPath, symbolPath, IntPtr.Zero); } diaSource.openSession(out _session); } catch (COMException ce) { throw new PdbParseException(ce); } }
static ProgramDatabase() { module = GetUnityModule(); #if UNITY_EDITOR dia = new DiaSource(); dia.loadDataForExe(module.FileName, null, null); dia.openSession(out session); #else const string PipeName = "Unity.PdbService"; server = new NamedPipeServerStream(PipeName, PipeDirection.InOut); process = new Process { StartInfo = new ProcessStartInfo { FileName = Path.GetFullPath("PdbService.exe"), Arguments = PipeName, CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true, } }; process.Start(); server.WaitForConnection(); writer = new StreamWriter(server) { AutoFlush = true }; reader = new StreamReader(server); writer.WriteLine("InitFromExe"); writer.WriteLine(module.FileName); Application.quitting += () => { reader.Dispose(); writer.Dispose(); server.Dispose(); process.Kill(); process.Dispose(); }; #endif }