Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using the Java debugger in IntelliJ, what does "Drop Frame" mean?

I was using the Java debugger within IntelliJ 8 and noticed a button labeled "drop frame". Does anybody know what purpose this serves? How/why would this be used/useful?

like image 346
benstpierre Avatar asked Mar 02 '10 23:03

benstpierre


People also ask

What is drop frame IntelliJ Debug?

IntelliJ IDEA lets you fall back to a previous stack frame in a program's execution flow. This can be useful, for example, if you've mistakenly stepped too far, or want to re-enter a method where you missed a critical spot. Click the Drop Frame icon. on the toolbar of the Debug tool window.

What are frames in IntelliJ debugger?

Frames: lets you navigate in call stacks of the threads. Variables: lists the variables available in the current context and lets you analyze and modify the program state. Watches: lets you manage watches. By default, watches are shown on the Variables tab for more efficient use of the screen space.

What is drop to frame?

Definition of drop-frame (Entry 2 of 2) : having most or all of the floor at an unusually low level —used especially of the chassis of a motor truck or a trailer.

What are frames in debugging?

The frame contains the arguments given to the function, the function's local variables, and the address at which the function is executing. When your program is started, the stack has only one frame, that of the function main . This is called the initial frame or the outermost frame.


2 Answers

The call stack of your application can be viewed in the debugger. Using the "Drop Frame" functionality you can "fall back" to a previous stack frame, in a sense going back in time. This can be helpful to re-enter a function if you missed a critical spot you would like to see again.

As the name "Stack Frame" suggests, changes that were already made to global state (like static variables, changes to field values and the like) will not be undone, only local variables are reset. This can lead to a different execution path than the one that originally led to your break point. You need to be aware of this - I often consider it a useful feature to explore different paths of execution without having to restart the application or a particular lengthy process that led to the current stack. Combined with the change of variable values also available through the debugger, you can do all sorts of interesting things.

Please note, that of course, any side effects that might have occurred - e. g. network traffic, file manipulations, console output etc. - cannot be rewound.

like image 180
Daniel Schneller Avatar answered Sep 19 '22 14:09

Daniel Schneller


Drop Frame within the debugger pops the current stack frame and puts control back out to the calling method, resetting any local variables. This is very useful to repeatedly step through a function, but be warned: field mutations or global state changes will remain.

See more info here.

like image 33
Jorge Ferreira Avatar answered Sep 17 '22 14:09

Jorge Ferreira