Ejemplo n.º 1
0
        // Engines notify the debugger about the results of a symbol serach by sending an instance
        // of IDebugSymbolSearchEvent2
        public void OnSymbolSearch(DebuggedModule module, string status, uint dwStatusFlags)
        {
            enum_MODULE_INFO_FLAGS statusFlags = (enum_MODULE_INFO_FLAGS)dwStatusFlags;

            string statusString = ((statusFlags & enum_MODULE_INFO_FLAGS.MIF_SYMBOLS_LOADED) != 0 ? "Symbols Loaded - " : "No symbols loaded") + status;

            AD7Module            ad7Module   = new AD7Module(module, _engine.DebuggedProcess);
            AD7SymbolSearchEvent eventObject = new AD7SymbolSearchEvent(ad7Module, statusString, statusFlags);

            Send(eventObject, AD7SymbolSearchEvent.IID, null);
        }
Ejemplo n.º 2
0
        public void OnModuleUnload(DebuggedModule debuggedModule)
        {
            Debug.Assert(_engine.DebuggedProcess.WorkerThread.IsPollThread());

            AD7Module ad7Module = (AD7Module)debuggedModule.Client;

            Debug.Assert(ad7Module != null);

            AD7ModuleLoadEvent eventObject = new AD7ModuleLoadEvent(ad7Module, false /* this is a module unload */);

            Send(eventObject, AD7ModuleLoadEvent.IID, null);
        }
Ejemplo n.º 3
0
        // EnumModules is called by the debugger when it needs to enumerate the modules in the program.
        public int EnumModules(out IEnumDebugModules2 ppEnum)
        {
            DebuggedModule[] modules = _debuggedProcess.GetModules();

            AD7Module[] moduleObjects = new AD7Module[modules.Length];
            for (int i = 0; i < modules.Length; i++)
            {
                moduleObjects[i] = new AD7Module(modules[i], _debuggedProcess);
            }

            ppEnum = new Microsoft.MIDebugEngine.AD7ModuleEnum(moduleObjects);

            return(Constants.S_OK);
        }
Ejemplo n.º 4
0
        public void OnModuleLoad(DebuggedModule debuggedModule)
        {
            // This will get called when the entrypoint breakpoint is fired because the engine sends a mod-load event
            // for the exe.
            if (_engine.DebuggedProcess != null)
            {
                Debug.Assert(_engine.DebuggedProcess.WorkerThread.IsPollThread());
            }

            AD7Module          ad7Module   = new AD7Module(debuggedModule, _engine.DebuggedProcess);
            AD7ModuleLoadEvent eventObject = new AD7ModuleLoadEvent(ad7Module, true /* this is a module load */);

            debuggedModule.Client = ad7Module;

            // The sample engine does not support binding breakpoints as modules load since the primary exe is the only module
            // symbols are loaded for. A production debugger will need to bind breakpoints when a new module is loaded.

            Send(eventObject, AD7ModuleLoadEvent.IID, null);
        }
Ejemplo n.º 5
0
        public void OnModuleLoad(DebuggedModule debuggedModule)
        {
            // This will get called when the entrypoint breakpoint is fired because the engine sends a mod-load event
            // for the exe.
            if (_engine.DebuggedProcess != null)
            {
                Debug.Assert(_engine.DebuggedProcess.WorkerThread.IsPollThread());
            }

            AD7Module ad7Module = new AD7Module(debuggedModule, _engine.DebuggedProcess);
            AD7ModuleLoadEvent eventObject = new AD7ModuleLoadEvent(ad7Module, true /* this is a module load */);

            debuggedModule.Client = ad7Module;

            // The sample engine does not support binding breakpoints as modules load since the primary exe is the only module
            // symbols are loaded for. A production debugger will need to bind breakpoints when a new module is loaded.

            Send(eventObject, AD7ModuleLoadEvent.IID, null);
        }
