Example #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);
            });
        }
Example #2
0
        protected override void Initialize() //async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
        {
            base.Initialize();

            // TODO : Can remove?
            VsProjectHelper.Initialize();

            //await PrepareWindowsAsync();
            PrepareWidnows();

            VsEvents.Initialize(this as IVsEventsHandler, GetService(typeof(SVsSolution)) as IVsSolution);

            DeviceManager.Initialize(VsPackage.outputPaneTizen);

            DeviceManager.ResetDeviceMonitorRetry();
            DeviceManager.StartDeviceMonitor();

            TizenPackageTracer.Initialize();

            PrepareToolsWindows();
            StartDebuggerMonitoring();

            base.RegisterEditorFactory(new ManifestEditorFactory(this));
            APICheckerCommand.Initialize(this, VsPackage.outputPaneTizen);

            string guidVSstd97     = "{5efc7975-14bc-11cf-9b2b-00aa00573819}".ToUpper();
            int    cmdidStartupPrj = 246;
            DTE2   dte2            = GetService(typeof(SDTE)) as DTE2;

            CEvents = dte2.Events.CommandEvents[guidVSstd97, cmdidStartupPrj];
            CEvents.AfterExecute += SetStartup_AfterExecute;

            ProfilerPlugin.Initialize(this, outputPaneTizen, dialogFactory);

            instance = this;
        }
        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
        }