Beispiel #1
0
        internal int GetNumberModules(out uint count, out uint unloadedCount)
        {
            if (_symbols3 == null)
            {
                count         = 0;
                unloadedCount = 0;
                return(-1);
            }

            SetClientInstance();
            return(_symbols3.GetNumberModules(out count, out unloadedCount));
        }
Beispiel #2
0
        public void Execute(CommandExecutionContext context)
        {
            if (!String.IsNullOrEmpty(SpecificModule))
            {
                var module = context.Runtime.Modules.FirstOrDefault(
                    m => String.Equals(Path.GetFileName(m.Name), SpecificModule, StringComparison.InvariantCultureIgnoreCase));
                if (module != null)
                {
                    var moduleInfo = context.Runtime.DataTarget.EnumerateModules().Single(
                        m => String.Equals(m.FileName, module.FileName, StringComparison.InvariantCultureIgnoreCase));
                    context.WriteLine("Module:     {0}", module.Name);
                    context.WriteLine("PDB name:   {0}", moduleInfo.Pdb.FileName);
                    context.WriteLine("Debug mode: {0}", module.DebuggingMode);
                }
                else
                {
                    // Couldn't find managed module, try to find native:
                    using (var target = context.CreateTemporaryDbgEngTarget())
                    {
                        var moduleInfo = context.Runtime.DataTarget.EnumerateModules().FirstOrDefault(
                            m => String.Equals(Path.GetFileName(m.FileName), SpecificModule, StringComparison.InvariantCultureIgnoreCase));
                        if (moduleInfo == null)
                        {
                            return;
                        }

                        IDebugSymbols3 debugSymbols = (IDebugSymbols3)target.DebuggerInterface;

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

                        for (uint moduleIdx = 0; moduleIdx < loaded; ++moduleIdx)
                        {
                            StringBuilder 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;
                            }

                            DEBUG_MODULE_PARAMETERS[] 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());
                        }
                    }
                }
                return;
            }

            context.WriteLine("{0,-20:x16} {1,-10} {2,-20} {3}", "start", "size", "version", "filename");
            foreach (var module in context.Runtime.DataTarget.EnumerateModules())
            {
                context.WriteLine("{0,-20:x16} {1,-10:x} {2,-20} {3}",
                                  module.ImageBase, module.FileSize, module.Version, module.FileName);
            }
        }