예제 #1
0
        protected virtual bool GetPkgInstalledStatus(out bool isInstalled)
        {
            isInstalled  = false;
            ErrorMessage = string.Empty;

            PkgInstalledStatusWaiter waiter2 = new PkgInstalledStatusWaiter();
            string argument = DeviceManager.AdjustSdbArgument(
                "shell \"rpm -qa | grep " + lldbPkgName + "\"");
            Process process = SDBLib.CreateSdbProcess(true, true);
            var     result  = (process == null) ? null : SDBLib.RunSdbProcessAsync(process, argument, true, waiter2);

            if (!waiter2.Waiter.WaitOne(30000))
            {
                OutputDeviceErrorMsg("GetPkgInstalledStatus failed: " + lldbPkgName);
                return(false);
            }

            if (!string.IsNullOrEmpty(waiter2.InstalledStatus))
            {
                Version installedLldbVersion = new Version(waiter2.InstalledStatus.Split('-')[1]);
                Version lldbRpmFileVersion   = new Version(lldbVersion);

                if (installedLldbVersion >= lldbRpmFileVersion)
                {
                    OutputDeviceErrorMsg("GetPkgInstalledStatus (already installed): " + lldbPkgName);
                    isInstalled = true;
                }
            }

            return(true);
        }
예제 #2
0
        protected override bool GetPkgInstalledStatus(out bool isInstalled)
        {
            isInstalled  = false;
            ErrorMessage = string.Empty;

            PkgInstalledStatusWaiter waiter = new PkgInstalledStatusWaiter();
            string  argument = DeviceManager.AdjustSdbArgument("shell 0 vs_lldbversion");
            Process process  = SDBLib.CreateSdbProcess(true, true);
            var     result   = (process == null) ? null : SDBLib.RunSdbProcessAsync(process, argument, true, waiter);

            if (!waiter.Waiter.WaitOne(30000))
            {
                OutputDeviceErrorMsg("GetPkgInstalledStatus failed: Timeout");
                return(false);
            }

            try
            {
                Version installedLldbVersion = new Version(waiter.InstalledStatus);
                Version lldbRpmFileVersion   = new Version(lldbVersion);

                if (installedLldbVersion >= lldbRpmFileVersion)
                {
                    OutputDeviceErrorMsg("GetPkgInstalledStatus (already installed): " + lldbPkgName);
                    isInstalled = true;
                }

                return(true);
            }
            catch (Exception e)
            {
                OutputDeviceErrorMsg("GetPkgInstalledStatus failed: " + e.Message);
                return(false);
            }
        }
예제 #3
0
        private void CheckPackage(string name, ProfilerPackage package)
        {
            InstalledWaiter waiter  = new InstalledWaiter();
            var             proc    = SDBLib.CreateSdbProcess(true, true);
            string          cmdline = DeviceManager.AdjustSdbArgument("shell \"rpm -q " + name + "\"");
            var             result  = SDBLib.RunSdbProcessAsync(proc, cmdline, true, waiter);

            if (!waiter.Waiter.WaitOne(30000))
            {
                Print($"CheckPackage fails for {name}");
                return;
            }

            bool installed = !string.IsNullOrEmpty(waiter.InstalledStatus) &&
                             !waiter.InstalledStatus.EndsWith("not installed");

            Print($"Package {name} installed: {installed}");
            if (installed)
            {
                string[] components = ParsePackageFilename(waiter.InstalledStatus);
                if (components.Length > 2)
                {
                    package.InstalledVersion = components[2];
                }

                if (components.Length > 3)
                {
                    package.InstalledRelease = components[3];
                }
            }

            package.NeedToInstall = !installed;
        }
예제 #4
0
        protected override bool DeployDebuggerPackage(string debugger)
        {
            bool    result  = true;
            Process process = SDBLib.CreateSdbProcess(true, true);

            if (process == null)
            {
                ErrorMessage = "Failed to get sdb.exe program";
                return(false);
            }

            string arg       = "shell 0 vs_lldbinstall";
            string arguments = DeviceManager.AdjustSdbArgument(arg);

            process.StartInfo.Arguments = arguments;
            ErrorMessage = String.Empty;

            try
            {
                if (!process.Start())
                {
                    ErrorMessage = "Failed to install lldb.tar.gz";
                    return(false);
                }

                process.WaitForExit(5 * 1000);
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
                result       = false;
            }

            return(result);
        }
