public void ParseHeader(string file)
        {
            var parserProject = new Project();
            var parser        = new CppSharp.ClangParser();
            var sourceFile    = parserProject.AddFile(file);
            var options       = new ParserOptions();

            parser.SourcesParsed = OnParserResult;

            options.SetupMSVC(VisualStudioVersion.VS2012);

            foreach (var includeDirectory in includeDirectories.Values)
            {
                options.addSystemIncludeDirs(includeDirectory.FullName);
            }

            sourceFile.Options = options;

            try
            {
                parser.ParseProject(parserProject, false);
            }
            catch (Exception ex)
            {
                SetDiagnosticsStatus("Error parsing {0}, Error:{1}", file, ex.Message);
            }

            parser.ASTContext.Dispose();

            entities.SaveChanges();
        }
Exemple #2
0
        public static tblComponent CreateComponent(this SdkInterfaceLibraryEntities entities, Type type, Guid typeGuid, Process process, object objComponent)
        {
            var tblModule    = GetModuleObject(type, process, objComponent);
            var tblComponent = new tblComponent
            {
                ComponentId   = Guid.NewGuid(),
                ComponentType = entities.GetComponentTypeName(tblModule, type, typeGuid),
                ModuleId      = entities.SaveIfNotExists <tblModule>(m => m.ModuleFileName == tblModule.ModuleFileName, () =>
                {
                    return(tblModule);
                }).ModuleId
            };

            entities.tblComponents.AddObject(tblComponent);
            entities.SaveChanges();

            return(tblComponent);
        }
Exemple #3
0
        public static void SaveAll(this SdkInterfaceLibraryEntities entities, Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProvider, IEnumerable <KeyValuePair <Guid, object> > services = null, IEnumerable <KeyValuePair <Guid, object> > packages = null)
        {
            var process = Process.GetCurrentProcess();

            entities.TruncateAll();

            if (services != null)
            {
                entities.SaveVsComServices(process, services);
            }

            if (packages != null)
            {
                entities.SaveVsComPackages(process, packages);
            }

            entities.SaveServices(process, serviceProvider);
            entities.SaveTypes(process);

            entities.SaveChanges();
        }
Exemple #4
0
        private static void BuildModuleSymbolsTable(this SdkInterfaceLibraryEntities entities, tblModule tblModule)
        {
            var     cvdump    = @"C:\Projects\MC\RazorViewsDesigner\Microsoft.Pdb\cvdump\cvdump.exe";
            var     startInfo = new ProcessStartInfo(cvdump, string.Format("-p \"{0}\"", tblModule.ModuleFileName));
            var     output    = string.Empty;
            var     error     = string.Empty;
            int     exitCode;
            Process process;

            startInfo.CreateNoWindow         = false;
            startInfo.UseShellExecute        = false;
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError  = true;

            process = new Process();

            process.EnableRaisingEvents = true;
            process.StartInfo           = startInfo;

            process.OutputDataReceived += (s, e) =>
            {
                output += e.Data + "\r\n";
            };

            process.ErrorDataReceived += (s, e) =>
            {
                error += e.Data + "\r\n";
            };

            process.Start();

            process.BeginOutputReadLine();
            process.BeginErrorReadLine();

            process.WaitForExit();

            exitCode = process.ExitCode;

            //exitCode = 0;
            //output = File.ReadAllText(@"C:\Projects\MC\RazorViewsDesigner\Net2Html5Package\InterfaceLibrary\cvdump.txt");
            //error = string.Empty;

            if (error.Trim().IsNullOrEmpty())
            {
                var pattern = @"^S_PUB32: \[(?<segment>[\da-zA-Z]*?):(?<offset>[\da-zA-Z]*?)\], Flags: (?<flags>[\da-zA-Z]*?), (?<symbol>.*$)$";
                var regex   = new Regex(pattern);
                var lines   = output.Split('\n', StringSplitOptions.RemoveEmptyEntries);

                foreach (var readLine in lines)
                {
                    var line = readLine.Trim();

                    if (regex.IsMatch(line))
                    {
                        var match            = regex.Match(line.Trim());
                        var segment          = match.Groups["segment"].Value;
                        var offset           = match.Groups["offset"].Value;
                        var flags            = match.Groups["flags"].Value;
                        var symbol           = match.Groups["symbol"].Value;
                        var tblModuleSymbols = entities.tblModuleSymbols;
                        var tblModuleSymbol  = new tblModuleSymbol
                        {
                            ModuleSymbolId    = Guid.NewGuid(),
                            ModuleId          = tblModule.ModuleId,
                            Segment           = segment,
                            Offset            = offset,
                            Flags             = flags,
                            DecoratedSymbol   = symbol,
                            UndecoratedSymbol = UndecorateSymbol(symbol)
                        };

                        tblModuleSymbols.AddObject(tblModuleSymbol);
                        entities.SaveChanges();
                    }
                }
            }
            else
            {
                SetStatus("Errors from cvdump: \r\n\r\n{0}", error);
            }

            SetStatus("Exit code from cvdump: {0}", exitCode);
        }