[英]Using jdb to step inside object construction during execution
I use jdb
for my Java development. 我将
jdb
用于Java开发。 For my application I have two classes: WordUniverseTest
and WordUniverse
, and the main method is contained in WordUniverseTest
. 对于我的应用程序,我有两个类:
WordUniverseTest
和WordUniverse
,主要方法包含在WordUniverseTest
。 When I execute WordUniverseTest
inside of jdb
, I construct a WordUniverse
object called obj
inside of the main
method. 当我在
jdb
内部执行WordUniverseTest
时,我在main
方法内部构造了一个名为obj
的WordUniverse
对象。
But I do not know how to have jdb
leave the WordUniverseTest
class and step inside WordUniverse
while obj
is being constructed. 但我不知道如何有
jdb
离开WordUniverseTest
内部类和步WordUniverse
同时 obj
正在紧张施工。 How do I do this? 我该怎么做呢?
You can put a regular breakpoint there stop at
and then when you are actually on the line (call list
to verify), you can call step into
. 你可以把经常有断点
stop at
,然后当你实际上就行了(调用list
来验证),你可以调用step into
。
As long as all your classes are known to jdb, it is going to work, I tested it. 只要jdb知道您所有的类,它就会起作用,我已经对其进行了测试。
I found the answer, and although Gergely Bacso didn't give the full answer, he did lead me to find the full answer. 我找到了答案,尽管Gergely Bacso没有给出完整的答案,但他的确带领我找到了完整的答案。
jdb
uses a different procedure for stepping into methods versus stepping into constructors. 与进入构造器相比,
jdb
使用不同的过程进入方法。 To step into a method, you have to do what Gergely Basco said, which is set a breakpoint at where the method is called and then step into
. 要进入方法,您必须执行Gergely Basco所说的,该方法在调用方法的位置设置一个断点,然后
step into
。 But for stepping into a constructor you must say stop in ClassName.<init>
(with brackets). 但是要进入构造函数,您必须说
stop in ClassName.<init>
(带括号) stop in ClassName.<init>
。 Saying that command will take you inside of the constructor. 说该命令会将您带入构造函数的内部。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.