VSNDK.DebugEngine.AD7StackFrame.SetFrameInfo C# (CSharp) Method

SetFrameInfo() public method

Construct a FRAMEINFO for this stack frame with the requested information.
public SetFrameInfo ( enum_FRAMEINFO_FLAGS dwFieldSpec, FRAMEINFO &frameInfo ) : void
dwFieldSpec enum_FRAMEINFO_FLAGS A combination of flags from the FRAMEINFO_FLAGS enumeration that specifies which fields of the /// frameInfo parameter are to be filled in.
frameInfo FRAMEINFO A FRAMEINFO structure that is filled in with the description of the stack frame.
return void
        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)
            {
                // If there is source information, construct a string that contains the module name, function name, and optionally argument names and values.
                if (m_hasSource)
                {
                    frameInfo.m_bstrFuncName = "";

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

                    if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_RETURNTYPE) != 0)
                    {
                        // Adds the return type to the m_bstrFuncName field.
                        //frameInfo.m_bstrFuncName += _returnType;
                    }

                    if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_LANGUAGE) != 0)
                    {
                        // Adds the language to the m_bstrFuncName field.
                        if (m_documentName.EndsWith(".c"))
                            frameInfo.m_bstrFuncName += "(C) ";
                        else if (m_documentName.EndsWith(".cpp") || m_documentName.EndsWith(".c++"))
                            frameInfo.m_bstrFuncName += "(C++) ";
                    }

                    frameInfo.m_bstrFuncName += m_functionName;

                    if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_ARGS) != 0)
                    {
                        // Add the arguments to the m_bstrFuncName field.
                        frameInfo.m_bstrFuncName += "(";
                        bool all = (dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_ARGS_ALL) != 0;
                        int i = 0;
                        foreach (VariableInfo arg in _arguments)
                        {
                            if (all || (dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_ARGS_TYPES) != 0)
                            {
                                frameInfo.m_bstrFuncName += arg._type + " ";
                            }

                            if (all || (dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_ARGS_NAMES) != 0)
                            {
                                frameInfo.m_bstrFuncName += arg._name;
                            }

                            if (all || (dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_ARGS_VALUES) != 0)
                            {
                                frameInfo.m_bstrFuncName += "=" + arg._value;
                            }

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

                    if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_LINES) != 0)
                    {
                        frameInfo.m_bstrFuncName += " Line: " + m_lineNum.ToString();
                    }

                    if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_OFFSET) != 0)
                    {
                        // TODO:
                        // Adds to the m_bstrFuncName field the offset in bytes from the start of the line if FIF_FUNCNAME_LINES is specified.
                        // If FIF_FUNCNAME_LINES is not specified, or if line numbers are not available, adds the offset in bytes from the start of the function.
                    }

                    if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_FORMAT) != 0)
                    {
                        // TODO:
                        // Formats the function name. The result is returned in the m_bstrFuncName field and no other fields are filled out.
                        // According to http://msdn.microsoft.com/en-us/library/bb145138.aspx, this flag "Specify the FIF_FUNCNAME_FORMAT
                        // flag to format the function name into a single string". This method already works on this way.
                    }
                }
                else
                {
                    frameInfo.m_bstrFuncName = "[External Code]";
                    // No source information, so only return the module name and the instruction pointer.
                    /*
                    if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_MODULE) != 0)
                    {
                        frameInfo.m_bstrFuncName = EngineUtils.GetAddressDescription(module, ip);
                    }
                    else
                    {
                        frameInfo.m_bstrFuncName = EngineUtils.GetAddressDescription(null, ip);
                    }
                    */
                }
                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)
            {
                frameInfo.m_bstrModule = "";
                frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_MODULE;
            }

            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_RETURNTYPE) != 0)
            {
                // TODO:
                // Initialize/use the m_bstrReturnType field.
                frameInfo.m_bstrReturnType = "";
                frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_RETURNTYPE;
            }

            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_ARGS) != 0)
            {
                // Initialize/use the m_bstrArgs field.
                frameInfo.m_bstrArgs = "";
                bool all = (dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_ARGS_ALL) != 0;
                int i = 0;
                foreach (VariableInfo arg in _arguments)
                {
                    if (all || (dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_ARGS_TYPES) != 0)
                    {
                        frameInfo.m_bstrArgs += arg._type + " ";
                    }

                    if (all || (dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_ARGS_NAMES) != 0)
                    {
                        frameInfo.m_bstrArgs += arg._name;
                    }

                    if (all || (dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_ARGS_VALUES) != 0)
                    {
                        frameInfo.m_bstrArgs += "=" + arg._value;
                    }

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

                if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_ARGS_NO_TOSTRING) != 0)
                {
                    // TODO:
                    // Do not allow ToString() function evaluation or formatting when returning function arguments.
                }

                if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_ARGS_NO_FUNC_EVAL) != 0)
                {
                    // TODO:
                    // Specifies that function (property) evaluation should not be used when retrieving argument values.
                }

                if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_ARGS_NOFORMAT) != 0)
                {
                    // TODO:
                    // Specifies that the arguments are not be formatted (for example, do not add opening and closing parentheses around
                    // the argument list nor add a separator between arguments).
                }

                frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_ARGS;
            }

            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_LANGUAGE) != 0)
            {
                // Initialize/use the m_bstrLanguage field.
                if (m_documentName != null)
                {
                    if (m_documentName.EndsWith(".c"))
                        frameInfo.m_bstrLanguage = "C";
                    else if (m_documentName.EndsWith(".cpp") || m_documentName.EndsWith(".c++"))
                        frameInfo.m_bstrLanguage = "C++";
                    else
                        frameInfo.m_bstrLanguage = "";
                }
                else
                    frameInfo.m_bstrLanguage = "";
                frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_LANGUAGE;
            }

            // The debugger would like a pointer to the IDebugModule2 that contains this stack frame.
            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_DEBUG_MODULEP) != 0)
            {
                frameInfo.m_pModule = m_engine.m_module;
                frameInfo.m_dwValidFields |= enum_FRAMEINFO_FLAGS.FIF_DEBUG_MODULEP;
            }

            // 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)
            {
                // TODO:
                // Initialize/use the m_addrMin and m_addrMax (stack range) fields.

                frameInfo.m_addrMin = 0;
                frameInfo.m_addrMax = 0;
                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 = m_hasSource ? 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 debug engine is to filter non-user code frames so they are not included.
            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_FILTER_NON_USER_CODE ) != 0)
            {
            }

            // Frame information should be gotten from the hosted app-domain rather than the hosting process.
            if ((dwFieldSpec & enum_FRAMEINFO_FLAGS.FIF_DESIGN_TIME_EXPR_EVAL) != 0)
            {
            }
        }