示例#1
0
 /// <summary>
 /// Initialises a new PDB Dump Manager loading the specified DLL
 /// as the root assembly of the assembly manager.
 /// </summary>
 /// <param name="rootDLLFileName">The path to the DLL to use as the root assembly.</param>
 public PDBDumpManager(string rootDLLFileName)
 {
     TheAssemblyManager = new AssemblyManager();
     var rootAssembly = TheAssemblyManager.LoadAssembly(rootDLLFileName);
     TheAssemblyManager.LoadReferences(rootAssembly);
     Init();
 }
示例#2
0
 /// <summary>
 /// Initialises a new PDB Dump Manager using the specified assembly
 /// manager.
 /// </summary>
 /// <param name="anAssemblyManager">The assembly manager to use.</param>
 public PDBDumpManager(AssemblyManager anAssemblyManager)
 {
     TheAssemblyManager = anAssemblyManager;
     Init();
 }
示例#3
0
        /// <summary>
        /// Initialises the compiler environment including initialising TheAssemblyManager.
        /// </summary>
        /// <returns>True if initialisation completed successfully. Otherwise false.</returns>
        private bool InitEnvironment()
        {
            bool OK = true;

            //Init the assembly manager
            TheAssemblyManager = new AssemblyManager();
            Assembly rootAssembly = null;
            //Get it to load the assembly specified in Settings
            try
            {
                rootAssembly = TheAssemblyManager.LoadAssembly(TheSettings[Settings.InputFileKey]);
                if (rootAssembly == null)
                {
                    OK = false;
                }

                //Debug database is still used even for release builds. 
                //  - At the time of writing, (6/6/14) the Type and ComplexTypeLinks tables were the only
                //    ones required during a release build.
                Debug.Data.DebugDatabase.Empty();
            }
            catch(Exception ex)
            {
                OK = false;
                OutputError(ex);
            }
            //Get it to load references (ignoring mscorlib and kernel compiler assemblies)
            if (OK)
            {
                try
                {
                    TheAssemblyManager.LoadReferences(rootAssembly);
                    TheAssemblyManager.LoadAllTypes();

                    string outputFilePath = TheSettings[Settings.OutputFileKey];
                    string executionPath = TheSettings[Settings.ToolsPathKey];
                    string Dia2DumpPath = Path.Combine(executionPath, @"Dia2Dump\Dia2Dump.exe");
                    string workingDir = Path.GetDirectoryName(outputFilePath);

                    //Debug data - takes the pdb file and dumps the source files and source lines info

                    //Need to dump data for all referenced DLLs as well as the main dll

                    foreach (Assembly anAssembly in TheAssemblyManager.Assemblies.Values)
                    {
                        string assemblyFileName = Path.Combine(Path.GetDirectoryName(anAssembly.Location), Path.GetFileNameWithoutExtension(anAssembly.Location));
                        string aPDBPathname = assemblyFileName + ".pdb";
                        string aPDBDumpPathname = assemblyFileName + ".pdb_dump";

                        if (File.Exists(aPDBDumpPathname))
                        {
                            File.Delete(aPDBDumpPathname);
                        }

                        if (!ExecuteProcess(workingDir, Dia2DumpPath, string.Format("-all \"{0}\"", aPDBPathname), "Dia2Dump", false, aPDBDumpPathname))
                        {
                            OutputError(new Exception("Failed to execute Dia2Dump. Debug information will be missing. " + assemblyFileName));
                        }
                    }
                }
                catch (ReflectionTypeLoadException ex)
                {
                    OK = false;
                    OutputError(ex);
                    foreach (Exception anEx in ex.LoaderExceptions)
                    {
                        OutputError(anEx);
                    }
                }
                catch (Exception ex)
                {
                    OK = false;
                    OutputError(ex);
                }
            }

            return OK;
        }
示例#4
0
文件: ILReader.cs 项目: kztao/FlingOS
        /// <summary>
        /// Initialises a new ILReader with the specified assembly manager and output handlers.
        /// </summary>
        /// <param name="aSettings">The settings to use.</param>
        /// <param name="anAssemblyManager">The assembly manager to use.</param>
        /// <param name="anOutputError">The reference to the method to call to output an error message.</param>
        /// <param name="anOutputMessage">The reference to the method to call to output a standard message.</param>
        /// <param name="anOutputWarning">The reference to the method to call to output a warning message.</param>
        /// <exception cref="System.Exception">
        /// Thrown if the IL op types fail to load.
        /// </exception>
        public ILReader(Settings aSettings,
                        AssemblyManager anAssemblyManager,
                        OutputErrorDelegate anOutputError,
                        OutputMessageDelegate anOutputMessage,
                        OutputWarningDelegate anOutputWarning)
        {
            TheSettings = aSettings;
            TheAssemblyManager = anAssemblyManager;
            OutputError = anOutputError;
            OutputMessage = anOutputMessage;
            OutputWarning = anOutputWarning;

            if (!LoadILOpTypes())
            {
                throw new Exception("Failed to load IL op types!");
            }
        }