开发者

Print the callstack of debugger (method names) to the file or console in VS2010

Is it possible to pri开发者_C百科nt route of debugger into the file or console? I think about e.g names of methods where it actually enter. In other words what I see hit F11, F11, F11 ... I want to have in file. How can I do this?


Yes, you could add the following to your code, or just run it from the Immediate Window when you are in Break mode:

System.IO.File.WriteAllText("myTrace.txt", new System.Diagnostics.StackTrace(true).ToString())

Alternatively, you could add tracepoints to your code and use the $CALLSTACK psuedo-variable.

UPDATE: I'm a co-creator of a Visual Studio extensions called OzCode, and I added a feature that makes it much easier to do what OP requested. The feature is essentially "Tracepoints on Steroids".

To do this, use the QuickAction "Create Tracepoint Here"

Print the callstack of debugger (method names) to the file or console in VS2010

Then, enter some text and/or expressions you want to appear next to the callstack, and make sure "Save Stack" is checked:

Print the callstack of debugger (method names) to the file or console in VS2010

Then, every time you hit your tracepoint, a new line will be added to the Tracepoint Viewer. You can view the full callstack by clicking the arrow next to it:

Print the callstack of debugger (method names) to the file or console in VS2010

Now, just hit the "Export" button in the top-right corner to save all your callstacks to a file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