The !for_each_frame extension executes a debugger command one time for each frame in the stack of the current thread.

!for_each_frame ["CommandString"] 
!for_each_frame -?


Specifies the debugger commands to execute one time for each frame. If CommandString includes multiple commands, you must separate them with semicolons and enclose CommandString in quotation marks. If you include multiple commands, the individual commands within CommandString cannot contain quotation marks. If you want to refer to the index of the current frame within CommandString, use the @$frame pseudoregister.

Displays some Help text for this extension in the Debugger Command window.


Windows 2000


Windows XP and later


Additional Information

For more information about the local context, see Changing Contexts.


If you do not specify any arguments, the !for_each_frame extension displays a list of all frames and their frame indexes. For a more detailed list of all frames, use the k (Display Stack Backtrace) command.

The k command walks up to 256 frames. For each enumerated frame, that frame temporarily becomes the current local context (similar to the .frame (Set Local Context) command). After the context has been set, CommandString is executed. After all frames have been used, the local context is reset to the value that it had before you used the !for_each_frame extension.

If you include CommandString, the debugger displays the frame and its index before the command is executed for that frame.

The following command displays all local variables for the current stack.

!for_each_frame !for_each_local dt @#Local

Send comments about this topic to Microsoft