예제 #5
0
        public static bool InstallRpmPackage(SDBDeviceInfo device, string rpmFileName, out string errorMessage,
                                             TimeSpan?timeout = null)
        {
            string command          = $"rpm -U --force {rpmFileName}";
            string lastNonEmptyLine = "";
            bool   success          = SDBLib.RunSdbShellCommandAndCheckExitStatus(device, command,
                                                                                  (bool isStdOut, string line) =>
            {
                if (line != "")
                {
                    lastNonEmptyLine = line;
                }
                return(false);    // continue processing
            },
                                                                                  out errorMessage, timeout);

            if (!success)
            {
                if (!(errorMessage.Contains(rpmFileName) || lastNonEmptyLine.Contains(rpmFileName)))
                {
                    errorMessage = StringHelper.CombineMessages(errorMessage, $"Package: \"{rpmFileName}\"");
                }
                errorMessage = StringHelper.CombineMessages(errorMessage, lastNonEmptyLine);
            }
            return(success);
        }
        private System.Diagnostics.Process StartSdbProcess(string arguments, string message, bool showStdErr = true)
        {
            var proc = SDBLib.CreateSdbProcess();

            proc.StartInfo.Arguments = arguments;
            proc.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
            {
                if (!String.IsNullOrEmpty(e.Data))
                {
                    OutputDebugLaunchMessage(e.Data);
                }
            });
            if (showStdErr)
            {
                proc.ErrorDataReceived += new DataReceivedEventHandler((sender, e) =>
                {
                    if (!String.IsNullOrEmpty(e.Data))
                    {
                        OutputDebugLaunchMessage($"[StdErr] {e.Data}");
                    }
                });
            }
            OutputDebugLaunchMessage(message);
            System.Diagnostics.Debug.WriteLine("{0} {1} StartSdbProcess command '{2}'", DateTime.Now, this.ToString(), proc.StartInfo.Arguments);
            proc.Start();
            proc.BeginOutputReadLine();
            if (showStdErr)
            {
                proc.BeginErrorReadLine();
            }
            return(proc);
        }
예제 #7
0
        private EmulatorPlatformType GetPlatform()
        {
            EmulatorPlatformType result = EmulatorPlatformType.Mobile;
            int exitCode;

            SDBLib.SdbRunResult sdbResult = SDBLib.RunSdbCommand(_selectedDevice,
                                                                 "shell grep TZ_BUILD_PROFILE /etc/tizen-build.conf",
                                                                 (bool isStdOut, string line) =>
            {
                if (line.StartsWith("TZ_BUILD_PROFILE"))
                {
                    if (line.EndsWith("=tv"))
                    {
                        result = EmulatorPlatformType.TV;
                    }
                    return(true);
                }
                return(false);
            },
                                                                 out exitCode, SdbCommandTimeout);

            if (sdbResult != SDBLib.SdbRunResult.Success)
            {
                ShowWarning("Failed to determine the target platform type. " + SDBLib.FormatSdbRunResult(sdbResult, exitCode));
            }
            return(result);
        }
예제 #8
0
        private bool IsPreviewerInstalled(EmulatorPlatformType platformType)
        {
            bool isPreviewerInstalled = false;
            int  exitCode;

            SDBLib.SdbRunResult sdbResult = SDBLib.RunSdbCommand(_selectedDevice,
                                                                 String.Format(
                                                                     "shell [ -f /opt/usr/home/owner/apps_rw/{0}/tizen-manifest.xml ] && echo 1 || echo 0",
                                                                     (platformType == EmulatorPlatformType.TV) ? AppIdTV : AppIdMobile),
                                                                 (bool isStdOut, string line) =>
            {
                if (line.StartsWith("1"))
                {
                    isPreviewerInstalled = true;
                }
                return(true);    // only one line is needed
            },
                                                                 out exitCode, SdbCommandTimeout);

            if (sdbResult != SDBLib.SdbRunResult.Success)
            {
                ShowError("Failed to detect the XAML previewer application. " + SDBLib.FormatSdbRunResult(sdbResult, exitCode));
            }
            return(isPreviewerInstalled);
        }
