Search code examples
windbgdbgeng

Inline stack frames with IDebugControl5.GetContextStackTraceEx?


How can I resolve the symbols of a DEBUG_STACK_FRAME_EX with inline frames?

I am aware of DEBUG_STACK_FRAME_EX and its ULONG InlineFrameContext, but I don't understand how to resolve the InlineFrameContext to the corresponding symbol.

And what is the FrameSignature and FrameId in INLINE_FRAME_CONTEXT?


Solution

  • This is using some wrappers, but the intention should be clear. Using IDebugSymbols4::GetNameByInlineContext if the InlineFrameContext indicates that it is an inline frame, and IDebugSymbols4::GetSymbolNameByOffset otherwise.

    C# example below:

    ulong displacement;
    var builder = new StringBuilder(256);
    var isInlineFrame = frame.InlineFrameContext.FrameType.HasFlag(StackFrameType.Inline);
    if (isInlineFrame)
    {
        _symbols5.GetNameByInlineContext(frame.InstructionOffset, frame.InlineFrameContext.ContextValue, ref builder, out displacement);                
    }
    else {
        _symbols5.GetSymbolNameByOffset(frame.InstructionOffset, ref builder, out displacement);
    }
    var name = builder.ToString();