使用调试器逐步执行程序需要很长时间

时间:2022-10-19 18:37:28

When I debug my program by stepping through it, it sometimes takes a long time for the step to finish. This was not happening in the beginning of the project so most likely it is due to something I have added. Could you give me pointers as to how to remedy this. I did notice one of the problems was due to the main thread trying to paint a widget. My application is multi-threaded (1 background thread and 1 main thread) so I am wondering if it has something to do with that. Your comments are appreciated.

当我通过单步调试我的程序时,有时需要很长时间才能完成该步骤。这不是在项目开始时发生的,所以很可能是由于我添加了一些东西。你能否指点一下如何解决这个问题。我注意到其中一个问题是由于主线程试图绘制一个小部件。我的应用程序是多线程的(1个后台线程和1个主线程)所以我想知道它是否与此有关。您的意见表示赞赏。

3 个解决方案

#1


2  

With gdb just set scheduler-locking mode to desired behaviour.

使用gdb只需将调度程序锁定模式设置为所需的行为。

In this case: "The step mode optimizes for single-stepping. It stops other threads from "seizing the prompt" by preempting the current thread while you are stepping. Other threads will only rarely (or never) get a chance to run when you step."

在这种情况下:“步进模式优化单步执行。它会阻止其他线程通过在您踩踏时抢占当前线程来”抓住提示“。其他线程很少(或从不)有机会在您执行时运行步。”

#2


2  

A guess: Is your "background thread" pegged at near 100% CPU utilization?

猜测:你的“后台线程”是否接近100%的CPU利用率?

Between lines of of your main thread, while stepping, the debugger is going to allow the background thread to also "step". If the background thread is pegged it can be running a lot more than a few instructions, causing things to appear unresponsive.

在主线程的行之间,在步进时,调试器将允许后台线程也“步进”。如果后台线程被挂起,它可能会运行很多指令,导致事情看起来没有响应。

Probably if your second thread is doing that much computation continuously it indicates you've got another problem in your application that you need to fix. If you get that thread under control you will probably see your debugger handling things a lot better.

可能如果您的第二个线程持续进行那么多计算,则表明您在应用程序中遇到了另一个需要修复的问题。如果你控制了那个线程,你可能会看到你的调试器处理得更好。

#3


1  

I asked a very similar question regarding visual studio: VS2010 debugger takes an unreasonable amount of time

我问了一个关于visual studio的非常类似的问题:VS2010调试器需要花费不合理的时间

No real answer came about. You'll find similar questions for past versions of the IDE here as well.

没有真正的答案。您也可以在此处找到与以前版本的IDE类似的问题。

#1


2  

With gdb just set scheduler-locking mode to desired behaviour.

使用gdb只需将调度程序锁定模式设置为所需的行为。

In this case: "The step mode optimizes for single-stepping. It stops other threads from "seizing the prompt" by preempting the current thread while you are stepping. Other threads will only rarely (or never) get a chance to run when you step."

在这种情况下:“步进模式优化单步执行。它会阻止其他线程通过在您踩踏时抢占当前线程来”抓住提示“。其他线程很少(或从不)有机会在您执行时运行步。”

#2


2  

A guess: Is your "background thread" pegged at near 100% CPU utilization?

猜测:你的“后台线程”是否接近100%的CPU利用率?

Between lines of of your main thread, while stepping, the debugger is going to allow the background thread to also "step". If the background thread is pegged it can be running a lot more than a few instructions, causing things to appear unresponsive.

在主线程的行之间,在步进时,调试器将允许后台线程也“步进”。如果后台线程被挂起,它可能会运行很多指令,导致事情看起来没有响应。

Probably if your second thread is doing that much computation continuously it indicates you've got another problem in your application that you need to fix. If you get that thread under control you will probably see your debugger handling things a lot better.

可能如果您的第二个线程持续进行那么多计算,则表明您在应用程序中遇到了另一个需要修复的问题。如果你控制了那个线程,你可能会看到你的调试器处理得更好。

#3


1  

I asked a very similar question regarding visual studio: VS2010 debugger takes an unreasonable amount of time

我问了一个关于visual studio的非常类似的问题:VS2010调试器需要花费不合理的时间

No real answer came about. You'll find similar questions for past versions of the IDE here as well.

没有真正的答案。您也可以在此处找到与以前版本的IDE类似的问题。