예제 #9
0
        public SDBAppCmd(SDBDeviceInfo device, params string[] args)
        {
            List <string> rawItemList = SDBLib.RequestToTargetSync(device.Serial, SDBProtocol.appcmd, CombineArgs(args));

            ConsoleOutput = new List <string>();

            IsTargetFound = (rawItemList != null);
            RetrunString  = string.Empty;
            ExitCode      = SDBReqExitCode.EXIT_DEFAULT_FAILURE;

            if (IsTargetFound)
            {
                foreach (string item in rawItemList)
                {
                    if (HasPrefix(item, SDBProtocol.appcmd_returnstr))
                    {
                        RetrunString = GetPureValue(item);
                    }
                    else if (HasPrefix(item, SDBProtocol.appcmd_exitcode))
                    {
                        ExitCode = ParseInt(item);
                    }
                    else if (!string.IsNullOrWhiteSpace(item))
                    {
                        ConsoleOutput.Add(item.Replace("\r\n\0", string.Empty));
                    }
                }
            }
        }
예제 #10
0
        public SDBCapability(SDBDeviceInfo device)
        {
            string[] args = { "-s", device.Serial, SDBProtocol.capability };

            string returnValue;

            using (ProcessProxy p = new ProcessProxy())
            {
                p.StartInfo.FileName               = SDBLib.GetSdbFilePath();
                p.StartInfo.UseShellExecute        = false;
                p.StartInfo.CreateNoWindow         = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.Arguments              = string.Join(" ", args);
                Debug.WriteLine("{0} SDBCapability command '{1}'", DateTime.Now, p.StartInfo.Arguments);
                p.Start();

                returnValue = p.StandardOutput.ReadToEnd().Replace("\r", string.Empty);
                p.WaitForExit();
            }

            IsSupported = !string.IsNullOrEmpty(returnValue);
            if (IsSupported)
            {
                GenCapDic(returnValue);
            }
        }
예제 #11
0
        // download a log file from a Tizen device, change LF to CR LF, and remove the file from the target
        protected void DownloadAndDeleteOnTargetLogFile(string sourceLogPathName, string destinationLogFileName)
        {
            if (!String.IsNullOrEmpty(SessionDirectory))
            {
                string tempFileName = Path.GetTempFileName();
                try
                {
                    if (DownloadFile(sourceLogPathName, tempFileName))
                    {
                        string errorString;
                        FileHelper.CopyToWindowsText(tempFileName, Path.Combine(SessionDirectory, destinationLogFileName));
                        bool successResult;

                        if (_isSecureProtocol)
                        {
                            string profilerName = _profilerNameFromLogPattern.Match(sourceLogPathName).Groups[1].Value;
                            successResult = SDBLib.RunSdbShellSecureCommand(_selectedDevice, $"vs_profiler_log_remove {profilerName}", null, out errorString);
                        }
                        else
                        {
                            successResult = SDBLib.RunSdbShellCommand(_selectedDevice, $"rm -f {sourceLogPathName}", null, out errorString);
                        }
                        if (!successResult)
                        {
                            WriteToOutput(Tizen.VisualStudio.Utilities.StringHelper.CombineMessages(
                                              "Cannot execute command.", errorString));
                        }
                    }
                }
                finally
                {
                    try { File.Delete(tempFileName); } catch { }
                }
            }
        }
예제 #12
0
        protected virtual bool PushDebuggerPackage(string source, string destination)
        {
            DebuggerInstallWaiter waiter = new DebuggerInstallWaiter(this as IOndemandInstallerEvents);
            Process process = SDBLib.CreateSdbProcess(true, true);

            if (process == null)
            {
                ErrorMessage = "Failed to get sdb.exe program";
                return(false);
            }

            string fmt      = "push \"{0}\" \"{1}\"";
            string arg      = String.Format(fmt, source, destination);
            string argument = DeviceManager.AdjustSdbArgument(arg);
            var    result   = SDBLib.RunSdbProcessAsync(process, argument, true,
                                                        waiter);

            if (waiter.Waiter.WaitOne(300 * 1000)) // 5 minutes will be enough?
            {
                ErrorMessage = waiter.LastErrorMessage;
                return(waiter.PushResult);
            }

            ErrorMessage = "SDB Push Timeout.";
            return(false);
        }
