跟踪点有什么用? [英] What are tracepoints used for?

查看:197
本文介绍了跟踪点有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它们只能放在方法名称上.它们的用法和用途是什么?

They can only be placed on method names. How are they used and what are they for?

推荐答案

调试器团队在该主题上也有不错的博客文章,并提供了示例:

The Debugger team has a good blog post on this subject with examples as well: http://blogs.msdn.com/b/visualstudioalm/archive/2013/10/10/tracepoints.aspx

https://web.archive.org/web/20190109221722/https://blogs.msdn.microsoft.com/devops/2013/10/10/tracepoints/

跟踪点根本不是一个新功能(自VS 2005开始,它们就已出现在Visual Studio中).它们本身并不是断点,因为它们不会导致程序执行中断.当您需要检查某些东西,但又不停止程序时会很有用,因为这会导致错误行为无法再现等.

Tracepoints are not a new feature at all (they been in Visual Studio since VS 2005). And they aren't breakpoints per se, as they don't cause the program execution to break. That can be useful when you need to inspect something, but not stop the program as that causes the behavior of a bug not to repro, etc.

跟踪点是一种尝试,它可以允许断点将信息记录到调试输出窗口并继续运行,而不会暂停,从而克服了无法停止程序检查某些情况的情况,因为这将导致某些行为无法重现.用户界面.您也可以使用宏来执行此操作,但这可能会花费更多时间.

Tracepoints are an attempt to overcome the case when you can't stop the program to inspect something as that will cause some behavior not to repro, by allowing a breakpoint to log information to the debug output window and continue, without pausing at the UI. You can also do this with macros, but it can be more time consuming.

要设置跟踪点,请先在代码中设置一个断点.然后使用断点上的上下文菜单,然后选择"When Hit ..."(当命中...)菜单项.现在,您可以为断点添加日志语句,并关闭默认的停止"操作,以便登录并继续.您可以将许多其他信息添加到日志字符串中,包括有关bp位置的静态信息,例如文件,行,函数和地址.您还可以添加动态信息,例如表达式,调用函数或调用堆栈.添加线程信息和进程信息之类的事情可以帮助您在处理多个线程和/或进程时跟踪计时错误.

To set a tracepoint, first set a breakpoint in code. Then use the context menu on the breakpoint and select the "When Hit..." menu item. You can now add log statements for the breakpoint and switch off the default Stop action, so that you log and go. There is a host of other info you can add to the log string, including static information about the location of the bp, such as file, line, function and address. You can also add dynamic information such as expressions, the calling function or callstack. Things like adding thread info and process info, can help you track down timing bugs when dealing with multiple threads and/or processes.

这篇关于跟踪点有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