Esempio n. 1
0
        private uint GetProjectItemId(string ItemPath)
        {
            uint nID;

            VsHierarchy.ParseCanonicalName(ItemPath, out nID);

            return(nID);
        }
        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);
                    }
                }
            }
        }