예제 #1
0
        private bool Prepare()
        {
            try
            {
                string errorMessage;
                if (!SDBLib.ForwardTcpPort(_selectedDevice, ControlPort, ControlPort, out errorMessage))
                {
                    WriteToOutput($"[ForwardTcpPort] {errorMessage}");
                    return(false);
                }
                if (!SDBLib.ForwardTcpPort(_selectedDevice, DataPort, DataPort, out errorMessage))
                {
                    WriteToOutput($"[ForwardTcpPort] {errorMessage}");
                    return(false);
                }
                if (!SDBLib.ForwardTcpPort(_selectedDevice, StatisticsPort, StatisticsPort, out errorMessage))
                {
                    WriteToOutput($"[ForwardTcpPort] {errorMessage}");
                    return(false);
                }

                if (!InstallProfiler("profctl", "coreprofiler"))
                {
                    return(false);
                }

                SessionDirectory = GetSessionDirName("DotNET-");
                Directory.CreateDirectory(SessionDirectory);

                _procLogStreamWriter = new StreamWriter(
                    Path.Combine(SessionDirectory, "proc.log"), false, Encoding.ASCII, 4096);

                // Generate files and copy them to target
                SetState(ProfileSessionState.UploadFiles, true);
                if (!PrepareAndCopyFilesToTarget())
                {
                    return(false);
                }

                SetState(ProfileSessionState.StartHost, true);

                if (!StartRemoteApplication(_isLiveProfiling ? "LIVEPROFILER" : "COREPROFILER"))
                {
                    return(false);
                }

                SetState(_sessionConfiguration.ProfilingSettings.DelayedStart
                    ? ProfileSessionState.Waiting : ProfileSessionState.Running, true);
            }
            catch (Exception ex)
            {
                DisplaySessionError($"Session prepare error. {ex.Message}");
                return(false);
            }

            return(true);
        }
예제 #2
0
        private bool RunHeaptrackSession()
        {
            string errorMessage;

            if (!SDBLib.ForwardTcpPort(_selectedDevice, ControlPort, ControlPort, out errorMessage))
            {
                WriteToOutput($"[ForwardTcpPort] {errorMessage}");
                return(false);
            }
            if (!SDBLib.ForwardTcpPort(_selectedDevice, DataPort, DataPort, out errorMessage))
            {
                WriteToOutput($"[ForwardTcpPort] {errorMessage}");
                return(false);
            }

            if (!InstallProfiler("profctl", "heaptrack"))
            {
                return(false);
            }

            SessionDirectory = GetSessionDirName("DotNETMP-");
            Directory.CreateDirectory(SessionDirectory);

            lock (_logFileLock)
            {
                _resFileStream = new GZipStream(
                    new FileStream(Path.Combine(SessionDirectory, "resfile.gz"), FileMode.CreateNew),
                    CompressionLevel.Optimal);
            }

            // Generate files and copy them to target
            SetState(HeaptrackSessionState.UploadFiles, true);
            if (!PrepareAndCopyFilesToTarget())
            {
                return(false);
            }

            // need to start the application first
            if (!StartRemoteApplication("HEAPTRACK"))
            {
                return(false);
            }

            SetState(HeaptrackSessionState.Running);

            if (!CommunicateWithControlProcess())
            {
                return(false);
            }

            return(true);
        }