예제 #13
0
        public static bool EnsureRootOff(SDBDeviceInfo device, RunMode runMode)
        {
            bool   isRoot;
            string errorMessage;

            bool isSecureProtocol = (new SDBCapability(DeviceManager.SelectedDevice)).GetAvailabilityByKey("secure_protocol");

            if (isSecureProtocol)
            {
                return(true);
            }

            if (!SDBLib.CheckIsRoot(device, out isRoot, out errorMessage))
            {
                Instance.ShowError(StringHelper.CombineMessages("Cannot check if \"root off\" mode set", errorMessage));
                return(false);
            }

            if (isRoot)
            {
                string msg = $"Currently \"root on\" mode is used on the \"{device.Name}\" device.\n";
                switch (runMode)
                {
                case RunMode.Debug:
                    msg +=
                        "Debugging cannot be started until switching the device to \"root off\".\n\n" +
                        "Do you want the plugin to switch the device to \"root off\" for you and continue?\n\n" +
                        "Note: please don't switch to \"root on\" mode manually while debugging.";
                    break;

                case RunMode.CoreProfiler:
                case RunMode.LiveProfiler:
                case RunMode.MemoryProfiler:
                    msg +=
                        "Profiling cannot be started until switching the device to \"root off\".\n\n" +
                        "Do you want the plugin to switch the device to \"root off\" for you and continue?\n\n" +
                        "Note: please don't switch to \"root on\" mode manually while profiling.";
                    break;

                default:
                    msg +=
                        "An application cannot be started until switching the device to \"root off\".\n\n" +
                        "Do you want the plugin to switch the device to \"root off\" for you and continue?";
                    break;
                }
                if (System.Windows.MessageBox.Show(msg, "Tizen Plugin", MessageBoxButton.YesNoCancel,
                                                   MessageBoxImage.Question) != MessageBoxResult.Yes)
                {
                    return(false);
                }
                if (!SDBLib.SwitchToRoot(device, false))
                {
                    ProfilerPlugin.Instance.ShowError($"Cannot switch \"{device.Name}\" to \"root off\" mode");
                    return(false);
                }
            }

            return(true);
        }
예제 #14
0
        public static bool PushFile(SDBDeviceInfo device, string sourceFileName, string destinationFileName,
                                    Func <bool, string, bool> onLineRead, out string errorMessage, TimeSpan?timeout = null)
        {
            if (!File.Exists(sourceFileName))
            {
                errorMessage = $"File \"{sourceFileName}\" not found";
                return(false);
            }
            string sdbErr     = null;
            string sdbOutput  = null;
            int    exitResult = 0;

            SDBLib.SdbRunResult sdbResult = SDBLib.RunSdbCommand(device,
                                                                 $"push \"{sourceFileName}\" \"{destinationFileName}\"",
                                                                 (bool isStdOut, string line) =>
            {
                bool stop = false;
                if (onLineRead != null)
                {
                    stop = onLineRead(isStdOut, line);
                }
                if (line.Contains("1 file(s) pushed"))
                {
                    stop = true;
                }
                if (line.StartsWith("error:"))
                {
                    sdbErr = line;
                    stop   = true;
                }
                sdbOutput += line;
                return(stop);
            },
                                                                 out exitResult,
                                                                 timeout ?? DefaultTimeout);
            if (sdbResult == SDBLib.SdbRunResult.Success && exitResult == 0)
            {
                if (sdbErr == null)
                {
                    errorMessage = "";
                    return(true);
                }
            }
            errorMessage = $"Cannot push \"{sourceFileName}\" to \"{destinationFileName}\"";
            if (sdbResult != SDBLib.SdbRunResult.Success)
            {
                errorMessage = StringHelper.CombineMessages(errorMessage, SDBLib.FormatSdbRunResult(sdbResult));
            }
            if (sdbOutput != null)
            {
                errorMessage = StringHelper.CombineMessages(errorMessage, sdbOutput);
            }
            return(false);
            //if (sdbErr != null)
            //{
            //    errorMessage = StringHelper.CombineMessages(errorMessage, sdbErr);
            //}
            //return false;
        }
