コード例 #1
0
ファイル: CLRProfiler.cs プロジェクト: xescrp/breinstormin
        public void ProfileProcess(string profilingProcessfilename, CLRSKU clrruntime, ProfilingProcessType processtype)
        {
            processFileName = profilingProcessfilename;

            switch (processtype)
            {
                case ProfilingProcessType.ASPNET:
                    serviceName = null;
                    break;
                case ProfilingProcessType.Executable:
                    serviceName = null;
                    break;
                case ProfilingProcessType.Service:
                    break;
            }

            if (processFileName == null)
            {
                throw new Exception("The processFileName is empty!");
            }
            else if (processFileName == "ASP.NET")
            {
                profileASP_NET();
                return;
            }
            else if (serviceName != null)
            {
                ProfileService();
                return;
            }

            if (targetv2DesktopCLR())
            {
                RegisterDLL.Register();  // Register profilerOBJ.dll for v2 CLR, which doesn't support registry free activation
            }

            if (processFileName == null)
                return;

            if (profiledProcess == null || ProfiledProcessHasExited())
            {
                System.Diagnostics.ProcessStartInfo processStartInfo = new System.Diagnostics.ProcessStartInfo(processFileName);
                if (targetv4CoreCLR())
                {
                    processStartInfo.EnvironmentVariables["CoreCLR_Enable_Profiling"] = "0x1";
                    processStartInfo.EnvironmentVariables["CORECLR_PROFILER"] = "{8C29BC4E-1F57-461a-9B51-1200C32E6F1F}";
                    processStartInfo.EnvironmentVariables["CORECLR_PROFILER_PATH"] = getProfilerFullPath();
                }
                else
                {
                    processStartInfo.EnvironmentVariables["Cor_Enable_Profiling"] = "0x1";
                    processStartInfo.EnvironmentVariables["COR_PROFILER"] = "{8C29BC4E-1F57-461a-9B51-1200C32E6F1F}";
                    processStartInfo.EnvironmentVariables["COR_PROFILER_PATH"] = getProfilerFullPath();
                }

                processStartInfo.EnvironmentVariables["OMV_USAGE"] = CreateUsageString();
                processStartInfo.EnvironmentVariables["OMV_SKIP"] = "0";
                processStartInfo.EnvironmentVariables["OMV_PATH"] = GetLogDir();
                processStartInfo.EnvironmentVariables["OMV_STACK"] = trackCallStacks ? "1" : "0";
                processStartInfo.EnvironmentVariables["OMV_FORMAT"] = "v2";
                processStartInfo.EnvironmentVariables["OMV_DynamicObjectTracking"] = "0x1";
                processStartInfo.EnvironmentVariables["OMV_FORCE_GC_ON_COMMENT"] = gcOnLogFileComments ? "1" : "0";
                processStartInfo.EnvironmentVariables["OMV_INITIAL_SETTING"] = CreateInitialString();
                processStartInfo.EnvironmentVariables["OMV_TargetCLRVersion"] = targetv2DesktopCLR() ? "v2" : "v4";

                if (commandLine != null)
                    processStartInfo.Arguments = commandLine;

                if (workingDirectory != null)
                    processStartInfo.WorkingDirectory = workingDirectory;

                processStartInfo.UseShellExecute = false;

                profiledProcess = System.Diagnostics.Process.Start(processStartInfo);

                if (WaitForProcessToConnect(GetLogDir(), "Waiting for application to start common language runtime") <= 0)
                    profiledProcessEnded();
            }
        }
コード例 #2
0
ファイル: CLRProfiler.cs プロジェクト: xescrp/breinstormin
        public void ProfileProcess(string profilingProcessfilename, CLRSKU clrruntime, ProfilingProcessType processtype)
        {
            processFileName = profilingProcessfilename;

            switch (processtype)
            {
            case ProfilingProcessType.ASPNET:
                serviceName = null;
                break;

            case ProfilingProcessType.Executable:
                serviceName = null;
                break;

            case ProfilingProcessType.Service:
                break;
            }

            if (processFileName == null)
            {
                throw new Exception("The processFileName is empty!");
            }
            else if (processFileName == "ASP.NET")
            {
                profileASP_NET();
                return;
            }
            else if (serviceName != null)
            {
                ProfileService();
                return;
            }

            if (targetv2DesktopCLR())
            {
                RegisterDLL.Register();  // Register profilerOBJ.dll for v2 CLR, which doesn't support registry free activation
            }

            if (processFileName == null)
            {
                return;
            }

            if (profiledProcess == null || ProfiledProcessHasExited())
            {
                System.Diagnostics.ProcessStartInfo processStartInfo = new System.Diagnostics.ProcessStartInfo(processFileName);
                if (targetv4CoreCLR())
                {
                    processStartInfo.EnvironmentVariables["CoreCLR_Enable_Profiling"] = "0x1";
                    processStartInfo.EnvironmentVariables["CORECLR_PROFILER"]         = "{8C29BC4E-1F57-461a-9B51-1200C32E6F1F}";
                    processStartInfo.EnvironmentVariables["CORECLR_PROFILER_PATH"]    = getProfilerFullPath();
                }
                else
                {
                    processStartInfo.EnvironmentVariables["Cor_Enable_Profiling"] = "0x1";
                    processStartInfo.EnvironmentVariables["COR_PROFILER"]         = "{8C29BC4E-1F57-461a-9B51-1200C32E6F1F}";
                    processStartInfo.EnvironmentVariables["COR_PROFILER_PATH"]    = getProfilerFullPath();
                }

                processStartInfo.EnvironmentVariables["OMV_USAGE"]  = CreateUsageString();
                processStartInfo.EnvironmentVariables["OMV_SKIP"]   = "0";
                processStartInfo.EnvironmentVariables["OMV_PATH"]   = GetLogDir();
                processStartInfo.EnvironmentVariables["OMV_STACK"]  = trackCallStacks ? "1" : "0";
                processStartInfo.EnvironmentVariables["OMV_FORMAT"] = "v2";
                processStartInfo.EnvironmentVariables["OMV_DynamicObjectTracking"] = "0x1";
                processStartInfo.EnvironmentVariables["OMV_FORCE_GC_ON_COMMENT"]   = gcOnLogFileComments ? "1" : "0";
                processStartInfo.EnvironmentVariables["OMV_INITIAL_SETTING"]       = CreateInitialString();
                processStartInfo.EnvironmentVariables["OMV_TargetCLRVersion"]      = targetv2DesktopCLR() ? "v2" : "v4";


                if (commandLine != null)
                {
                    processStartInfo.Arguments = commandLine;
                }

                if (workingDirectory != null)
                {
                    processStartInfo.WorkingDirectory = workingDirectory;
                }

                processStartInfo.UseShellExecute = false;

                profiledProcess = System.Diagnostics.Process.Start(processStartInfo);

                if (WaitForProcessToConnect(GetLogDir(), "Waiting for application to start common language runtime") <= 0)
                {
                    profiledProcessEnded();
                }
            }
        }