Exemplo n.º 1
0
        private void StartButton_Checked(object sender, System.Windows.RoutedEventArgs e)
        {
            var platform = PlatformCombo.ActivePlatform;

            if (platform == null)
            {
                return;
            }

            Properties.Settings.Default.DefaultIP   = platform.IP.ToString();
            Properties.Settings.Default.DefaultPort = platform.Port;
            Properties.Settings.Default.Save();

            ProfilerClient.Get().IpAddress = platform.IP;
            ProfilerClient.Get().Port      = platform.Port;

            StartMessage message = new StartMessage();

            if (ProfilerClient.Get().SendMessage(message))
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    StatusText.Text       = "Capturing...";
                    StatusText.Visibility = System.Windows.Visibility.Visible;
                }));

                if (socketThread == null)
                {
                    socketThread = new Thread(RecieveMessage);
                    socketThread.Start();
                }
            }
        }
Exemplo n.º 2
0
        private void serverPort_TextChanged(object sender, TextChangedEventArgs e)
        {
            int value;

            if (int.TryParse(serverPort.Text, out value))
            {
                ProfilerClient.Get().Port = value;
            }
        }
Exemplo n.º 3
0
        private void serverIP_TextChanged(object sender, TextChangedEventArgs e)
        {
            IPAddress ip = null;

            if (IPAddress.TryParse(serverIP.Text, out ip))
            {
                ProfilerClient.Get().IpAddress = ip;
            }
        }
Exemplo n.º 4
0
        public void RecieveMessage()
        {
            while (true)
            {
                DataResponse response = ProfilerClient.Get().RecieveMessage();

                if (response != null)
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() => ApplyResponse(response)));
                }
                else
                {
                    Thread.Sleep(1000);
                }
            }
        }
Exemplo n.º 5
0
        public TimeLine()
        {
            this.InitializeComponent();
            this.DataContext = frames;

            statusToError.Add(TracerStatus.TRACER_ERROR_ACCESS_DENIED, new KeyValuePair <string, string>("ETW can't start: launch your Game/VisualStudio/UE4Editor as administrator to collect context switches", "https://github.com/bombomby/optick/wiki/Event-Tracing-for-Windows"));
            statusToError.Add(TracerStatus.TRACER_ERROR_ALREADY_EXISTS, new KeyValuePair <string, string>("ETW session already started (Reboot should help)", "https://github.com/bombomby/optick/wiki/Event-Tracing-for-Windows"));
            statusToError.Add(TracerStatus.TRACER_FAILED, new KeyValuePair <string, string>("ETW session failed (Run your Game or Visual Studio as Administrator to get ETW data)", "https://github.com/bombomby/optick/wiki/Event-Tracing-for-Windows"));
            statusToError.Add(TracerStatus.TRACER_INVALID_PASSWORD, new KeyValuePair <string, string>("Tracing session failed: invalid root password. Run the game as a root or pass a valid password through Optick GUI", "https://github.com/bombomby/optick/wiki/Event-Tracing-for-Windows"));
            statusToError.Add(TracerStatus.TRACER_NOT_IMPLEMENTED, new KeyValuePair <string, string>("Tracing sessions are not supported yet on the selected platform! Stay tuned!", "https://github.com/bombomby/optick"));

            ProfilerClient.Get().ConnectionChanged += TimeLine_ConnectionChanged;

            socketThread = new Thread(RecieveMessage);
            socketThread.Start();
        }
Exemplo n.º 6
0
        //private void FrameFilterSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        //{
        //	ICollectionView view = CollectionViewSource.GetDefaultView(frameList.ItemsSource);
        //	view.Filter = new Predicate<object>((item) => { return (item is Frame) ? (item as Frame).Duration >= FrameFilterSlider.Value : true; });
        //}

        public void StartCapture(IPAddress address, UInt16 port, CaptureSettings settings, SecureString password)
        {
            ProfilerClient.Get().IpAddress = address;
            ProfilerClient.Get().Port      = port;

            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                StatusText.Text       = "Connecting...";
                StatusText.Visibility = System.Windows.Visibility.Visible;
            }));

            Task.Run(() => { ProfilerClient.Get().SendMessage(new StartMessage()
                {
                    Settings = settings, Password = password
                }, true); });
        }
Exemplo n.º 7
0
        private void StartButton_Checked(object sender, System.Windows.RoutedEventArgs e)
        {
            var platform = PlatformCombo.ActivePlatform;

            if (platform == null)
            {
                return;
            }

            Properties.Settings.Default.DefaultIP   = platform.IP.ToString();
            Properties.Settings.Default.DefaultPort = platform.Port;
            Properties.Settings.Default.Save();

            ProfilerClient.Get().IpAddress = platform.IP;
            ProfilerClient.Get().Port      = platform.Port;

            timeLine.StartCapture();
        }
