/// <summary> /// Creates an instance of PipeLaunchOptions /// </summary> /// <param name="pipePath">Path of the pipe program</param> /// <param name="pipeArguments">Argument to the pipe program</param> /// <param name="pipeCommandArguments">Command to be invoked on the pipe program</param> /// <param name="pipeCwd">Current working directory of pipe program. If empty directory of the pipePath is set as the cwd.</param> /// <param name="pipeEnvironment">Environment variables set before invoking the pipe program</param> public PipeLaunchOptions(string pipePath, string pipeArguments, string pipeCommandArguments, string pipeCwd, MICore.Xml.LaunchOptions.EnvironmentEntry[] pipeEnvironment) { if (string.IsNullOrEmpty(pipePath)) throw new ArgumentNullException("PipePath"); this.PipePath = pipePath; this.PipeArguments = pipeArguments; this.PipeCommandArguments = pipeCommandArguments; this.PipeCwd = pipeCwd; this.PipeEnvironment = (pipeEnvironment != null) ? pipeEnvironment.Select(e => new EnvironmentEntry(e)).ToArray() : new EnvironmentEntry[] { }; }
public BlackBerryLaunchOptions(string exePath, MICore.Xml.LaunchOptions.BlackBerryLaunchOptions xmlOptions, TargetEngine targetEngine) { if (string.IsNullOrEmpty(exePath)) throw new ArgumentNullException("exePath"); if (xmlOptions == null) throw new ArgumentNullException("xmlOptions"); GdbPath = LaunchOptions.RequireAttribute(xmlOptions.GdbPath, "GdbPath"); GdbHostPath = LaunchOptions.RequireAttribute(xmlOptions.GdbHostPath, "GdbHostPath"); PID = LaunchOptions.RequirePositiveAttribute(xmlOptions.PID, "PID"); ExePath = exePath; TargetAddress = LaunchOptions.RequireAttribute(xmlOptions.TargetAddress, "TargetAddress"); TargetPort = xmlOptions.TargetPort; TargetType = GetTargetType(xmlOptions.TargetType); IsAttach = xmlOptions.Attach; AdditionalSOLibSearchPath = Combine(";", xmlOptions.AdditionalSOLibSearchPath, GetDefaultSearchPaths(xmlOptions.NdkHostPath, xmlOptions.NdkTargetPath, TargetType)); TargetArchitecture = LaunchOptions.ConvertTargetArchitectureAttribute(xmlOptions.TargetArchitecture); }
public IOSLaunchOptions(string exePath, MICore.Xml.LaunchOptions.IOSLaunchOptions xmlOptions) { if (string.IsNullOrEmpty(exePath)) throw new ArgumentNullException("exePath"); if (xmlOptions == null) throw new ArgumentNullException("xmlOptions"); this.ExePath = exePath; this.RemoteMachineName = LaunchOptions.RequireAttribute(xmlOptions.RemoteMachineName, "RemoteMachineName"); this.PackageId = LaunchOptions.RequireAttribute(xmlOptions.PackageId, "PackageId"); this.VcRemotePort = LaunchOptions.RequirePortAttribute(xmlOptions.vcremotePort, "vcremotePort"); Debug.Assert((uint)IOSDebugTarget.Device == (uint)MICore.Xml.LaunchOptions.IOSLaunchOptionsIOSDebugTarget.device); Debug.Assert((uint)IOSDebugTarget.Simulator == (uint)MICore.Xml.LaunchOptions.IOSLaunchOptionsIOSDebugTarget.simulator); this.IOSDebugTarget = (IOSDebugTarget)xmlOptions.IOSDebugTarget; this.TargetArchitecture = LaunchOptions.ConvertTargetArchitectureAttribute(xmlOptions.TargetArchitecture); this.AdditionalSOLibSearchPath = xmlOptions.AdditionalSOLibSearchPath; this.Secure = xmlOptions.Secure; }
public AndroidLaunchOptions(MICore.Xml.LaunchOptions.AndroidLaunchOptions xmlOptions, TargetEngine targetEngine) { if (xmlOptions == null) { throw new ArgumentNullException("xmlOptions"); } this.Package = LaunchOptions.RequireAttribute(xmlOptions.Package, "Package"); this.IsAttach = xmlOptions.Attach; if (!IsAttach) { // LaunchActivity is only required when we're launching this.LaunchActivity = LaunchOptions.RequireAttribute(xmlOptions.LaunchActivity, "LaunchActivity"); } this.SDKRoot = GetOptionalDirectoryAttribute(xmlOptions.SDKRoot, "SDKRoot"); this.NDKRoot = GetOptionalDirectoryAttribute(xmlOptions.NDKRoot, "NDKRoot"); this.TargetArchitecture = LaunchOptions.ConvertTargetArchitectureAttribute(xmlOptions.TargetArchitecture); if (targetEngine == TargetEngine.Native) this.IntermediateDirectory = RequireValidDirectoryAttribute(xmlOptions.IntermediateDirectory, "IntermediateDirectory"); else this.IntermediateDirectory = GetOptionalDirectoryAttribute(xmlOptions.IntermediateDirectory, "IntermediateDirectory"); if (targetEngine == TargetEngine.Java) { this.JVMHost = LaunchOptions.RequireAttribute(xmlOptions.JVMHost, "JVMHost"); this.JVMPort = xmlOptions.JVMPort; this.SourceRoots = GetSourceRoots(xmlOptions.SourceRoots); foreach (SourceRoot root in this.SourceRoots) { EnsureValidDirectory(root.Path, "SourceRoots"); } } this.AdditionalSOLibSearchPath = xmlOptions.AdditionalSOLibSearchPath; this.AbsolutePrefixSOLibSearchPath = xmlOptions.AbsolutePrefixSOLibSearchPath ?? "\"\""; this.DeviceId = LaunchOptions.RequireAttribute(xmlOptions.DeviceId, "DeviceId"); this.LogcatServiceId = GetLogcatServiceIdAttribute(xmlOptions.LogcatServiceId); this.WaitDynamicLibLoad = xmlOptions.WaitDynamicLibLoad; CheckTargetArchitectureSupported(); }
public AndroidLaunchOptions(MICore.Xml.LaunchOptions.AndroidLaunchOptions xmlOptions) { if (xmlOptions == null) { throw new ArgumentNullException("xmlOptions"); } this.Package = LaunchOptions.RequireAttribute(xmlOptions.Package, "Package"); this.IsAttach = xmlOptions.Attach; if (!IsAttach) { // LaunchActivity is only required when we're launching this.LaunchActivity = LaunchOptions.RequireAttribute(xmlOptions.LaunchActivity, "LaunchActivity"); } this.SDKRoot = GetOptionalDirectoryAttribute(xmlOptions.SDKRoot, "SDKRoot"); this.NDKRoot = GetOptionalDirectoryAttribute(xmlOptions.NDKRoot, "NDKRoot"); this.TargetArchitecture = LaunchOptions.ConvertTargetArchitectureAttribute(xmlOptions.TargetArchitecture); this.IntermediateDirectory = RequireValidDirectoryAttribute(xmlOptions.IntermediateDirectory, "IntermediateDirectory"); this.AdditionalSOLibSearchPath = xmlOptions.AdditionalSOLibSearchPath; this.DeviceId = LaunchOptions.RequireAttribute(xmlOptions.DeviceId, "DeviceId"); this.LogcatServiceId = GetLogcatServiceIdAttribute(xmlOptions.LogcatServiceId); CheckTargetArchitectureSupported(); }
public async Task Initialize(MICore.WaitLoop waitLoop, CancellationToken token) { bool success = false; Natvis.Initialize(_launchOptions.VisualizerFile); int total = 1; await this.WaitForConsoleDebuggerInitialize(token); try { await this.MICommandFactory.EnableTargetAsyncOption(); List<LaunchCommand> commands = GetInitializeCommands(); total = commands.Count(); var i = 0; foreach (var command in commands) { token.ThrowIfCancellationRequested(); waitLoop.SetProgress(total, i++, command.Description); if (command.IsMICommand) { Results results = await CmdAsync(command.CommandText, ResultClass.None); if (results.ResultClass == ResultClass.error && !command.IgnoreFailures) { string miError = results.FindString("msg"); throw new UnexpectedMIResultException(command.CommandText, miError); } } else { await ConsoleCmdAsync(command.CommandText); } } success = true; } finally { if (!success) { Terminate(); } } waitLoop.SetProgress(total, total, String.Empty); token.ThrowIfCancellationRequested(); }
/// <summary> /// Resolves the various file paths used by the AndroidDebugLauncher and returns an initialized InstallPaths object /// </summary> /// <param name="token">token to check for cancelation</param> /// <param name="launchOptions">[Required] launch options object</param> /// <returns>[Required] Created InstallPaths object</returns> public static InstallPaths Resolve(CancellationToken token, AndroidLaunchOptions launchOptions, MICore.Logger logger) { var result = new InstallPaths(); if (launchOptions.SDKRoot != null) { result.SDKRoot = launchOptions.SDKRoot; } else { result.SDKRoot = GetDirectoryFromRegistry(@"SOFTWARE\Android SDK Tools", "Path", checkBothBitnesses: true, externalProductName: LauncherResources.ProductName_SDK); } string ndkRoot = launchOptions.NDKRoot; if (ndkRoot == null) { ndkRoot = GetDirectoryFromRegistry(RegistryRoot.Value + @"\Setup\VS\SecondaryInstaller\AndroidNDK", "NDK_HOME", checkBothBitnesses: false, externalProductName: LauncherResources.ProductName_NDK); } string ndkReleaseVersionFile = Path.Combine(ndkRoot, "RELEASE.TXT"); if (!File.Exists(ndkReleaseVersionFile)) { ThrowExternalFileNotFoundException(ndkReleaseVersionFile, LauncherResources.ProductName_NDK); } NdkReleaseId ndkReleaseId; NdkReleaseId.TryParseFile(ndkReleaseVersionFile, out ndkReleaseId); logger.WriteLine("Using NDK '{0}' from path '{1}'", ndkReleaseId, ndkRoot); string targetArchitectureName; NDKToolChainFilePath[] possibleGDBPaths; switch (launchOptions.TargetArchitecture) { case MICore.TargetArchitecture.X86: targetArchitectureName = "x86"; possibleGDBPaths = NDKToolChainFilePath.x86_GDBPaths(); break; case MICore.TargetArchitecture.X64: targetArchitectureName = "x64"; possibleGDBPaths = NDKToolChainFilePath.x64_GDBPaths(); break; case MICore.TargetArchitecture.ARM: targetArchitectureName = "arm"; possibleGDBPaths = NDKToolChainFilePath.ARM_GDBPaths(); break; case MICore.TargetArchitecture.ARM64: targetArchitectureName = "arm64"; possibleGDBPaths = NDKToolChainFilePath.ARM64_GDBPaths(); break; default: Debug.Fail("Should be impossible"); throw new InvalidOperationException(); } NDKToolChainFilePath matchedPath; result.GDBPath = GetNDKFilePath( string.Concat("Android-", targetArchitectureName, "-GDBPath"), ndkRoot, possibleGDBPaths, out matchedPath ); if (launchOptions.TargetArchitecture == MICore.TargetArchitecture.X86 && matchedPath != null) { var r10b = new NdkReleaseId(10, 'b', true); // Before r10b, the 'windows-x86_64' ndk didn't support x86 debugging if (ndkReleaseId.IsValid && ndkReleaseId.CompareVersion(r10b) < 0 && matchedPath.PartialFilePath.Contains(@"\windows-x86_64\")) { throw new LauncherException(Telemetry.LaunchFailureCode.NoReport, LauncherResources.Error_64BitNDKNotSupportedForX86); } } token.ThrowIfCancellationRequested(); return result; }
public PipeLaunchOptions(string pipePath, string pipeArguments, string pipeCommandArguments, string pipeCwd, MICore.Xml.LaunchOptions.EnvironmentEntry[] pipeEnvironment) { if (string.IsNullOrEmpty(pipePath)) throw new ArgumentNullException("PipePath"); this.PipePath = pipePath; this.PipeArguments = pipeArguments; this.PipeCommandArguments = pipeCommandArguments; if (!String.IsNullOrWhiteSpace(pipeCwd)) { this.PipeCwd = pipeCwd; } else { this.PipeCwd = Path.GetDirectoryName(pipePath); } this.PipeEnvironment = (pipeEnvironment != null) ? pipeEnvironment.Select(e => new EnvironmentEntry(e)).ToArray() : new EnvironmentEntry[] { }; }
/// <summary> /// Resolves the various file paths used by the AndroidDebugLauncher and returns an initialized InstallPaths object /// </summary> /// <param name="token">token to check for cancelation</param> /// <param name="launchOptions">[Required] launch options object</param> /// <returns>[Required] Created InstallPaths object</returns> public static InstallPaths Resolve(CancellationToken token, AndroidLaunchOptions launchOptions, MICore.Logger logger) { var result = new InstallPaths(); if (launchOptions.SDKRoot != null) { result.SDKRoot = launchOptions.SDKRoot; } else { result.SDKRoot = GetDirectoryFromRegistry(@"SOFTWARE\Android SDK Tools", "Path", checkBothBitnesses: true, externalProductName: LauncherResources.ProductName_SDK); } string ndkRoot = launchOptions.NDKRoot; if (ndkRoot == null) { ndkRoot = GetDirectoryFromRegistry(RegistryRoot.Value + @"\Setup\VS\SecondaryInstaller\AndroidNDK", "NDK_HOME", checkBothBitnesses: false, externalProductName: LauncherResources.ProductName_NDK); } NdkReleaseId ndkReleaseId = new NdkReleaseId(); string ndkReleaseVersionFile = Path.Combine(ndkRoot, "RELEASE.TXT"); string ndkSourcePropertiesFile = Path.Combine(ndkRoot, "source.properties"); // NDK releases >= r11 have a source.properties file if (File.Exists(ndkSourcePropertiesFile)) { NdkReleaseId.TryParsePropertiesFile(ndkSourcePropertiesFile, out ndkReleaseId); } // NDK releases < r11 have a RELEASE.txt file else if (File.Exists(ndkReleaseVersionFile)) { NdkReleaseId.TryParseFile(ndkReleaseVersionFile, out ndkReleaseId); } else { ThrowExternalFileNotFoundException(ndkReleaseVersionFile, LauncherResources.ProductName_NDK); } logger.WriteLine("Using NDK '{0}' from path '{1}'", ndkReleaseId, ndkRoot); // 32 vs 64-bit doesn't matter when comparing var r11 = new NdkReleaseId(11, 'a'); // In NDK r11 and later, gdb is multi-arch and there's only one binary // in the prebuilt directory bool usePrebuiltGDB = ndkReleaseId.CompareVersion(r11) >= 0; IEnumerable<INDKFilePath> prebuiltGDBPath = NDKPrebuiltFilePath.GDBPaths(); string targetArchitectureName = launchOptions.TargetArchitecture.ToNDKArchitectureName(); IEnumerable<INDKFilePath> possibleGDBPaths; switch (launchOptions.TargetArchitecture) { case MICore.TargetArchitecture.X86: possibleGDBPaths = usePrebuiltGDB ? prebuiltGDBPath: NDKToolChainFilePath.x86_GDBPaths(); break; case MICore.TargetArchitecture.X64: possibleGDBPaths = usePrebuiltGDB ? prebuiltGDBPath : NDKToolChainFilePath.x64_GDBPaths(); break; case MICore.TargetArchitecture.ARM: possibleGDBPaths = usePrebuiltGDB ? prebuiltGDBPath : NDKToolChainFilePath.ARM_GDBPaths(); break; case MICore.TargetArchitecture.ARM64: possibleGDBPaths = usePrebuiltGDB ? prebuiltGDBPath : NDKToolChainFilePath.ARM64_GDBPaths(); break; default: Debug.Fail("Should be impossible"); throw new InvalidOperationException(); } INDKFilePath gdbMatchedPath; result.GDBPath = GetNDKFilePath( string.Concat("Android-", targetArchitectureName, "-GDBPath"), ndkRoot, possibleGDBPaths, out gdbMatchedPath ); if (launchOptions.TargetArchitecture == MICore.TargetArchitecture.X86 && gdbMatchedPath != null) { var r10b = new NdkReleaseId(10, 'b'); // Before r10b, the 'windows-x86_64' ndk didn't support x86 debugging if (ndkReleaseId.IsValid && ndkReleaseId.CompareVersion(r10b) < 0 && gdbMatchedPath.PartialFilePath.Contains(@"\windows-x86_64\")) { throw new LauncherException(Telemetry.LaunchFailureCode.NoReport, LauncherResources.Error_64BitNDKNotSupportedForX86); } } IEnumerable<INDKFilePath> gdbServerPath = NDKPrebuiltFilePath.GDBServerPaths(targetArchitectureName); INDKFilePath gdbServerMatchedPath; result.GDBServerPath = GetNDKFilePath( string.Concat("Android-", targetArchitectureName, "-GDBServerPath"), ndkRoot, gdbServerPath, out gdbServerMatchedPath // not used ); token.ThrowIfCancellationRequested(); return result; }