Esempio n. 1
0
        private void m_testConnectionButton_Click(object sender, EventArgs e)
        {
            int port = 0;

            int.TryParse(m_portTextBox.Text, out port);
            if (port < 1 || port > ushort.MaxValue)
            {
                MessageBox.Show("Port must be between 1 and 65535.", "Launch Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            bool result = true;

            using (IDataEngine engine = new DummyDataEngine())
            {
                ConnectProgress progress = new ConnectProgress(m_hostNameTextBox.Text, port, engine, 1);
                progress.ShowDialog();
                if (progress.Client != null)
                {
                    result = true;
                    progress.Client.Dispose();
                }
                else
                {
                    result = false;
                }
            }

            if (result)
            {
                MessageBox.Show("Connection test was successful.", "Connection Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 2
0
        private bool Connect(string host, int port)
        {
            string dbFile = m_resultsFileTextBox.Text;

            //connect to data engine before launching the process -- we don't want to launch if this fails
            IDataEngine storage = null;

            try
            {
                //storage = new SqlServerCompactEngine(dbFile, true);
                if (SQLiteRadio.Checked)
                {
                    storage = new SQLiteEngine(dbFile, true);
                }
                else if (SQLiteMemoryRadio.Checked)
                {
                    storage = new SQLiteMemoryEngine();
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Launch Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            ConnectProgress progress = new ConnectProgress(host, port, storage, 10);

            progress.ShowDialog(this);

            if (progress.Client != null)
            {
                Connection conn = new Connection(storage);
                conn.RunClient(progress.Client);
                conn.SetAutoSnapshots(10000, false);

                var profilerWindow = new ProfilerWindow(m_mainWindow, conn);
                profilerWindow.Show();

                TypeEntry visEntry = m_visualizerCombo.SelectedItem as TypeEntry;
                if (visEntry != null && visEntry.Type != null)
                {
                    profilerWindow.AddVisualizer(visEntry.Type);
                }

                profilerWindow.BringToFront();
            }
            else
            {
                storage.Dispose();
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        private void ReconnectButton_Click(object sender, EventArgs e)
        {
            ConnectProgress progress = new ConnectProgress(Connection.HostName, Connection.Port, Connection.DataEngine, 10);

            progress.ShowDialog(this);

            if (progress.Client != null)
            {
                Connection.RunClient(progress.Client);
                ReconnectButton.Enabled = false;
                StatusLabel.Text        = "Status: Running";
                this.BringToFront();
            }
        }
Esempio n. 4
0
		private bool Connect(string host, int port)
		{
			string dbFile = m_resultsFileTextBox.Text;

			//connect to data engine before launching the process -- we don't want to launch if this fails
			IDataEngine storage = null;
			try
			{
				//storage = new SqlServerCompactEngine(dbFile, true);
				if(SQLiteRadio.Checked)
					storage = new SQLiteEngine(dbFile, true);
				else if(SQLiteMemoryRadio.Checked)
					storage = new SQLiteMemoryEngine();
				else
					throw new NotImplementedException();
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message, "Launch Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return false;
			}

			ConnectProgress progress = new ConnectProgress(host, port, storage, 10);
			progress.ShowDialog(this);

			if(progress.Client != null)
			{
				Connection conn = new Connection(storage);
				conn.RunClient(progress.Client);
				conn.SetAutoSnapshots(10000, false);

				var profilerWindow = new ProfilerWindow(m_mainWindow, conn);
				profilerWindow.Show();

				TypeEntry visEntry = m_visualizerCombo.SelectedItem as TypeEntry;
				if(visEntry != null && visEntry.Type != null)
					profilerWindow.AddVisualizer(visEntry.Type);

				profilerWindow.BringToFront();
			}
			else
			{
				storage.Dispose();
				return false;
			}

			return true;
		}
Esempio n. 5
0
		private void ReconnectButton_Click(object sender, EventArgs e)
		{
			ConnectProgress progress = new ConnectProgress(Connection.HostName, Connection.Port, Connection.DataEngine, 10);
			progress.ShowDialog(this);

			if(progress.Client != null)
			{
				Connection.RunClient(progress.Client);
				ReconnectButton.Enabled = false;
				StatusLabel.Text = "Status: Running";
				this.BringToFront();
			}
		}
Esempio n. 6
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. 7
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. 8
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);
        }
Esempio n. 9
0
        private bool LaunchLocal()
        {
            string dbFile = m_resultsFileTextBox.Text;

            if (!m_launcher.CheckParams())
            {
                return(false);
            }

            //connect to data engine before launching the process -- we don't want to launch if this fails
            IDataEngine data = null;

            if (m_connectCheckBox.Checked)
            {
                try
                {
                    this.Cursor = Cursors.WaitCursor;
                    if (m_sqliteRadio.Checked)
                    {
                        data = new SQLiteEngine(dbFile, true);
                    }
                    else if (m_sqliteMemoryRadio.Checked)
                    {
                        data = new SQLiteMemoryEngine();
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Launch Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }

            if (!m_launcher.Launch())
            {
                if (data != null)
                {
                    data.Dispose();
                }
                return(false);
            }

            //connect, if we're asked to
            if (m_connectCheckBox.Checked)
            {
                ConnectProgress progress = new ConnectProgress("localhost", m_launcher.ListenPort, data, 10);
                progress.ShowDialog(this);

                if (progress.Client != null)
                {
                    Connection conn = new Connection(data);
                    conn.Executable = m_launcher.Name;
                    conn.RunClient(progress.Client);
                    //TODO: set options like auto snapshot frequency
                    conn.SetAutoSnapshots(10000, false);

                    var profilerWindow = new ProfilerWindow(m_mainWindow, conn);
                    profilerWindow.Show();

                    TypeEntry visEntry = m_visualizerCombo.SelectedItem as TypeEntry;
                    if (visEntry != null && visEntry.Type != null)
                    {
                        profilerWindow.AddVisualizer(visEntry.Type);
                    }

                    profilerWindow.BringToFront();
                }
                else
                {
                    //connection failed, shut down the storage
                    data.Dispose();
                }
            }

            return(true);
        }
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;
		}
Esempio n. 11
0
		private void m_testConnectionButton_Click(object sender, EventArgs e)
		{
			int port = 0;
			int.TryParse(m_portTextBox.Text, out port);
			if(port < 1 || port > ushort.MaxValue)
			{
				MessageBox.Show("Port must be between 1 and 65535.", "Launch Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}

			bool result = true;
			using(IDataEngine engine = new DummyDataEngine())
			{
				ConnectProgress progress = new ConnectProgress(m_hostNameTextBox.Text, port, engine, 1);
				progress.ShowDialog();
				if(progress.Client != null)
				{
					result = true;
					progress.Client.Dispose();
				}
				else
				{
					result = false;
				}
			}

			if(result)
				MessageBox.Show("Connection test was successful.", "Connection Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
		}
Esempio n. 12
0
		private bool LaunchLocal()
		{
			string dbFile = m_resultsFileTextBox.Text;

			if(!m_launcher.CheckParams())
				return false;

			//connect to data engine before launching the process -- we don't want to launch if this fails
			IDataEngine data = null;
			if(m_connectCheckBox.Checked)
			{
				try
				{
					this.Cursor = Cursors.WaitCursor;
					if(m_sqliteRadio.Checked)
						data = new SQLiteEngine(dbFile, true);
					else if(m_sqliteMemoryRadio.Checked)
						data = new SQLiteMemoryEngine();
					else
						throw new NotImplementedException();
				}
				catch(Exception ex)
				{
					MessageBox.Show(ex.Message, "Launch Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
					return false;
				}
				finally
				{
					this.Cursor = Cursors.Default;
				}
			}

			if(!m_launcher.Launch())
			{
				if(data != null)
					data.Dispose();
				return false;
			}

			//connect, if we're asked to
			if(m_connectCheckBox.Checked)
			{
				ConnectProgress progress = new ConnectProgress("localhost", m_launcher.ListenPort, data, 10);
				progress.ShowDialog(this);

				if(progress.Client != null)
				{
					Connection conn = new Connection(data);
					conn.Executable = m_launcher.Name;
					conn.RunClient(progress.Client);
					//TODO: set options like auto snapshot frequency
					conn.SetAutoSnapshots(10000, false);

					var profilerWindow = new ProfilerWindow(m_mainWindow, conn);
					profilerWindow.Show();

					TypeEntry visEntry = m_visualizerCombo.SelectedItem as TypeEntry;
					if(visEntry != null && visEntry.Type != null)
						profilerWindow.AddVisualizer(visEntry.Type);

					profilerWindow.BringToFront();
				}
				else
				{
					//connection failed, shut down the storage
					data.Dispose();
				}
			}

			return true;
		}