// Gets the language information for this code context. public int GetLanguageInfo(ref string pbstrLanguage, ref Guid pguidLanguage) { if (_documentContext != null) { return(_documentContext.GetLanguageInfo(ref pbstrLanguage, ref pguidLanguage)); } AD7Engine.MapLanguageInfo(FileName, out pbstrLanguage, out pguidLanguage); return(VSConstants.S_OK); }
// Gets the language associated with this document context. // The language for this sample is always C++ int IDebugDocumentContext2.GetLanguageInfo(ref string pbstrLanguage, ref Guid pguidLanguage) { AD7Engine.MapLanguageInfo(FileName, out pbstrLanguage, out pguidLanguage); return(VSConstants.S_OK); }
// Construct a FRAMEINFO for this stack frame with the requested information. public void SetFrameInfo(enum_FRAMEINFO_FLAGS dwFieldSpec, out FRAMEINFO frameInfo) { frameInfo = new FRAMEINFO(); // 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) { var funcName = this._stackFrame.FunctionName; if (funcName == "<module>") { if (this._stackFrame.FileName.IndexOfAny(Path.GetInvalidPathChars()) == -1) { funcName = Path.GetFileName(this._stackFrame.FileName) + " module"; } else if (this._stackFrame.FileName.EndsWith("<string>", StringComparison.Ordinal)) { funcName = "<exec or eval>"; } else { funcName = this._stackFrame.FileName + " unknown code"; } } else { if (this._stackFrame.FileName != "<unknown>") { funcName = string.Format(CultureInfo.InvariantCulture, "{0} [{1}]", funcName, Path.GetFileName(this._stackFrame.FileName)); } else { funcName = funcName + " in <unknown>"; } } frameInfo.m_bstrFuncName = string.Format(CultureInfo.InvariantCulture, "{0} Line {1}", funcName, this._stackFrame.Line + 1); frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_FUNCNAME; } if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_LANGUAGE) != 0) { Guid dummy; AD7Engine.MapLanguageInfo(this._stackFrame.FileName, out frameInfo.m_bstrLanguage, out dummy); frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_LANGUAGE; } // The debugger is requesting the name of the module for this stack frame. if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_MODULE) != 0) { if (this._stackFrame.FileName.IndexOfAny(Path.GetInvalidPathChars()) == -1) { frameInfo.m_bstrModule = Path.GetFileName(this._stackFrame.FileName); } else if (this._stackFrame.FileName.EndsWith("<string>", StringComparison.Ordinal)) { frameInfo.m_bstrModule = "<exec/eval>"; } else { frameInfo.m_bstrModule = "<unknown>"; } frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_MODULE; } // 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 = 1; 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) { // TODO: Module /* * 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; * }*/ } }
// Gets the language associated with this stack frame. // In this sample, all the supported stack frames are C++ int IDebugStackFrame2.GetLanguageInfo(ref string pbstrLanguage, ref Guid pguidLanguage) { AD7Engine.MapLanguageInfo(this._stackFrame.FileName, out pbstrLanguage, out pguidLanguage); return(VSConstants.S_OK); }