Ejemplo n.º 6
0
        // EnumModules is called by the debugger when it needs to enumerate the modules in the program.
        public int EnumModules(out IEnumDebugModules2 ppEnum)
        {
            DebuggedModule[] modules = _debuggedProcess.GetModules();

            AD7Module[] moduleObjects = new AD7Module[modules.Length];
            for (int i = 0; i < modules.Length; i++)
            {
                moduleObjects[i] = new AD7Module(modules[i], _debuggedProcess);
            }

            ppEnum = new Microsoft.MIDebugEngine.AD7ModuleEnum(moduleObjects);

            return Constants.S_OK;
        }
Ejemplo n.º 7
0
 public AD7SymbolSearchEvent(AD7Module module, string searchInfo, enum_MODULE_INFO_FLAGS symbolFlags)
 {
     _module      = module;
     _searchInfo  = searchInfo;
     _symbolFlags = symbolFlags;
 }
Ejemplo n.º 8
0
 public AD7ModuleLoadEvent(AD7Module module, bool fLoad)
 {
     _module = module;
     _fLoad  = fLoad;
 }
Ejemplo n.º 9
0
        // Construct a FRAMEINFO for this stack frame with the requested information.
        public void SetFrameInfo(enum_FRAMEINFO_FLAGS dwFieldSpec, out FRAMEINFO frameInfo, List <SimpleVariableInformation> parameters)
        {
            frameInfo = new FRAMEINFO();

            DebuggedModule module = ThreadContext.FindModule(Engine.DebuggedProcess);

            // The debugger is asking for the formatted name of the function which is displayed in the callstack window.
            // There are several optional parts to this name including the module, argument types and values, and line numbers.
            // The optional information is requested by setting flags in the dwFieldSpec parameter.
            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME) != 0)
            {
                // If there is source information, construct a string that contains the module name, function name, and optionally argument names and values.
                if (_textPosition != null)
                {
                    frameInfo.m_bstrFuncName = "";

                    if (module != null && (dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_MODULE) != 0)
                    {
                        frameInfo.m_bstrFuncName = System.IO.Path.GetFileName(module.Name) + "!";
                    }

                    frameInfo.m_bstrFuncName += _functionName;

                    if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_ARGS) != 0 && !Engine.DebuggedProcess.MICommandFactory.SupportsFrameFormatting)
                    {
                        frameInfo.m_bstrFuncName += "(";
                        if (parameters != null && parameters.Count > 0)
                        {
                            for (int i = 0; i < parameters.Count; i++)
                            {
                                if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_ARGS_TYPES) != 0)
                                {
                                    frameInfo.m_bstrFuncName += parameters[i].TypeName + " ";
                                }

                                if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_ARGS_NAMES) != 0)
                                {
                                    frameInfo.m_bstrFuncName += parameters[i].Name;
                                }

                                if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_ARGS_NAMES) != 0 &&
                                    (dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_ARGS_VALUES) != 0)
                                {
                                    frameInfo.m_bstrFuncName += "=";
                                }

                                if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_ARGS_VALUES) != 0)
                                {
                                    frameInfo.m_bstrFuncName += parameters[i].Value;
                                }

                                if (i < parameters.Count - 1)
                                {
                                    frameInfo.m_bstrFuncName += ", ";
                                }
                            }
                        }
                        frameInfo.m_bstrFuncName += ")";
                    }

                    if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_LINES) != 0)
                    {
                        frameInfo.m_bstrFuncName += string.Format(CultureInfo.CurrentCulture, " Line {0}", _textPosition.BeginPosition.dwLine + 1);
                    }
                }
                else
                {
                    // No source information, so only return the module name and the instruction pointer.
                    if (_functionName != null)
                    {
                        if (module != null)
                        {
                            frameInfo.m_bstrFuncName = System.IO.Path.GetFileName(module.Name) + '!' + _functionName;
                        }
                        else
                        {
                            frameInfo.m_bstrFuncName = _functionName;
                        }
                    }
                    else if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_MODULE) != 0 && module != null)
                    {
                        frameInfo.m_bstrFuncName = module.Name + '!' + EngineUtils.GetAddressDescription(Engine.DebuggedProcess, ThreadContext.pc.Value);
                    }
                    else
                    {
                        frameInfo.m_bstrFuncName = EngineUtils.GetAddressDescription(Engine.DebuggedProcess, ThreadContext.pc.Value);
                    }
                }
                frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_FUNCNAME;
            }

            // The debugger is requesting the name of the module for this stack frame.
            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_MODULE) != 0)
            {
                if (module != null)
                {
                    frameInfo.m_bstrModule = module.Name;
                }
                else
                {
                    frameInfo.m_bstrModule = "";
                }
                frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_MODULE;
            }

            // The debugger is requesting the range of memory addresses for this frame.
            // For the sample engine, this is the contents of the frame pointer.
            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_STACKRANGE) != 0)
            {
                frameInfo.m_addrMin        = ThreadContext.sp;
                frameInfo.m_addrMax        = ThreadContext.sp;
                frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_STACKRANGE;
            }

            // The debugger is requesting the IDebugStackFrame2 value for this frame info.
            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FRAME) != 0)
            {
                frameInfo.m_pFrame         = this;
                frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_FRAME;
            }

            // Does this stack frame of symbols loaded?
            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_DEBUGINFO) != 0)
            {
                frameInfo.m_fHasDebugInfo  = _textPosition != null ? 1 : 0;
                frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_DEBUGINFO;
            }

            // Is this frame stale?
            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_STALECODE) != 0)
            {
                frameInfo.m_fStaleCode     = 0;
                frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_STALECODE;
            }

            // The debugger would like a pointer to the IDebugModule2 that contains this stack frame.
            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_DEBUG_MODULEP) != 0)
            {
                if (module != null)
                {
                    AD7Module ad7Module = (AD7Module)module.Client;
                    Debug.Assert(ad7Module != null);
                    frameInfo.m_pModule        = ad7Module;
                    frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_DEBUG_MODULEP;
                }
            }

            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FLAGS) != 0)
            {
                if (_codeCxt == null && _documentCxt == null)
                {
                    frameInfo.m_dwFlags |= (uint)enum_FRAMEINFO_FLAGS_VALUES.FIFV_ANNOTATEDFRAME;
                }
                frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_FLAGS;
            }

            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_LANGUAGE) != 0)
            {
                Guid unused = Guid.Empty;
                if (GetLanguageInfo(ref frameInfo.m_bstrLanguage, ref unused) == 0)
                {
                    frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_LANGUAGE;
                }
            }
        }
