string RunShellCommand(string command, SbPlatform platform) { SbPlatformShellCommand shellCommand = _lldbPlatformShellCommandFactory.Create(command); SbError error = platform.Run(shellCommand); if (error.Fail()) { return(null); } return(shellCommand.GetOutput()); }
// Run the specified command. public override Task <RunResponse> Run(RunRequest request, ServerCallContext context) { PreconditionCheck(); var shellCommand = sbPlatformShellCommandFactory.Create(request.ShellCommand.Command); var error = sbPlatform.Run(shellCommand); var grpcError = new GrpcSbError { Success = error.Success(), Error = error.GetCString() }; var response = new RunResponse { Error = grpcError, Output = shellCommand.GetOutput(), Signal = shellCommand.GetSignal(), Status = shellCommand.GetStatus() }; return(Task.FromResult(response)); }
bool GetRemoteProcessId(string executable, SbPlatform platform, out uint pid) { pid = 0; var shellCommand = _lldbPlatformShellCommandFactory.Create($"pidof \"{executable}\""); if (platform == null) { Trace.WriteLine("Unable to find process, no platform selected"); return(false); } var error = platform.Run(shellCommand); if (error.Fail()) { Trace.WriteLine("Unable to find process: " + error.GetCString()); return(false); } string output = shellCommand.GetOutput(); if (string.IsNullOrEmpty(output)) { Trace.WriteLine("Unable to find process '" + executable + "'"); return(false); } string[] pids = output.Split(' '); if (pids.Length > 1) { Trace.WriteLine("Unable to select process, multiple instances of '" + executable + "' are running"); return(false); } if (!uint.TryParse(pids[0], out pid)) { Trace.WriteLine("Unable to convert pid '" + pids[0] + "' to int"); return(false); } return(true); }
public void TestRunCommandWithUnknownCommand() { Assert.Throws <NotSupportedException>(() => platform.Run( shellCommandFactory.Create("awk blah"))); }