Exemplo n.º 8
0
        private void StartButton_Checked(object sender, System.Windows.RoutedEventArgs e)
        {
            StartMessage message = new StartMessage();

            if (ProfilerClient.Get().SendMessage(message))
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    StatusText.Text       = "Capturing...";
                    StatusText.Visibility = System.Windows.Visibility.Visible;
                }));

                if (socketThread == null)
                {
                    socketThread = new Thread(RecieveMessage);
                    socketThread.Start();
                }
            }
        }
Exemplo n.º 9
0
        public static void RecieveMessage()
        {
            while (true)
            {
                DataResponse response = ProfilerClient.Get().RecieveMessage();

                if (response != null)
                {
                    // Handle the response
                    if (response.Version == NetworkProtocol.NETWORK_PROTOCOL_VERSION)
                    {
                        switch (response.ResponseType)
                        {
                        case DataResponse.Type.ReportProgress:
                            Int32 length = response.Reader.ReadInt32();
                            System.Console.WriteLine("Progress: " + new String(response.Reader.ReadChars(length)));
                            break;

                        case DataResponse.Type.NullFrame:
                            lock (frames)
                            {
                                frames.Flush();
                            }
                            break;

                        case DataResponse.Type.Handshake:
                            break;

                        default:
                            lock (frames)
                            {
                                frames.Add(response.ResponseType, response.Reader);
                            }
                            break;
                        }
                    }
                }
                else
                {
                    Thread.Sleep(1000);
                }
            }
        }
Exemplo n.º 10
0
        public void StartCapture()
        {
            StartMessage message = new StartMessage();

            if (ProfilerClient.Get().SendMessage(message))
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    StatusText.Text       = "Capturing...";
                    StatusText.Visibility = System.Windows.Visibility.Visible;
                }));

                if (socketThread == null)
                {
                    socketThread = new Thread(RecieveMessage);
                    socketThread.Start();
                }
            }
        }
Exemplo n.º 11
0
 protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
 {
     timeLine.Close();
     ProfilerClient.Get().Close();
     base.OnClosing(e);
 }
Exemplo n.º 12
0
 private void StartButton_Unchecked(object sender, System.Windows.RoutedEventArgs e)
 {
     ProfilerClient.Get().SendMessage(new StopMessage());
 }
Exemplo n.º 13
0
 private void ClearHooksButton_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     ProfilerClient.Get().SendMessage(new SetupHookMessage(0, false));
 }
Exemplo n.º 14
0
 private void ClearSamplingButton_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     ProfilerClient.Get().SendMessage(new TurnSamplingMessage(-1, false));
 }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            var options = new Options();

            if (!CommandLine.Parser.Default.ParseArguments(args, options))
            {
                return;
            }

            IPAddress ip = null;

            IPAddress.TryParse(options.IpAddress, out ip);

            ProfilerClient.Get().IpAddress = ip;
            ProfilerClient.Get().Port      = options.Port;

            // Receive thread
            Thread socketThread = new Thread(RecieveMessage);

            socketThread.Start();

            var connectionEstablished = false;

            do
            {
                System.Console.WriteLine("Trying to connect...");

                connectionEstablished = ProfilerClient.Get().CheckConnection(100);

                if (connectionEstablished)
                {
                    System.Console.WriteLine("Connected sucessfully.");
                }
                else
                {
                    System.Threading.Thread.Sleep(500);
                }
            }while (!connectionEstablished);

            // Begin profiling
            if (ProfilerClient.Get().SendMessage(new StartMessage()))
            {
                System.Console.WriteLine("Begin capturing...");
                while (true)
                {
                    // Wait until a packet was done
                    Thread.Sleep(1000);

                    // Lost connection -> exit
                    if (!ProfilerClient.Get().IsConnected)
                    {
                        break;
                    }

                    // Emulate a message dump
                    ProfilerClient.Get().SendMessage(new StopMessage());
                    ProfilerClient.Get().SendMessage(new StartMessage());
                }

                System.Console.WriteLine("Done capturing.");

                socketThread.Abort();
                socketThread = null;

                // Connection was closed, save the data
                FileStream stream = new FileStream(options.Output, FileMode.Create);
                frames.Serialize(stream);
            }

            // Close the connection
            ProfilerClient.Get().Close();
        }