Partager via


_EFN_StackTrace Function

Provides a text representation of a managed stack trace and an array of CONTEXT records, one for each transition between unmanaged and managed code.

HRESULT CALLBACK _EFN_StackTrace(
        [in]  PDEBUG_CLIENT  Client,
        [out] WCHAR          wszTextOut[],
        [out] size_t         *puiTextLength,
        [out] LPVOID         pTransitionContexts,
        [out] size_t         *puiTransitionContextCount,
        [in]  size_t         uiSizeOfContext,
        [in]  DWORD          Flags
);

Parameters

  • Client
    [in] The client being debugged.
  • wszTextOut
    [out] The text representation of the stack trace.
  • puiTextLength
    [out] A pointer to the number of characters in wszTextOut.
  • pTransitionContexts
    [out] The array of transition contexts.
  • puiTransitionContextCount
    [out] A pointer to the number of transition contexts in the array.
  • uiSizeOfContext
    [in] The size of the context structure. This parameter must be either sizeof(SimpleContext) or sizeof(CONTEXT) for the architecture (x86, IA64, x64).
  • Flags
    [in] Set to either 0 or SOS_STACKTRACE_SHOWADDRESSES (0x01) to show the EBP register and the enter stack pointer (ESP) in front of each module!functionname line.

Remarks

The _EFN_StackTrace structure can be called from a WinDbg programmatic interface. Parameters are used as follows:

  • If wszTextOut is null and puiTextLength is not null, the function returns the string length in puiTextLength.

  • If wszTextOut is not null, the function stores text in wszTextOut up to the location indicated by puiTextLength. It returns successfully if there was enough room in the buffer, or returns E_OUTOFMEMORY if the buffer was not long enough.

  • The transition portion of the function is ignored if pTransitionContexts and puiTransitionContextCount are both null. In this case, the function provides callers with text output of only the function names.

  • If pTransitionContexts is null and puiTransitionContextCount is not null, the function returns the necessary number of context entries in puiTransitionContextCount.

  • If pTransitionContexts is not null, the function treats it as an array of structures of length puiTransitionContextCount. The structure size is given by uiSizeOfContext, and must be the size of StackTrace_SimpleContext Structure or CONTEXT for the architecture.

  • wszTextOut is written in the following format:

    "<ModuleName>!<Function Name>[+<offset in hex>]
    ...
    (TRANSITION)
    ..."
    
  • If the offset in hex is 0x0, no offset is written.

  • If there is no managed code on the thread currently in context, the function returns SOS_E_NOMANAGEDCODE.

  • The Flags parameter is either 0 or SOS_STACKTRACE_SHOWADDRESSES to see EBP and ESP in front of each module!functionname line. By default this is off.

    #define SOS_STACKTRACE_SHOWADDRESSES        0x00000001
    

Requirements

Platforms: Windows 2000, Windows XP, Windows Server 2003 family

Header: SOS_Stacktrace.h

.NET Framework Version: 2.0

See Also

Other Resources

Debugging Global Static Functions