예제 #1
0
        public VCDocumentInfo(DTE app)
        {
            VCProjectW       vcproj;
            VCConfigurationW cfg;

            if (!ProjectUtil.getActiveProjectAndConfig(app, out vcproj, out cfg))
            {
                return;
            }

            Document    doc  = app.ActiveDocument;
            ProjectItem item = doc.ProjectItem;

            if (ProjectUtil.matchTypeName(item.Object, "VCProjectFileShim"))
            {
                VCFileW vcfile = new VCFileW(item.Object);
                this.VCProject       = vcproj;
                this.VCConfiguration = cfg;
                this.VCFile          = vcfile;
            }
        }
예제 #2
0
 public Object callMember(String name, Object obj)
 {
     return(ProjectUtil.callMember(Object, name, obj));
 }
예제 #3
0
 public Object getProperty(String name)
 {
     return(ProjectUtil.getProperty(Object, name));
 }
예제 #4
0
        /// <summary>
        /// </summary>
        private void onApplyChange(object sender, EventArgs e)
        {
            DTE            dte   = (DTE)GetService(typeof(DTE));
            VCDocumentInfo vcdoc = new VCDocumentInfo(dte);

            if (!vcdoc.IsValid())
            {
                return;
            }

            dte.ActiveDocument.Save();

            List <String>    cur_func = ProjectUtil.GetFunctionsInCurrentPosition(dte);
            VCFileW          vcfile   = vcdoc.VCFile;
            VCConfigurationW vcconf   = vcdoc.VCConfiguration;

            Dictionary <String, String> properties = new Dictionary <String, String>();

            properties.Add("Configuration", vcconf.Evaluate("$(Configuration)"));
            properties.Add("Platform", vcconf.Evaluate("$(Platform)"));
            properties.Add("SelectedFiles", vcdoc.FileRelpath);
            properties.Add("BuildProjectReferences", "false");
            properties.Add("SolutionDir", vcconf.Evaluate("$(SolutionDir)"));
            properties.Add("SolutionExt", vcconf.Evaluate("$(SolutionExt)"));
            properties.Add("SolutionName", vcconf.Evaluate("$(SolutionName)"));
            properties.Add("SolutionFileName", vcconf.Evaluate("$(SolutionFileName)"));
            properties.Add("SolutionPath", vcconf.Evaluate("$(SolutionPath)"));

            RunBuild(vcdoc.ProjPath, vcfile.ItemType, properties, (BuildLogger logger) =>
            {
                if (vcfile.ItemType == "ClCompile")
                {
                    List <alcSymbolFilterColumn> filter = SymbolFilterUtil.GetDefaultFilter(vcdoc.ObjPath, true);
                    {
                        List <alcSymbolFilterColumn> loaded_filter = SymbolFilterUtil.LoadFromConfigFile(vcdoc.ObjFilterPath);
                        if (loaded_filter != null)
                        {
                            filter = SymbolFilterUtil.MergeFilter(filter, loaded_filter);
                        }
                    }

                    if (filter != null && cur_func.Count > 0)
                    {
                        bool changed = false;
                        foreach (alcSymbolFilterColumn c in filter)
                        {
                            foreach (String f in cur_func)
                            {
                                if (c.Name == f)
                                {
                                    c.FlagUpdate = true;
                                    changed      = true;
                                }
                            }
                        }
                        if (changed)
                        {
                            SymbolFilterUtil.SaveConfig(vcdoc.ObjFilterPath, filter);
                        }
                    }
                    else
                    {
                        logger.Write(String.Format("Alcantarea warning: could not get cursor's current position function\n"));
                    }
                    AlcantareaHelper.RequestSetSymbolFilter(vcdoc.ObjPath, filter);
                    SendCommand("dpLoadBinary\n" + vcdoc.ObjPath + "\n\n");
                }
            });
        }
예제 #5
0
        /// <summary>
        /// </summary>
        private void onStartDebugging(object sender, EventArgs e)
        {
            m_context |= (int)UIContext.AlcStart;

            DTE dte = (DTE)GetService(typeof(DTE));

            IVsOutputWindowPane pane = (IVsOutputWindowPane)Package.GetGlobalService(typeof(SVsGeneralOutputWindowPane));

            VCProjectW       vcproj;
            VCConfigurationW cfg;

            if (!ProjectUtil.getStartupProjectAndConfig(dte, out vcproj, out cfg))
            {
                return;
            }

            String exepath     = cfg.Evaluate("$(TargetPath)");
            String workdir     = cfg.Evaluate("$(LocalDebuggerWorkingDirectory)");
            String environment = cfg.Evaluate("$(LocalDebuggerEnvironment)");
            String platform    = cfg.Evaluate("$(Platform)");
            String addindir    = m_addindir;

            if (pane != null)
            {
                pane.OutputString(exepath);
            }

            if (!File.Exists(exepath))
            {
                ShowMessage("Alcantarea: Error", "Executabe " + exepath + " not found");
                return;
            }

            // プロセスを suspend で起動して DynamicPatcher を inject
            uint pid = AlcantareaHelper.ExecuteSuspended(exepath, workdir, addindir, environment, platform);

            if (pid != 0)
            {
                // デバッガを attach
                VsDebugTargetInfo2 info = new VsDebugTargetInfo2();
                info.cbSize  = (uint)Marshal.SizeOf(info);
                info.bstrExe = exepath;
                info.dlo     = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
                //info.dlo = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AttachToSuspendedLaunchProcess; // somehow this makes debugger not work
                info.dwProcessId = pid;
                info.LaunchFlags = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd | (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_DetachOnStop;

                Guid   guidDbgEngine = VSConstants.DebugEnginesGuids.ManagedAndNative_guid;
                IntPtr pGuids        = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine));
                Marshal.StructureToPtr(guidDbgEngine, pGuids, false);
                info.pDebugEngines      = pGuids;
                info.dwDebugEngineCount = 1;

                IVsDebugger2 idbg = (IVsDebugger2)Package.GetGlobalService(typeof(SVsShellDebugger));
                IntPtr       ptr  = Marshal.AllocCoTaskMem((int)info.cbSize);
                Marshal.StructureToPtr(info, ptr, false);
                int ret = idbg.LaunchDebugTargets2(1, ptr);

                // プロセスのスレッドを resume
                AlcantareaHelper.Resume(pid);
            }
        }