为什么条件断点在调试时降低应用程序执行速度? [英] Why does Conditional breakpoint decrease the application execution speed at debug time?

查看:155
本文介绍了为什么条件断点在调试时降低应用程序执行速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在VS2005中使用条件断点而不是使用临时代码检查特定条件时,我注意到需要更多的时间,执行速度降低!
你知道为什么吗以及如何解决这个问题?

When I use conditional breakpoint in VS2005 instead of using temporary code to check specific conditions, I noticed it takes more time and the execution speed is decreased!! Do you know why? and how to resolve this issue?

Exmaple:

    int sequence = atoi(m_SequenceNumber.GetAscii());
    if( sequence == 392914)//temporary code to check to step into code
    {
        int x = 0;//I put breakpoint here
    }

以前的代码执行速度要比使用条件断点(sequence == 392914)

The previous code will execute faster than if I used conditional breakpoint with ( sequence == 392914)

推荐答案

使用内存观察点比条件断点更好(如果可能)。条件断点(如其他人已经指出的)必须在每次执行指针超过该点时运行附加代码,以确定是否会断开 - 显然这需要额外的时间。某种类型的内存观察点可以使用某些特殊的硬件寄存器 - 您可以设置多少观察点可以加速,但是如果可以使用它们,则几乎没有速度的惩罚。

It is better (if possible) to use a memory watchpoint than a conditional breakpoint. A conditional breakpoint (as others have pointed out) has to run additional code each time the execution pointer goes past that point in order to determine if it would break or not - obviously this takes additional time. A memory watchpoint of a certain type gets to use certain special hardware registers - there is a limit on how many watchpoints you can set that can get accelerated, but if you can use them there is almost no speed penalty.

使用断点窗口设置内存观察点。您不要将其设置在一行代码上,而是在内存中的一个地址上。这表明了明显的限制,它仅适用于您可以实际使用的地址,例如全局变量和动态分配的内存区域(使用 new 等)。你被限制在多少内存被允许观看(基于CPU,我认为你可能得到或多或少的特殊寄存器分配)。

A memory watchpoint is set using the breakpoint window. You do not set it on a line of code, but rather on an address in memory. This suggests the obvious limitation, it only works for things you can actually take the address of, such as global variables and dynamically allocated areas of memory (using new etc). You are limited in how much memory you are allowed to watch (based on the CPU, I think you probably get more or less special registers allocated).

我不是实际上现在坐在VS前面,但是大致来说,你点击断点窗口,选择新数据断点。然后输入内存的地址和大小(以字节为单位)。每当值改变时,您的观察点将触发。这对于找出内存损坏问题特别有用。

I'm not actually sitting in front of VS right now, but roughly speaking, you right click in the breakpoints window and choose something like "new data breakpoint". You then enter the address of the memory and the size in bytes. Whenever the value changes your watchpoint will fire. This is particularly useful for figuring out memory corruption issues.

这篇关于为什么条件断点在调试时降低应用程序执行速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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