예제 #15
0
        protected bool StartRemoteApplication(string sdkCode)
        {
            string appId = _sessionConfiguration.AppId;

            DebugWriteToOutput($"Starting launch_app({appId}; SDK={sdkCode})");
            ProcessProxy launchAppProcess = SDBLib.CreateSdbProcess(true, true);

            if (launchAppProcess == null)
            {
                WriteToOutput(SDBLib.FormatSdbRunResult(SDBLib.SdbRunResult.CreateProcessError));
                return(false);
            }
            launchAppProcess.StartInfo.Arguments = GetSdbLaunchCommand(sdkCode);
            string firstOutputLine = null;

            _launchAppStartedEvent.Reset();
            launchAppProcess.OutputDataReceived += ((sender, e) =>
            {
                if (!String.IsNullOrEmpty(e.Data))
                {
                    firstOutputLine = e.Data;
                    _launchAppStartedEvent.Set();
                    DebugWriteToOutput($"{appId} : {e.Data}");
                }
            });
            launchAppProcess.ErrorDataReceived += ((sender, e) =>
            {
                if (!String.IsNullOrEmpty(e.Data))
                {
                    DebugWriteToOutput($"{appId} [StdErr] {e.Data}");
                }
            });
            launchAppProcess.Exited += (object sender, EventArgs e) =>
            {
                DebugWriteToOutput($"launch_app({appId}) finished");
                launchAppProcess.Dispose();
            };
            Debug.WriteLine("{0} {1} StartRemoteApplication command '{2}'", DateTime.Now, this.ToString(), launchAppProcess.StartInfo.Arguments);
            launchAppProcess.Start();
            DebugWriteProcessToOutput(launchAppProcess);
            try
            {
                launchAppProcess.BeginOutputReadLine();
                launchAppProcess.BeginErrorReadLine();
                if (_launchAppStartedEvent.WaitOne(30000))
                {
                    if (firstOutputLine.EndsWith("launch failed"))
                    {
                        WriteToOutput($"launch_app({appId}) failed");
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            return(true);
        }
        private bool InstallPackage(string tarPath, out string errorMessage)
        {
            string sdkToolPath = sdbCapability.GetValueByKey("sdk_toolpath");
            string errorString;

            SDBLib.RunSdbShellCommand(null, $"rm -rf {sdkToolPath}/{pkgName}", null, out errorString); // remove old files (if any)
            return(DeployHelper.ExtractTarGzip(null, tarPath, sdkToolPath, out errorMessage));
        }
예제 #17
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);
        }
예제 #18
0
        private bool InstallPackage(string packageName, string packageFileName)
        {
            string errorMessage;
            bool   success;

            if (packageFileName.EndsWith(".rpm"))
            {
                success = DeployHelper.InstallRpmPackage(_device, packageFileName, out errorMessage);
            }
            else
            {
                if (_isSecureProtocol)
                {
                    // TODO!! try to remove special handling of "lldb-tv"
                    if (packageName == LldbTvPackage)
                    {
                        // TODO!! do need to uninstall?
                        string outputLine;
                        success = DeployHelperSecure.RunCommand(_device, "shell 0 vs_lldbinstall", out outputLine, out errorMessage);
                    }
                    else
                    {
                        // TODO!! do need to uninstall?
                        if (DeployHelperSecure.GetInstalledPackageVersion(_device, packageName, out errorMessage) != null)
                        {
                            DeployHelperSecure.UninstallPackage(_device, packageName, out errorMessage);
                        }
                        success = DeployHelperSecure.InstallPackage(_device, packageName, out errorMessage);
                    }
                    if (!success)
                    {
                        errorMessage = StringHelper.CombineMessages($"Cannot install package \"{packageName}\"", errorMessage);
                    }
                }
                else
                {
                    // remove old files (if any)
                    if (!SDBLib.RunSdbShellCommandAndCheckExitStatus(_device, $"rm -rf {_sdkToolPath}/{packageName}", null,
                                                                     out errorMessage))
                    {
                        DebugPrint(StringHelper.CombineMessages("Cannot remove old files", errorMessage));
                    }
                    success = DeployHelper.ExtractTarGzip(_device, packageFileName, _sdkToolPath, out errorMessage);
                }
            }
            if (success)
            {
                Print($"Successfully installed \"{packageFileName}\"");
            }
            else
            {
                Print(errorMessage);
            }
            return(success);
        }
 protected virtual Parameters GetDebugEngineLaunchParameters()
 {
     return(new Parameters(
                pipePath: SDBLib.GetSdbFilePath(),
                pipeArguments: GetLldbArguments(),
                miMode: "lldb",
                additionalOptions: "",
                launchCommand: "launch_app",
                launchpadArgs: " __AUL_SDK__ LLDB-SERVER __DLP_DEBUG_ARG__ g,--platform=host,*:1234,-- CORECLR_GDBJIT " + GetDebuggeeDllList() + niDisableOption
                ));
 }
 protected override Parameters GetDebugEngineLaunchParameters()
 {
     return(new Parameters(
                pipePath: SDBLib.GetSdbFilePath(),
                pipeArguments: GetLldbArguments(),
                miMode: "lldb",
                additionalOptions: "",
                launchCommand: "0 vs_debug",
                launchpadArgs: " " + GetDebuggeeDllList() + niDisableOption
                ));
 }
예제 #21
0
        protected bool DownloadFile(string source, string destination)
        {
            string errorString;

            if (!SDBLib.RunSdbCommandAndGetError(_selectedDevice, $"pull {source} \"{destination}\"", null, out errorString))
            {
                WriteToOutput(Tizen.VisualStudio.Utilities.StringHelper.CombineMessages(
                                  "Cannot execute command.", errorString));
                return(false);
            }
            return(true);
        }
예제 #22
0
        private bool RemountRW()
        {
            Print("Remount rootfs RW");
            var    process = SDBLib.CreateSdbProcess();
            string cmdline = DeviceManager.AdjustSdbArgument("shell \"mount / -o remount,rw\"");

            SDBLib.RunSdbProcess(process, cmdline);
            var rc = process.ExitCode;

            process.Close();
            return(rc == 0);
        }
예제 #23
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);
        }
