方法断点可能会大大减慢调试速度

时间:2022-04-17 11:16:04

Whenever adding a breakpoint to the line of a method declaration (in Intellij IDEA or Android Studio), a popup appears:

每当向方法声明的行添加断点时(在Intellij IDEA或Android Studio中),都会出现一个弹出窗口:

Method breakpoints may dramatically slow down debugging

方法断点可能会大大减慢调试速度

Why would it dramatically slow down debugging, is my question? What is different about putting the breakpoint on the first line of the function?

为什么它会大大减慢调试速度,这是我的问题?将断点放在函数的第一行有什么不同?

Thanks!

谢谢!

2 个解决方案

#1


7  

I looked around a little, and saw this post in the Intellij Documetation:

我环顾四周,看到Intellij Documetation中的这篇文章:

Method Breakpoint

方法断点

Method breakpoints act in response to the program entering or exiting a particular method. They let you target your debugging sessions by method you wish to investigate, rather than by line number. Method breakpoints let you follow the program flow at the method level as well as check entry and exit conditions. Note that using method breakpoints can slow down the application you are debugging.

方法断点响应于程序进入或退出特定方法而起作用。它们允许您按照要调查的方法而不是按行号来定位调试会话。方法断点允许您遵循方法级别的程序流程以及检查进入和退出条件。请注意,使用方法断点可能会降低正在调试的应用程序的速度。

I guess it stops the program right before it enters the method, so that you can evaluate the parameters and such before entering the method.

我想它会在程序进入方法之前就停止程序,这样你就可以在输入方法之前评估参数等。

The reason it dramatically slows down is (This is what I can gather, because that is all I could find on method breakpoints in Intellij's documentation) that it has to:

它急剧减速的原因是(这是我可以收集的,因为这是我在Intellij文档中的方法断点上可以找到的)它必须:

let you follow the program flow at the method level as well as check entry and exit conditions

让您按照方法级别的程序流程,以及检查进入和退出条件

and I suppose that would take a lot longer than just halting the program's execution

而且我认为这比停止程序的执行需要更长的时间

#2


0  

My understanding is that the code must be run interpretively (instead of using JIT to pre-compile?) when the breakpoint is set on method entry.

我的理解是,当在方法入口上设置断点时,代码必须以解释方式运行(而不是使用JIT进行预编译?)。

If you set the breakpoint on the first line of the method instead, I suspect a line number index into the code can be used to simply swap a break opcode for the original opcode, so the app runs full speed. (which still seems pretty slow to me when debugging ;)

如果你在方法的第一行设置断点,我怀疑代码中的行号索引可以用来简单地交换原始操作码的break操作码,因此应用程序全速运行。 (调试时对我来说似乎还很慢;)

#1


7  

I looked around a little, and saw this post in the Intellij Documetation:

我环顾四周,看到Intellij Documetation中的这篇文章:

Method Breakpoint

方法断点

Method breakpoints act in response to the program entering or exiting a particular method. They let you target your debugging sessions by method you wish to investigate, rather than by line number. Method breakpoints let you follow the program flow at the method level as well as check entry and exit conditions. Note that using method breakpoints can slow down the application you are debugging.

方法断点响应于程序进入或退出特定方法而起作用。它们允许您按照要调查的方法而不是按行号来定位调试会话。方法断点允许您遵循方法级别的程序流程以及检查进入和退出条件。请注意,使用方法断点可能会降低正在调试的应用程序的速度。

I guess it stops the program right before it enters the method, so that you can evaluate the parameters and such before entering the method.

我想它会在程序进入方法之前就停止程序,这样你就可以在输入方法之前评估参数等。

The reason it dramatically slows down is (This is what I can gather, because that is all I could find on method breakpoints in Intellij's documentation) that it has to:

它急剧减速的原因是(这是我可以收集的,因为这是我在Intellij文档中的方法断点上可以找到的)它必须:

let you follow the program flow at the method level as well as check entry and exit conditions

让您按照方法级别的程序流程,以及检查进入和退出条件

and I suppose that would take a lot longer than just halting the program's execution

而且我认为这比停止程序的执行需要更长的时间

#2


0  

My understanding is that the code must be run interpretively (instead of using JIT to pre-compile?) when the breakpoint is set on method entry.

我的理解是,当在方法入口上设置断点时,代码必须以解释方式运行(而不是使用JIT进行预编译?)。

If you set the breakpoint on the first line of the method instead, I suspect a line number index into the code can be used to simply swap a break opcode for the original opcode, so the app runs full speed. (which still seems pretty slow to me when debugging ;)

如果你在方法的第一行设置断点,我怀疑代码中的行号索引可以用来简单地交换原始操作码的break操作码,因此应用程序全速运行。 (调试时对我来说似乎还很慢;)