Exemplo n.º 1
0
 public void Analyze()
 {
     using (DataTarget t = context.CreateTemporaryDbgEngTarget()) {
         this.Analyze((IDebugControl6)t.DebuggerInterface, logfilepath);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Get symbol information for module, see if PDB was loaded or not.
        ///
        /// -----> CN: does not work if no CLR is loaded
        /// </summary>
        /// <param name="module"></param>
        public void PrintSymbolState(string module)
        {
            if (!string.IsNullOrEmpty(module))
            {
                ClrModule mod = context.Runtime?.Modules.FirstOrDefault(
                    m => string.Equals(Path.GetFileName(m.Name), module, StringComparison.InvariantCultureIgnoreCase));                     //ignore case

                if (mod != null)
                {
                    ModuleInfo moduleInfo = context.Runtime.DataTarget.EnumerateModules().Single(
                        m => string.Equals(m.FileName, mod.FileName, StringComparison.InvariantCultureIgnoreCase));
                    context.WriteLine("Module:     {0}", mod.Name);
                    context.WriteLine("PDB name:   {0}", moduleInfo.Pdb.FileName);
                    context.WriteLine("Debug mode: {0}", mod.DebuggingMode);
                }
                else
                {
                    // try to find native
                    using (DataTarget target = context.CreateTemporaryDbgEngTarget()) {
                        ModuleInfo moduleInfo = context.Runtime.DataTarget.EnumerateModules().FirstOrDefault(
                            m => string.Equals(Path.GetFileName(m.FileName), module, StringComparison.InvariantCultureIgnoreCase));
                        if (moduleInfo == null)
                        {
                            return;
                        }

                        var debugSymbols = (IDebugSymbols3)target.DebuggerInterface;

                        uint loaded, unloaded;
                        if (0 != debugSymbols.GetNumberModules(out loaded, out unloaded))
                        {
                            return;
                        }

                        for (uint moduleIdx = 0; moduleIdx < loaded; ++moduleIdx)
                        {
                            var  name = new StringBuilder(2048);
                            uint nameSize;
                            if (0 != debugSymbols.GetModuleNameString(DEBUG_MODNAME.IMAGE, moduleIdx, 0, name, (uint)name.Capacity, out nameSize))
                            {
                                continue;
                            }

                            if (!string.Equals(name.ToString(), moduleInfo.FileName, StringComparison.InvariantCultureIgnoreCase))
                            {
                                continue;
                            }

                            var modInfo = new DEBUG_MODULE_PARAMETERS[1];
                            if (0 != debugSymbols.GetModuleParameters(1, null, moduleIdx, modInfo))
                            {
                                return;
                            }

                            name = new StringBuilder(2048);
                            debugSymbols.GetModuleNameString(DEBUG_MODNAME.SYMBOL_FILE, moduleIdx, 0, name, (uint)name.Capacity, out nameSize);

                            context.WriteLine("Module:     {0}", moduleInfo.FileName);
                            context.WriteLine("PDB loaded: {0}", modInfo[0].SymbolType == DEBUG_SYMTYPE.DIA || modInfo[0].SymbolType == DEBUG_SYMTYPE.PDB);
                            context.WriteLine("PDB name:   {0}", name.ToString());
                        }
                    }
                }
            }
            else
            {
                context.WriteLine("No module specified.");
            }
        }