原文轉載至:https://blog.csdn.net/qq_21262611/article/details/52121270
前些天和同事交流調試技巧時,知道了 Eclipse debug 時有個 drop to frame 的技巧。這是我以前不知道的,自己又查了一下這個功能的含義。官方的解釋是:
Select the Drop to Frame command [
] to re-enter the selected stack frame in the Debug View.
Note this command is only available if the current VM supports drop to frame and the selected stackframe is not the top frame or a frame in a native method.
就是說,這個功能可以重新跳到當前方法的開始處重新執行,並且所有上下文變量的值也回到那個時候。不一定是當前方法,可以點擊當前調用棧中的任何一個frame跳到那里(除了最開始的那個frame)。主要用途是所有變量狀態快速恢復到方法開始時候的樣子重新執行一遍,即可以一遍又一遍地在那個你關注的上下文中進行多次調試(結合改變變量值等其它功能),而不用重來一遍調試到哪里了。當然,原來執行過程中產生的副作用是不可逆的(比如你往數據庫中插入了一條記錄)。
這里也說了如何使用這個功能:http://www.javalobby.org/forums/thread.jspa?threadID=15271&tstart=0
其實這個功能早就有了,就是一般人不知道或很少使用。

