在Visual studio中使用跟踪断点

来源:互联网 发布:钢管租赁计算软件 编辑:程序博客网 时间:2024/04/30 04:09


https://blogs.msdn.microsoft.com/visualstudioalm/2013/10/10/tracepoints/


This blog post is part of a series on breakpoints in the Visual Studio debugger and has been updated to reflect the experience of using Visual Studio 2015. If you are interested in details about setting tracepoints using earlier versions of Visual Studio please see theMSDN documentation.

What is a tracepoint? It is a point in the application that allows the developer to perform some action, like logging a message to the output window, and then have the option to continue execution of the program, so it does not have to break at that point during debugging.

To first illustrate how tracepoints are used, we will look at the GCD function in ourmanaged sample. Let’s say we wanted to see all of the steps in calculating the GCD, but we didn’t want to have to stop the program at every iteration.

To get started, first create a breakpoint in the GCD function, and then hover over the breakpoint to bring up the breakpoint’s toolbar and click the “Settings…” icon.

You can also right-click on the breakpoint to bring up the context menu, and select “Actions…”

This will bring up the Breakpoint Settings window. Select “Actions” and “Continue execution”. In the message field you can include custom text, variables, and expressions. (Tip: Using the context menu will open the window with the Actions box already checked.)

You can include the value of a variable or other expression by placing it in curly braces. (To insert a curly brace or backslash into your message as text use “\{“ or “\\” respectively).

There are also many pseudo variables available to output for tracepoint messages. The following special keywords will be replaced with their current
values when the tracepoint is reached during debugging.
 

Pseudo Variable:

Description:

$ADDRESS

Current Instruction

$CALLER

Previous Function Name

$CALLSTACK

Call Stack

$FUNCTION

Current Function Name

$PID

Process Id

$PNAME

Process Name

$TID

Thread Id

$TNAME

Thread Name

You’ll notice that, the breakpoint icon takes on a diamond shape. This indicates that the action is set to continue execution automatically so the program will not stop at that location.

When the program is executed, you can view the results of the tracepoints in the Output Window.

In this way, tracepoints give you a way to print out values without having to make changes to your source code.

Additionally, if you use IntelliTrace, you can view your tracepoints in the Events View and after selecting the event, you can view the output of the tracepoint in the Locals window.

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 孩子d和b分不清怎么办 和家人走散后怎么办幼儿教案 小孩胃口不好不爱吃饭怎么办 幼儿园孩子学习记不住怎么办 幼儿园小孩数字记不住怎么办 大班教案走丢了怎么办 ppt加视频反了怎么办 拔罐之后背疼怎么办 拔完火罐后背疼怎么办 打印机红色的口堵了怎么办 打印机红色复印不出来怎么办 打印机加错颜色墨水怎么办 中班安全教案脚扭伤了怎么办 中班脚扭伤了怎么办教案 中班安全脚扭伤了怎么办 中班安全脚扭伤了怎么办反思 走丢了怎么办教案反思 汽车后轱辘不转怎么办 走丢了怎么办社会教案 小老鼠搬鸡蛋鸡蛋太大怎么办 小班走丢了怎么办教案 小班走丢了怎么办反思 房屋外墙漏水物业不管怎么办 厨房墙砖用色花怎么办 小孩子做错事很偏激怎么办 孩子在学校偷钱怎么办 房间墙壁上到处有湿虫怎么办 买了西晒的房子怎么办 墙面瓷砖下水管漏水怎么办 西晒房间开空调没效果怎么办 墙纸被小孩画了怎么办 集成墙板缝隙大怎么办 高血压变低血压怎么办会恢复吗 总是感觉睡不够好困怎么办 两岁宝宝说有鬼怎么办 阳台改成了卧室晒衣服怎么办 室外墙角边墙泥受潮脱落怎么办 新房装修墙体发霉了怎么办 宝宝吃多了发烧怎么办 宝宝睡觉不爱盖被子怎么办 1岁宝宝不盖被子怎么办