打印传单N调用堆栈的水平? [英] Print n levels of callstack?
本文介绍了打印传单N调用堆栈的水平?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用C ++和Visual Studio,我在想,如果有,将打印调用堆栈我的API。 preferably,我想深打印调用堆栈5级。窗户是否提供了一个简单的API来让我这样做呢?
Using C++ with Visual Studio, I was wondering if there's an API that will print the callstack for me. Preferably, I'd like to print a callstack 5 levels deep. Does windows provide a simple API to allow me to do this?
推荐答案
有许多方法可以做到这一点。
There is a number of ways to do this.
请参阅http://stackoverflow.com/questions/590160/how-to-log-stack-frames-with-windows-x64
在我看来,最简单,也最可靠的方式是Win32 API函数:
In my opinion, the simplest and as well the most reliable way is the Win32 API function:
USHORT WINAPI CaptureStackBackTrace(
__in ULONG FramesToSkip,
__in ULONG FramesToCapture,
__out PVOID *BackTrace,
__out_opt PULONG BackTraceHash
);
这FramesToCapture参数,确定最大调用堆栈的深度返回。
This FramesToCapture parameter, determines the maximum call stack depth returned.
这篇关于打印传单N调用堆栈的水平?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文