예제 #24
0
        private bool RunTpk(EmulatorPlatformType platformType)
        {
            string errorMessage;
            bool   result = SDBLib.RunSdbShellCommandAndCheckExitStatus(_selectedDevice,
                                                                        $"launch_app {((platformType == EmulatorPlatformType.TV) ? AppIdTV : AppIdMobile)} " +
                                                                        "__AUL_SDK__ dotnet-launcher", null, out errorMessage);

            if (!result)
            {
                ShowError(errorMessage);
            }
            return(result);
        }
예제 #25
0
        private bool SwitchToRoot(bool on)
        {
            Print($"Switch to root: {on}");

            var    process = SDBLib.CreateSdbProcess();
            string cmdline = DeviceManager.AdjustSdbArgument($"root {((on) ? "on" : "off")}");

            SDBLib.RunSdbProcess(process, cmdline);
            var rc = process.ExitCode;

            process.Close();
            return(rc == 0);
        }
예제 #26
0
        public static bool InstallTpk(SDBDeviceInfo device, string tpkFileName,
                                      Func <bool, string, bool> onLineRead, out string errorMessage, TimeSpan?timeout = null)
        {
            if (!File.Exists(tpkFileName))
            {
                errorMessage = $"File \"{tpkFileName}\" not found";
                return(false);
            }
            string sdbErr = null;
            int    exitCode;

            SDBLib.SdbRunResult sdbResult = SDBLib.RunSdbCommand(device,
                                                                 $"install \"{tpkFileName}\"",
                                                                 (bool isStdOut, string line) =>
            {
                bool stop = false;
                if (onLineRead != null)
                {
                    stop = onLineRead(isStdOut, line);
                }
                if (line.StartsWith("spend time for pkgcmd is"))
                {
                    stop = true;
                }
                if (line.StartsWith("error:"))
                {
                    sdbErr = line;
                    stop   = true;
                }
                return(stop);
            },
                                                                 out exitCode, timeout ?? DefaultTimeout);
            if (sdbResult == SDBLib.SdbRunResult.Success)
            {
                if (sdbErr == null)
                {
                    errorMessage = "";
                    return(true);
                }
            }
            errorMessage = StringHelper.CombineMessages($"Cannot install TPK", SDBLib.FormatSdbRunResult(sdbResult, exitCode));
            if (sdbErr != null)
            {
                if (!sdbErr.Contains(tpkFileName))
                {
                    errorMessage = StringHelper.CombineMessages(errorMessage, $"Package: \"{tpkFileName}\"");
                }
                errorMessage = StringHelper.CombineMessages(errorMessage, sdbErr);
            }
            return(false);
        }
