AfxDumpStack
void AFXAPI AfxDumpStack(DWORD dwTarget = AFX_STACK_DUMP_TARGET_DEFAULT);
Parameters
dwTarget
Indicates the target of the dump output. Possible values, which can be combined using the bitwise-OR (|) operator, are as follows:
-
AFX_STACK_DUMP_TARGET_TRACE Sends output via the TRACE macro. The TRACE macro generates output in debug builds only; it generates no output in release builds. Also, TRACE can be redirected to other targets besides the debugger.
-
AFX_STACK_DUMP_TARGET_DEFAULT Sends dump output to the default target. For a debug build, output goes to the TRACE macro. In a release build, output goes to the Clipboard.
-
AFX_STACK_DUMP_TARGET_CLIPBOARD Sends output to the Clipboard only. The data is placed on the Clipboard as plain text using the CF_TEXT Clipboard format.
-
AFX_STACK_DUMP_TARGET_BOTH Sends output to the Clipboard and to the TRACE macro, simultaneously.
-
AFX_STACK_DUMP_TARGET_ODS Sends output directly to the debugger via the Win32 function OutputDebugString(). This option will generate debugger output in both debug and release builds when a debugger is attached to the process. AFX_STACK_DUMP_TARGET_ODS always reaches the debugger (if it is attached) and cannot be redirected.
Remarks
This global function can be used to generate an image of the current stack. The example below reflects a single line of the output generated from calling AfxDumpStack from a button handler in an MFC dialog applicaton:
=== begin AfxDumpStack output ===
…
BFF928E0: WINDOWS\SYSTEM\KERNEL32.DLL! UTUnRegister + 2492 bytes
=== end AfxDumpStack() output ===
The following table describes the above line of output:
Output |
Description |
BFF928E0: |
The return address of the last function call. |
WINDOWS\SYSTEM\KERNEL32.DLL! |
The full path name of the module that contains the function call. |
UTUnRegister |
The function prototype called. |
+ 2492 bytes |
The offset in bytes from the address of the function prototype (in this case, UTUnRegister ) to the return address (in this case, BFF928E0 ). |
AfxDumpStack is available in debug and nondebug versions of the MFC libraries; however, the function is always linked statically, even when your executable file uses MFC in a shared DLL. In shared-library implementations, the function is found in the MFCS42.LIB library (and its variants).
To use this function successfully:
-
The file IMAGEHLP.DLL must be on your path. If you do not have this DLL, the function will display an error message. IMAGEHLP.DLL is a redistributable DLL that ships with the Win32 SDK, and with Windows. Look for it in C:\[windows]\system[32]. See Portable Executable File Manipulation for an introduction to the function set provided by IMAGEHLP.
-
The modules that have frames on the stack must include debugging information. If they do not contain debugging information, the function will still generate a stack trace, but the trace will be less detailed.
See Also afxDump