예제 #1
0
        protected AbstractSession(SDBDeviceInfo device, TSessionConfiguration sessionConfiguration)
        {
            _selectedDevice = device;
            var cap = new SDBCapability(_selectedDevice);

            _tizenVersion = cap.GetValueByKey("platform_version");
            if (!ProfilerPlugin.IsTizenVersionSupported(_tizenVersion, false))
            {
                throw new Exception($"Target platform version {_tizenVersion} is not supported");
            }
            _sdkToolPath          = cap.GetValueByKey("sdk_toolpath");
            _isSecureProtocol     = cap.GetAvailabilityByKey("secure_protocol");
            _sessionConfiguration = sessionConfiguration;
            ProjectDirectory      = _sessionConfiguration.ProjectHostPath;
            DeviceName            = _selectedDevice.Name;
            _asyncErrorTask       = Task.Run(() =>
            {
                try
                {
                    _asyncErrorEvent.WaitOne();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
                DisposeHelper.SafeDispose(ref _asyncErrorEvent);
            });
        }
        private bool IsNetCoreDbgSupported()
        {
            SDBDeviceInfo device = DeviceManager.SelectedDevice;
            bool          is_netcoredbg_support = false;

            if (device != null)
            {
                var cap = new SDBCapability(device);
                is_netcoredbg_support =
                    cap.GetAvailabilityByKey("netcoredbg_support");
            }
            return(is_netcoredbg_support);
        }
예제 #3
0
        /// <summary>
        /// Install packages on the target.
        /// </summary>
        /// <param name="packageNames">E.g. "profctl", "heaptrack", "coreprofiler".</param>
        /// <returns>True iff installed successfully</returns>
        public bool Install(params string[] packageNames)
        {
            if ((packageNames == null) || (packageNames.Length == 0))
            {
                throw new ArgumentException(nameof(packageNames));
            }
            ErrorMessage = "";
            var    cap          = new SDBCapability(_device);
            string tizenVersion = cap.GetValueByKey("platform_version");

            if (!DeployHelper.IsTizenVersionSupported(tizenVersion))
            {
                ErrorMessage = $"The target system platform version {tizenVersion} is not supported";
                return(false);
            }
            _sdkOnDemandFolder = ToolsPathInfo.GetOnDemandFolderPath(tizenVersion);
            if (string.IsNullOrEmpty(_sdkOnDemandFolder))
            {
                ErrorMessage = $"Can not find the folder with target packages for version \"{tizenVersion}\"";
                return(false);
            }
            if (!Directory.Exists(_sdkOnDemandFolder))
            {
                ErrorMessage = $"Folder \"{_sdkOnDemandFolder}\" not found";
                return(false);
            }
            _isSecureProtocol = cap.GetAvailabilityByKey("secure_protocol");
            if (_isSecureProtocol)
            {
                if (!_supportTarGz)
                {
                    ErrorMessage = "The target uses secure protocol. Only tar.gz packages are supported for secure targets";
                }
                _supportRpms = false;
            }
            _sdkToolPath = cap.GetValueByKey("sdk_toolpath");
            _cpuArch     = DeployHelper.GetPackageSuffix(cap.GetValueByKey("cpu_arch"));
            var unavailablePackages = new List <string>();

            CheckAvailable(packageNames, unavailablePackages);
            bool result = true;

            try
            {
                if (unavailablePackages != null)
                {
                    foreach (string packageName in unavailablePackages)
                    {
                        Version installedVersion = GetInstalledPackageVersion(packageName);
                        if (installedVersion == null)
                        {
                            ErrorMessage = $"Package \"{packageName}\" not found both in \"{_sdkOnDemandFolder}\" and on the target system";
                            return(false);
                        }
                    }
                }
                CheckInstalled();
                if (_packages.Any(p => p.Value.NeedToInstall))
                {
                    result = InstallPackages(_sdkToolPath + "/on-demand");
                }
            }
            finally
            {
                //
            }
            _packages.Clear();
            return(result);
        }
        public override async Task LaunchAsync(DebugLaunchOptions launchOptions)
        {
            if (ProfilerPlugin.Instance.ProfileLauncher.SessionActive ||
                ProfilerPlugin.Instance.HeaptrackLauncher.SessionActive)
            {
                ProfilerPlugin.Instance.ShowError("Cannot start debugging: a profiling session is active");
                return;
            }

            SDBDeviceInfo device = DeviceManager.SelectedDevice;

            if (device == null)
            {
                new EmulatorManagerLauncher().Launch();
                return;
            }

            var    cap          = new SDBCapability(device);
            string tizenVersion = cap.GetValueByKey("platform_version");

            if (!ProfilerPlugin.IsTizenVersionSupported(tizenVersion, true))
            {
                return;
            }

            bool isSecureProtocol = cap.GetAvailabilityByKey("secure_protocol");
            bool useNetCoreDbg    = cap.GetAvailabilityByKey("netcoredbg_support");
            bool isDebugMode      = !launchOptions.Equals(DebugLaunchOptions.NoDebug);
            bool useLiveProfiler  = isDebugMode && useNetCoreDbg && DebuggerInfo.UseLiveProfiler;

            // check the root mode is off
            if (!ProfilerPlugin.EnsureRootOff(device,
                                              isDebugMode ?
                                              (useLiveProfiler ? ProfilerPlugin.RunMode.LiveProfiler : ProfilerPlugin.RunMode.Debug)
                    : ProfilerPlugin.RunMode.NoDebug))
            {
                return;
            }

            Project debuggeeProj = VsHierarchy.GetDTEProject();

            tDebugLaunchOptions = isSecureProtocol ?
                                  (useNetCoreDbg ?
                                   new SecuredTizenNetCoreDbgLaunchOptions(device, isDebugMode, debuggeeProj, _tizenLaunchSettingsProvider.TizenLaunchSetting.ExtraArguments) :
                                   new SecuredTizenDebugLaunchOptions(device, isDebugMode, debuggeeProj, _tizenLaunchSettingsProvider.TizenLaunchSetting.ExtraArguments)) :
                                  (useNetCoreDbg ?
                                   new TizenNetCoreDbgLaunchOptions(device, isDebugMode, debuggeeProj, _tizenLaunchSettingsProvider.TizenLaunchSetting.ExtraArguments) :
                                   new TizenDebugLaunchOptions(device, isDebugMode, debuggeeProj, _tizenLaunchSettingsProvider.TizenLaunchSetting.ExtraArguments));

            string msg = $"Start {(isDebugMode ? "" : "without ")}debugging \"{tDebugLaunchOptions.AppId}\"";

            if (isSecureProtocol)
            {
                msg += " (secure protocol)";
            }
            OutputDebugLaunchMessage($"<<< {msg} >>>");

            bool isDebugNeeded = InstallTizenPackage(device, tDebugLaunchOptions);

            if (isDebugNeeded)
            {
                if (isDebugMode)
                {
/*
 *                  OnDemandDebuggerInstaller debuggerInstaller = isSecureProtocol ?
 *                      (useNetCoreDbg ?
 *                          new OnDemandDebuggerInstallerSecure("netcoredbg", "1.0.0") :
 *                          new OnDemandDebuggerInstallerSecure("lldb-tv", "3.8.1")) :
 *                      (useNetCoreDbg ?
 *                          new OnDemandDebuggerInstaller("netcoredbg", "1.0.0") :
 *                          new OnDemandDebuggerInstaller("lldb", "3.8.1"));
 *
 *                  isDebugNeeded = debuggerInstaller.InstallPackage(tizenVersion, VsPackage.outputPaneTizen, VsPackage.dialogFactory);
 */
                    // TODO!! remove OnDemandDebuggerInstaller.cs after checking OnDemandInstaller

                    var installer = new OnDemandInstaller(device, supportRpms: false, supportTarGz: true,
                                                          onMessage: (s) => ProfilerPlugin.Instance.WriteToOutput(s));

                    isDebugNeeded = installer.Install(useNetCoreDbg ? "netcoredbg" :
                                                      (isSecureProtocol ? "lldb-tv" : "lldb"));

                    if (!isDebugNeeded)
                    {
                        ProfilerPlugin.Instance.ShowError(StringHelper.CombineMessages(
                                                              "Cannot check/install the debugger package.\n", installer.ErrorMessage));
                    }
                }
                if (isDebugNeeded)
                {
                    isDebugNeeded = LaunchApplication(device, tDebugLaunchOptions) && isDebugMode;
                    if (isDebugNeeded)
                    {
                        await base.LaunchAsync(launchOptions);
                    }
                }
            }
        }
        private bool LaunchDebugModeApplication(SDBDeviceInfo device, TizenDebugLaunchOptions tDebugLaunchOptions)
        {
            #region W/A launch due to not-implemented parameter(for debug) of runapp protocol
            switch (tDebugLaunchOptions.AppType)
            {
            case "watch-application":
            case "widget-application":
                SDBLauncher.Create(VsPackage.outputPaneTizen).LaunchApplication(device, DebugLaunchDataStore.WidgetViewerSdkAppId);
                break;
            }
            var  cap = new SDBCapability(device);
            bool startLiveProfiler = tDebugLaunchOptions.IsDebugMode && cap.GetAvailabilityByKey("netcoredbg_support") && DebuggerInfo.UseLiveProfiler;
            if (startLiveProfiler)
            {
                switch (tDebugLaunchOptions.AppType)
                {
                case "ui-application":
                case "service-application":
                    if (tDebugLaunchOptions is SecuredTizenDebugLaunchOptions)
                    {
                        startLiveProfiler = false;
                    }
                    break;

                default:
                    startLiveProfiler = false;
                    break;
                }
            }

            bool ok = true;
            if (startLiveProfiler)
            {
                var proc = StartSdbProcess("-s " + device.Serial + " forward --remove tcp:4712",
                                           "Removing port forward...", false);
                WaitProcessExit(proc, 5000);
                proc = StartSdbProcess("-s " + device.Serial + " forward tcp:4712 tcp:4711",
                                       "Forwarding port...");
                WaitProcessExit(proc, 5000);
                ok = ProfilerPlugin.Instance.StartProfiler(true); // StartProfiler checks whether the root mode is off
            }
            else
            {
                if (ProfilerPlugin.EnsureRootOff(device, ProfilerPlugin.RunMode.Debug)) // check the root mode is off
                {
                    foreach (var arg in tDebugLaunchOptions.LaunchSequence)
                    {
                        var proc = StartSdbProcess(arg.Args, arg.Message);
                        if (arg.Timeout != 0)
                        {
                            if (!WaitProcessExit(proc, arg.Timeout))
                            {
                                // TODO!! show diagnostics
                                ok = false;
                                break;
                            }
                        }
                    }
                }
            }

            return(ok);

            #endregion
        }