Wednesday, January 26, 2011

Using StackWalk, MiniDumpWriteDump APIs for getting CallStack info

Tip -
StackWalk - Obtains a stack trace.
MiniDumpWriteDump - Writes minidump information to the specified file.

Details - 
StackWalk
In some cases we need to display the callstack of the current thread or the callstack of other threads/processes. This will be helpful for the application crash analysis etc.
Syntax:
                    StackWalk(
                 DWORD MachineType,
                 __in HANDLE hProcess,
                 __in HANDLE hThread,
                 __inout LPSTACKFRAME StackFrame,                      
                 __inout PVOID ContextRecord,
                 __in_opt PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine,
                 __in_opt PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,
                 __in_opt PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
                 __in_opt PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
                 );
This interface is in the dbghelp.dll library. The latest dbghelp.dll can be downloaded with the “Debugging Tools for Windows” available in http://www.microsoft.com/whdc/devtools/debugging/default.mspx.
 
MiniDumpWriteDump
Writes user-mode minidump information to the specified file. This helps to dump the call stack information to the specified file. The dump data can be analyzed using WinDbg. This interface is also in the dbghelp.dll library.
Syntax:
BOOL WINAPI MiniDumpWriteDump(
  __in  HANDLE hProcess,
  __in  DWORD ProcessId,
  __in  HANDLE hFile,
  __in  MINIDUMP_TYPE DumpType,
  __in  PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
  __in  PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
  __in  PMINIDUMP_CALLBACK_INFORMATION CallbackParam
);

Reference   -

Posted By :Jijo Krishnan

No comments:

Post a Comment