예제 #27
0
 private void ExcuteLogProcess(string name)
 {
     if (!string.IsNullOrEmpty(name) && (logProcess = SDBLib.CreateSdbProcess(true, true)) != null)
     {
         logProcess.StartInfo.Arguments = " -s " + name + " dlog -v long";/* *:* */
         logProcess.StartInfo.RedirectStandardOutput = true;
         logProcess.StartInfo.RedirectStandardError  = true;
         logProcess.OutputDataReceived += new DataReceivedEventHandler(Sdb_OutputDataReceived);
         Debug.WriteLine("{0} {1} ExcuteLogProcess command '{2}'", DateTime.Now, this.ToString(), logProcess.StartInfo.Arguments);
         logProcess.Start();
         logProcess.BeginErrorReadLine();
         logProcess.BeginOutputReadLine();
     }
 }
예제 #28
0
        private bool InstallPackage(string name, ProfilerPackage p)
        {
            string rpm = name + "-" + p.AvailableVersion + "-" + p.AvailableRelease
                         + "." + ArchToSuffix(GetArch()) + ".rpm";
            string package_path = GetRpmsPath() + "/" + rpm;

            Print($"Installing {package_path}");
            var    process = SDBLib.CreateSdbProcess();
            string cmdline = DeviceManager.AdjustSdbArgument($"shell \"rpm -U --force {package_path}\"");

            SDBLib.RunSdbProcess(process, cmdline, true);
            int rc = process.ExitCode;

            process.Close();
            return(rc == 0);
        }
예제 #29
0
        public static bool IsRmpPackageInstalled(SDBDeviceInfo device, string packageName,
                                                 out string installedPackageName, out string errorMessage, TimeSpan?timeout = null)
        {
            string command = $"rpm -q {packageName}";

            installedPackageName = "";
            string lastNonEmptyLine = "";
            bool   success          = SDBLib.RunSdbShellCommandAndCheckExitStatus(device, command,
                                                                                  (bool isStdOut, string line) =>
            {
                if (line != "")
                {
                    lastNonEmptyLine = line;
                }
                return(false);    // continue processing
            },
                                                                                  out errorMessage, timeout);

            if (success)
            {
                if (!String.IsNullOrEmpty(lastNonEmptyLine))
                {
                    installedPackageName = lastNonEmptyLine;
                }
                else
                {
                    errorMessage = $"Cannot check RPM package \"{packageName}\"";
                    success      = false;
                }
            }
            else
            {
                if (lastNonEmptyLine.EndsWith("is not installed"))
                {
                    errorMessage = ""; // no error, package just not installed
                }
                else
                {
                    if (!(errorMessage.Contains(packageName) || lastNonEmptyLine.Contains(packageName)))
                    {
                        errorMessage = StringHelper.CombineMessages(errorMessage, $"Package: \"{packageName}\"");
                    }
                    errorMessage = StringHelper.CombineMessages(errorMessage, lastNonEmptyLine);
                }
            }
            return(success);
        }
예제 #30
0
        private bool PushPackage(string name, ProfilerPackage p)
        {
            string rpm = name + "-" + p.AvailableVersion + "-" + p.AvailableRelease
                         + "." + ArchToSuffix(GetArch()) + ".rpm";
            string src = ToolsPathInfo.OndemandFolderPath + @"\" + rpm;
            string dst = GetRpmsPath() + "/" + rpm;

            Print($"Push {src} -> {dst}");
            var    proc    = SDBLib.CreateSdbProcess(true, true);
            string cmdline = DeviceManager.AdjustSdbArgument($"push \"{src}\" {dst}");

            SDBLib.RunSdbProcess(proc, cmdline, true);
            int rc = proc.ExitCode;

            proc.Close();
            return(rc == 0);
        }