Ejemplo n.º 10
0
 public AD7SymbolSearchEvent(AD7Module module, string searchInfo, enum_MODULE_INFO_FLAGS symbolFlags)
 {
     _module = module;
     _searchInfo = searchInfo;
     _symbolFlags = symbolFlags;
 }
Ejemplo n.º 11
0
 public AD7ModuleLoadEvent(AD7Module module, bool fLoad)
 {
     _module = module;
     _fLoad = fLoad;
 }
Ejemplo n.º 12
0
        // Engines notify the debugger about the results of a symbol serach by sending an instance
        // of IDebugSymbolSearchEvent2
        public void OnSymbolSearch(DebuggedModule module, string status, uint dwStatusFlags)
        {
            enum_MODULE_INFO_FLAGS statusFlags = (enum_MODULE_INFO_FLAGS)dwStatusFlags;

            string statusString = ((statusFlags & enum_MODULE_INFO_FLAGS.MIF_SYMBOLS_LOADED) != 0 ? "Symbols Loaded - " : "No symbols loaded") + status;

            AD7Module ad7Module = new AD7Module(module, _engine.DebuggedProcess);
            AD7SymbolSearchEvent eventObject = new AD7SymbolSearchEvent(ad7Module, statusString, statusFlags);
            Send(eventObject, AD7SymbolSearchEvent.IID, null);
        }
Ejemplo n.º 13
0
 public AD7SymbolLoadEvent(AD7Module module)
 {
     _module = module;
 }