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