Esempio n. 1
0
        public override bool Launch()
        {
            ClrConfig config = new ClrConfig
            {
                ProfilingMode       = ProfilingMode,
                ListenPort          = ListenPort,
                WaitForConnection   = WaitForConnection,
                IncludeNative       = IncludeNative,
                SamplingInterval    = SamplingInterval,
                CounterInterval     = CounterInterval,
                AllowMethodInlining = AllowMethodInlining,
                TrackGC             = TrackGC,
                TrackAllocs         = TrackAllocs,
                WeightedSampling    = WeightedSampling,
            };

            string configString = config.CreateString();
            var    psi          = new ProcessStartInfo(Executable, Arguments);

            LauncherCommon.SetProcessOptions(psi, configString, LauncherCommon.GetCounterString(PerformanceCounters), true);
            psi.WorkingDirectory = string.IsNullOrEmpty(WorkingDir) ?
                                   Path.GetDirectoryName(Executable) : WorkingDir;

            try
            {
                Process.Start(psi);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Launch Error");
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public bool Launch()
        {
            NativeConfig config = new NativeConfig
            {
                ProfilingMode    = ProfilerMode.Sampling,
                ListenPort       = ListenPort,
                SamplingInterval = SamplingInterval,
                CounterInterval  = 1000
            };

            string configString = config.CreateString();
            string argStr       = Executable + " " + Arguments;
            var    psi          = new ProcessStartInfo("Backends\\SlimTuneNative_x86.exe", argStr);

            LauncherCommon.SetProcessOptions(psi, configString, string.Empty, false);
            psi.WorkingDirectory = string.IsNullOrEmpty(WorkingDir) ?
                                   Path.GetDirectoryName(Executable) : WorkingDir;

            try
            {
                Process.Start(psi);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Launch Error");
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        public bool CheckParams()
        {
            if (Executable == string.Empty)
            {
                MessageBox.Show("You must enter an executable file to run.", "Configuration Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (!File.Exists(Executable))
            {
                MessageBox.Show("Executable does not exist.", "Configuration Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            using (var tempEngine = new DummyDataEngine())
            {
                bool used = LauncherCommon.TestConnection("localhost", ListenPort, tempEngine);
                if (used)
                {
                    DialogResult result = MessageBox.Show("This port appears to be in use already. Continue anyway?",
                                                          "Port In Use", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (result == DialogResult.No)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Esempio n. 4
0
        private void m_appTypeCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            //this only happens when we detect admin required and revert the change
            if (m_appTypeCombo.SelectedIndex == m_launcherIndex)
            {
                return;
            }

            //not sure this CAN happen
            if (m_appTypeCombo.SelectedItem == null)
            {
                m_launcher = null;
                m_launchPropGrid.SelectedObject = null;
                return;
            }

            Type      launcherType = (m_appTypeCombo.SelectedItem as TypeEntry).Type;
            ILauncher launcher     = (ILauncher)Activator.CreateInstance(launcherType);

            //Don't allow the user to select a launcher that will just fail due to admin privileges required
            if (launcher.RequiresAdmin && !LauncherCommon.UserIsAdmin())
            {
                MessageBox.Show("You must run SlimTune as an administrator to profile the selected application type.");
                m_appTypeCombo.SelectedIndex = m_launcherIndex;
                return;
            }

            m_launcher = launcher;
            m_launchPropGrid.SelectedObject = m_launcher;
            m_launcherIndex = m_appTypeCombo.SelectedIndex;
        }
Esempio n. 5
0
        public override bool Launch(ConnectDelegate connect)
        {
            StopIIS();

            string config = LauncherCommon.CreateConfigString(ProfilingMode, ListenPort, false, IncludeNative, SamplingInterval, CounterInterval, AllowMethodInlining, TrackGC, TrackAllocs);

            string[] profilerEnv = LauncherCommon.CreateProfilerEnvironment(config, LauncherCommon.GetCounterString(PerformanceCounters));
            string[] baseEnv     = LauncherCommon.GetServicesEnvironment();
            baseEnv = LauncherCommon.ReplaceTempDir(baseEnv, Path.GetTempPath());
            string[] env = LauncherCommon.CombineEnvironments(baseEnv, profilerEnv);

            LauncherCommon.SetEnvironmentVariables("IISADMIN", env);
            LauncherCommon.SetEnvironmentVariables("W3SVC", env);
            LauncherCommon.SetEnvironmentVariables("WAS", env);

            string accountName = GetASP_NETaccountName();
            string accountSid  = null;

            if (accountName != null)
            {
                accountSid = LauncherCommon.GetAccountSid(accountName);
                if (accountSid != null)
                {
                    LauncherCommon.SetAccountEnvironment(accountSid, profilerEnv);
                }
            }

            bool returnVal = StartIIS();

            if (returnVal)
            {
                Thread.Sleep(1000);

                //we need to create a connection in order to know when CLR has been loaded
                using (IDataEngine engine = new DummyDataEngine())
                {
                    var client = connect("localhost", ListenPort, engine, 10);
                    if (client != null)
                    {
                        client.Dispose();
                    }
                    else
                    {
                        returnVal = false;
                    }
                }
            }

            LauncherCommon.DeleteEnvironmentVariables("IISADMIN");
            LauncherCommon.DeleteEnvironmentVariables("W3SVC");
            LauncherCommon.DeleteEnvironmentVariables("WAS");

            if (accountSid != null)
            {
                LauncherCommon.ResetAccountEnvironment(accountSid, profilerEnv);
            }

            return(returnVal);
        }
Esempio n. 6
0
        public override bool CheckParams()
        {
            var key = LauncherCommon.GetServiceKey("IISADMIN") ?? LauncherCommon.GetServiceKey("W3SVC") ?? LauncherCommon.GetServiceKey("WAS");

            if (key == null)
            {
                MessageBox.Show("Unable to find a compatible ASP.NET installation.", "ASP.NET Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            return(base.CheckParams());
        }
Esempio n. 7
0
        public override bool CheckParams()
        {
            if (ServiceName == string.Empty)
            {
                MessageBox.Show("You must enter a service name to run.", "Configuration Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            var key = LauncherCommon.GetServiceKey(ServiceName);

            if (key == null)
            {
                MessageBox.Show("Unable to find a service with the specified name.", "Configuration Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            return(base.CheckParams());
        }
Esempio n. 8
0
        public virtual bool CheckParams()
        {
            using (var tempEngine = new DummyDataEngine())
            {
                bool used = LauncherCommon.TestConnection("localhost", ListenPort, tempEngine);
                if (used)
                {
                    DialogResult result = MessageBox.Show("This port appears to be in use already. Continue anyway?",
                                                          "Port In Use", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (result == DialogResult.No)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Esempio n. 9
0
        public override bool Launch()
        {
            StopIIS();

            ClrConfig config = new ClrConfig
            {
                ProfilingMode       = ProfilingMode,
                ListenPort          = ListenPort,
                WaitForConnection   = WaitForConnection,
                IncludeNative       = IncludeNative,
                SamplingInterval    = SamplingInterval,
                CounterInterval     = CounterInterval,
                AllowMethodInlining = AllowMethodInlining,
                TrackGC             = TrackGC,
                TrackAllocs         = TrackAllocs,
                WeightedSampling    = WeightedSampling,
            };

            string configString = config.CreateString();

            string[] profilerEnv = LauncherCommon.CreateProfilerEnvironment(configString, LauncherCommon.GetCounterString(PerformanceCounters), true);
            string[] baseEnv     = LauncherCommon.GetServicesEnvironment();
            baseEnv = LauncherCommon.ReplaceTempDir(baseEnv, Path.GetTempPath());
            string[] env = LauncherCommon.CombineEnvironments(baseEnv, profilerEnv);

            LauncherCommon.SetEnvironmentVariables("IISADMIN", env);
            LauncherCommon.SetEnvironmentVariables("W3SVC", env);
            LauncherCommon.SetEnvironmentVariables("WAS", env);

            string accountName = GetASP_NETaccountName();
            string accountSid  = null;

            if (accountName != null)
            {
                accountSid = LauncherCommon.GetAccountSid(accountName);
                if (accountSid != null)
                {
                    LauncherCommon.SetAccountEnvironment(accountSid, profilerEnv);
                }
            }

            bool returnVal = StartIIS();

            if (returnVal)
            {
                Thread.Sleep(1000);

                //we need to create a connection in order to know when CLR has been loaded
                using (IDataEngine engine = new DummyDataEngine())
                {
                    ConnectProgress progress = new ConnectProgress("localhost", ListenPort, engine, 20);
                    progress.ShowDialog();
                    if (progress.Client != null)
                    {
                        progress.Client.Dispose();
                    }
                    else
                    {
                        returnVal = false;
                    }
                }
            }

            LauncherCommon.DeleteEnvironmentVariables("IISADMIN");
            LauncherCommon.DeleteEnvironmentVariables("W3SVC");
            LauncherCommon.DeleteEnvironmentVariables("WAS");

            if (accountSid != null)
            {
                LauncherCommon.ResetAccountEnvironment(accountSid, profilerEnv);
            }

            return(returnVal);
        }
Esempio n. 10
0
        public override bool Launch()
        {
            StopService(ServiceName, StopCommand);

            ClrConfig config = new ClrConfig
            {
                ProfilingMode       = ProfilingMode,
                ListenPort          = ListenPort,
                WaitForConnection   = WaitForConnection,
                IncludeNative       = IncludeNative,
                SamplingInterval    = SamplingInterval,
                CounterInterval     = CounterInterval,
                AllowMethodInlining = AllowMethodInlining,
                TrackGC             = TrackGC,
                TrackAllocs         = TrackAllocs,
                WeightedSampling    = WeightedSampling,
            };

            string configString = config.ToString();

            string[] profEnv = LauncherCommon.CreateProfilerEnvironment(configString, LauncherCommon.GetCounterString(PerformanceCounters), true);

            string serviceAccountSid  = null;
            string serviceAccountName = LauncherCommon.GetServiceAccountName(ServiceName);

            if (serviceAccountName != null && serviceAccountName.StartsWith(@".\"))
            {
                serviceAccountName = Environment.MachineName + serviceAccountName.Substring(1);
            }
            if (serviceAccountName != null && serviceAccountName != "LocalSystem")
            {
                serviceAccountSid = LauncherCommon.GetAccountSid(serviceAccountName);
            }

            if (serviceAccountSid != null)
            {
                //set environment for target account
                LauncherCommon.SetAccountEnvironment(serviceAccountSid, profEnv);
            }
            else
            {
                string[] baseEnv = LauncherCommon.GetServicesEnvironment();
                baseEnv = LauncherCommon.ReplaceTempDir(baseEnv, Path.GetTempPath());
                string[] combinedEnv = LauncherCommon.CombineEnvironments(baseEnv, profEnv);
                LauncherCommon.SetEnvironmentVariables(ServiceName, combinedEnv);
            }

            bool returnVal = true;

            StartService(ServiceName, StartCommand);

            Thread.Sleep(1000);
            using (var engine = new DummyDataEngine())
            {
                var progress = new ConnectProgress("localhost", ListenPort, engine, 10);
                progress.ShowDialog();
                if (progress.Client != null)
                {
                    progress.Client.Dispose();
                }
                else
                {
                    returnVal = false;
                }
            }

            if (serviceAccountSid != null)
            {
                LauncherCommon.ResetAccountEnvironment(serviceAccountSid, profEnv);
            }
            else
            {
                LauncherCommon.DeleteEnvironmentVariables(ServiceName);
            }

            return(returnVal);
        }