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); }
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); } }
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); }
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); }
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; }
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); }
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 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); }
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); }
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(); } }
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); }
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); }
private bool SetSDBRoot(bool beRoot) { bool result = true; Process process = SDBLib.CreateSdbProcess(true, true); if (process == null) { ErrorMessage = "Failed to get sdb.exe program"; return(false); } string arguments; if (beRoot) { arguments = DeviceManager.AdjustSdbArgument("root on"); } else { arguments = DeviceManager.AdjustSdbArgument("root off"); } process.StartInfo.Arguments = arguments; ErrorMessage = String.Empty; try { if (!process.Start()) { ErrorMessage = "Failed to set SDB root"; return(false); } process.WaitForExit(5 * 1000); } catch (Exception e) { ErrorMessage = e.Message; result = false; } return(result); }
private bool InstallDebuggerRPM(string rpm) { bool result = true; Process process = SDBLib.CreateSdbProcess(true, true); if (process == null) { ErrorMessage = "Failed to get sdb.exe program"; return(false); } string fmt = "shell rpm -Uvh \"{0}\" --force"; string arg = String.Format(fmt, rpm); string arguments = DeviceManager.AdjustSdbArgument(arg); process.StartInfo.Arguments = arguments; ErrorMessage = String.Empty; try { if (!process.Start()) { ErrorMessage = "Failed to install lldb rpm."; return(false); } process.WaitForExit(5 * 1000); } catch (Exception e) { ErrorMessage = e.Message; result = false; } return(result); }
private bool RemountRootRW() { bool result = true; Process process = SDBLib.CreateSdbProcess(true, true); if (process == null) { ErrorMessage = "Failed to get sdb.exe program"; return(false); } string fmt = "shell mount -o remount, rw /"; string arguments = DeviceManager.AdjustSdbArgument(fmt); process.StartInfo.Arguments = arguments; ErrorMessage = String.Empty; try { if (!process.Start()) { ErrorMessage = "Failed to remount RW"; return(false); } process.WaitForExit(5 * 1000); } catch (Exception e) { ErrorMessage = e.Message; result = false; } return(result); }