<type>documentation</type>
<domain>debug</domain>
<id>viewing-the-stack</id>
<title>Viewing the Stack</title>
<date>$Date$</date>
<version>$Revision$</version>
<product>all</product>

Whenever the debug program is paused at a breakpoint, at an exception, or during stepping,
the current stack is displayed in the `Call Stack
<script:show_panel#panel_type="debug-stack">`__ tool. This shows all program stack frames
encountered between invocation of the program and the current run position. Outermost
stack frames are higher up on the list. If there are `PEP 3134
<https://www.python.org/dev/peps/pep-3134/>`__ chained exceptions, these are listed in the
order that they occurred, above the final exception.

When the debugger steps or stops at a breakpoint or exception, it selects the innermost
stack frame by default. In order to visit other stack frames further up or down the stack,
select them in the ``Call Stack`` tool. 

You may also change stack frames using the ``Up Stack`` and ``Down Stack`` items in the
``Debug`` menu, the up/down stack icons in the toolbar, the toolbar stack popup menu, and
the stack selector popup menus at the top of other debugging tools.

When you change stack frames, all the tools in Wing that reference the current stack frame
will be updated, and the current line of code at that stack frame is shown in the editor.

~~~if WINGPRO:
In Wing Pro, the current stack frame is also used to control evaluation context in the
`Debug Console <ref:debug/debug-console>`__ and `Watch <ref:debug/tracking-values>`__ 
tools.
~~~

To change the type of stack display, right-click on the ``Call Stack`` tool.

When an exception has occurred, a backtrace is also captured by the `Exceptions
<script:show_panel#panel_type="debug-exceptions">`__ tool, where it can be accessed even
after the debug process has exited.

