Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PdbReadType"/> class.
        /// </summary>
        /// <param name="pdbReader">The PDB reader.</param>
        /// <param name="reader">The reader.</param>
        public PdbReadType(PdbReader pdbReader, BinaryReader reader)
            : base(reader)
        {
            if (pdbReader == null)
                throw new ArgumentNullException(@"pdbReader");

            this.pdbReader = pdbReader;
        }
        private void LoadAssemblyDebugInfo(string assemblyFileName)
        {
            string dbgFile;
            dbgFile = Path.Combine(Path.GetDirectoryName(assemblyFileName), Path.GetFileNameWithoutExtension(assemblyFileName) + ".pdb") + "!!";
            if (File.Exists(dbgFile))
            {
                using (FileStream fileStream = new FileStream(dbgFile, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (PdbReader reader = new PdbReader(fileStream))
                    {
                        Debug.WriteLine(@"Global symbols:");
                        foreach (CvSymbol symbol in reader.GlobalSymbols)
                        {
                            Debug.WriteLine("\t" + symbol.ToString());
                        }

                        Debug.WriteLine(@"Types:");
                        foreach (PdbType type in reader.Types)
                        {
                            Debug.WriteLine("\t" + type.Name);
                            Debug.WriteLine("\t\tSymbols:");
                            foreach (CvSymbol symbol in type.Symbols)
                            {
                                Debug.WriteLine("\t\t\t" + symbol.ToString());
                            }

                            Debug.WriteLine("\t\tLines:");
                            foreach (CvLine line in type.LineNumbers)
                            {
                                Debug.WriteLine("\t\t\t" + line.ToString());
                            }
                        }
                    }
                }
            }
        }
Example #3
0
        private void Compile()
        {
            using (CompilationRuntime runtime = new CompilationRuntime()) {

                // Append the paths of the folder to the loader path
                List<string> paths = new List<string>();
                foreach (FileInfo assembly in this.inputFiles) {

                    string path = Path.GetDirectoryName(assembly.FullName);
                    if (!paths.Contains(path))
                        paths.Add(path);
                }

                // Append the search paths
                foreach (string path in paths)
                    runtime.AssemblyLoader.AppendPrivatePath(path);
                paths = null;

                /* FIXME: This only compiles the very first assembly, but we want to
                 * potentially merge multiple assemblies into our kernel. This will
                 * need an extension/modification of the assembly compiler method.
                 *
                // Load all input assemblies
                foreach (FileInfo assembly in this.inputFiles)
                {
                    IMetadataModule module = runtime.AssemblyLoader.Load(assembly.FullName);
                }
                 */

                IMetadataModule assemblyModule;
                FileInfo file = null;

                try {
                    file = this.inputFiles[0];
                    assemblyModule = runtime.AssemblyLoader.Load(file.FullName);

                    // Try to load debug information for the compilation
                    string dbgFile;
                    dbgFile = Path.Combine(Path.GetDirectoryName(file.FullName), Path.GetFileNameWithoutExtension(file.FullName) + ".pdb");
                    //dbgFile = Path.Combine(Path.GetDirectoryName(file.FullName), "mosacl.pdb");
                    if (File.Exists(dbgFile) == true) {
                        using (FileStream fileStream = new FileStream(dbgFile, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                            using (PdbReader reader = new PdbReader(fileStream)) {
                                Debug.WriteLine(@"Global symbols:");
                                foreach (CvSymbol symbol in reader.GlobalSymbols) {
                                    Debug.WriteLine("\t" + symbol.ToString());
                                }

                                Debug.WriteLine(@"Types:");
                                foreach (PdbType type in reader.Types) {
                                    Debug.WriteLine("\t" + type.Name);
                                    Debug.WriteLine("\t\tSymbols:");
                                    foreach (CvSymbol symbol in type.Symbols) {
                                        Debug.WriteLine("\t\t\t" + symbol.ToString());
                                    }

                                    Debug.WriteLine("\t\tLines:");
                                    foreach (CvLine line in type.LineNumbers) {
                                        Debug.WriteLine("\t\t\t" + line.ToString());
                                    }
                                }
                            }
                        }
                    }
                }
                catch (BadImageFormatException) {
                    ShowError(String.Format("Couldn't load input file {0} (invalid format).", file.FullName));
                    return;
                }

                // Create the compiler
                using (AotCompiler aot = new AotCompiler(this.architectureSelector.Architecture, assemblyModule)) {
                    aot.Pipeline.AddRange(new IAssemblyCompilerStage[] {
                        bootFormatStage,
                        new TypeLayoutStage(),
                        new MethodCompilerBuilderStage(),
                        new MethodCompilerRunnerStage(),
                        new TypeInitializers.TypeInitializerSchedulerStage(),
                        new x86.InterruptStage(),
                        bootFormatStage,
                        new MetadataBuilderStage(),
                        new CilHeaderBuilderStage(),
                        new ObjectFileLayoutStage(),
                        linkerStage,
                        mapFileWrapper
                    });

                    aot.Run();
                }
            }
        }